--- a/src/hotspot/share/gc/z/zRootsIterator.cpp Thu Oct 17 20:27:44 2019 +0100
+++ b/src/hotspot/share/gc/z/zRootsIterator.cpp Thu Oct 17 20:53:35 2019 +0100
@@ -30,6 +30,7 @@
#include "gc/shared/barrierSet.hpp"
#include "gc/shared/barrierSetNMethod.hpp"
#include "gc/shared/oopStorageParState.inline.hpp"
+#include "gc/shared/oopStorageSet.hpp"
#include "gc/shared/suspendibleThreadSet.hpp"
#include "gc/z/zBarrierSetNMethod.hpp"
#include "gc/z/zGlobals.hpp"
@@ -43,7 +44,6 @@
#include "prims/jvmtiExport.hpp"
#include "prims/resolvedMethodTable.hpp"
#include "runtime/atomic.hpp"
-#include "runtime/jniHandles.hpp"
#include "runtime/thread.hpp"
#include "runtime/safepoint.hpp"
#include "runtime/synchronizer.hpp"
@@ -69,6 +69,7 @@
static const ZStatSubPhase ZSubPhaseConcurrentRoots("Concurrent Roots");
static const ZStatSubPhase ZSubPhaseConcurrentRootsTeardown("Concurrent Roots Teardown");
static const ZStatSubPhase ZSubPhaseConcurrentRootsJNIHandles("Concurrent Roots JNIHandles");
+static const ZStatSubPhase ZSubPhaseConcurrentRootsVMHandles("Concurrent Roots VMHandles");
static const ZStatSubPhase ZSubPhaseConcurrentRootsClassLoaderDataGraph("Concurrent Roots ClassLoaderDataGraph");
static const ZStatSubPhase ZSubPhasePauseWeakRootsSetup("Pause Weak Roots Setup");
@@ -170,7 +171,8 @@
}
};
-ZRootsIterator::ZRootsIterator() :
+ZRootsIterator::ZRootsIterator(bool visit_jvmti_weak_export) :
+ _visit_jvmti_weak_export(visit_jvmti_weak_export),
_universe(this),
_object_synchronizer(this),
_management(this),
@@ -198,7 +200,6 @@
} else {
ZNMethod::oops_do_end();
}
- JvmtiExport::gc_epilogue();
COMPILER2_PRESENT(DerivedPointerTable::update_pointers());
Threads::assert_all_threads_claimed();
@@ -232,7 +233,8 @@
void ZRootsIterator::do_system_dictionary(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRootsSystemDictionary);
- SystemDictionary::oops_do(cl);
+ // Handles are processed via _vm_handles.
+ SystemDictionary::oops_do(cl, false /* include_handles */);
}
void ZRootsIterator::do_threads(ZRootsIteratorClosure* cl) {
@@ -247,7 +249,7 @@
ZNMethod::oops_do(cl);
}
-void ZRootsIterator::oops_do(ZRootsIteratorClosure* cl, bool visit_jvmti_weak_export) {
+void ZRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRoots);
_universe.oops_do(cl);
_object_synchronizer.oops_do(cl);
@@ -258,29 +260,24 @@
if (!ClassUnloading) {
_code_cache.oops_do(cl);
}
- if (visit_jvmti_weak_export) {
+ if (_visit_jvmti_weak_export) {
_jvmti_weak_export.oops_do(cl);
}
}
-ZConcurrentRootsIterator::ZConcurrentRootsIterator(bool marking) :
- _marking(marking),
- _sts_joiner(marking /* active */),
- _jni_handles_iter(JNIHandles::global_handles()),
+ZConcurrentRootsIterator::ZConcurrentRootsIterator(int cld_claim) :
+ _jni_handles_iter(OopStorageSet::jni_global()),
+ _vm_handles_iter(OopStorageSet::vm_global()),
+ _cld_claim(cld_claim),
_jni_handles(this),
+ _vm_handles(this),
_class_loader_data_graph(this) {
ZStatTimer timer(ZSubPhaseConcurrentRootsSetup);
- if (_marking) {
- ClassLoaderDataGraph_lock->lock();
- ClassLoaderDataGraph::clear_claimed_marks();
- }
+ ClassLoaderDataGraph::clear_claimed_marks(cld_claim);
}
ZConcurrentRootsIterator::~ZConcurrentRootsIterator() {
ZStatTimer timer(ZSubPhaseConcurrentRootsTeardown);
- if (_marking) {
- ClassLoaderDataGraph_lock->unlock();
- }
}
void ZConcurrentRootsIterator::do_jni_handles(ZRootsIteratorClosure* cl) {
@@ -288,20 +285,21 @@
_jni_handles_iter.oops_do(cl);
}
+void ZConcurrentRootsIterator::do_vm_handles(ZRootsIteratorClosure* cl) {
+ ZStatTimer timer(ZSubPhaseConcurrentRootsVMHandles);
+ _vm_handles_iter.oops_do(cl);
+}
+
void ZConcurrentRootsIterator::do_class_loader_data_graph(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhaseConcurrentRootsClassLoaderDataGraph);
- if (_marking) {
- CLDToOopClosure cld_cl(cl, ClassLoaderData::_claim_strong);
- ClassLoaderDataGraph::always_strong_cld_do(&cld_cl);
- } else {
- CLDToOopClosure cld_cl(cl, ClassLoaderData::_claim_none);
- ClassLoaderDataGraph::cld_do(&cld_cl);
- }
+ CLDToOopClosure cld_cl(cl, _cld_claim);
+ ClassLoaderDataGraph::always_strong_cld_do(&cld_cl);
}
void ZConcurrentRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhaseConcurrentRoots);
_jni_handles.oops_do(cl);
+ _vm_handles.oops_do(cl),
_class_loader_data_graph.oops_do(cl);
}
@@ -340,10 +338,10 @@
}
ZConcurrentWeakRootsIterator::ZConcurrentWeakRootsIterator() :
- _vm_weak_handles_iter(SystemDictionary::vm_weak_oop_storage()),
- _jni_weak_handles_iter(JNIHandles::weak_global_handles()),
- _string_table_iter(StringTable::weak_storage()),
- _resolved_method_table_iter(ResolvedMethodTable::weak_storage()),
+ _vm_weak_handles_iter(OopStorageSet::vm_weak()),
+ _jni_weak_handles_iter(OopStorageSet::jni_weak()),
+ _string_table_iter(OopStorageSet::string_table_weak()),
+ _resolved_method_table_iter(OopStorageSet::resolved_method_table_weak()),
_vm_weak_handles(this),
_jni_weak_handles(this),
_string_table(this),
@@ -413,26 +411,3 @@
_string_table.oops_do(cl);
_resolved_method_table.oops_do(cl);
}
-
-ZThreadRootsIterator::ZThreadRootsIterator() :
- _threads(this) {
- assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
- ZStatTimer timer(ZSubPhasePauseRootsSetup);
- Threads::change_thread_claim_token();
-}
-
-ZThreadRootsIterator::~ZThreadRootsIterator() {
- ZStatTimer timer(ZSubPhasePauseRootsTeardown);
- Threads::assert_all_threads_claimed();
-}
-
-void ZThreadRootsIterator::do_threads(ZRootsIteratorClosure* cl) {
- ZStatTimer timer(ZSubPhasePauseRootsThreads);
- ResourceMark rm;
- Threads::possibly_parallel_oops_do(true, cl, NULL);
-}
-
-void ZThreadRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
- ZStatTimer timer(ZSubPhasePauseRoots);
- _threads.oops_do(cl);
-}