--- old/src/hotspot/share/gc/epsilon/epsilonHeap.cpp 2020-08-05 21:29:24.497604249 +0800 +++ new/src/hotspot/share/gc/epsilon/epsilonHeap.cpp 2020-08-05 21:29:24.193604238 +0800 @@ -277,11 +277,6 @@ _space->object_iterate(cl); } -// No workGang for EpsilonHeap, work serially with thread 0 -void EpsilonHeap::run_task(AbstractGangTask* task) { - task->work(0); -} - void EpsilonHeap::print_on(outputStream *st) const { st->print_cr("Epsilon Heap"); --- old/src/hotspot/share/gc/epsilon/epsilonHeap.hpp 2020-08-05 21:29:25.033604268 +0800 +++ new/src/hotspot/share/gc/epsilon/epsilonHeap.hpp 2020-08-05 21:29:24.741604257 +0800 @@ -119,6 +119,10 @@ // No GC threads virtual void gc_threads_do(ThreadClosure* tc) const {} + // Runs the given AbstractGangTask with the current active workers + // No workGang for EpsilonHeap, work serially with thread 0 + virtual void run_task(AbstractGangTask* task) { task->work(0); } + // No nmethod handling virtual void register_nmethod(nmethod* nm) {} virtual void unregister_nmethod(nmethod* nm) {} @@ -141,8 +145,6 @@ virtual void print_tracing_info() const; virtual bool print_location(outputStream* st, void* addr) const; - // Runs the given AbstractGangTask with the current active workers. - virtual void run_task(AbstractGangTask* task); private: void print_heap_info(size_t used) const; --- old/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2020-08-05 21:29:25.825604296 +0800 +++ new/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2020-08-05 21:29:25.521604285 +0800 @@ -2300,6 +2300,30 @@ heap_region_iterate(&blk); } +class G1ParallelObjectIterator : public ParallelObjectIterator { +private: + G1CollectedHeap* _heap; + HeapRegionClaimer _claimer; + +public: + G1ParallelObjectIterator(uint thread_num) : + _heap(G1CollectedHeap::heap()), + _claimer(thread_num == 0 ? G1CollectedHeap::heap()->workers()->active_workers() : thread_num) {} + + virtual void object_iterate(ObjectClosure* cl, uint worker_id) { + _heap->object_iterate_parallel(cl, worker_id, &_claimer); + } +}; + +ParallelObjectIterator* G1CollectedHeap::parallel_object_iterator(uint thread_num) { + return new G1ParallelObjectIterator(thread_num); +} + +void G1CollectedHeap::object_iterate_parallel(ObjectClosure* cl, uint worker_id, HeapRegionClaimer* claimer) { + IterateObjectClosureRegionClosure blk(cl); + heap_region_par_iterate_from_worker_offset(&blk, claimer, worker_id); +} + void G1CollectedHeap::keep_alive(oop obj) { G1BarrierSet::enqueue(obj); } @@ -4919,27 +4943,3 @@ GrowableArray G1CollectedHeap::memory_pools() { return _g1mm->memory_pools(); } - -class G1ParallelObjectIterator : public ParallelObjectIterator { -private: - G1CollectedHeap* _heap; - HeapRegionClaimer _claimer; - -public: - G1ParallelObjectIterator(uint thread_num) : - _heap(G1CollectedHeap::heap()), - _claimer(thread_num == 0 ? G1CollectedHeap::heap()->workers()->active_workers() : thread_num) {} - - virtual void object_iterate(ObjectClosure* cl, uint worker_id) { - _heap->object_iterate_parallel(cl, worker_id, &_claimer); - } -}; - -ParallelObjectIterator* G1CollectedHeap::parallel_object_iterator(uint thread_num) { - return new G1ParallelObjectIterator(thread_num); -} - -void G1CollectedHeap::object_iterate_parallel(ObjectClosure* cl, uint worker_id, HeapRegionClaimer* claimer) { - IterateObjectClosureRegionClosure blk(cl); - heap_region_par_iterate_from_worker_offset(&blk, claimer, worker_id); -} --- old/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp 2020-08-05 21:29:26.913604335 +0800 +++ new/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp 2020-08-05 21:29:26.605604324 +0800 @@ -539,10 +539,6 @@ old_gen()->object_iterate(cl); } -void ParallelScavengeHeap::run_task(AbstractGangTask* task) { - _workers.run_task(task); -} - HeapWord* ParallelScavengeHeap::block_start(const void* addr) const { if (young_gen()->is_in_reserved(addr)) { assert(young_gen()->is_in(addr), @@ -618,6 +614,10 @@ ParallelScavengeHeap::heap()->workers().threads_do(tc); } +void ParallelScavengeHeap::run_task(AbstractGangTask* task) { + _workers.run_task(task); +} + void ParallelScavengeHeap::print_tracing_info() const { AdaptiveSizePolicyOutput::print(); log_debug(gc, heap, exit)("Accumulated young generation GC time %3.7f secs", PSScavenge::accumulated_time()->seconds()); --- old/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp 2020-08-05 21:29:27.717604364 +0800 +++ new/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp 2020-08-05 21:29:27.417604353 +0800 @@ -220,6 +220,8 @@ virtual void print_on(outputStream* st) const; virtual void print_on_error(outputStream* st) const; virtual void gc_threads_do(ThreadClosure* tc) const; + // Runs the given AbstractGangTask with the current active workers. + virtual void run_task(AbstractGangTask* task); virtual void print_tracing_info() const; virtual WorkGang* get_safepoint_workers() { return &_workers; } @@ -259,9 +261,6 @@ WorkGang& workers() { return _workers; } - - // Runs the given AbstractGangTask with the current active workers. - virtual void run_task(AbstractGangTask* task); }; // Class that can be used to print information about the --- old/src/hotspot/share/gc/serial/serialHeap.hpp 2020-08-05 21:29:28.313604385 +0800 +++ new/src/hotspot/share/gc/serial/serialHeap.hpp 2020-08-05 21:29:28.009604374 +0800 @@ -77,6 +77,7 @@ OopClosureType2* older); // Runs the given AbstractGangTask with the current active workers. + // No workGang for SerialHeap, work serially with thread 0. virtual void run_task(AbstractGangTask* task); }; --- old/src/hotspot/share/gc/shared/collectedHeap.hpp 2020-08-05 21:29:29.097604413 +0800 +++ new/src/hotspot/share/gc/shared/collectedHeap.hpp 2020-08-05 21:29:28.797604402 +0800 @@ -29,8 +29,8 @@ #include "gc/shared/gcWhen.hpp" #include "gc/shared/verifyOption.hpp" #include "memory/allocation.hpp" -#include "memory/universe.hpp" #include "memory/heapInspection.hpp" +#include "memory/universe.hpp" #include "runtime/handles.hpp" #include "runtime/perfData.hpp" #include "runtime/safepoint.hpp" @@ -412,9 +412,6 @@ return NULL; } - // Run given task. Possibly in parallel if the GC supports it. - virtual void run_task(AbstractGangTask* task) = 0; - // Keep alive an object that was loaded with AS_NO_KEEPALIVE. virtual void keep_alive(oop obj) {} @@ -461,6 +458,9 @@ // Iterator for all GC threads (other than VM thread) virtual void gc_threads_do(ThreadClosure* tc) const = 0; + // Run given task. Possibly in parallel if the GC supports it. + virtual void run_task(AbstractGangTask* task) = 0; + // Print any relevant tracing info that flags imply. // Default implementation does nothing. virtual void print_tracing_info() const = 0; --- old/src/hotspot/share/gc/shared/gcVMOperations.hpp 2020-08-05 21:29:29.901604441 +0800 +++ new/src/hotspot/share/gc/shared/gcVMOperations.hpp 2020-08-05 21:29:29.589604430 +0800 @@ -129,11 +129,11 @@ public: VM_GC_HeapInspection(outputStream* out, bool request_full_gc, uint parallel_thread_num = 1) : - VM_GC_Operation(0 /* total collections, dummy, ignored */, - GCCause::_heap_inspection /* GC Cause */, - 0 /* total full collections, dummy, ignored */, - request_full_gc), _out(out), _full_gc(request_full_gc), - _parallel_thread_num(parallel_thread_num) {} + VM_GC_Operation(0 /* total collections, dummy, ignored */, + GCCause::_heap_inspection /* GC Cause */, + 0 /* total full collections, dummy, ignored */, + request_full_gc), _out(out), _full_gc(request_full_gc), + _parallel_thread_num(parallel_thread_num) {} ~VM_GC_HeapInspection() {} virtual VMOp_Type type() const { return VMOp_GC_HeapInspection; } --- old/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp 2020-08-05 21:29:30.709604470 +0800 +++ new/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp 2020-08-05 21:29:30.405604459 +0800 @@ -1215,6 +1215,10 @@ } } +void ShenandoahHeap::run_task(AbstractGangTask* task) { + workers()->run_task(task, workers()->active_workers()); +} + void ShenandoahHeap::print_tracing_info() const { LogTarget(Info, gc, stats) lt; if (lt.is_enabled()) { @@ -1343,10 +1347,6 @@ } } -void ShenandoahHeap::run_task(AbstractGangTask* task) { - workers()->run_task(task, workers()->active_workers()); -} - // Keep alive an object that was loaded with AS_NO_KEEPALIVE. void ShenandoahHeap::keep_alive(oop obj) { if (is_concurrent_mark_in_progress()) { --- old/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp 2020-08-05 21:29:31.557604501 +0800 +++ new/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp 2020-08-05 21:29:31.237604489 +0800 @@ -209,6 +209,8 @@ WorkGang* get_safepoint_workers(); void gc_threads_do(ThreadClosure* tcl) const; + // Runs the given AbstractGangTask with the current active workers. + virtual void run_task(AbstractGangTask* task); // ---------- Heap regions handling machinery // @@ -617,10 +619,6 @@ void tlabs_retire(bool resize); void gclabs_retire(bool resize); - // Runs the given AbstractGangTask with the current active workers. - // Returns the total time to run the task. - virtual void run_task(AbstractGangTask* task); - // ---------- Marking support // private: --- old/src/hotspot/share/gc/z/zHeap.hpp 2020-08-05 21:29:32.361604529 +0800 +++ new/src/hotspot/share/gc/z/zHeap.hpp 2020-08-05 21:29:32.061604519 +0800 @@ -98,8 +98,8 @@ uint nconcurrent_no_boost_worker_threads() const; void set_boost_worker_threads(bool boost); void threads_do(ThreadClosure* tc) const; - void run_task(AbstractGangTask* task); + // Reference processing ReferenceDiscoverer* reference_discoverer(); void set_soft_reference_policy(bool clear); --- old/src/hotspot/share/memory/heapInspection.cpp 2020-08-05 21:29:33.165604558 +0800 +++ new/src/hotspot/share/memory/heapInspection.cpp 2020-08-05 21:29:32.861604547 +0800 @@ -518,7 +518,7 @@ class RecordInstanceClosure : public ObjectClosure { private: KlassInfoTable* _cit; - uint _missed_count; + uintx _missed_count; BoolObjectClosure* _filter; public: RecordInstanceClosure(KlassInfoTable* cit, BoolObjectClosure* filter) : @@ -532,7 +532,7 @@ } } - uint missed_count() { return _missed_count; } + uintx missed_count() { return _missed_count; } private: bool should_visit(oop obj) { @@ -543,7 +543,7 @@ // Heap inspection for every worker. // When native OOM hanppens for KlassInfoTable, set _success to false. void ParHeapInspectTask::work(uint worker_id) { - uint missed_count = 0; + uintx missed_count = 0; bool merge_success = true; if (!Atomic::load(&_success)) { // other worker has failed on parallel iteration. @@ -570,7 +570,7 @@ } } -uint HeapInspection::populate_table(KlassInfoTable* cit, BoolObjectClosure *filter, uint parallel_thread_num) { +uintx HeapInspection::populate_table(KlassInfoTable* cit, BoolObjectClosure *filter, uint parallel_thread_num) { // Try parallel first. if (parallel_thread_num > 1) { @@ -599,7 +599,7 @@ KlassInfoTable cit(false); if (!cit.allocation_failed()) { // populate table with object allocation info - uint missed_count = populate_table(&cit, NULL, parallel_thread_num); + uintx missed_count = populate_table(&cit, NULL, parallel_thread_num); if (missed_count != 0) { log_info(gc, classhisto)("WARNING: Ran out of C-heap; undercounted " UINTX_FORMAT " total instances in data below", --- old/src/hotspot/share/memory/heapInspection.hpp 2020-08-05 21:29:33.737604578 +0800 +++ new/src/hotspot/share/memory/heapInspection.hpp 2020-08-05 21:29:33.441604568 +0800 @@ -217,7 +217,7 @@ class HeapInspection : public StackObj { public: void heap_inspection(outputStream* st, uint parallel_thread_num = 1) NOT_SERVICES_RETURN; - uint populate_table(KlassInfoTable* cit, BoolObjectClosure* filter = NULL, uint parallel_thread_num = 1) NOT_SERVICES_RETURN_(0); + uintx populate_table(KlassInfoTable* cit, BoolObjectClosure* filter = NULL, uint parallel_thread_num = 1) NOT_SERVICES_RETURN_(0); static void find_instances_at_safepoint(Klass* k, GrowableArray* result) NOT_SERVICES_RETURN; private: void iterate_over_heap(KlassInfoTable* cit, BoolObjectClosure* filter = NULL); @@ -231,7 +231,7 @@ ParallelObjectIterator* _poi; KlassInfoTable* _shared_cit; BoolObjectClosure* _filter; - uint _missed_count; + uintx _missed_count; bool _success; Mutex _mutex; @@ -247,7 +247,7 @@ _success(true), _mutex(Mutex::leaf, "Parallel heap iteration data merge lock") {} - uint missed_count() const { + uintx missed_count() const { return _missed_count; }