diff -r 8b6cc0bb93d0 -r 9186be5c78ba src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp --- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp Wed Nov 27 06:36:41 2019 -0800 +++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp Wed Nov 27 11:52:57 2019 -0500 @@ -27,8 +27,10 @@ #include "classfile/stringTable.hpp" #include "classfile/systemDictionary.hpp" #include "code/codeCache.hpp" +#include "gc/shenandoah/shenandoahClosures.inline.hpp" +#include "gc/shenandoah/shenandoahConcurrentRoots.hpp" #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp" -#include "gc/shenandoah/shenandoahHeap.inline.hpp" +#include "gc/shenandoah/shenandoahHeap.hpp" #include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "gc/shenandoah/shenandoahStringDedup.hpp" #include "gc/shenandoah/shenandoahTimingTracker.hpp" @@ -159,14 +161,22 @@ _heap->phase_timings()->record_workers_end(_phase); } -ShenandoahRootEvacuator::ShenandoahRootEvacuator(uint n_workers, ShenandoahPhaseTimings::Phase phase, bool include_concurrent_roots) : +ShenandoahRootEvacuator::ShenandoahRootEvacuator(uint n_workers, + ShenandoahPhaseTimings::Phase phase, + bool include_concurrent_roots, + bool include_concurrent_code_roots) : ShenandoahRootProcessor(phase), _thread_roots(n_workers > 1), - _include_concurrent_roots(include_concurrent_roots) { + _include_concurrent_roots(include_concurrent_roots), + _include_concurrent_code_roots(include_concurrent_code_roots) { } void ShenandoahRootEvacuator::roots_do(uint worker_id, OopClosure* oops) { MarkingCodeBlobClosure blobsCl(oops, CodeBlobToOopClosure::FixRelocations); + ShenandoahCodeBlobAndDisarmClosure blobs_and_disarm_Cl(oops); + CodeBlobToOopClosure* codes_cl = ShenandoahConcurrentRoots::can_do_concurrent_class_unloading() ? + static_cast(&blobs_and_disarm_Cl) : + static_cast(&blobsCl); AlwaysTrueClosure always_true; _serial_roots.oops_do(oops, worker_id); @@ -178,8 +188,12 @@ _weak_roots.oops_do(oops, worker_id); } - _thread_roots.oops_do(oops, NULL, worker_id); - _code_roots.code_blobs_do(&blobsCl, worker_id); + if (_include_concurrent_code_roots) { + _code_roots.code_blobs_do(codes_cl, worker_id); + _thread_roots.oops_do(oops, NULL, worker_id); + } else { + _thread_roots.oops_do(oops, codes_cl, worker_id); + } _dedup_roots.oops_do(&always_true, oops, worker_id); } @@ -208,7 +222,11 @@ } void ShenandoahRootAdjuster::roots_do(uint worker_id, OopClosure* oops) { - CodeBlobToOopClosure adjust_code_closure(oops, CodeBlobToOopClosure::FixRelocations); + CodeBlobToOopClosure code_blob_cl(oops, CodeBlobToOopClosure::FixRelocations); + ShenandoahCodeBlobAndDisarmClosure blobs_and_disarm_Cl(oops); + CodeBlobToOopClosure* adjust_code_closure = ShenandoahConcurrentRoots::can_do_concurrent_class_unloading() ? + static_cast(&blobs_and_disarm_Cl) : + static_cast(&code_blob_cl); CLDToOopClosure adjust_cld_closure(oops, ClassLoaderData::_claim_strong); AlwaysTrueClosure always_true; @@ -217,7 +235,7 @@ _thread_roots.oops_do(oops, NULL, worker_id); _cld_roots.cld_do(&adjust_cld_closure, worker_id); - _code_roots.code_blobs_do(&adjust_code_closure, worker_id); + _code_roots.code_blobs_do(adjust_code_closure, worker_id); _serial_weak_roots.weak_oops_do(oops, worker_id); _weak_roots.oops_do(oops, worker_id);