8229213: Shenandoah: Allow VM global oop storage to be processed concurrently jdk-14+9
authorzgu
Wed, 07 Aug 2019 09:17:08 -0400
changeset 57669 18f189e69b29
parent 57668 33b160ef735c
child 57670 cffcc4c5a5ba
8229213: Shenandoah: Allow VM global oop storage to be processed concurrently Reviewed-by: shade, rkennke
src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp
src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp
src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp
src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp	Wed Aug 07 08:10:45 2019 -0400
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp	Wed Aug 07 09:17:08 2019 -0400
@@ -1582,7 +1582,7 @@
 
 class ShenandoahConcurrentRootsEvacUpdateTask : public AbstractGangTask {
 private:
-  ShenandoahJNIHandleRoots<true /*concurrent*/> _jni_roots;
+  ShenandoahVMRoots<true /*concurrent*/>        _vm_roots;
   ShenandoahWeakRoots<true /*concurrent*/>      _weak_roots;
   ShenandoahClassLoaderDataRoots<true /*concurrent*/, false /*single threaded*/> _cld_roots;
 
@@ -1597,7 +1597,7 @@
       // jni_roots and weak_roots are OopStorage backed roots, concurrent iteration
       // may race against OopStorage::release() calls.
       ShenandoahEvacUpdateOopStorageRootsClosure cl;
-      _jni_roots.oops_do<ShenandoahEvacUpdateOopStorageRootsClosure>(&cl);
+      _vm_roots.oops_do<ShenandoahEvacUpdateOopStorageRootsClosure>(&cl);
       _weak_roots.oops_do<ShenandoahEvacUpdateOopStorageRootsClosure>(&cl);
     }
 
--- a/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp	Wed Aug 07 08:10:45 2019 -0400
+++ b/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp	Wed Aug 07 09:17:08 2019 -0400
@@ -52,6 +52,7 @@
   f(scan_jni_weak_roots,                            "    S: JNI Weak Roots")            \
   f(scan_stringtable_roots,                         "    S: String Table Roots")        \
   f(scan_resolved_method_table_roots,               "    S: Resolved Table Roots")      \
+  f(scan_vm_global_roots,                           "    S: VM Global Roots")           \
   f(scan_vm_weak_roots,                             "    S: VM Weak Roots")             \
   f(scan_synchronizer_roots,                        "    S: Synchronizer Roots")        \
   f(scan_management_roots,                          "    S: Management Roots")          \
@@ -78,6 +79,7 @@
   f(update_jni_weak_roots,                          "    U: JNI Weak Roots")            \
   f(update_stringtable_roots,                       "    U: String Table Roots")        \
   f(update_resolved_method_table_roots,             "    U: Resolved Table Roots")      \
+  f(update_vm_global_roots,                         "    U: VM Global Roots")           \
   f(update_vm_weak_roots,                           "    U: VM Weak Roots")             \
   f(update_synchronizer_roots,                      "    U: Synchronizer Roots")        \
   f(update_management_roots,                        "    U: Management Roots")          \
@@ -112,6 +114,7 @@
   f(evac_jni_weak_roots,                            "    E: JNI Weak Roots")            \
   f(evac_stringtable_roots,                         "    E: String Table Roots")        \
   f(evac_resolved_method_table_roots,               "    E: Resolved Table Roots")      \
+  f(evac_vm_global_roots,                           "    E: VM Global Roots")           \
   f(evac_vm_weak_roots,                             "    E: VM Weak Roots")             \
   f(evac_synchronizer_roots,                        "    E: Synchronizer Roots")        \
   f(evac_management_roots,                          "    E: Management Roots")          \
@@ -143,6 +146,7 @@
   f(final_update_jni_weak_roots,                     "    UR: JNI Weak Roots")          \
   f(final_update_stringtable_roots,                  "    UR: String Table Roots")      \
   f(final_update_resolved_method_table_roots,        "    UR: Resolved Table Roots")    \
+  f(final_update_vm_global_roots,                    "    UR: VM Global Roots")         \
   f(final_update_vm_weak_roots,                      "    UR: VM Weak Roots")           \
   f(final_update_refs_synchronizer_roots,            "    UR: Synchronizer Roots")      \
   f(final_update_refs_management_roots,              "    UR: Management Roots")        \
@@ -169,6 +173,7 @@
   f(degen_gc_update_jni_weak_roots,                  "    DU: JNI Weak Roots")          \
   f(degen_gc_update_stringtable_roots,               "    DU: String Table Roots")      \
   f(degen_gc_update_resolved_method_table_roots,     "    DU: Resolved Table Roots")    \
+  f(degen_gc_update_vm_global_roots,                 "    DU: VM Global Roots")         \
   f(degen_gc_update_vm_weak_roots,                   "    DU: VM Weak Roots")           \
   f(degen_gc_update_synchronizer_roots,              "    DU: Synchronizer Roots")      \
   f(degen_gc_update_management_roots,                "    DU: Management Roots")        \
