8225572: Shenandoah: Move JNIHandles root out of serial roots
authorzgu
Tue, 11 Jun 2019 19:15:31 -0400
changeset 55335 f7cc25dda38a
parent 55334 ff74a3c584e5
child 55336 c2398053ee90
8225572: Shenandoah: Move JNIHandles root out of serial roots Reviewed-by: rkennke
src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp
src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp
src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp
src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp
src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.hpp
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp	Tue Jun 11 14:59:46 2019 -0700
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp	Tue Jun 11 19:15:31 2019 -0400
@@ -60,8 +60,7 @@
   _object_synchronizer_root(&ObjectSynchronizer::oops_do, ShenandoahPhaseTimings::ObjectSynchronizerRoots),
   _management_root(&Management::oops_do, ShenandoahPhaseTimings::ManagementRoots),
   _system_dictionary_root(&SystemDictionary::oops_do, ShenandoahPhaseTimings::SystemDictionaryRoots),
-  _jvmti_root(&JvmtiExport::oops_do, ShenandoahPhaseTimings::JVMTIRoots),
-  _jni_handle_root(&JNIHandles::oops_do, ShenandoahPhaseTimings::JNIRoots) {
+  _jvmti_root(&JvmtiExport::oops_do, ShenandoahPhaseTimings::JVMTIRoots) {
 }
 
 void ShenandoahSerialRoots::oops_do(OopClosure* cl, uint worker_id) {
@@ -70,7 +69,10 @@
   _management_root.oops_do(cl, worker_id);
   _system_dictionary_root.oops_do(cl, worker_id);
   _jvmti_root.oops_do(cl, worker_id);
-  _jni_handle_root.oops_do(cl, worker_id);
+}
+
+ShenandoahJNIHandleRoots::ShenandoahJNIHandleRoots() :
+  ShenandoahSerialRoot(&JNIHandles::oops_do, ShenandoahPhaseTimings::JNIRoots) {
 }
 
 ShenandoahThreadRoots::ShenandoahThreadRoots(bool is_par) : _is_par(is_par) {
@@ -160,6 +162,7 @@
   AlwaysTrueClosure always_true;
 
   _serial_roots.oops_do(oops, worker_id);
+  _jni_roots.oops_do(oops, worker_id);
 
   _thread_roots.oops_do(oops, NULL, worker_id);
   _cld_roots.clds_do(&clds, &clds, worker_id);
@@ -189,6 +192,7 @@
   AlwaysTrueClosure always_true;
 
   _serial_roots.oops_do(oops, worker_id);
+  _jni_roots.oops_do(oops, worker_id);
 
   _thread_roots.oops_do(oops, NULL, worker_id);
   _cld_roots.clds_do(&adjust_cld_closure, NULL, worker_id);
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp	Tue Jun 11 14:59:46 2019 -0700
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp	Tue Jun 11 19:15:31 2019 -0400
@@ -56,12 +56,16 @@
   ShenandoahSerialRoot  _management_root;
   ShenandoahSerialRoot  _system_dictionary_root;
   ShenandoahSerialRoot  _jvmti_root;
-  ShenandoahSerialRoot  _jni_handle_root;
 public:
   ShenandoahSerialRoots();
   void oops_do(OopClosure* cl, uint worker_id);
 };
 
+class ShenandoahJNIHandleRoots : public ShenandoahSerialRoot {
+public:
+  ShenandoahJNIHandleRoots();
+};
+
 class ShenandoahThreadRoots {
 private:
   const bool _is_par;
@@ -126,6 +130,7 @@
 class ShenandoahRootScanner : public ShenandoahRootProcessor {
 private:
   ShenandoahSerialRoots          _serial_roots;
+  ShenandoahJNIHandleRoots       _jni_roots;
   ShenandoahClassLoaderDataRoots _cld_roots;
   ShenandoahThreadRoots          _thread_roots;
   ShenandoahCodeCacheRoots<ITR>  _code_roots;
@@ -152,6 +157,7 @@
 class ShenandoahRootEvacuator : public ShenandoahRootProcessor {
 private:
   ShenandoahSerialRoots          _serial_roots;
+  ShenandoahJNIHandleRoots       _jni_roots;
   ShenandoahClassLoaderDataRoots _cld_roots;
   ShenandoahThreadRoots          _thread_roots;
   ShenandoahWeakRoots            _weak_roots;
@@ -168,6 +174,7 @@
 class ShenandoahRootUpdater : public ShenandoahRootProcessor {
 private:
   ShenandoahSerialRoots          _serial_roots;
+  ShenandoahJNIHandleRoots       _jni_roots;
   ShenandoahClassLoaderDataRoots _cld_roots;
   ShenandoahThreadRoots          _thread_roots;
   ShenandoahWeakRoots            _weak_roots;
@@ -186,6 +193,7 @@
 class ShenandoahRootAdjuster : public ShenandoahRootProcessor {
 private:
   ShenandoahSerialRoots          _serial_roots;
+  ShenandoahJNIHandleRoots       _jni_roots;
   ShenandoahClassLoaderDataRoots _cld_roots;
   ShenandoahThreadRoots          _thread_roots;
   ShenandoahWeakRoots            _weak_roots;
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp	Tue Jun 11 14:59:46 2019 -0700
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp	Tue Jun 11 19:15:31 2019 -0400
@@ -99,6 +99,7 @@
   ResourceMark rm;
 
   _serial_roots.oops_do(oops, worker_id);
+  _jni_roots.oops_do(oops, worker_id);
   _cld_roots.clds_do(clds, clds, worker_id);
   _thread_roots.threads_do(&tc_cl, worker_id);
 
@@ -118,6 +119,7 @@
   ResourceMark rm;
 
   _serial_roots.oops_do(oops, 0);
+  _jni_roots.oops_do(oops, 0);
   _cld_roots.clds_do(&clds, &clds, 0);
   _thread_roots.threads_do(&tc_cl, 0);
   _code_roots.code_blobs_do(&code, 0);
@@ -130,6 +132,7 @@
   ResourceMark rm;
 
   _serial_roots.oops_do(oops, worker_id);
+  _jni_roots.oops_do(oops, worker_id);
   _cld_roots.clds_do(clds, NULL, worker_id);
   _thread_roots.threads_do(&tc_cl, worker_id);
 }
@@ -141,6 +144,7 @@
   CLDToOopClosure* weak_clds = ShenandoahHeap::heap()->unload_classes() ? NULL : &clds;
 
   _serial_roots.oops_do(keep_alive, worker_id);
+  _jni_roots.oops_do(keep_alive, worker_id);
 
   _thread_roots.oops_do(keep_alive, NULL, worker_id);
   _cld_roots.clds_do(&clds, weak_clds, worker_id);
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp	Tue Jun 11 14:59:46 2019 -0700
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp	Tue Jun 11 19:15:31 2019 -0400
@@ -69,15 +69,18 @@
 
   if (verify(SerialRoots)) {
     shenandoah_assert_safepoint();
-
     Universe::oops_do(oops);
     Management::oops_do(oops);
     JvmtiExport::oops_do(oops);
-    JNIHandles::oops_do(oops);
     ObjectSynchronizer::oops_do(oops);
     SystemDictionary::oops_do(oops);
   }
 
+  if (verify(JNIHandleRoots)) {
+    shenandoah_assert_safepoint();
+    JNIHandles::oops_do(oops);
+  }
+
   if (verify(WeakRoots)) {
     shenandoah_assert_safepoint();
     AlwaysTrueClosure always_true;
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.hpp	Tue Jun 11 14:59:46 2019 -0700
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.hpp	Tue Jun 11 19:15:31 2019 -0400
@@ -36,7 +36,8 @@
     CLDGRoots           = 1 << 3,
     WeakRoots           = 1 << 4,
     StringDedupRoots    = 1 << 5,
-    AllRoots            = (SerialRoots | ThreadRoots | CodeRoots | CLDGRoots | WeakRoots | StringDedupRoots)
+    JNIHandleRoots      = 1 << 6,
+    AllRoots            = (SerialRoots | ThreadRoots | CodeRoots | CLDGRoots | WeakRoots | StringDedupRoots | JNIHandleRoots)
   };
 
 private: