changeset 55934:79a7fc6c9bc7

8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API Reviewed-by: rkennke
author zgu
date Thu, 20 Jun 2019 18:29:34 -0400
parents d3030613fab9
children 81ac9262e63b
files src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp
diffstat 3 files changed, 30 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp	Thu Jun 20 20:20:01 2019 +0000
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp	Thu Jun 20 18:29:34 2019 -0400
@@ -152,7 +152,7 @@
   }
 
   _thread_roots.oops_do(oops, NULL, worker_id);
-  _cld_roots.clds_do(&clds, &clds, worker_id);
+  _cld_roots.cld_do(&clds, worker_id);
   _code_roots.code_blobs_do(&blobsCl, worker_id);
 
   _weak_roots.oops_do<AlwaysTrueClosure, OopClosure>(&always_true, oops, worker_id);
@@ -182,7 +182,7 @@
   _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);
+  _cld_roots.cld_do(&adjust_cld_closure, worker_id);
   _code_roots.code_blobs_do(&adjust_code_closure, worker_id);
 
   _weak_roots.oops_do<AlwaysTrueClosure, OopClosure>(&always_true, oops, worker_id);
@@ -204,7 +204,7 @@
 
    _serial_roots.oops_do(oops, 0);
    _jni_roots.oops_do(oops, 0);
-   _cld_roots.clds_do(&clds, &clds, 0);
+   _cld_roots.cld_do(&clds, 0);
    _thread_roots.threads_do(&tc_cl, 0);
    _code_roots.code_blobs_do(&code, 0);
  }
@@ -219,6 +219,6 @@
 
    _serial_roots.oops_do(oops, 0);
    _jni_roots.oops_do(oops, 0);
-   _cld_roots.clds_do(&clds, NULL, 0);
+   _cld_roots.always_strong_cld_do(&clds, 0);
    _thread_roots.threads_do(&tc_cl, 0);
  }
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp	Thu Jun 20 20:20:01 2019 +0000
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp	Thu Jun 20 18:29:34 2019 -0400
@@ -119,7 +119,8 @@
 public:
   ShenandoahClassLoaderDataRoots();
 
-  void clds_do(CLDClosure* strong_clds, CLDClosure* weak_clds, uint worker_id);
+  void always_strong_cld_do(CLDClosure* clds, uint worker_id);
+  void cld_do(CLDClosure* clds, uint worker_id);
 };
 
 class ShenandoahRootProcessor : public StackObj {
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp	Thu Jun 20 20:20:01 2019 +0000
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp	Thu Jun 20 18:29:34 2019 -0400
@@ -63,16 +63,28 @@
 }
 
 template <bool SINGLE_THREADED>
-void ShenandoahClassLoaderDataRoots<SINGLE_THREADED>::clds_do(CLDClosure* strong_clds, CLDClosure* weak_clds, uint worker_id) {
+void ShenandoahClassLoaderDataRoots<SINGLE_THREADED>::always_strong_cld_do(CLDClosure* clds, uint worker_id) {
   if (SINGLE_THREADED) {
     assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
     assert(Thread::current()->is_VM_thread(), "Single threaded CLDG iteration can only be done by VM thread");
+    ClassLoaderDataGraph::always_strong_cld_do(clds);
+  } else {
+   ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
+   ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::CLDGRoots, worker_id);
+   ClassLoaderDataGraph::always_strong_cld_do(clds);
+  }
+}
 
-    ClassLoaderDataGraph::roots_cld_do(strong_clds, weak_clds);
+template <bool SINGLE_THREADED>
+void ShenandoahClassLoaderDataRoots<SINGLE_THREADED>::cld_do(CLDClosure* clds, uint worker_id) {
+  if (SINGLE_THREADED) {
+    assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
+    assert(Thread::current()->is_VM_thread(), "Single threaded CLDG iteration can only be done by VM thread");
+    ClassLoaderDataGraph::cld_do(clds);
   } else {
     ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
     ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::CLDGRoots, worker_id);
-    ClassLoaderDataGraph::roots_cld_do(strong_clds, weak_clds);
+    ClassLoaderDataGraph::cld_do(clds);
   }
 }
 
@@ -141,7 +153,13 @@
 
   _serial_roots.oops_do(oops, worker_id);
   _jni_roots.oops_do(oops, worker_id);
-  _cld_roots.clds_do(clds, clds, worker_id);
+
+  if (clds != NULL) {
+    _cld_roots.cld_do(clds, worker_id);
+  } else {
+    assert(ShenandoahHeap::heap()->is_concurrent_traversal_in_progress(), "Only possible with traversal GC");
+  }
+
   _thread_roots.threads_do(&tc_cl, worker_id);
 
   // With ShenandoahConcurrentScanCodeRoots, we avoid scanning the entire code cache here,
@@ -160,7 +178,7 @@
 
   _serial_roots.oops_do(oops, worker_id);
   _jni_roots.oops_do(oops, worker_id);
-  _cld_roots.clds_do(clds, NULL, worker_id);
+  _cld_roots.always_strong_cld_do(clds, worker_id);
   _thread_roots.threads_do(&tc_cl, worker_id);
 }
 
@@ -168,13 +186,12 @@
 void ShenandoahRootUpdater::roots_do(uint worker_id, IsAlive* is_alive, KeepAlive* keep_alive) {
   CodeBlobToOopClosure update_blobs(keep_alive, CodeBlobToOopClosure::FixRelocations);
   CLDToOopClosure clds(keep_alive, ClassLoaderData::_claim_strong);
-  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);
+  _cld_roots.cld_do(&clds, worker_id);
 
   if(_update_code_cache) {
     _code_roots.code_blobs_do(&update_blobs, worker_id);