@@ -196,6 +201,7 @@
   f(init_traversal_gc_jni_weak_roots,                "    TI: JNI Weak Roots")          \
   f(init_traversal_gc_stringtable_roots,             "    TI: String Table Roots")      \
   f(init_traversal_gc_resolved_method_table_roots,   "    TI: Resolved Table Roots")    \
+  f(init_traversal_gc_vm_global_roots,               "    TI: VM Global Roots")         \
   f(init_traversal_gc_vm_weak_roots,                 "    TI: VM Weak Roots")           \
   f(init_traversal_gc_synchronizer_roots,            "    TI: Synchronizer Roots")      \
   f(init_traversal_gc_management_roots,              "    TI: Management Roots")        \
@@ -220,6 +226,7 @@
   f(final_traversal_gc_jni_weak_roots,               "    TF: JNI Weak Roots")          \
   f(final_traversal_gc_stringtable_roots,            "    TF: String Table Roots")      \
   f(final_traversal_gc_resolved_method_table_roots,  "    TF: Resolved Table Roots")    \
+  f(final_traversal_gc_vm_global_roots,              "    TF: VM Global Roots")         \
   f(final_traversal_gc_vm_weak_roots,                "    TF: VM Weak Roots")           \
   f(final_traversal_gc_synchronizer_roots,           "    TF: Synchronizer Roots")      \
   f(final_traversal_gc_management_roots,             "    TF: Management Roots")        \
@@ -242,6 +249,7 @@
   f(final_traversal_update_jni_weak_roots,              "    TU: JNI Weak Roots")       \
   f(final_traversal_update_stringtable_roots,           "    TU: String Table Roots")   \
   f(final_traversal_update_resolved_method_table_roots, "    TU: Resolved Table Roots") \
+  f(final_traversal_update_vm_global_roots,             "    TU: VM Global Roots")      \
   f(final_traversal_update_vm_weak_roots,               "    TU: VM Weak Roots")        \
   f(final_traversal_update_synchronizer_roots,          "    TU: Synchronizer Roots")   \
   f(final_traversal_update_management_roots,            "    TU: Management Roots")     \
@@ -270,6 +278,7 @@
   f(full_gc_jni_weak_roots,                          "    F: JNI Weak Roots")           \
   f(full_gc_stringtable_roots,                       "    F: String Table Roots")       \
   f(full_gc_resolved_method_table_roots,             "    F: Resolved Table Roots")     \
+  f(full_gc_vm_global_roots,                         "    F: VM Global Roots")          \
   f(full_gc_vm_weak_roots,                           "    F: VM Weak Roots")            \
   f(full_gc_synchronizer_roots,                      "    F: Synchronizer Roots")       \
   f(full_gc_management_roots,                        "    F: Management Roots")         \
@@ -330,6 +339,7 @@
   f(JNIWeakRoots,             "JNI Weak Roots (ms):")            \
   f(StringTableRoots,         "StringTable Roots(ms):")          \
   f(ResolvedMethodTableRoots, "Resolved Table Roots(ms):")       \
+  f(VMGlobalRoots,            "VM Global Roots(ms)")             \
   f(VMWeakRoots,              "VM Weak Roots(ms)")               \
   f(ObjectSynchronizerRoots,  "ObjectSynchronizer Roots (ms):")  \
   f(ManagementRoots,          "Management Roots (ms):")          \
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp	Wed Aug 07 08:10:45 2019 -0400
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp	Wed Aug 07 09:17:08 2019 -0400
@@ -52,9 +52,9 @@
   }
 }
 
-// Default the second argument for SD::oops_do.
+// Overwrite the second argument for SD::oops_do, don't include vm global oop storage.
 static void system_dictionary_oops_do(OopClosure* cl) {
-  SystemDictionary::oops_do(cl);
+  SystemDictionary::oops_do(cl, false);
 }
 
 ShenandoahSerialRoots::ShenandoahSerialRoots() :
@@ -173,7 +173,7 @@
   _serial_weak_roots.weak_oops_do(oops, worker_id);
   if (_include_concurrent_roots) {
     CLDToOopClosure clds(oops, ClassLoaderData::_claim_strong);
-    _jni_roots.oops_do<OopClosure>(oops, worker_id);
+    _vm_roots.oops_do<OopClosure>(oops, worker_id);
     _cld_roots.cld_do(&clds, worker_id);
     _weak_roots.oops_do<OopClosure>(oops, worker_id);
   }
@@ -202,7 +202,7 @@
   AlwaysTrueClosure always_true;
 
   _serial_roots.oops_do(oops, worker_id);
