< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp

Print this page
rev 57380 : 8234974: Shenandoah: Do concurrent roots even when no evacuation is necessary
rev 57381 : [mq]: JDK-8234974-changes.patch

@@ -1553,10 +1553,14 @@
 
       if (ShenandoahVerify) {
         verifier()->verify_before_evacuation();
       }
 
+      if (ShenandoahConcurrentRoots::should_do_concurrent_class_unloading()) {
+        ShenandoahCodeRoots::prepare_concurrent_unloading();
+      }
+
       set_evacuation_in_progress(true);
       // From here on, we need to update references.
       set_has_forwarded_objects(true);
 
       if (!is_degenerated_gc_in_progress()) {

@@ -1654,36 +1658,29 @@
     AbstractGangTask("Shenandoah Evacuate/Update Concurrent Roots Task") {
   }
 
   void work(uint worker_id) {
     ShenandoahEvacOOMScope oom;
+    ShenandoahEvacUpdateCleanupRootsClosure cl;
     {
-      // jni_roots and weak_roots are OopStorage backed roots, concurrent iteration
-      // may race against OopStorage::release() calls.
-      ShenandoahEvacUpdateOopStorageRootsClosure cl;
-      _vm_roots.oops_do<ShenandoahEvacUpdateOopStorageRootsClosure>(&cl);
-      _weak_roots.oops_do<ShenandoahEvacUpdateOopStorageRootsClosure>(&cl);
-    }
-
-    {
-      ShenandoahEvacuateUpdateRootsClosure cl;
+      _vm_roots.oops_do<>(&cl);
+      _weak_roots.oops_do<>(&cl);
       CLDToOopClosure clds(&cl, ClassLoaderData::_claim_strong);
       _cld_roots.cld_do(&clds);
     }
   }
 };
 
 void ShenandoahHeap::op_roots() {
   if (is_concurrent_root_in_progress()) {
-    if (ShenandoahConcurrentRoots::should_do_concurrent_class_unloading()) {
-      _unloader.unload();
-    }
-
-    if (ShenandoahConcurrentRoots::should_do_concurrent_roots() && is_concurrent_root_in_progress()) {
+    if (ShenandoahConcurrentRoots::should_do_concurrent_roots()) {
       ShenandoahConcurrentRootsEvacUpdateTask task;
       workers()->run_task(&task);
     }
+    if (ShenandoahConcurrentRoots::should_do_concurrent_class_unloading()) {
+      _unloader.unload();
+    }
   }
 
   set_concurrent_root_in_progress(false);
 }
 

@@ -2237,11 +2234,10 @@
 }
 
 void ShenandoahHeap::prepare_concurrent_unloading() {
   assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
   if (ShenandoahConcurrentRoots::should_do_concurrent_class_unloading()) {
-    ShenandoahCodeRoots::prepare_concurrent_unloading();
     _unloader.prepare();
   }
 }
 
 void ShenandoahHeap::finish_concurrent_unloading() {
< prev index next >