10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 #include "precompiled.hpp" 25 #include "gc/shared/locationPrinter.hpp" 26 #include "gc/z/zAddress.inline.hpp" 27 #include "gc/z/zGlobals.hpp" 28 #include "gc/z/zHeap.inline.hpp" 29 #include "gc/z/zHeapIterator.hpp" 30 #include "gc/z/zMark.inline.hpp" 31 #include "gc/z/zPage.inline.hpp" 32 #include "gc/z/zPageTable.inline.hpp" 33 #include "gc/z/zRelocationSet.inline.hpp" 34 #include "gc/z/zRelocationSetSelector.inline.hpp" 35 #include "gc/z/zResurrection.hpp" 36 #include "gc/z/zStat.hpp" 37 #include "gc/z/zThread.inline.hpp" 38 #include "gc/z/zVerify.hpp" 39 #include "gc/z/zWorkers.inline.hpp" 40 #include "logging/log.hpp" 41 #include "memory/iterator.hpp" 42 #include "memory/resourceArea.hpp" 43 #include "runtime/handshake.hpp" 44 #include "runtime/safepoint.hpp" 45 #include "runtime/thread.hpp" 46 #include "utilities/debug.hpp" 47 48 static const ZStatSampler ZSamplerHeapUsedBeforeMark("Memory", "Heap Used Before Mark", ZStatUnitBytes); 49 static const ZStatSampler ZSamplerHeapUsedAfterMark("Memory", "Heap Used After Mark", ZStatUnitBytes); 50 static const ZStatSampler ZSamplerHeapUsedBeforeRelocation("Memory", "Heap Used Before Relocation", ZStatUnitBytes); 51 static const ZStatSampler ZSamplerHeapUsedAfterRelocation("Memory", "Heap Used After Relocation", ZStatUnitBytes); 52 static const ZStatCounter ZCounterUndoPageAllocation("Memory", "Undo Page Allocation", ZStatUnitOpsPerSecond); 53 static const ZStatCounter ZCounterOutOfMemory("Memory", "Out Of Memory", ZStatUnitOpsPerSecond); 54 55 ZHeap* ZHeap::_heap = NULL; 56 57 ZHeap::ZHeap() : 58 _workers(), 59 _object_allocator(), 60 _page_allocator(&_workers, heap_min_size(), heap_initial_size(), heap_max_size(), heap_max_reserve_size()), 61 _page_table(), 62 _forwarding_table(), 63 _mark(&_workers, &_page_table), 64 _reference_processor(&_workers), 65 _weak_roots_processor(&_workers), 66 _relocate(&_workers), 67 _relocation_set(), 68 _unload(&_workers), 69 _serviceability(heap_min_size(), heap_max_size()) { 70 // Install global heap instance 71 assert(_heap == NULL, "Already initialized"); 72 _heap = this; 73 74 // Update statistics 75 ZStatHeap::set_at_initialize(heap_min_size(), heap_max_size(), heap_max_reserve_size()); 76 } 77 78 size_t ZHeap::heap_min_size() const { 79 return MAX2(MinHeapSize, heap_max_reserve_size()); 80 } 81 82 size_t ZHeap::heap_initial_size() const { 83 return MAX2(InitialHeapSize, heap_max_reserve_size()); 84 } 85 86 size_t ZHeap::heap_max_size() const { 87 return MaxHeapSize; 88 } 89 90 size_t ZHeap::heap_max_reserve_size() const { 91 // Reserve one small page per worker plus one shared medium page. This is still just 92 // an estimate and doesn't guarantee that we can't run out of memory during relocation. 93 const size_t max_reserve_size = (_workers.nworkers() * ZPageSizeSmall) + ZPageSizeMedium; 94 return MIN2(max_reserve_size, heap_max_size()); 95 } 96 97 bool ZHeap::is_initialized() const { 98 return _page_allocator.is_initialized() && _mark.is_initialized(); 99 } 100 101 size_t ZHeap::min_capacity() const { 102 return _page_allocator.min_capacity(); 103 } 104 105 size_t ZHeap::max_capacity() const { 106 return _page_allocator.max_capacity(); 107 } 108 109 size_t ZHeap::soft_max_capacity() const { 110 return _page_allocator.soft_max_capacity(); 111 } 112 113 size_t ZHeap::capacity() const { 114 return _page_allocator.capacity(); | 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 #include "precompiled.hpp" 25 #include "gc/shared/locationPrinter.hpp" 26 #include "gc/z/zAddress.inline.hpp" 27 #include "gc/z/zGlobals.hpp" 28 #include "gc/z/zHeap.inline.hpp" 29 #include "gc/z/zHeapIterator.hpp" 30 #include "gc/z/zHeuristics.hpp" 31 #include "gc/z/zMark.inline.hpp" 32 #include "gc/z/zPage.inline.hpp" 33 #include "gc/z/zPageTable.inline.hpp" 34 #include "gc/z/zRelocationSet.inline.hpp" 35 #include "gc/z/zRelocationSetSelector.inline.hpp" 36 #include "gc/z/zResurrection.hpp" 37 #include "gc/z/zStat.hpp" 38 #include "gc/z/zThread.inline.hpp" 39 #include "gc/z/zVerify.hpp" 40 #include "gc/z/zWorkers.inline.hpp" 41 #include "logging/log.hpp" 42 #include "memory/iterator.hpp" 43 #include "memory/resourceArea.hpp" 44 #include "runtime/handshake.hpp" 45 #include "runtime/safepoint.hpp" 46 #include "runtime/thread.hpp" 47 #include "utilities/debug.hpp" 48 49 static const ZStatSampler ZSamplerHeapUsedBeforeMark("Memory", "Heap Used Before Mark", ZStatUnitBytes); 50 static const ZStatSampler ZSamplerHeapUsedAfterMark("Memory", "Heap Used After Mark", ZStatUnitBytes); 51 static const ZStatSampler ZSamplerHeapUsedBeforeRelocation("Memory", "Heap Used Before Relocation", ZStatUnitBytes); 52 static const ZStatSampler ZSamplerHeapUsedAfterRelocation("Memory", "Heap Used After Relocation", ZStatUnitBytes); 53 static const ZStatCounter ZCounterUndoPageAllocation("Memory", "Undo Page Allocation", ZStatUnitOpsPerSecond); 54 static const ZStatCounter ZCounterOutOfMemory("Memory", "Out Of Memory", ZStatUnitOpsPerSecond); 55 56 ZHeap* ZHeap::_heap = NULL; 57 58 ZHeap::ZHeap() : 59 _workers(), 60 _object_allocator(), 61 _page_allocator(&_workers, MinHeapSize, InitialHeapSize, MaxHeapSize, ZHeuristics::max_reserve()), 62 _page_table(), 63 _forwarding_table(), 64 _mark(&_workers, &_page_table), 65 _reference_processor(&_workers), 66 _weak_roots_processor(&_workers), 67 _relocate(&_workers), 68 _relocation_set(), 69 _unload(&_workers), 70 _serviceability(min_capacity(), max_capacity()) { 71 // Install global heap instance 72 assert(_heap == NULL, "Already initialized"); 73 _heap = this; 74 75 // Update statistics 76 ZStatHeap::set_at_initialize(min_capacity(), max_capacity(), max_reserve()); 77 } 78 79 bool ZHeap::is_initialized() const { 80 return _page_allocator.is_initialized() && _mark.is_initialized(); 81 } 82 83 size_t ZHeap::min_capacity() const { 84 return _page_allocator.min_capacity(); 85 } 86 87 size_t ZHeap::max_capacity() const { 88 return _page_allocator.max_capacity(); 89 } 90 91 size_t ZHeap::soft_max_capacity() const { 92 return _page_allocator.soft_max_capacity(); 93 } 94 95 size_t ZHeap::capacity() const { 96 return _page_allocator.capacity(); |