-  _jni_roots.oops_do(oops, worker_id);
+  _vm_roots.oops_do(oops, worker_id);
 
   _thread_roots.oops_do(oops, NULL, worker_id);
   _cld_roots.cld_do(&adjust_cld_closure, worker_id);
@@ -227,7 +227,7 @@
    ResourceMark rm;
 
    _serial_roots.oops_do(oops, 0);
-   _jni_roots.oops_do(oops, 0);
+   _vm_roots.oops_do(oops, 0);
    _cld_roots.cld_do(&clds, 0);
    _thread_roots.threads_do(&tc_cl, 0);
    _code_roots.code_blobs_do(&code, 0);
@@ -242,7 +242,7 @@
    ResourceMark rm;
 
    _serial_roots.oops_do(oops, 0);
-   _jni_roots.oops_do(oops, 0);
+   _vm_roots.oops_do(oops, 0);
    _cld_roots.always_strong_cld_do(&clds, 0);
    _thread_roots.threads_do(&tc_cl, 0);
  }
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp	Wed Aug 07 08:10:45 2019 -0400
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp	Wed Aug 07 09:17:08 2019 -0400
@@ -93,17 +93,23 @@
 };
 
 template <bool CONCURRENT>
-class ShenandoahWeakRoot {
+class ShenandoahVMRoot {
 private:
   OopStorage::ParState<CONCURRENT, false /* is_const */> _itr;
   const ShenandoahPhaseTimings::GCParPhases _phase;
 public:
-  ShenandoahWeakRoot(OopStorage* storage, ShenandoahPhaseTimings::GCParPhases phase);
+  ShenandoahVMRoot(OopStorage* storage, ShenandoahPhaseTimings::GCParPhases phase);
 
   template <typename Closure>
   void oops_do(Closure* cl, uint worker_id);
 };
 
+template <bool CONCURRENT>
+class ShenandoahWeakRoot : public ShenandoahVMRoot<CONCURRENT> {
+public:
+  ShenandoahWeakRoot(OopStorage* storage, ShenandoahPhaseTimings::GCParPhases phase);
+};
+
 template <>
 class ShenandoahWeakRoot<false /*concurrent*/> {
 private:
@@ -150,11 +156,13 @@
 };
 
 template <bool CONCURRENT>
-class ShenandoahJNIHandleRoots {
+class ShenandoahVMRoots {
 private:
-  OopStorage::ParState<CONCURRENT, false /*is_const*/> _itr;
+  ShenandoahVMRoot<CONCURRENT>    _jni_handle_roots;
+  ShenandoahVMRoot<CONCURRENT>    _vm_global_roots;
+
 public:
-  ShenandoahJNIHandleRoots();
+  ShenandoahVMRoots();
 
   template <typename T>
   void oops_do(T* cl, uint worker_id = 0);
@@ -217,7 +225,7 @@
   ShenandoahSerialRoots                                     _serial_roots;
   ShenandoahThreadRoots                                     _thread_roots;
   ShenandoahCodeCacheRoots<ITR>                             _code_roots;
-  ShenandoahJNIHandleRoots<false /*concurrent*/ >           _jni_roots;
+  ShenandoahVMRoots<false /*concurrent*/ >                  _vm_roots;
   ShenandoahClassLoaderDataRoots<false /*concurrent*/, false /*single threaded*/>
                                                             _cld_roots;
 public:
@@ -243,7 +251,7 @@
 private:
   ShenandoahSerialRoots                                    _serial_roots;
   ShenandoahThreadRoots                                    _thread_roots;
-  ShenandoahJNIHandleRoots<false /*concurrent*/>           _jni_roots;
+  ShenandoahVMRoots<false /*concurrent*/>                  _vm_roots;
   ShenandoahClassLoaderDataRoots<false /*concurrent*/, true /*single threaded*/>
                                                            _cld_roots;
   ShenandoahCodeCacheRoots<ShenandoahAllCodeRootsIterator> _code_roots;
@@ -259,7 +267,7 @@
 class ShenandoahRootEvacuator : public ShenandoahRootProcessor {
 private:
   ShenandoahSerialRoots                                     _serial_roots;
-  ShenandoahJNIHandleRoots<false /*concurrent*/>            _jni_roots;
+  ShenandoahVMRoots<false /*concurrent*/>                   _vm_roots;
   ShenandoahClassLoaderDataRoots<false /*concurrent*/, false /*single threaded*/>
                                                             _cld_roots;
   ShenandoahThreadRoots                                     _thread_roots;
@@ -279,7 +287,7 @@
 class ShenandoahRootUpdater : public ShenandoahRootProcessor {
 private:
   ShenandoahSerialRoots                                     _serial_roots;
-  ShenandoahJNIHandleRoots<false /*concurrent*/>            _jni_roots;
+  ShenandoahVMRoots<false /*concurrent*/>                   _vm_roots;
   ShenandoahClassLoaderDataRoots<false /*concurrent*/, false /*single threaded*/>
                                                             _cld_roots;
   ShenandoahThreadRoots                                     _thread_roots;
@@ -300,7 +308,7 @@
 class ShenandoahRootAdjuster : public ShenandoahRootProcessor {
 private:
   ShenandoahSerialRoots                                     _serial_roots;
-  ShenandoahJNIHandleRoots<false /*concurrent*/>            _jni_roots;
+  ShenandoahVMRoots<false /*concurrent*/>                   _vm_roots;
   ShenandoahClassLoaderDataRoots<false /*concurrent*/, false /*single threaded*/>
                                                             _cld_roots;
   ShenandoahThreadRoots                                     _thread_roots;
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp	Wed Aug 07 08:10:45 2019 -0400
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp	Wed Aug 07 09:17:08 2019 -0400
@@ -37,13 +37,13 @@
 #include "runtime/safepoint.hpp"
 
 template <bool CONCURRENT>
-inline ShenandoahWeakRoot<CONCURRENT>::ShenandoahWeakRoot(OopStorage* storage, ShenandoahPhaseTimings::GCParPhases phase) :
+inline ShenandoahVMRoot<CONCURRENT>::ShenandoahVMRoot(OopStorage* storage, ShenandoahPhaseTimings::GCParPhases phase) :
   _itr(storage), _phase(phase) {
 }
 
 template <bool CONCURRENT>
 template <typename Closure>
-inline void ShenandoahWeakRoot<CONCURRENT>::oops_do(Closure* cl, uint worker_id) {
+inline void ShenandoahVMRoot<CONCURRENT>::oops_do(Closure* cl, uint worker_id) {
   if (CONCURRENT) {
     _itr.oops_do(cl);
   } else {
@@ -53,6 +53,11 @@
   }
 }
 
+template <bool CONCURRENT>
+inline ShenandoahWeakRoot<CONCURRENT>::ShenandoahWeakRoot(OopStorage* storage, ShenandoahPhaseTimings::GCParPhases phase) :
+  ShenandoahVMRoot<CONCURRENT>(storage, phase) {
+}
+
 inline ShenandoahWeakRoot<false>::ShenandoahWeakRoot(OopStorage* storage, ShenandoahPhaseTimings::GCParPhases phase) :
   _itr(storage), _phase(phase) {
 }
@@ -103,20 +108,16 @@
 }
 
 template <bool CONCURRENT>
-ShenandoahJNIHandleRoots<CONCURRENT>::ShenandoahJNIHandleRoots() :
-  _itr(JNIHandles::global_handles()) {
+ShenandoahVMRoots<CONCURRENT>::ShenandoahVMRoots() :
+  _jni_handle_roots(JNIHandles::global_handles(), ShenandoahPhaseTimings::JNIRoots),
+  _vm_global_roots(SystemDictionary::vm_global_oop_storage(), ShenandoahPhaseTimings::VMGlobalRoots) {
 }
 
 template <bool CONCURRENT>
 template <typename T>
-void ShenandoahJNIHandleRoots<CONCURRENT>::oops_do(T* cl, uint worker_id) {
-  if (CONCURRENT) {
-    _itr.oops_do(cl);
-  } else {
-    ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
-    ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::JNIRoots, worker_id);
-    _itr.oops_do(cl);
-  }
+void ShenandoahVMRoots<CONCURRENT>::oops_do(T* cl, uint worker_id) {
+  _jni_handle_roots.oops_do(cl, worker_id);
+  _vm_global_roots.oops_do(cl, worker_id);
 }
 
 template <bool CONCURRENT, bool SINGLE_THREADED>
@@ -231,7 +232,7 @@
   ResourceMark rm;
 
   _serial_roots.oops_do(oops, worker_id);
-  _jni_roots.oops_do(oops, worker_id);
+  _vm_roots.oops_do(oops, worker_id);
 
   if (clds != NULL) {
     _cld_roots.cld_do(clds, worker_id);
@@ -256,7 +257,7 @@
   ResourceMark rm;
 
   _serial_roots.oops_do(oops, worker_id);
-  _jni_roots.oops_do(oops, worker_id);
+  _vm_roots.oops_do(oops, worker_id);
   _cld_roots.always_strong_cld_do(clds, worker_id);
   _thread_roots.threads_do(&tc_cl, worker_id);
 }
@@ -267,7 +268,7 @@
   CLDToOopClosure clds(keep_alive, ClassLoaderData::_claim_strong);
 
   _serial_roots.oops_do(keep_alive, worker_id);
-  _jni_roots.oops_do(keep_alive, worker_id);
+  _vm_roots.oops_do(keep_alive, worker_id);
 
   _thread_roots.oops_do(keep_alive, NULL, worker_id);
   _cld_roots.cld_do(&clds, worker_id);