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(), 187 } 188 189 uint ZHeap::nconcurrent_worker_threads() const { 190 return _workers.nconcurrent(); 191 } 192 193 uint ZHeap::nconcurrent_no_boost_worker_threads() const { 194 return _workers.nconcurrent_no_boost(); 195 } 196 197 void ZHeap::set_boost_worker_threads(bool boost) { 198 _workers.set_boost(boost); 199 } 200 201 void ZHeap::worker_threads_do(ThreadClosure* tc) const { 202 _workers.threads_do(tc); 203 } 204 205 void ZHeap::print_worker_threads_on(outputStream* st) const { 206 _workers.print_threads_on(st); 207 } 208 209 void ZHeap::out_of_memory() { 210 ResourceMark rm; 211 212 ZStatInc(ZCounterOutOfMemory); 213 log_info(gc)("Out Of Memory (%s)", Thread::current()->name()); 214 } 215 216 ZPage* ZHeap::alloc_page(uint8_t type, size_t size, ZAllocationFlags flags) { 217 ZPage* const page = _page_allocator.alloc_page(type, size, flags); 218 if (page != NULL) { 219 // Insert page table entry 220 _page_table.insert(page); 221 } 222 223 return page; 224 } 225 226 void ZHeap::undo_alloc_page(ZPage* page) { | 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/zTask.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 class ZTask; 50 static const ZStatSampler ZSamplerHeapUsedBeforeMark("Memory", "Heap Used Before Mark", ZStatUnitBytes); 51 static const ZStatSampler ZSamplerHeapUsedAfterMark("Memory", "Heap Used After Mark", ZStatUnitBytes); 52 static const ZStatSampler ZSamplerHeapUsedBeforeRelocation("Memory", "Heap Used Before Relocation", ZStatUnitBytes); 53 static const ZStatSampler ZSamplerHeapUsedAfterRelocation("Memory", "Heap Used After Relocation", ZStatUnitBytes); 54 static const ZStatCounter ZCounterUndoPageAllocation("Memory", "Undo Page Allocation", ZStatUnitOpsPerSecond); 55 static const ZStatCounter ZCounterOutOfMemory("Memory", "Out Of Memory", ZStatUnitOpsPerSecond); 56 57 ZHeap* ZHeap::_heap = NULL; 58 59 ZHeap::ZHeap() : 60 _workers(), 61 _object_allocator(), 62 _page_allocator(&_workers, heap_min_size(), heap_initial_size(), heap_max_size(), heap_max_reserve_size()), 63 _page_table(), 64 _forwarding_table(), 65 _mark(&_workers, &_page_table), 66 _reference_processor(&_workers), 67 _weak_roots_processor(&_workers), 68 _relocate(&_workers), 69 _relocation_set(), 189 } 190 191 uint ZHeap::nconcurrent_worker_threads() const { 192 return _workers.nconcurrent(); 193 } 194 195 uint ZHeap::nconcurrent_no_boost_worker_threads() const { 196 return _workers.nconcurrent_no_boost(); 197 } 198 199 void ZHeap::set_boost_worker_threads(bool boost) { 200 _workers.set_boost(boost); 201 } 202 203 void ZHeap::worker_threads_do(ThreadClosure* tc) const { 204 _workers.threads_do(tc); 205 } 206 207 void ZHeap::print_worker_threads_on(outputStream* st) const { 208 _workers.print_threads_on(st); 209 } 210 211 // A delegate class for AbstractGangTask to Ztask. 212 class DelegatedZAbstractGangTask : public ZTask { 213 private: 214 AbstractGangTask* _task; 215 216 public: 217 DelegatedZAbstractGangTask(AbstractGangTask* task) : 218 ZTask(task->name()), 219 _task(task) { } 220 221 virtual void work() { 222 _task->work(ZThread::worker_id()); 223 } 224 }; 225 226 Tickspan ZHeap::run_task(AbstractGangTask* task) { 227 Ticks start = Ticks::now(); 228 DelegatedZAbstractGangTask dtask(task); 229 _workers.run_parallel(&dtask); 230 return Ticks::now() - start; 231 } 232 233 void ZHeap::out_of_memory() { 234 ResourceMark rm; 235 236 ZStatInc(ZCounterOutOfMemory); 237 log_info(gc)("Out Of Memory (%s)", Thread::current()->name()); 238 } 239 240 ZPage* ZHeap::alloc_page(uint8_t type, size_t size, ZAllocationFlags flags) { 241 ZPage* const page = _page_allocator.alloc_page(type, size, flags); 242 if (page != NULL) { 243 // Insert page table entry 244 _page_table.insert(page); 245 } 246 247 return page; 248 } 249 250 void ZHeap::undo_alloc_page(ZPage* page) { |