diff --git a/src/hotspot/share/gc/z/zRootsIterator.cpp b/src/hotspot/share/gc/z/zRootsIterator.cpp index 751d268..317c68d 100644 --- a/src/hotspot/share/gc/z/zRootsIterator.cpp +++ b/src/hotspot/share/gc/z/zRootsIterator.cpp @@ -52,16 +52,20 @@ static const ZStatSubPhase ZSubPhasePauseRootsSetup("Pause Roots Setup"); static const ZStatSubPhase ZSubPhasePauseRoots("Pause Roots"); static const ZStatSubPhase ZSubPhasePauseRootsTeardown("Pause Roots Teardown"); static const ZStatSubPhase ZSubPhasePauseRootsUniverse("Pause Roots Universe"); -static const ZStatSubPhase ZSubPhasePauseRootsJNIHandles("Pause Roots JNIHandles"); static const ZStatSubPhase ZSubPhasePauseRootsObjectSynchronizer("Pause Roots ObjectSynchronizer"); static const ZStatSubPhase ZSubPhasePauseRootsManagement("Pause Roots Management"); static const ZStatSubPhase ZSubPhasePauseRootsJVMTIExport("Pause Roots JVMTIExport"); static const ZStatSubPhase ZSubPhasePauseRootsJVMTIWeakExport("Pause Roots JVMTIWeakExport"); static const ZStatSubPhase ZSubPhasePauseRootsSystemDictionary("Pause Roots SystemDictionary"); -static const ZStatSubPhase ZSubPhasePauseRootsClassLoaderDataGraph("Pause Roots ClassLoaderDataGraph"); static const ZStatSubPhase ZSubPhasePauseRootsThreads("Pause Roots Threads"); static const ZStatSubPhase ZSubPhasePauseRootsCodeCache("Pause Roots CodeCache"); +static const ZStatSubPhase ZSubPhaseConcurrentRootsSetup("Concurrent Roots Setup"); +static const ZStatSubPhase ZSubPhaseConcurrentRoots("Concurrent Roots"); +static const ZStatSubPhase ZSubPhaseConcurrentRootsTeardown("Concurrent Roots Teardown"); +static const ZStatSubPhase ZSubPhaseConcurrentRootsJNIHandles("Concurrent Roots JNIHandles"); +static const ZStatSubPhase ZSubPhaseConcurrentRootsClassLoaderDataGraph("Concurrent Roots ClassLoaderDataGraph"); + static const ZStatSubPhase ZSubPhasePauseWeakRootsSetup("Pause Weak Roots Setup"); static const ZStatSubPhase ZSubPhasePauseWeakRoots("Pause Weak Roots"); static const ZStatSubPhase ZSubPhasePauseWeakRootsTeardown("Pause Weak Roots Teardown"); @@ -128,21 +132,17 @@ void ZParallelWeakOopsDo::weak_oops_do(BoolObjectClosure* is_alive, OopClo } ZRootsIterator::ZRootsIterator() : - _jni_handles_iter(JNIHandles::global_handles()), _universe(this), _object_synchronizer(this), _management(this), _jvmti_export(this), _jvmti_weak_export(this), _system_dictionary(this), - _jni_handles(this), - _class_loader_data_graph(this), _threads(this), _code_cache(this) { assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); ZStatTimer timer(ZSubPhasePauseRootsSetup); Threads::change_thread_claim_parity(); - ClassLoaderDataGraph::clear_claimed_marks(); COMPILER2_PRESENT(DerivedPointerTable::clear()); CodeCache::gc_prologue(); ZNMethodTable::gc_prologue(); @@ -163,11 +163,6 @@ void ZRootsIterator::do_universe(OopClosure* cl) { Universe::oops_do(cl); } -void ZRootsIterator::do_jni_handles(OopClosure* cl) { - ZStatTimer timer(ZSubPhasePauseRootsJNIHandles); - _jni_handles_iter.oops_do(cl); -} - void ZRootsIterator::do_object_synchronizer(OopClosure* cl) { ZStatTimer timer(ZSubPhasePauseRootsObjectSynchronizer); ObjectSynchronizer::oops_do(cl); @@ -194,12 +189,6 @@ void ZRootsIterator::do_system_dictionary(OopClosure* cl) { SystemDictionary::oops_do(cl); } -void ZRootsIterator::do_class_loader_data_graph(OopClosure* cl) { - ZStatTimer timer(ZSubPhasePauseRootsClassLoaderDataGraph); - CLDToOopClosure cld_cl(cl); - ClassLoaderDataGraph::cld_do(&cld_cl); -} - class ZRootsIteratorThreadClosure : public ThreadClosure { private: OopClosure* const _cl; @@ -238,8 +227,6 @@ void ZRootsIterator::oops_do(OopClosure* cl, bool visit_jvmti_weak_export) { _management.oops_do(cl); _jvmti_export.oops_do(cl); _system_dictionary.oops_do(cl); - _jni_handles.oops_do(cl); - _class_loader_data_graph.oops_do(cl); _threads.oops_do(cl); _code_cache.oops_do(cl); if (visit_jvmti_weak_export) { @@ -247,6 +234,37 @@ void ZRootsIterator::oops_do(OopClosure* cl, bool visit_jvmti_weak_export) { } } +ZConcurrentRootsIterator::ZConcurrentRootsIterator() : + _jni_handles_iter(JNIHandles::global_handles()), + _jni_handles(this), + _class_loader_data_graph(this) { + ZStatTimer timer(ZSubPhaseConcurrentRootsSetup); + ClassLoaderDataGraph_lock->lock(); + ClassLoaderDataGraph::clear_claimed_marks(); +} + +ZConcurrentRootsIterator::~ZConcurrentRootsIterator() { + ZStatTimer timer(ZSubPhaseConcurrentRootsTeardown); + ClassLoaderDataGraph_lock->unlock(); +} + +void ZConcurrentRootsIterator::do_jni_handles(OopClosure* cl) { + ZStatTimer timer(ZSubPhaseConcurrentRootsJNIHandles); + _jni_handles_iter.oops_do(cl); +} + +void ZConcurrentRootsIterator::do_class_loader_data_graph(OopClosure* cl) { + ZStatTimer timer(ZSubPhaseConcurrentRootsClassLoaderDataGraph); + CLDToOopClosure cld_cl(cl); + ClassLoaderDataGraph::cld_do(&cld_cl); +} + +void ZConcurrentRootsIterator::oops_do(OopClosure* cl) { + ZStatTimer timer(ZSubPhaseConcurrentRoots); + _jni_handles.oops_do(cl); + _class_loader_data_graph.oops_do(cl); +} + ZWeakRootsIterator::ZWeakRootsIterator() : _jvmti_weak_export(this), _jfr_weak(this) {