--- old/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2017-11-15 17:15:23.140587195 +0100 +++ new/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2017-11-15 17:15:22.892577393 +0100 @@ -39,7 +39,6 @@ #include "gc/g1/g1ConcurrentRefineThread.hpp" #include "gc/g1/g1EvacStats.inline.hpp" #include "gc/g1/g1FullCollector.hpp" -#include "gc/g1/g1FullGCScope.hpp" #include "gc/g1/g1GCPhaseTimes.hpp" #include "gc/g1/g1HeapSizingPolicy.hpp" #include "gc/g1/g1HeapTransition.hpp" @@ -1217,34 +1216,6 @@ #endif } -void G1CollectedHeap::do_full_collection_inner(G1FullGCScope* scope) { - GCTraceTime(Info, gc) tm("Pause Full", NULL, gc_cause(), true); - g1_policy()->record_full_collection_start(); - - print_heap_before_gc(); - print_heap_regions(); - - abort_concurrent_cycle(); - verify_before_full_collection(scope->is_explicit_gc()); - - gc_prologue(true); - prepare_heap_for_full_collection(); - - G1FullCollector collector(scope, ref_processor_stw(), concurrent_mark()->next_mark_bitmap(), workers()->active_workers()); - collector.prepare_collection(); - collector.collect(); - collector.complete_collection(); - - prepare_heap_for_mutators(); - - g1_policy()->record_full_collection_end(); - gc_epilogue(true); - - verify_after_full_collection(); - - print_heap_after_full_collection(scope->heap_transition()); -} - bool G1CollectedHeap::do_full_collection(bool explicit_gc, bool clear_all_soft_refs) { assert_at_safepoint(true /* should_be_vm_thread */); @@ -1257,8 +1228,12 @@ const bool do_clear_all_soft_refs = clear_all_soft_refs || collector_policy()->should_clear_all_soft_refs(); - G1FullGCScope scope(explicit_gc, do_clear_all_soft_refs); - do_full_collection_inner(&scope); + G1FullCollector collector(this, explicit_gc, do_clear_all_soft_refs); + GCTraceTime(Info, gc) tm("Pause Full", NULL, gc_cause(), true); + + collector.prepare_collection(); + collector.collect(); + collector.complete_collection(); // Full collection was successfully completed. return true; --- old/src/hotspot/share/gc/g1/g1CollectedHeap.hpp 2017-11-15 17:15:24.020621978 +0100 +++ new/src/hotspot/share/gc/g1/g1CollectedHeap.hpp 2017-11-15 17:15:23.784612650 +0100 @@ -126,6 +126,7 @@ friend class VM_G1IncCollectionPause; friend class VMStructs; friend class MutatorAllocRegion; + friend class G1FullCollector; friend class G1GCAllocRegion; friend class G1HeapVerifier; @@ -517,7 +518,6 @@ private: // Internal helpers used during full GC to split it up to // increase readability. - void do_full_collection_inner(G1FullGCScope* scope); void abort_concurrent_cycle(); void verify_before_full_collection(bool explicit_gc); void prepare_heap_for_full_collection(); --- old/src/hotspot/share/gc/g1/g1FullCollector.cpp 2017-11-15 17:15:24.888656286 +0100 +++ new/src/hotspot/share/gc/g1/g1FullCollector.cpp 2017-11-15 17:15:24.624645851 +0100 @@ -35,6 +35,7 @@ #include "gc/g1/g1FullGCReferenceProcessorExecutor.hpp" #include "gc/g1/g1FullGCScope.hpp" #include "gc/g1/g1OopClosures.hpp" +#include "gc/g1/g1Policy.hpp" #include "gc/g1/g1StringDedup.hpp" #include "gc/shared/gcTraceTime.inline.hpp" #include "gc/shared/preservedMarks.hpp" @@ -62,20 +63,24 @@ #endif } -G1FullCollector::G1FullCollector(G1FullGCScope* scope, - ReferenceProcessor* reference_processor, - G1CMBitMap* bitmap, - uint workers) : - _scope(scope), - _num_workers(workers), - _mark_bitmap(bitmap), +G1CMBitMap* G1FullCollector::mark_bitmap() { + return heap()->concurrent_mark()->next_mark_bitmap(); +} + +ReferenceProcessor* G1FullCollector::reference_processor() { + return heap()->ref_processor_stw(); +} + +G1FullCollector::G1FullCollector(G1CollectedHeap* heap, bool explicit_gc, bool clear_soft_refs) : + _heap(heap), + _scope(explicit_gc, clear_soft_refs), + _num_workers(_heap->workers()->active_workers()), _oop_queue_set(_num_workers), _array_queue_set(_num_workers), _preserved_marks_set(true), - _reference_processor(reference_processor), _serial_compaction_point(), - _is_alive(_mark_bitmap), - _is_alive_mutator(_reference_processor, &_is_alive) { + _is_alive(mark_bitmap()), + _is_alive_mutator(reference_processor(), &_is_alive) { assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint"); _preserved_marks_set.init(_num_workers); @@ -99,8 +104,19 @@ } void G1FullCollector::prepare_collection() { - _reference_processor->enable_discovery(); - _reference_processor->setup_policy(scope()->should_clear_soft_refs()); + heap()->g1_policy()->record_full_collection_start(); + + heap()->print_heap_before_gc(); + heap()->print_heap_regions(); + + heap()->abort_concurrent_cycle(); + heap()->verify_before_full_collection(scope()->is_explicit_gc()); + + heap()->gc_prologue(true); + heap()->prepare_heap_for_full_collection(); + + reference_processor()->enable_discovery(); + reference_processor()->setup_policy(scope()->should_clear_soft_refs()); // When collecting the permanent generation Method*s may be moving, // so we either have to flush all bcp data or convert it into bci. @@ -139,6 +155,15 @@ BiasedLocking::restore_marks(); CodeCache::gc_epilogue(); JvmtiExport::gc_epilogue(); + + heap()->prepare_heap_for_mutators(); + + heap()->g1_policy()->record_full_collection_end(); + heap()->gc_epilogue(true); + + heap()->verify_after_full_collection(); + + heap()->print_heap_after_full_collection(scope()->heap_transition()); } void G1FullCollector::phase1_mark_live_objects() { --- old/src/hotspot/share/gc/g1/g1FullCollector.hpp 2017-11-15 17:15:25.772691226 +0100 +++ new/src/hotspot/share/gc/g1/g1FullCollector.hpp 2017-11-15 17:15:25.520681266 +0100 @@ -28,6 +28,7 @@ #include "gc/g1/g1FullGCCompactionPoint.hpp" #include "gc/g1/g1FullGCMarker.hpp" #include "gc/g1/g1FullGCOopClosures.hpp" +#include "gc/g1/g1FullGCScope.hpp" #include "gc/shared/preservedMarks.hpp" #include "gc/shared/referenceProcessor.hpp" #include "gc/shared/taskqueue.hpp" @@ -42,41 +43,37 @@ // The G1FullCollector holds data associated with the current Full GC. class G1FullCollector : StackObj { - G1FullGCScope* _scope; + G1CollectedHeap* _heap; + G1FullGCScope _scope; uint _num_workers; G1FullGCMarker** _markers; G1FullGCCompactionPoint** _compaction_points; - G1CMBitMap* _mark_bitmap; OopQueueSet _oop_queue_set; ObjArrayTaskQueueSet _array_queue_set; PreservedMarksSet _preserved_marks_set; - ReferenceProcessor* _reference_processor; G1FullGCCompactionPoint _serial_compaction_point; - G1IsAliveClosure _is_alive; ReferenceProcessorIsAliveMutator _is_alive_mutator; public: - G1FullCollector(G1FullGCScope* scope, - ReferenceProcessor* reference_processor, - G1CMBitMap* mark_bitmap, - uint workers); + G1FullCollector(G1CollectedHeap* heap, bool explicit_gc, bool clear_soft_refs); ~G1FullCollector(); void prepare_collection(); void collect(); void complete_collection(); - G1FullGCScope* scope() { return _scope; } + G1CollectedHeap* heap() { return _heap; } + G1FullGCScope* scope() { return &_scope; } uint workers() { return _num_workers; } G1FullGCMarker* marker(uint id) { return _markers[id]; } G1FullGCCompactionPoint* compaction_point(uint id) { return _compaction_points[id]; } - G1CMBitMap* mark_bitmap() { return _mark_bitmap; } OopQueueSet* oop_queue_set() { return &_oop_queue_set; } ObjArrayTaskQueueSet* array_queue_set() { return &_array_queue_set; } PreservedMarksSet* preserved_mark_set() { return &_preserved_marks_set; } - ReferenceProcessor* reference_processor() { return _reference_processor; } G1FullGCCompactionPoint* serial_compaction_point() { return &_serial_compaction_point; } + G1CMBitMap* mark_bitmap(); + ReferenceProcessor* reference_processor(); private: void phase1_mark_live_objects();