# HG changeset patch # User rkennke # Date 1511373178 -3600 # Wed Nov 22 18:52:58 2017 +0100 # Node ID 71fc860d19fed38e62686cfa1555bfe7117a8695 # Parent bca569f79fa1f9e13d61b7984311aeb0c49c8b51 8191564: Refactor GC related servicability code into GC specific subclasses diff --git a/src/hotspot/share/gc/cms/cmsHeap.cpp b/src/hotspot/share/gc/cms/cmsHeap.cpp --- a/src/hotspot/share/gc/cms/cmsHeap.cpp +++ b/src/hotspot/share/gc/cms/cmsHeap.cpp @@ -23,14 +23,19 @@ */ #include "precompiled.hpp" +#include "gc/cms/compactibleFreeListSpace.hpp" +#include "gc/cms/concurrentMarkSweepGeneration.hpp" #include "gc/cms/concurrentMarkSweepThread.hpp" #include "gc/cms/cmsHeap.hpp" +#include "gc/cms/parNewGeneration.hpp" #include "gc/cms/vmCMSOperations.hpp" #include "gc/shared/genOopClosures.inline.hpp" #include "gc/shared/strongRootsScope.hpp" #include "gc/shared/workgroup.hpp" #include "oops/oop.inline.hpp" #include "runtime/vmThread.hpp" +#include "services/memoryManager.hpp" +#include "services/memoryPool.hpp" #include "utilities/stack.inline.hpp" CMSHeap::CMSHeap(GenCollectorPolicy *policy) : GenCollectedHeap(policy) { @@ -183,3 +188,82 @@ GenCollectedHeap::gc_epilogue(full); always_do_update_barrier = true; }; + +class ParNewMemoryManager : public GCMemoryManager { +private: +public: + ParNewMemoryManager() : GCMemoryManager() {} + + const char* name() { return "ParNew"; } + virtual const char* gc_end_message() { return "end of major GC"; } +}; + +class CMSMemoryManager : public GCMemoryManager { +private: +public: + CMSMemoryManager() : GCMemoryManager() {} + + const char* name() { return "ConcurrentMarkSweep";} + virtual const char* gc_end_message() { return "end of minor GC"; } +}; + +class CompactibleFreeListSpacePool : public CollectedMemoryPool { +private: + CompactibleFreeListSpace* _space; +public: + CompactibleFreeListSpacePool(CompactibleFreeListSpace* space, + const char* name, + PoolType type, + size_t max_size, + bool support_usage_threshold) : + CollectedMemoryPool(name, type, space->capacity(), max_size, + support_usage_threshold), _space(space) { + } + + MemoryUsage get_memory_usage() { + size_t maxSize = (available_for_allocation() ? max_size() : 0); + size_t used = used_in_bytes(); + size_t committed = _space->capacity(); + + return MemoryUsage(initial_size(), used, committed, maxSize); + } + + size_t used_in_bytes() { + return _space->used(); + } +}; + +void CMSHeap::init_memory_managers() { + _minor_mgr = new ParNewMemoryManager(); + _major_mgr = new CMSMemoryManager(); +} + +GrowableArray CMSHeap::memory_managers() { + GrowableArray cms_memory_managers; + cms_memory_managers.append(_minor_mgr); + cms_memory_managers.append(_major_mgr); + return cms_memory_managers; +} + +GrowableArray CMSHeap::memory_pools() { + GrowableArray cms_memory_pools; + + ParNewGeneration* young = (ParNewGeneration*) young_gen(); + ContiguousSpacePool* eden = new ContiguousSpacePool(young->eden(), "Par Eden Space", MemoryPool::Heap, young->max_eden_size(), false); + SurvivorContiguousSpacePool* survivor = new SurvivorContiguousSpacePool(young, "Par Survivor Space", MemoryPool::Heap, young->max_survivor_size(), false); + + ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*) old_gen(); + CompactibleFreeListSpacePool* old = new CompactibleFreeListSpacePool(cms->cmsSpace(), "CMS Old Gen", MemoryPool::Heap, cms->reserved().byte_size(), true); + + cms_memory_pools.append(eden); + cms_memory_pools.append(survivor); + cms_memory_pools.append(old); + + _minor_mgr->add_pool(eden); + _major_mgr->add_pool(eden); + _minor_mgr->add_pool(survivor); + _major_mgr->add_pool(survivor); + _major_mgr->add_pool(old); + + return cms_memory_pools; +} diff --git a/src/hotspot/share/gc/cms/cmsHeap.hpp b/src/hotspot/share/gc/cms/cmsHeap.hpp --- a/src/hotspot/share/gc/cms/cmsHeap.hpp +++ b/src/hotspot/share/gc/cms/cmsHeap.hpp @@ -29,9 +29,12 @@ #include "gc/shared/collectedHeap.hpp" #include "gc/shared/gcCause.hpp" #include "gc/shared/genCollectedHeap.hpp" +#include "utilities/growableArray.hpp" class CLDClosure; class GenCollectorPolicy; +class MemoryManager; +class MemoryPool; class OopsInGenClosure; class outputStream; class StrongRootsScope; @@ -39,7 +42,6 @@ class WorkGang; class CMSHeap : public GenCollectedHeap { - protected: virtual void check_gen_kinds(); @@ -80,6 +82,10 @@ void safepoint_synchronize_begin(); void safepoint_synchronize_end(); + virtual void init_memory_managers(); + virtual GrowableArray memory_managers(); + virtual GrowableArray memory_pools(); + // If "young_gen_as_roots" is false, younger generations are // not scanned as roots; in this case, the caller must be arranging to // scan the younger generations itself. (For example, a generation might diff --git a/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp b/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp --- a/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp +++ b/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp @@ -197,8 +197,8 @@ }; ConcurrentMarkSweepGeneration::ConcurrentMarkSweepGeneration( - ReservedSpace rs, size_t initial_byte_size, CardTableRS* ct) : - CardGeneration(rs, initial_byte_size, ct), + ReservedSpace rs, size_t initial_byte_size, GCMemoryManager* mem_mgr, CardTableRS* ct) : + CardGeneration(rs, initial_byte_size, mem_mgr, ct), _dilatation_factor(((double)MinChunkSize)/((double)(CollectedHeap::min_fill_size()))), _did_compact(false) { @@ -8116,10 +8116,10 @@ } TraceCMSMemoryManagerStats::TraceCMSMemoryManagerStats(CMSCollector::CollectorState phase, GCCause::Cause cause): TraceMemoryManagerStats() { - + GCMemoryManager* mgr = CMSHeap::heap()->major_mgr(); switch (phase) { case CMSCollector::InitialMarking: - initialize(true /* fullGC */ , + initialize(mgr /* major */ , cause /* cause of the GC */, true /* recordGCBeginTime */, true /* recordPreGCUsage */, @@ -8131,7 +8131,7 @@ break; case CMSCollector::FinalMarking: - initialize(true /* fullGC */ , + initialize(mgr /* major */ , cause /* cause of the GC */, false /* recordGCBeginTime */, false /* recordPreGCUsage */, @@ -8143,7 +8143,7 @@ break; case CMSCollector::Sweeping: - initialize(true /* fullGC */ , + initialize(mgr /* major */ , cause /* cause of the GC */, false /* recordGCBeginTime */, false /* recordPreGCUsage */, diff --git a/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.hpp b/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.hpp --- a/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.hpp +++ b/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.hpp @@ -1076,7 +1076,7 @@ void assert_correct_size_change_locking(); public: - ConcurrentMarkSweepGeneration(ReservedSpace rs, size_t initial_byte_size, CardTableRS* ct); + ConcurrentMarkSweepGeneration(ReservedSpace rs, size_t initial_byte_size, GCMemoryManager* mem_mgr, CardTableRS* ct); // Accessors CMSCollector* collector() const { return _collector; } diff --git a/src/hotspot/share/gc/cms/parNewGeneration.cpp b/src/hotspot/share/gc/cms/parNewGeneration.cpp --- a/src/hotspot/share/gc/cms/parNewGeneration.cpp +++ b/src/hotspot/share/gc/cms/parNewGeneration.cpp @@ -628,8 +628,8 @@ _old_gen->par_oop_since_save_marks_iterate_done((int) worker_id); } -ParNewGeneration::ParNewGeneration(ReservedSpace rs, size_t initial_byte_size) - : DefNewGeneration(rs, initial_byte_size, "PCopy"), +ParNewGeneration::ParNewGeneration(ReservedSpace rs, size_t initial_byte_size, GCMemoryManager* mem_mgr) + : DefNewGeneration(rs, initial_byte_size, mem_mgr, "PCopy"), _overflow_list(NULL), _is_alive_closure(this), _plab_stats("Young", YoungPLABSize, PLABWeight) diff --git a/src/hotspot/share/gc/cms/parNewGeneration.hpp b/src/hotspot/share/gc/cms/parNewGeneration.hpp --- a/src/hotspot/share/gc/cms/parNewGeneration.hpp +++ b/src/hotspot/share/gc/cms/parNewGeneration.hpp @@ -349,7 +349,7 @@ void restore_preserved_marks(); public: - ParNewGeneration(ReservedSpace rs, size_t initial_byte_size); + ParNewGeneration(ReservedSpace rs, size_t initial_byte_size, GCMemoryManager* mem_mgr); ~ParNewGeneration() { for (uint i = 0; i < ParallelGCThreads; i++) diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp --- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp @@ -45,6 +45,7 @@ #include "gc/g1/g1HeapTransition.hpp" #include "gc/g1/g1HeapVerifier.hpp" #include "gc/g1/g1HotCardCache.hpp" +#include "gc/g1/g1MemoryPool.hpp" #include "gc/g1/g1OopClosures.inline.hpp" #include "gc/g1/g1ParScanThreadState.inline.hpp" #include "gc/g1/g1Policy.hpp" @@ -82,6 +83,7 @@ #include "runtime/init.hpp" #include "runtime/orderAccess.inline.hpp" #include "runtime/vmThread.hpp" +#include "services/memoryManager.hpp" #include "utilities/align.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/stack.inline.hpp" @@ -2980,7 +2982,7 @@ log_info(gc,task)("Using %u workers of %u for evacuation", active_workers, workers()->total_workers()); TraceCollectorStats tcs(g1mm()->incremental_collection_counters()); - TraceMemoryManagerStats tms(false /* fullGC */, gc_cause()); + TraceMemoryManagerStats tms(_minor_mgr, gc_cause()); // If the secondary_free_list is not empty, append it to the // free_list. No need to wait for the cleanup operation to finish; @@ -5394,3 +5396,56 @@ RebuildStrongCodeRootClosure blob_cl(this); CodeCache::blobs_do(&blob_cl); } + +class G1YoungGenMemoryManager : public GCMemoryManager { +private: +public: + G1YoungGenMemoryManager() : GCMemoryManager() {} + + const char* name() { return "G1 Young Generation"; } + virtual const char* gc_end_message() { return "end of minor GC"; } +}; + +class G1OldGenMemoryManager : public GCMemoryManager { +private: +public: + G1OldGenMemoryManager() : GCMemoryManager() {} + + const char* name() { return "G1 Old Generation"; } + virtual const char* gc_end_message() { return "end of major GC"; } +}; + +GrowableArray G1CollectedHeap::memory_managers() { + _minor_mgr = new G1YoungGenMemoryManager(); + _major_mgr = new G1OldGenMemoryManager(); + GrowableArray mem_mgrs; + mem_mgrs.append(_minor_mgr); + mem_mgrs.append(_major_mgr); + return mem_mgrs; +} + +GCMemoryManager* G1CollectedHeap::minor_mgr() { + return _minor_mgr; +} + +GCMemoryManager* G1CollectedHeap::major_mgr() { + return _major_mgr; +} + +GrowableArray G1CollectedHeap::memory_pools() { + G1EdenPool* eden = new G1EdenPool(this); + G1SurvivorPool* survivor = new G1SurvivorPool(this); + G1OldGenPool* old_gen = new G1OldGenPool(this); + + _major_mgr->add_pool(eden); + _major_mgr->add_pool(survivor); + _major_mgr->add_pool(old_gen); + _minor_mgr->add_pool(eden); + _minor_mgr->add_pool(survivor); + + GrowableArray mem_pools; + mem_pools.append(eden); + mem_pools.append(survivor); + mem_pools.append(old_gen); + return mem_pools; +} diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp --- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp @@ -92,6 +92,8 @@ class G1HeapSizingPolicy; class G1HeapSummary; class G1EvacSummary; +class MemoryManager; +class MemoryPool; typedef OverflowTaskQueue RefToScanQueue; typedef GenericTaskQueueSet RefToScanQueueSet; @@ -148,6 +150,9 @@ WorkGang* _workers; G1CollectorPolicy* _collector_policy; + GCMemoryManager* _minor_mgr; + GCMemoryManager* _major_mgr; + static size_t _humongous_object_threshold_in_words; // The secondary free list which contains regions that have been @@ -1006,6 +1011,12 @@ // Adaptive size policy. No such thing for g1. virtual AdaptiveSizePolicy* size_policy() { return NULL; } + virtual GrowableArray memory_managers(); + virtual GrowableArray memory_pools(); + + GCMemoryManager* minor_mgr(); + GCMemoryManager* major_mgr(); + // The rem set and barrier set. G1RemSet* g1_rem_set() const { return _g1_rem_set; } diff --git a/src/hotspot/share/gc/g1/g1FullGCScope.cpp b/src/hotspot/share/gc/g1/g1FullGCScope.cpp --- a/src/hotspot/share/gc/g1/g1FullGCScope.cpp +++ b/src/hotspot/share/gc/g1/g1FullGCScope.cpp @@ -36,7 +36,7 @@ _active(), _cpu_time(), _soft_refs(clear_soft, _g1h->collector_policy()), - _memory_stats(true, _g1h->gc_cause()), + _memory_stats(_g1h->major_mgr(), _g1h->gc_cause()), _collector_stats(_g1h->g1mm()->full_collection_counters()), _heap_transition(_g1h) { _timer.register_gc_start(); diff --git a/src/hotspot/share/services/g1MemoryPool.cpp b/src/hotspot/share/gc/g1/g1MemoryPool.cpp rename from src/hotspot/share/services/g1MemoryPool.cpp rename to src/hotspot/share/gc/g1/g1MemoryPool.cpp --- a/src/hotspot/share/services/g1MemoryPool.cpp +++ b/src/hotspot/share/gc/g1/g1MemoryPool.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,8 +24,8 @@ #include "precompiled.hpp" #include "gc/g1/g1CollectedHeap.hpp" +#include "gc/g1/g1MemoryPool.hpp" #include "gc/g1/heapRegion.hpp" -#include "services/g1MemoryPool.hpp" G1MemoryPoolSuper::G1MemoryPoolSuper(G1CollectedHeap* g1h, const char* name, diff --git a/src/hotspot/share/services/g1MemoryPool.hpp b/src/hotspot/share/gc/g1/g1MemoryPool.hpp rename from src/hotspot/share/services/g1MemoryPool.hpp rename to src/hotspot/share/gc/g1/g1MemoryPool.hpp --- a/src/hotspot/share/services/g1MemoryPool.hpp +++ b/src/hotspot/share/gc/g1/g1MemoryPool.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,11 +26,9 @@ #define SHARE_VM_SERVICES_G1MEMORYPOOL_HPP #include "utilities/macros.hpp" -#if INCLUDE_ALL_GCS #include "gc/g1/g1MonitoringSupport.hpp" #include "services/memoryPool.hpp" #include "services/memoryUsage.hpp" -#endif // INCLUDE_ALL_GCS // This file contains the three classes that represent the memory // pools of the G1 spaces: G1EdenPool, G1SurvivorPool, and diff --git a/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp b/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp --- a/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp +++ b/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp @@ -33,6 +33,7 @@ #include "gc/parallel/parallelScavengeHeap.inline.hpp" #include "gc/parallel/psAdaptiveSizePolicy.hpp" #include "gc/parallel/psMarkSweep.hpp" +#include "gc/parallel/psMemoryPool.hpp" #include "gc/parallel/psParallelCompact.inline.hpp" #include "gc/parallel/psPromotionManager.hpp" #include "gc/parallel/psScavenge.hpp" @@ -45,6 +46,7 @@ #include "runtime/handles.inline.hpp" #include "runtime/java.hpp" #include "runtime/vmThread.hpp" +#include "services/memoryManager.hpp" #include "services/memTracker.hpp" #include "utilities/vmError.hpp" @@ -674,3 +676,63 @@ void ParallelScavengeHeap::verify_nmethod(nmethod* nm) { CodeCache::verify_scavenge_root_nmethod(nm); } + +class PSScavengeMemoryManager : public GCMemoryManager { +private: +public: + PSScavengeMemoryManager() : GCMemoryManager() {} + + const char* name() { return "PS Scavenge"; } + virtual const char* gc_end_message() { return "end of minor GC"; } +}; + +class PSMarkSweepMemoryManager : public GCMemoryManager { +private: +public: + PSMarkSweepMemoryManager() : GCMemoryManager() {} + + const char* name() { return "PS MarkSweep"; } + virtual const char* gc_end_message() { return "end of major GC"; } +}; + +GrowableArray ParallelScavengeHeap::memory_managers() { + _minor_mgr = new PSScavengeMemoryManager(); + _major_mgr = new PSMarkSweepMemoryManager(); + GrowableArray mem_mgrs; + mem_mgrs.append(_minor_mgr); + mem_mgrs.append(_major_mgr); + return mem_mgrs; +} + +GrowableArray ParallelScavengeHeap::memory_pools() { + PSYoungGen* young = young_gen(); + EdenMutableSpacePool* eden = new EdenMutableSpacePool(young, + young->eden_space(), + "PS Eden Space", + MemoryPool::Heap, + false /* support_usage_threshold */); + + SurvivorMutableSpacePool* survivor = new SurvivorMutableSpacePool(young, + "PS Survivor Space", + MemoryPool::Heap, + false /* support_usage_threshold */); + + PSGenerationPool* old_gen_pool = new PSGenerationPool(old_gen(), + "PS Old Gen", + MemoryPool::Heap, + true /* support_usage_threshold */); + + _major_mgr->add_pool(eden); + _major_mgr->add_pool(survivor); + _major_mgr->add_pool(old_gen_pool); + + _minor_mgr->add_pool(eden); + _minor_mgr->add_pool(survivor); + + GrowableArray mem_pools; + mem_pools.append(eden); + mem_pools.append(survivor); + mem_pools.append(old_gen_pool); + return mem_pools; +} + diff --git a/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp b/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp --- a/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp +++ b/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,11 +36,14 @@ #include "gc/shared/gcWhen.hpp" #include "gc/shared/strongRootsScope.hpp" #include "memory/metaspace.hpp" +#include "utilities/growableArray.hpp" #include "utilities/ostream.hpp" class AdjoiningGenerations; class GCHeapSummary; class GCTaskManager; +class MemoryManager; +class MemoryPool; class PSAdaptiveSizePolicy; class PSHeapSummary; @@ -64,6 +67,9 @@ // The task manager static GCTaskManager* _gc_task_manager; + GCMemoryManager* _minor_mgr; + GCMemoryManager* _major_mgr; + void trace_heap(GCWhen::Type when, const GCTracer* tracer); protected: @@ -94,6 +100,12 @@ virtual CollectorPolicy* collector_policy() const { return _collector_policy; } + virtual GrowableArray memory_managers(); + virtual GrowableArray memory_pools(); + + GCMemoryManager* minor_mgr() { return _minor_mgr; } + GCMemoryManager* major_mgr() { return _major_mgr; } + static PSYoungGen* young_gen() { return _young_gen; } static PSOldGen* old_gen() { return _old_gen; } diff --git a/src/hotspot/share/gc/parallel/psMarkSweep.cpp b/src/hotspot/share/gc/parallel/psMarkSweep.cpp --- a/src/hotspot/share/gc/parallel/psMarkSweep.cpp +++ b/src/hotspot/share/gc/parallel/psMarkSweep.cpp @@ -172,7 +172,7 @@ heap->pre_full_gc_dump(_gc_timer); TraceCollectorStats tcs(counters()); - TraceMemoryManagerStats tms(true /* Full GC */,gc_cause); + TraceMemoryManagerStats tms(heap->major_mgr(),gc_cause); if (log_is_enabled(Debug, gc, heap, exit)) { accumulated_time()->start(); diff --git a/src/hotspot/share/services/psMemoryPool.cpp b/src/hotspot/share/gc/parallel/psMemoryPool.cpp rename from src/hotspot/share/services/psMemoryPool.cpp rename to src/hotspot/share/gc/parallel/psMemoryPool.cpp --- a/src/hotspot/share/services/psMemoryPool.cpp +++ b/src/hotspot/share/gc/parallel/psMemoryPool.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,13 +25,13 @@ #include "precompiled.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" +#include "gc/parallel/psMemoryPool.hpp" #include "oops/oop.inline.hpp" #include "runtime/handles.inline.hpp" #include "runtime/javaCalls.hpp" #include "services/lowMemoryDetector.hpp" #include "services/management.hpp" #include "services/memoryManager.hpp" -#include "services/psMemoryPool.hpp" PSGenerationPool::PSGenerationPool(PSOldGen* old_gen, const char* name, diff --git a/src/hotspot/share/services/psMemoryPool.hpp b/src/hotspot/share/gc/parallel/psMemoryPool.hpp rename from src/hotspot/share/services/psMemoryPool.hpp rename to src/hotspot/share/gc/parallel/psMemoryPool.hpp --- a/src/hotspot/share/services/psMemoryPool.hpp +++ b/src/hotspot/share/gc/parallel/psMemoryPool.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/src/hotspot/share/gc/parallel/psParallelCompact.cpp b/src/hotspot/share/gc/parallel/psParallelCompact.cpp --- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp +++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp @@ -1772,7 +1772,7 @@ heap->pre_full_gc_dump(&_gc_timer); TraceCollectorStats tcs(counters()); - TraceMemoryManagerStats tms(true /* Full GC */,gc_cause); + TraceMemoryManagerStats tms(heap->major_mgr(), gc_cause); if (log_is_enabled(Debug, gc, heap, exit)) { accumulated_time()->start(); diff --git a/src/hotspot/share/gc/parallel/psScavenge.cpp b/src/hotspot/share/gc/parallel/psScavenge.cpp --- a/src/hotspot/share/gc/parallel/psScavenge.cpp +++ b/src/hotspot/share/gc/parallel/psScavenge.cpp @@ -305,7 +305,7 @@ GCTraceCPUTime tcpu; GCTraceTime(Info, gc) tm("Pause Young", NULL, gc_cause, true); TraceCollectorStats tcs(counters()); - TraceMemoryManagerStats tms(false /* not full GC */,gc_cause); + TraceMemoryManagerStats tms(heap->minor_mgr(), gc_cause); if (log_is_enabled(Debug, gc, heap, exit)) { accumulated_time()->start(); diff --git a/src/hotspot/share/gc/serial/defNewGeneration.cpp b/src/hotspot/share/gc/serial/defNewGeneration.cpp --- a/src/hotspot/share/gc/serial/defNewGeneration.cpp +++ b/src/hotspot/share/gc/serial/defNewGeneration.cpp @@ -178,8 +178,9 @@ DefNewGeneration::DefNewGeneration(ReservedSpace rs, size_t initial_size, + GCMemoryManager* mem_mgr, const char* policy) - : Generation(rs, initial_size), + : Generation(rs, initial_size, mem_mgr), _preserved_marks_set(false /* in_c_heap */), _promo_failure_drain_in_progress(false), _should_allocate_from_space(false) diff --git a/src/hotspot/share/gc/serial/defNewGeneration.hpp b/src/hotspot/share/gc/serial/defNewGeneration.hpp --- a/src/hotspot/share/gc/serial/defNewGeneration.hpp +++ b/src/hotspot/share/gc/serial/defNewGeneration.hpp @@ -201,7 +201,7 @@ }; public: - DefNewGeneration(ReservedSpace rs, size_t initial_byte_size, + DefNewGeneration(ReservedSpace rs, size_t initial_byte_size, GCMemoryManager* mem_mgr, const char* policy="Copy"); virtual void ref_processor_init(); diff --git a/src/hotspot/share/gc/serial/serialHeap.cpp b/src/hotspot/share/gc/serial/serialHeap.cpp --- a/src/hotspot/share/gc/serial/serialHeap.cpp +++ b/src/hotspot/share/gc/serial/serialHeap.cpp @@ -23,7 +23,10 @@ */ #include "precompiled.hpp" +#include "gc/serial/defNewGeneration.hpp" #include "gc/serial/serialHeap.hpp" +#include "services/memoryManager.hpp" +#include "services/memoryPool.hpp" SerialHeap::SerialHeap(GenCollectorPolicy* policy) : GenCollectedHeap(policy) {} @@ -33,3 +36,65 @@ assert(old_gen()->kind() == Generation::MarkSweepCompact, "Wrong generation kind"); } + +class CopyMemoryManager : public GCMemoryManager { +private: +public: + CopyMemoryManager() : GCMemoryManager() {} + + const char* name() { return "Copy"; } + virtual const char* gc_end_message() { return "end of minor GC"; } +}; + +class MSCMemoryManager : public GCMemoryManager { +private: +public: + MSCMemoryManager() : GCMemoryManager() {} + + const char* name() { return "MarkSweepCompact"; } + virtual const char* gc_end_message() { return "end of major GC"; } +}; + +void SerialHeap::init_memory_managers() { + _minor_mgr = new CopyMemoryManager(); + _major_mgr = new MSCMemoryManager(); +} + +GrowableArray SerialHeap::memory_managers() { + GrowableArray mem_mgrs; + mem_mgrs.append(_minor_mgr); + mem_mgrs.append(_major_mgr); + return mem_mgrs; +} + +GrowableArray SerialHeap::memory_pools() { + DefNewGeneration* young = (DefNewGeneration*) young_gen(); + + // Add a memory pool for each space and young gen doesn't + // support low memory detection as it is expected to get filled up. + MemoryPool* eden = new ContiguousSpacePool(young->eden(), + "Eden Space", + MemoryPool::Heap, + young->max_eden_size(), + false /* support_usage_threshold */); + MemoryPool* survivor = new SurvivorContiguousSpacePool(young, + "Survivor Space", + MemoryPool::Heap, + young->max_survivor_size(), + false /* support_usage_threshold */); + GenerationPool* old = new GenerationPool(old_gen(), "Tenured Gen", MemoryPool::Heap, true); + + GrowableArray mem_pools; + mem_pools.append(eden); + mem_pools.append(survivor); + mem_pools.append(old); + + _minor_mgr->add_pool(eden); + _minor_mgr->add_pool(survivor); + + _major_mgr->add_pool(eden); + _major_mgr->add_pool(survivor); + _major_mgr->add_pool(old); + + return mem_pools; +} diff --git a/src/hotspot/share/gc/serial/serialHeap.hpp b/src/hotspot/share/gc/serial/serialHeap.hpp --- a/src/hotspot/share/gc/serial/serialHeap.hpp +++ b/src/hotspot/share/gc/serial/serialHeap.hpp @@ -26,8 +26,11 @@ #define SHARE_VM_GC_SERIAL_SERIALHEAP_HPP #include "gc/shared/genCollectedHeap.hpp" +#include "utilities/growableArray.hpp" class GenCollectorPolicy; +class MemoryManager; +class MemoryPool; class SerialHeap : public GenCollectedHeap { protected: @@ -44,6 +47,10 @@ return "Serial"; } + virtual void init_memory_managers(); + virtual GrowableArray memory_managers(); + virtual GrowableArray memory_pools(); + // override virtual bool is_in_closed_subset(const void* p) const { return is_in(p); @@ -52,7 +59,6 @@ virtual bool card_mark_must_follow_store() const { return false; } - }; #endif // SHARE_VM_GC_CMS_CMSHEAP_HPP diff --git a/src/hotspot/share/gc/serial/tenuredGeneration.cpp b/src/hotspot/share/gc/serial/tenuredGeneration.cpp --- a/src/hotspot/share/gc/serial/tenuredGeneration.cpp +++ b/src/hotspot/share/gc/serial/tenuredGeneration.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,8 +44,9 @@ TenuredGeneration::TenuredGeneration(ReservedSpace rs, size_t initial_byte_size, + GCMemoryManager* mem_mgr, CardTableRS* remset) : - CardGeneration(rs, initial_byte_size, remset) + CardGeneration(rs, initial_byte_size, mem_mgr, remset) { HeapWord* bottom = (HeapWord*) _virtual_space.low(); HeapWord* end = (HeapWord*) _virtual_space.high(); diff --git a/src/hotspot/share/gc/serial/tenuredGeneration.hpp b/src/hotspot/share/gc/serial/tenuredGeneration.hpp --- a/src/hotspot/share/gc/serial/tenuredGeneration.hpp +++ b/src/hotspot/share/gc/serial/tenuredGeneration.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,6 +58,7 @@ public: TenuredGeneration(ReservedSpace rs, size_t initial_byte_size, + GCMemoryManager* mem_mgr, CardTableRS* remset); Generation::Name kind() { return Generation::MarkSweepCompact; } diff --git a/src/hotspot/share/gc/shared/cardGeneration.cpp b/src/hotspot/share/gc/shared/cardGeneration.cpp --- a/src/hotspot/share/gc/shared/cardGeneration.cpp +++ b/src/hotspot/share/gc/shared/cardGeneration.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,8 +38,9 @@ CardGeneration::CardGeneration(ReservedSpace rs, size_t initial_byte_size, + GCMemoryManager* mem_mgr, CardTableRS* remset) : - Generation(rs, initial_byte_size), _rs(remset), + Generation(rs, initial_byte_size, mem_mgr), _rs(remset), _shrink_factor(0), _min_heap_delta_bytes(), _capacity_at_prologue(), _used_at_prologue() { diff --git a/src/hotspot/share/gc/shared/cardGeneration.hpp b/src/hotspot/share/gc/shared/cardGeneration.hpp --- a/src/hotspot/share/gc/shared/cardGeneration.hpp +++ b/src/hotspot/share/gc/shared/cardGeneration.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,7 @@ size_t _capacity_at_prologue; size_t _used_at_prologue; - CardGeneration(ReservedSpace rs, size_t initial_byte_size, CardTableRS* remset); + CardGeneration(ReservedSpace rs, size_t initial_byte_size, GCMemoryManager* mem_mgr, CardTableRS* remset); virtual void assert_correct_size_change_locking() = 0; diff --git a/src/hotspot/share/gc/shared/collectedHeap.hpp b/src/hotspot/share/gc/shared/collectedHeap.hpp --- a/src/hotspot/share/gc/shared/collectedHeap.hpp +++ b/src/hotspot/share/gc/shared/collectedHeap.hpp @@ -34,6 +34,7 @@ #include "utilities/debug.hpp" #include "utilities/events.hpp" #include "utilities/formatBuffer.hpp" +#include "utilities/growableArray.hpp" // A "CollectedHeap" is an implementation of a java heap for HotSpot. This // is an abstract class: there may be many different kinds of heaps. This @@ -46,6 +47,8 @@ class GCHeapSummary; class GCTimer; class GCTracer; +class MemoryManager; +class MemoryPool; class MetaspaceSummary; class Thread; class ThreadClosure; @@ -485,6 +488,9 @@ // Return the CollectorPolicy for the heap virtual CollectorPolicy* collector_policy() const = 0; + virtual GrowableArray memory_managers() = 0; + virtual GrowableArray memory_pools() = 0; + // Iterate over all objects, calling "cl.do_object" on each. virtual void object_iterate(ObjectClosure* cl) = 0; diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp --- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp +++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp @@ -100,12 +100,14 @@ _rem_set = collector_policy()->create_rem_set(reserved_region()); set_barrier_set(rem_set()->bs()); + init_memory_managers(); + ReservedSpace young_rs = heap_rs.first_part(gen_policy()->young_gen_spec()->max_size(), false, false); - _young_gen = gen_policy()->young_gen_spec()->init(young_rs, rem_set()); + _young_gen = gen_policy()->young_gen_spec()->init(young_rs, rem_set(), _minor_mgr); heap_rs = heap_rs.last_part(gen_policy()->young_gen_spec()->max_size()); ReservedSpace old_rs = heap_rs.first_part(gen_policy()->old_gen_spec()->max_size(), false, false); - _old_gen = gen_policy()->old_gen_spec()->init(old_rs, rem_set()); + _old_gen = gen_policy()->old_gen_spec()->init(old_rs, rem_set(), _major_mgr); clear_incremental_collection_failed(); return JNI_OK; @@ -270,7 +272,7 @@ FormatBuffer<> title("Collect gen: %s", gen->short_name()); GCTraceTime(Trace, gc, phases) t1(title); TraceCollectorStats tcs(gen->counters()); - TraceMemoryManagerStats tmms(gen->kind(),gc_cause()); + TraceMemoryManagerStats tmms(gen->memory_manager(), gc_cause()); gen->stat_record()->invocations++; gen->stat_record()->accumulated_time.start(); diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.hpp b/src/hotspot/share/gc/shared/genCollectedHeap.hpp --- a/src/hotspot/share/gc/shared/genCollectedHeap.hpp +++ b/src/hotspot/share/gc/shared/genCollectedHeap.hpp @@ -112,6 +112,9 @@ // (gen-specific) roots processing. SubTasksDone* _process_strong_tasks; + GCMemoryManager* _minor_mgr; + GCMemoryManager* _major_mgr; + // Helper functions for allocation HeapWord* attempt_allocation(size_t size, bool is_tlab, @@ -149,6 +152,10 @@ // Returns JNI_OK on success virtual jint initialize(); + virtual void init_memory_managers() = 0; + GCMemoryManager* major_mgr() { return _major_mgr; } + GCMemoryManager* minor_mgr() { return _minor_mgr; } + // Does operations required after initialization has been done. void post_initialize(); diff --git a/src/hotspot/share/gc/shared/generation.cpp b/src/hotspot/share/gc/shared/generation.cpp --- a/src/hotspot/share/gc/shared/generation.cpp +++ b/src/hotspot/share/gc/shared/generation.cpp @@ -43,8 +43,9 @@ #include "utilities/copy.hpp" #include "utilities/events.hpp" -Generation::Generation(ReservedSpace rs, size_t initial_size) : - _ref_processor(NULL) { +Generation::Generation(ReservedSpace rs, size_t initial_size, GCMemoryManager* mem_mgr) : + _ref_processor(NULL), _memory_manager(mem_mgr) { + assert(mem_mgr != NULL, "need memory manager"); if (!_virtual_space.initialize(rs, initial_size)) { vm_exit_during_initialization("Could not reserve enough space for " "object heap"); diff --git a/src/hotspot/share/gc/shared/generation.hpp b/src/hotspot/share/gc/shared/generation.hpp --- a/src/hotspot/share/gc/shared/generation.hpp +++ b/src/hotspot/share/gc/shared/generation.hpp @@ -58,6 +58,7 @@ // class DefNewGeneration; +class GCMemoryManager; class GenerationSpec; class CompactibleSpace; class ContiguousSpace; @@ -86,6 +87,8 @@ MemRegion _prev_used_region; // for collectors that want to "remember" a value for // used region at some specific point during collection. + GCMemoryManager* _memory_manager; + protected: // Minimum and maximum addresses for memory reserved (not necessarily // committed) for generation. @@ -106,7 +109,7 @@ GCStats* _gc_stats; // Initialize the generation. - Generation(ReservedSpace rs, size_t initial_byte_size); + Generation(ReservedSpace rs, size_t initial_byte_size, GCMemoryManager* memory_manager); // Apply "cl->do_oop" to (the address of) (exactly) all the ref fields in // "sp" that point into younger generations. @@ -134,6 +137,10 @@ GenGrain = 1 << LogOfGenGrain }; + GCMemoryManager* memory_manager() { + return _memory_manager; + } + // allocate and initialize ("weak") refs processing support virtual void ref_processor_init(); void set_ref_processor(ReferenceProcessor* rp) { diff --git a/src/hotspot/share/gc/shared/generationSpec.cpp b/src/hotspot/share/gc/shared/generationSpec.cpp --- a/src/hotspot/share/gc/shared/generationSpec.cpp +++ b/src/hotspot/share/gc/shared/generationSpec.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,17 +36,17 @@ #include "gc/cms/parNewGeneration.hpp" #endif // INCLUDE_ALL_GCS -Generation* GenerationSpec::init(ReservedSpace rs, CardTableRS* remset) { +Generation* GenerationSpec::init(ReservedSpace rs, CardTableRS* remset, GCMemoryManager* mem_mgr) { switch (name()) { case Generation::DefNew: - return new DefNewGeneration(rs, init_size()); + return new DefNewGeneration(rs, init_size(), mem_mgr); case Generation::MarkSweepCompact: - return new TenuredGeneration(rs, init_size(), remset); + return new TenuredGeneration(rs, init_size(), mem_mgr, remset); #if INCLUDE_ALL_GCS case Generation::ParNew: - return new ParNewGeneration(rs, init_size()); + return new ParNewGeneration(rs, init_size(), mem_mgr); case Generation::ConcurrentMarkSweep: { assert(UseConcMarkSweepGC, "UseConcMarkSweepGC should be set"); @@ -58,7 +58,7 @@ // else registers with an existing CMSCollector ConcurrentMarkSweepGeneration* g = NULL; - g = new ConcurrentMarkSweepGeneration(rs, init_size(), remset); + g = new ConcurrentMarkSweepGeneration(rs, init_size(), mem_mgr, remset); g->initialize_performance_counters(); diff --git a/src/hotspot/share/gc/shared/generationSpec.hpp b/src/hotspot/share/gc/shared/generationSpec.hpp --- a/src/hotspot/share/gc/shared/generationSpec.hpp +++ b/src/hotspot/share/gc/shared/generationSpec.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ _max_size(align_up(max_size, alignment)) { } - Generation* init(ReservedSpace rs, CardTableRS* remset); + Generation* init(ReservedSpace rs, CardTableRS* remset, GCMemoryManager* mem_mgr); // Accessors Generation::Name name() const { return _name; } diff --git a/src/hotspot/share/services/memoryManager.cpp b/src/hotspot/share/services/memoryManager.cpp --- a/src/hotspot/share/services/memoryManager.cpp +++ b/src/hotspot/share/services/memoryManager.cpp @@ -59,38 +59,6 @@ return (MemoryManager*) new MetaspaceMemoryManager(); } -GCMemoryManager* MemoryManager::get_copy_memory_manager() { - return (GCMemoryManager*) new CopyMemoryManager(); -} - -GCMemoryManager* MemoryManager::get_msc_memory_manager() { - return (GCMemoryManager*) new MSCMemoryManager(); -} - -GCMemoryManager* MemoryManager::get_parnew_memory_manager() { - return (GCMemoryManager*) new ParNewMemoryManager(); -} - -GCMemoryManager* MemoryManager::get_cms_memory_manager() { - return (GCMemoryManager*) new CMSMemoryManager(); -} - -GCMemoryManager* MemoryManager::get_psScavenge_memory_manager() { - return (GCMemoryManager*) new PSScavengeMemoryManager(); -} - -GCMemoryManager* MemoryManager::get_psMarkSweep_memory_manager() { - return (GCMemoryManager*) new PSMarkSweepMemoryManager(); -} - -GCMemoryManager* MemoryManager::get_g1YoungGen_memory_manager() { - return (GCMemoryManager*) new G1YoungGenMemoryManager(); -} - -GCMemoryManager* MemoryManager::get_g1OldGen_memory_manager() { - return (GCMemoryManager*) new G1OldGenMemoryManager(); -} - instanceOop MemoryManager::get_memory_manager_instance(TRAPS) { // Must do an acquire so as to force ordering of subsequent // loads from anything _memory_mgr_obj points to or implies. @@ -308,8 +276,7 @@ } if (is_notification_enabled()) { - bool isMajorGC = this == MemoryService::get_major_gc_manager(); - GCNotifier::pushNotification(this, isMajorGC ? "end of major GC" : "end of minor GC", + GCNotifier::pushNotification(this, gc_end_message(), GCCause::to_string(cause)); } } diff --git a/src/hotspot/share/services/memoryManager.hpp b/src/hotspot/share/services/memoryManager.hpp --- a/src/hotspot/share/services/memoryManager.hpp +++ b/src/hotspot/share/services/memoryManager.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,14 +75,6 @@ // Static factory methods to get a memory manager of a specific type static MemoryManager* get_code_cache_memory_manager(); static MemoryManager* get_metaspace_memory_manager(); - static GCMemoryManager* get_copy_memory_manager(); - static GCMemoryManager* get_msc_memory_manager(); - static GCMemoryManager* get_parnew_memory_manager(); - static GCMemoryManager* get_cms_memory_manager(); - static GCMemoryManager* get_psScavenge_memory_manager(); - static GCMemoryManager* get_psMarkSweep_memory_manager(); - static GCMemoryManager* get_g1YoungGen_memory_manager(); - static GCMemoryManager* get_g1OldGen_memory_manager(); }; class CodeCacheMemoryManager : public MemoryManager { @@ -165,6 +157,8 @@ void initialize_gc_stat_info(); + virtual const char* gc_end_message() = 0; + bool is_gc_memory_manager() { return true; } jlong gc_time_ms() { return _accumulated_timer.milliseconds(); } size_t gc_count() { return _num_collections; } @@ -186,71 +180,4 @@ bool is_notification_enabled() { return _notification_enabled; } }; -// These subclasses of GCMemoryManager are defined to include -// GC-specific information. -// TODO: Add GC-specific information -class CopyMemoryManager : public GCMemoryManager { -private: -public: - CopyMemoryManager() : GCMemoryManager() {} - - const char* name() { return "Copy"; } -}; - -class MSCMemoryManager : public GCMemoryManager { -private: -public: - MSCMemoryManager() : GCMemoryManager() {} - - const char* name() { return "MarkSweepCompact"; } -}; - -class ParNewMemoryManager : public GCMemoryManager { -private: -public: - ParNewMemoryManager() : GCMemoryManager() {} - - const char* name() { return "ParNew"; } -}; - -class CMSMemoryManager : public GCMemoryManager { -private: -public: - CMSMemoryManager() : GCMemoryManager() {} - - const char* name() { return "ConcurrentMarkSweep";} -}; - -class PSScavengeMemoryManager : public GCMemoryManager { -private: -public: - PSScavengeMemoryManager() : GCMemoryManager() {} - - const char* name() { return "PS Scavenge"; } -}; - -class PSMarkSweepMemoryManager : public GCMemoryManager { -private: -public: - PSMarkSweepMemoryManager() : GCMemoryManager() {} - - const char* name() { return "PS MarkSweep"; } -}; - -class G1YoungGenMemoryManager : public GCMemoryManager { -private: -public: - G1YoungGenMemoryManager() : GCMemoryManager() {} - - const char* name() { return "G1 Young Generation"; } -}; - -class G1OldGenMemoryManager : public GCMemoryManager { -private: -public: - G1OldGenMemoryManager() : GCMemoryManager() {} - - const char* name() { return "G1 Old Generation"; } -}; - #endif // SHARE_VM_SERVICES_MEMORYMANAGER_HPP diff --git a/src/hotspot/share/services/memoryPool.cpp b/src/hotspot/share/services/memoryPool.cpp --- a/src/hotspot/share/services/memoryPool.cpp +++ b/src/hotspot/share/services/memoryPool.cpp @@ -38,9 +38,6 @@ #include "services/memoryPool.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" -#if INCLUDE_ALL_GCS -#include "gc/cms/compactibleFreeListSpace.hpp" -#endif MemoryPool::MemoryPool(const char* name, PoolType type, @@ -228,29 +225,6 @@ return MemoryUsage(initial_size(), used, committed, maxSize); } -#if INCLUDE_ALL_GCS -CompactibleFreeListSpacePool::CompactibleFreeListSpacePool(CompactibleFreeListSpace* space, - const char* name, - PoolType type, - size_t max_size, - bool support_usage_threshold) : - CollectedMemoryPool(name, type, space->capacity(), max_size, - support_usage_threshold), _space(space) { -} - -size_t CompactibleFreeListSpacePool::used_in_bytes() { - return _space->used(); -} - -MemoryUsage CompactibleFreeListSpacePool::get_memory_usage() { - size_t maxSize = (available_for_allocation() ? max_size() : 0); - size_t used = used_in_bytes(); - size_t committed = _space->capacity(); - - return MemoryUsage(initial_size(), used, committed, maxSize); -} -#endif // INCLUDE_ALL_GCS - GenerationPool::GenerationPool(Generation* gen, const char* name, PoolType type, diff --git a/src/hotspot/share/services/memoryPool.hpp b/src/hotspot/share/services/memoryPool.hpp --- a/src/hotspot/share/services/memoryPool.hpp +++ b/src/hotspot/share/services/memoryPool.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -178,22 +178,6 @@ size_t committed_in_bytes(); }; -#if INCLUDE_ALL_GCS -class CompactibleFreeListSpacePool : public CollectedMemoryPool { -private: - CompactibleFreeListSpace* _space; -public: - CompactibleFreeListSpacePool(CompactibleFreeListSpace* space, - const char* name, - PoolType type, - size_t max_size, - bool support_usage_threshold); - - MemoryUsage get_memory_usage(); - size_t used_in_bytes(); -}; -#endif // INCLUDE_ALL_GCS - class GenerationPool : public CollectedMemoryPool { private: diff --git a/src/hotspot/share/services/memoryService.cpp b/src/hotspot/share/services/memoryService.cpp --- a/src/hotspot/share/services/memoryService.cpp +++ b/src/hotspot/share/services/memoryService.cpp @@ -25,13 +25,8 @@ #include "precompiled.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" -#include "gc/parallel/mutableSpace.hpp" -#include "gc/serial/defNewGeneration.hpp" -#include "gc/serial/tenuredGeneration.hpp" -#include "gc/shared/collectorPolicy.hpp" -#include "gc/shared/genCollectedHeap.hpp" +#include "gc/shared/collectedHeap.hpp" #include "gc/shared/generation.hpp" -#include "gc/shared/generationSpec.hpp" #include "logging/logConfiguration.hpp" #include "memory/heap.hpp" #include "memory/memRegion.hpp" @@ -46,24 +41,12 @@ #include "services/memoryService.hpp" #include "utilities/growableArray.hpp" #include "utilities/macros.hpp" -#if INCLUDE_ALL_GCS -#include "gc/cms/concurrentMarkSweepGeneration.hpp" -#include "gc/cms/parNewGeneration.hpp" -#include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/parallel/parallelScavengeHeap.hpp" -#include "gc/parallel/psOldGen.hpp" -#include "gc/parallel/psYoungGen.hpp" -#include "services/g1MemoryPool.hpp" -#include "services/psMemoryPool.hpp" -#endif // INCLUDE_ALL_GCS GrowableArray* MemoryService::_pools_list = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(init_pools_list_size, true); GrowableArray* MemoryService::_managers_list = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(init_managers_list_size, true); -GCMemoryManager* MemoryService::_minor_gc_manager = NULL; -GCMemoryManager* MemoryService::_major_gc_manager = NULL; MemoryManager* MemoryService::_code_cache_manager = NULL; GrowableArray* MemoryService::_code_heap_pools = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(init_code_heap_pools_size, true); @@ -84,311 +67,30 @@ } void MemoryService::set_universe_heap(CollectedHeap* heap) { - CollectedHeap::Name kind = heap->kind(); - switch (kind) { - case CollectedHeap::SerialHeap : - case CollectedHeap::CMSHeap : { - add_gen_collected_heap_info(GenCollectedHeap::heap()); - break; - } -#if INCLUDE_ALL_GCS - case CollectedHeap::ParallelScavengeHeap : { - add_parallel_scavenge_heap_info(ParallelScavengeHeap::heap()); - break; - } - case CollectedHeap::G1CollectedHeap : { - add_g1_heap_info(G1CollectedHeap::heap()); - break; - } -#endif // INCLUDE_ALL_GCS - default: { - guarantee(false, "Unrecognized kind of heap"); - } - } + ResourceMark rm; // For internal allocations in GrowableArray. + GrowableArray gc_mem_mgrs = heap->memory_managers(); + _managers_list->appendAll(&gc_mem_mgrs); + + GrowableArray gc_mem_pools = heap->memory_pools(); + _pools_list->appendAll(&gc_mem_pools); // set the GC thread count GcThreadCountClosure gctcc; heap->gc_threads_do(&gctcc); int count = gctcc.count(); - if (count > 0) { - _minor_gc_manager->set_num_gc_threads(count); - _major_gc_manager->set_num_gc_threads(count); - } - // All memory pools and memory managers are initialized. - // - _minor_gc_manager->initialize_gc_stat_info(); - _major_gc_manager->initialize_gc_stat_info(); -} - -// Add memory pools for GenCollectedHeap -// This function currently only supports two generations collected heap. -// The collector for GenCollectedHeap will have two memory managers. -void MemoryService::add_gen_collected_heap_info(GenCollectedHeap* heap) { - CollectorPolicy* policy = heap->collector_policy(); - - assert(policy->is_generation_policy(), "Only support two generations"); - GenCollectorPolicy* gen_policy = policy->as_generation_policy(); - if (gen_policy != NULL) { - Generation::Name kind = gen_policy->young_gen_spec()->name(); - switch (kind) { - case Generation::DefNew: - _minor_gc_manager = MemoryManager::get_copy_memory_manager(); - break; -#if INCLUDE_ALL_GCS - case Generation::ParNew: - _minor_gc_manager = MemoryManager::get_parnew_memory_manager(); - break; -#endif // INCLUDE_ALL_GCS - default: - guarantee(false, "Unrecognized generation spec"); - break; + int num_mgrs = gc_mem_mgrs.length(); + for (int i = 0; i < num_mgrs; i++) { + assert(gc_mem_mgrs.at(i)->is_gc_memory_manager(), "expect GC memory manager"); + GCMemoryManager* gc_mgr = (GCMemoryManager*) gc_mem_mgrs.at(i); + if (count > 0) { + gc_mgr->set_num_gc_threads(count); } - if (policy->is_mark_sweep_policy()) { - _major_gc_manager = MemoryManager::get_msc_memory_manager(); -#if INCLUDE_ALL_GCS - } else if (policy->is_concurrent_mark_sweep_policy()) { - _major_gc_manager = MemoryManager::get_cms_memory_manager(); -#endif // INCLUDE_ALL_GCS - } else { - guarantee(false, "Unknown two-gen policy"); - } - } else { - guarantee(false, "Non two-gen policy"); - } - _managers_list->append(_minor_gc_manager); - _managers_list->append(_major_gc_manager); - - add_generation_memory_pool(heap->young_gen(), _major_gc_manager, _minor_gc_manager); - add_generation_memory_pool(heap->old_gen(), _major_gc_manager); -} - -#if INCLUDE_ALL_GCS -// Add memory pools for ParallelScavengeHeap -// This function currently only supports two generations collected heap. -// The collector for ParallelScavengeHeap will have two memory managers. -void MemoryService::add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap) { - // Two managers to keep statistics about _minor_gc_manager and _major_gc_manager GC. - _minor_gc_manager = MemoryManager::get_psScavenge_memory_manager(); - _major_gc_manager = MemoryManager::get_psMarkSweep_memory_manager(); - _managers_list->append(_minor_gc_manager); - _managers_list->append(_major_gc_manager); - - add_psYoung_memory_pool(heap->young_gen(), _major_gc_manager, _minor_gc_manager); - add_psOld_memory_pool(heap->old_gen(), _major_gc_manager); -} - -void MemoryService::add_g1_heap_info(G1CollectedHeap* g1h) { - assert(UseG1GC, "sanity"); - - _minor_gc_manager = MemoryManager::get_g1YoungGen_memory_manager(); - _major_gc_manager = MemoryManager::get_g1OldGen_memory_manager(); - _managers_list->append(_minor_gc_manager); - _managers_list->append(_major_gc_manager); - - add_g1YoungGen_memory_pool(g1h, _major_gc_manager, _minor_gc_manager); - add_g1OldGen_memory_pool(g1h, _major_gc_manager); -} -#endif // INCLUDE_ALL_GCS - -MemoryPool* MemoryService::add_gen(Generation* gen, - const char* name, - bool is_heap, - bool support_usage_threshold) { - - MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap); - GenerationPool* pool = new GenerationPool(gen, name, type, support_usage_threshold); - _pools_list->append(pool); - return (MemoryPool*) pool; -} - -MemoryPool* MemoryService::add_space(ContiguousSpace* space, - const char* name, - bool is_heap, - size_t max_size, - bool support_usage_threshold) { - MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap); - ContiguousSpacePool* pool = new ContiguousSpacePool(space, name, type, max_size, support_usage_threshold); - - _pools_list->append(pool); - return (MemoryPool*) pool; -} - -MemoryPool* MemoryService::add_survivor_spaces(DefNewGeneration* young_gen, - const char* name, - bool is_heap, - size_t max_size, - bool support_usage_threshold) { - MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap); - SurvivorContiguousSpacePool* pool = new SurvivorContiguousSpacePool(young_gen, name, type, max_size, support_usage_threshold); - - _pools_list->append(pool); - return (MemoryPool*) pool; -} - -#if INCLUDE_ALL_GCS -MemoryPool* MemoryService::add_cms_space(CompactibleFreeListSpace* space, - const char* name, - bool is_heap, - size_t max_size, - bool support_usage_threshold) { - MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap); - CompactibleFreeListSpacePool* pool = new CompactibleFreeListSpacePool(space, name, type, max_size, support_usage_threshold); - _pools_list->append(pool); - return (MemoryPool*) pool; -} -#endif // INCLUDE_ALL_GCS - -// Add memory pool(s) for one generation -void MemoryService::add_generation_memory_pool(Generation* gen, - MemoryManager* major_mgr, - MemoryManager* minor_mgr) { - guarantee(gen != NULL, "No generation for memory pool"); - Generation::Name kind = gen->kind(); - int index = _pools_list->length(); - - switch (kind) { - case Generation::DefNew: { - assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers"); - DefNewGeneration* young_gen = (DefNewGeneration*) gen; - // Add a memory pool for each space and young gen doesn't - // support low memory detection as it is expected to get filled up. - MemoryPool* eden = add_space(young_gen->eden(), - "Eden Space", - true, /* is_heap */ - young_gen->max_eden_size(), - false /* support_usage_threshold */); - MemoryPool* survivor = add_survivor_spaces(young_gen, - "Survivor Space", - true, /* is_heap */ - young_gen->max_survivor_size(), - false /* support_usage_threshold */); - break; - } - -#if INCLUDE_ALL_GCS - case Generation::ParNew: - { - assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers"); - // Add a memory pool for each space and young gen doesn't - // support low memory detection as it is expected to get filled up. - ParNewGeneration* parnew_gen = (ParNewGeneration*) gen; - MemoryPool* eden = add_space(parnew_gen->eden(), - "Par Eden Space", - true /* is_heap */, - parnew_gen->max_eden_size(), - false /* support_usage_threshold */); - MemoryPool* survivor = add_survivor_spaces(parnew_gen, - "Par Survivor Space", - true, /* is_heap */ - parnew_gen->max_survivor_size(), - false /* support_usage_threshold */); - - break; - } -#endif // INCLUDE_ALL_GCS - - case Generation::MarkSweepCompact: { - assert(major_mgr != NULL && minor_mgr == NULL, "Should have only one manager"); - add_gen(gen, - "Tenured Gen", - true, /* is_heap */ - true /* support_usage_threshold */); - break; - } - -#if INCLUDE_ALL_GCS - case Generation::ConcurrentMarkSweep: - { - assert(major_mgr != NULL && minor_mgr == NULL, "Should have only one manager"); - ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*) gen; - MemoryPool* pool = add_cms_space(cms->cmsSpace(), - "CMS Old Gen", - true, /* is_heap */ - cms->reserved().byte_size(), - true /* support_usage_threshold */); - break; - } -#endif // INCLUDE_ALL_GCS - - default: - assert(false, "should not reach here"); - // no memory pool added for others - break; - } - - assert(major_mgr != NULL, "Should have at least one manager"); - // Link managers and the memory pools together - for (int i = index; i < _pools_list->length(); i++) { - MemoryPool* pool = _pools_list->at(i); - major_mgr->add_pool(pool); - if (minor_mgr != NULL) { - minor_mgr->add_pool(pool); - } + // All memory pools and memory managers are initialized. + gc_mgr->initialize_gc_stat_info(); } } - -#if INCLUDE_ALL_GCS -void MemoryService::add_psYoung_memory_pool(PSYoungGen* young_gen, MemoryManager* major_mgr, MemoryManager* minor_mgr) { - assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers"); - - // Add a memory pool for each space and young gen doesn't - // support low memory detection as it is expected to get filled up. - EdenMutableSpacePool* eden = new EdenMutableSpacePool(young_gen, - young_gen->eden_space(), - "PS Eden Space", - MemoryPool::Heap, - false /* support_usage_threshold */); - - SurvivorMutableSpacePool* survivor = new SurvivorMutableSpacePool(young_gen, - "PS Survivor Space", - MemoryPool::Heap, - false /* support_usage_threshold */); - - major_mgr->add_pool(eden); - major_mgr->add_pool(survivor); - minor_mgr->add_pool(eden); - minor_mgr->add_pool(survivor); - _pools_list->append(eden); - _pools_list->append(survivor); -} - -void MemoryService::add_psOld_memory_pool(PSOldGen* old_gen, MemoryManager* mgr) { - PSGenerationPool* old_gen_pool = new PSGenerationPool(old_gen, - "PS Old Gen", - MemoryPool::Heap, - true /* support_usage_threshold */); - mgr->add_pool(old_gen_pool); - _pools_list->append(old_gen_pool); -} - -void MemoryService::add_g1YoungGen_memory_pool(G1CollectedHeap* g1h, - MemoryManager* major_mgr, - MemoryManager* minor_mgr) { - assert(major_mgr != NULL && minor_mgr != NULL, "should have two managers"); - - G1EdenPool* eden = new G1EdenPool(g1h); - G1SurvivorPool* survivor = new G1SurvivorPool(g1h); - - major_mgr->add_pool(eden); - major_mgr->add_pool(survivor); - minor_mgr->add_pool(eden); - minor_mgr->add_pool(survivor); - _pools_list->append(eden); - _pools_list->append(survivor); -} - -void MemoryService::add_g1OldGen_memory_pool(G1CollectedHeap* g1h, - MemoryManager* mgr) { - assert(mgr != NULL, "should have one manager"); - - G1OldGenPool* old_gen = new G1OldGenPool(g1h); - mgr->add_pool(old_gen); - _pools_list->append(old_gen); -} -#endif // INCLUDE_ALL_GCS - void MemoryService::add_code_heap_memory_pool(CodeHeap* heap, const char* name) { // Create new memory pool for this heap MemoryPool* code_heap_pool = new CodeHeapPool(heap, name, true /* support_usage_threshold */); @@ -463,16 +165,10 @@ } } -void MemoryService::gc_begin(bool fullGC, bool recordGCBeginTime, +void MemoryService::gc_begin(GCMemoryManager* mgr, bool recordGCBeginTime, bool recordAccumulatedGCTime, bool recordPreGCUsage, bool recordPeakUsage) { - GCMemoryManager* mgr; - if (fullGC) { - mgr = _major_gc_manager; - } else { - mgr = _minor_gc_manager; - } assert(mgr->is_gc_memory_manager(), "Sanity check"); mgr->gc_begin(recordGCBeginTime, recordPreGCUsage, recordAccumulatedGCTime); @@ -485,22 +181,16 @@ } } -void MemoryService::gc_end(bool fullGC, bool recordPostGCUsage, +void MemoryService::gc_end(GCMemoryManager* mgr, bool recordPostGCUsage, bool recordAccumulatedGCTime, bool recordGCEndTime, bool countCollection, GCCause::Cause cause) { - GCMemoryManager* mgr; - if (fullGC) { - mgr = (GCMemoryManager*) _major_gc_manager; - } else { - mgr = (GCMemoryManager*) _minor_gc_manager; - } assert(mgr->is_gc_memory_manager(), "Sanity check"); // register the GC end statistics and memory usage mgr->gc_end(recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime, - countCollection, cause); + countCollection, cause); } void MemoryService::oops_do(OopClosure* f) { @@ -551,36 +241,7 @@ return obj; } -// GC manager type depends on the type of Generation. Depending on the space -// availability and vm options the gc uses major gc manager or minor gc -// manager or both. The type of gc manager depends on the generation kind. -// For DefNew and ParNew generation doing scavenge gc uses minor gc manager (so -// _fullGC is set to false ) and for other generation kinds doing -// mark-sweep-compact uses major gc manager (so _fullGC is set to true). -TraceMemoryManagerStats::TraceMemoryManagerStats(Generation::Name kind, GCCause::Cause cause) { - switch (kind) { - case Generation::DefNew: -#if INCLUDE_ALL_GCS - case Generation::ParNew: -#endif // INCLUDE_ALL_GCS - _fullGC = false; - break; - case Generation::MarkSweepCompact: -#if INCLUDE_ALL_GCS - case Generation::ConcurrentMarkSweep: -#endif // INCLUDE_ALL_GCS - _fullGC = true; - break; - default: - _fullGC = false; - assert(false, "Unrecognized gc generation kind."); - } - // this has to be called in a stop the world pause and represent - // an entire gc pause, start to finish: - initialize(_fullGC, cause, true, true, true, true, true, true, true); -} - -TraceMemoryManagerStats::TraceMemoryManagerStats(bool fullGC, +TraceMemoryManagerStats::TraceMemoryManagerStats(GCMemoryManager* gc_mem_mgr, GCCause::Cause cause, bool recordGCBeginTime, bool recordPreGCUsage, @@ -589,14 +250,14 @@ bool recordAccumulatedGCTime, bool recordGCEndTime, bool countCollection) { - initialize(fullGC, cause, recordGCBeginTime, recordPreGCUsage, recordPeakUsage, + initialize(gc_mem_mgr, cause, recordGCBeginTime, recordPreGCUsage, recordPeakUsage, recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime, countCollection); } // for a subclass to create then initialize an instance before invoking // the MemoryService -void TraceMemoryManagerStats::initialize(bool fullGC, +void TraceMemoryManagerStats::initialize(GCMemoryManager* gc_mem_mgr, GCCause::Cause cause, bool recordGCBeginTime, bool recordPreGCUsage, @@ -605,7 +266,7 @@ bool recordAccumulatedGCTime, bool recordGCEndTime, bool countCollection) { - _fullGC = fullGC; + _gc_mem_mgr = gc_mem_mgr; _recordGCBeginTime = recordGCBeginTime; _recordPreGCUsage = recordPreGCUsage; _recordPeakUsage = recordPeakUsage; @@ -615,11 +276,11 @@ _countCollection = countCollection; _cause = cause; - MemoryService::gc_begin(_fullGC, _recordGCBeginTime, _recordAccumulatedGCTime, + MemoryService::gc_begin(_gc_mem_mgr, _recordGCBeginTime, _recordAccumulatedGCTime, _recordPreGCUsage, _recordPeakUsage); } TraceMemoryManagerStats::~TraceMemoryManagerStats() { - MemoryService::gc_end(_fullGC, _recordPostGCUsage, _recordAccumulatedGCTime, + MemoryService::gc_end(_gc_mem_mgr, _recordPostGCUsage, _recordAccumulatedGCTime, _recordGCEndTime, _countCollection, _cause); } diff --git a/src/hotspot/share/services/memoryService.hpp b/src/hotspot/share/services/memoryService.hpp --- a/src/hotspot/share/services/memoryService.hpp +++ b/src/hotspot/share/services/memoryService.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,10 +61,6 @@ static GrowableArray* _pools_list; static GrowableArray* _managers_list; - // memory managers for minor and major GC statistics - static GCMemoryManager* _major_gc_manager; - static GCMemoryManager* _minor_gc_manager; - // memory manager and code heap pools for the CodeCache static MemoryManager* _code_cache_manager; static GrowableArray* _code_heap_pools; @@ -72,51 +68,6 @@ static MemoryPool* _metaspace_pool; static MemoryPool* _compressed_class_pool; - static void add_generation_memory_pool(Generation* gen, - MemoryManager* major_mgr, - MemoryManager* minor_mgr); - static void add_generation_memory_pool(Generation* gen, - MemoryManager* major_mgr) { - add_generation_memory_pool(gen, major_mgr, NULL); - } - - - static void add_psYoung_memory_pool(PSYoungGen* young_gen, - MemoryManager* major_mgr, - MemoryManager* minor_mgr); - static void add_psOld_memory_pool(PSOldGen* old_gen, - MemoryManager* mgr); - - static void add_g1YoungGen_memory_pool(G1CollectedHeap* g1h, - MemoryManager* major_mgr, - MemoryManager* minor_mgr); - static void add_g1OldGen_memory_pool(G1CollectedHeap* g1h, - MemoryManager* mgr); - - static MemoryPool* add_space(ContiguousSpace* space, - const char* name, - bool is_heap, - size_t max_size, - bool support_usage_threshold); - static MemoryPool* add_survivor_spaces(DefNewGeneration* young_gen, - const char* name, - bool is_heap, - size_t max_size, - bool support_usage_threshold); - static MemoryPool* add_gen(Generation* gen, - const char* name, - bool is_heap, - bool support_usage_threshold); - static MemoryPool* add_cms_space(CompactibleFreeListSpace* space, - const char* name, - bool is_heap, - size_t max_size, - bool support_usage_threshold); - - static void add_gen_collected_heap_info(GenCollectedHeap* heap); - static void add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap); - static void add_g1_heap_info(G1CollectedHeap* g1h); - public: static void set_universe_heap(CollectedHeap* heap); static void add_code_heap_memory_pool(CodeHeap* heap, const char* name); @@ -155,10 +106,10 @@ } static void track_memory_pool_usage(MemoryPool* pool); - static void gc_begin(bool fullGC, bool recordGCBeginTime, + static void gc_begin(GCMemoryManager* mgr, bool recordGCBeginTime, bool recordAccumulatedGCTime, bool recordPreGCUsage, bool recordPeakUsage); - static void gc_end(bool fullGC, bool recordPostGCUsage, + static void gc_end(GCMemoryManager* mgr, bool recordPostGCUsage, bool recordAccumulatedGCTime, bool recordGCEndTime, bool countCollection, GCCause::Cause cause); @@ -170,19 +121,11 @@ // Create an instance of java/lang/management/MemoryUsage static Handle create_MemoryUsage_obj(MemoryUsage usage, TRAPS); - - static const GCMemoryManager* get_minor_gc_manager() { - return _minor_gc_manager; - } - - static const GCMemoryManager* get_major_gc_manager() { - return _major_gc_manager; - } }; class TraceMemoryManagerStats : public StackObj { private: - bool _fullGC; + GCMemoryManager* _gc_mem_mgr; bool _recordGCBeginTime; bool _recordPreGCUsage; bool _recordPeakUsage; @@ -193,7 +136,7 @@ GCCause::Cause _cause; public: TraceMemoryManagerStats() {} - TraceMemoryManagerStats(bool fullGC, + TraceMemoryManagerStats(GCMemoryManager* gc_mem_mgr, GCCause::Cause cause, bool recordGCBeginTime = true, bool recordPreGCUsage = true, @@ -203,7 +146,7 @@ bool recordGCEndTime = true, bool countCollection = true); - void initialize(bool fullGC, + void initialize(GCMemoryManager* gc_mem_mgr, GCCause::Cause cause, bool recordGCBeginTime, bool recordPreGCUsage, @@ -213,7 +156,6 @@ bool recordGCEndTime, bool countCollection); - TraceMemoryManagerStats(Generation::Name kind, GCCause::Cause cause); ~TraceMemoryManagerStats(); };