--- old/src/hotspot/share/gc/cms/cmsHeap.cpp 2017-11-28 22:17:21.023614801 +0100 +++ new/src/hotspot/share/gc/cms/cmsHeap.cpp 2017-11-28 22:17:20.631619439 +0100 @@ -65,9 +65,6 @@ CMSHeap::CMSHeap(GenCollectorPolicy *policy) : GenCollectedHeap(policy), _eden_pool(NULL), _survivor_pool(NULL), _old_pool(NULL) { - _young_manager = new GCMemoryManager("ParNew", "end of minor GC"); - _old_manager = new GCMemoryManager("ConcurrentMarkSweep", "end of major GC"); - _workers = new WorkGang("GC Thread", ParallelGCThreads, /* are_GC_task_threads */true, /* are_ConcurrentGC_threads */false); @@ -85,6 +82,13 @@ return JNI_ENOMEM; } + return JNI_OK; +} + +void CMSHeap::initialize_serviceability() { + _young_manager = new GCMemoryManager("ParNew", "end of minor GC"); + _old_manager = new GCMemoryManager("ConcurrentMarkSweep", "end of major GC"); + ParNewGeneration* young = (ParNewGeneration*) young_gen(); _eden_pool = new ContiguousSpacePool(young->eden(), "Par Eden Space", @@ -111,7 +115,6 @@ _old_manager->add_pool(_old_pool); old ->set_gc_manager(_old_manager); - return JNI_OK; } void CMSHeap::check_gen_kinds() { --- old/src/hotspot/share/gc/cms/cmsHeap.hpp 2017-11-28 22:17:22.092602150 +0100 +++ new/src/hotspot/share/gc/cms/cmsHeap.hpp 2017-11-28 22:17:21.667607180 +0100 @@ -109,6 +109,8 @@ virtual void gc_prologue(bool full); virtual void gc_epilogue(bool full); + virtual void initialize_serviceability(); + // Accessor for memory state verification support NOT_PRODUCT( virtual size_t skip_header_HeapWords() { return CMSCollector::skip_header_HeapWords(); } --- old/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2017-11-28 22:17:23.147589666 +0100 +++ new/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2017-11-28 22:17:22.707594873 +0100 @@ -1827,6 +1827,16 @@ // values in the heap have been properly initialized. _g1mm = new G1MonitoringSupport(this); + G1StringDedup::initialize(); + + _preserved_marks_set.init(ParallelGCThreads); + + _collection_set.initialize(max_regions()); + + return JNI_OK; +} + +void G1CollectedHeap::initialize_serviceability() { _eden_pool = new G1EdenPool(this); _survivor_pool = new G1SurvivorPool(this); _old_pool = new G1OldGenPool(this); @@ -1838,13 +1848,6 @@ _memory_manager.add_pool(_eden_pool); _memory_manager.add_pool(_survivor_pool); - G1StringDedup::initialize(); - - _preserved_marks_set.init(ParallelGCThreads); - - _collection_set.initialize(max_regions()); - - return JNI_OK; } void G1CollectedHeap::stop() { @@ -1872,6 +1875,7 @@ } void G1CollectedHeap::post_initialize() { + CollectedHeap::post_initialize(); ref_processing_init(); } --- old/src/hotspot/share/gc/g1/g1CollectedHeap.hpp 2017-11-28 22:17:24.253576578 +0100 +++ new/src/hotspot/share/gc/g1/g1CollectedHeap.hpp 2017-11-28 22:17:23.825581642 +0100 @@ -171,6 +171,8 @@ // It keeps track of the humongous regions. HeapRegionSet _humongous_set; + virtual void initialize_serviceability(); + void eagerly_reclaim_humongous_regions(); // Start a new incremental collection set for the next pause. void start_new_collection_set(); --- old/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp 2017-11-28 22:17:25.319563963 +0100 +++ new/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp 2017-11-28 22:17:24.902568897 +0100 @@ -118,6 +118,10 @@ return JNI_ENOMEM; } + return JNI_OK; +} + +void ParallelScavengeHeap::initialize_serviceability() { _eden_pool = new EdenMutableSpacePool(_young_gen, _young_gen->eden_space(), @@ -142,10 +146,10 @@ _young_manager->add_pool(_eden_pool); _young_manager->add_pool(_survivor_pool); - return JNI_OK; } void ParallelScavengeHeap::post_initialize() { + CollectedHeap::post_initialize(); // Need to init the tenuring threshold PSScavenge::initialize(); if (UseParallelOldGC) { --- old/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp 2017-11-28 22:17:26.395551230 +0100 +++ new/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp 2017-11-28 22:17:25.957556413 +0100 @@ -74,6 +74,8 @@ MemoryPool* _survivor_pool; MemoryPool* _old_pool; + virtual void initialize_serviceability(); + void trace_heap(GCWhen::Type when, const GCTracer* tracer); protected: --- old/src/hotspot/share/gc/serial/serialHeap.cpp 2017-11-28 22:17:27.490538272 +0100 +++ new/src/hotspot/share/gc/serial/serialHeap.cpp 2017-11-28 22:17:27.074543195 +0100 @@ -34,18 +34,16 @@ _old_manager = new GCMemoryManager("MarkSweepCompact", "end of major GC"); } -jint SerialHeap::initialize() { - jint status = GenCollectedHeap::initialize(); - if (status != JNI_OK) return status; +void SerialHeap::initialize_serviceability() { 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. _eden_pool = new ContiguousSpacePool(young->eden(), - "Eden Space", - young->max_eden_size(), - false /* support_usage_threshold */); + "Eden Space", + young->max_eden_size(), + false /* support_usage_threshold */); _survivor_pool = new SurvivorContiguousSpacePool(young, "Survivor Space", young->max_survivor_size(), @@ -62,7 +60,6 @@ _old_manager->add_pool(_old_pool); old->set_gc_manager(_old_manager); - return JNI_OK; } void SerialHeap::check_gen_kinds() { --- old/src/hotspot/share/gc/serial/serialHeap.hpp 2017-11-28 22:17:28.557525645 +0100 +++ new/src/hotspot/share/gc/serial/serialHeap.hpp 2017-11-28 22:17:28.153530426 +0100 @@ -33,10 +33,13 @@ class MemoryPool; class SerialHeap : public GenCollectedHeap { +private: MemoryPool* _eden_pool; MemoryPool* _survivor_pool; MemoryPool* _old_pool; + virtual void initialize_serviceability(); + protected: virtual void check_gen_kinds(); @@ -51,8 +54,6 @@ return "Serial"; } - virtual jint initialize(); - virtual GrowableArray memory_managers(); virtual GrowableArray memory_pools(); --- old/src/hotspot/share/gc/shared/collectedHeap.cpp 2017-11-28 22:17:29.677512391 +0100 +++ new/src/hotspot/share/gc/shared/collectedHeap.cpp 2017-11-28 22:17:29.242517539 +0100 @@ -611,3 +611,7 @@ _reserved.set_start(start); _reserved.set_end(end); } + +void CollectedHeap::post_initialize() { + initialize_serviceability(); +} --- old/src/hotspot/share/gc/shared/collectedHeap.hpp 2017-11-28 22:17:30.850498511 +0100 +++ new/src/hotspot/share/gc/shared/collectedHeap.hpp 2017-11-28 22:17:30.409503729 +0100 @@ -220,7 +220,7 @@ // In many heaps, there will be a need to perform some initialization activities // after the Universe is fully formed, but before general heap allocation is allowed. // This is the correct place to place such initialization methods. - virtual void post_initialize() = 0; + virtual void post_initialize(); // Stop any onging concurrent work and prepare for exit. virtual void stop() {} @@ -535,6 +535,9 @@ // Generate any dumps preceding or following a full gc private: void full_gc_dump(GCTimer* timer, bool before); + + virtual void initialize_serviceability() = 0; + public: void pre_full_gc_dump(GCTimer* timer); void post_full_gc_dump(GCTimer* timer); --- old/src/hotspot/share/gc/shared/genCollectedHeap.cpp 2017-11-28 22:17:31.872486416 +0100 +++ new/src/hotspot/share/gc/shared/genCollectedHeap.cpp 2017-11-28 22:17:31.456491339 +0100 @@ -143,6 +143,7 @@ } void GenCollectedHeap::post_initialize() { + CollectedHeap::post_initialize(); ref_processing_init(); check_gen_kinds(); DefNewGeneration* def_new_gen = (DefNewGeneration*)_young_gen;