8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
authorzgu
Mon, 27 May 2019 14:34:58 -0400
changeset 55048 812212323fb1
parent 55047 3131927311ee
child 55049 4853b1ceb3d6
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle Reviewed-by: rkennke
src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp
src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.hpp
src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp	Mon May 27 19:24:42 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp	Mon May 27 14:34:58 2019 -0400
@@ -59,7 +59,7 @@
   }
 
   if (verify(CLDGRoots)) {
-    CLDToOopClosure clds(oops, ClassLoaderData::_claim_strong);
+    CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
     ClassLoaderDataGraph::cld_do(&clds);
   }
 
@@ -88,3 +88,49 @@
     Threads::possibly_parallel_oops_do(false, oops, &blobs);
   }
 }
+
+void ShenandoahRootVerifier::roots_do(OopClosure* oops) {
+  CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
+  CodeCache::blobs_do(&blobs);
+
+  CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
+  ClassLoaderDataGraph::cld_do(&clds);
+
+  Universe::oops_do(oops);
+  Management::oops_do(oops);
+  JvmtiExport::oops_do(oops);
+  JNIHandles::oops_do(oops);
+  ObjectSynchronizer::oops_do(oops);
+  SystemDictionary::oops_do(oops);
+
+  AlwaysTrueClosure always_true;
+  WeakProcessor::weak_oops_do(&always_true, oops);
+
+  if (ShenandoahStringDedup::is_enabled()) {
+    ShenandoahStringDedup::oops_do_slow(oops);
+  }
+
+  // Do thread roots the last. This allows verification code to find
+  // any broken objects from those special roots first, not the accidental
+  // dangling reference from the thread root.
+  Threads::possibly_parallel_oops_do(false, oops, &blobs);
+}
+
+void ShenandoahRootVerifier::strong_roots_do(OopClosure* oops) {
+  CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
+
+  CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
+  ClassLoaderDataGraph::roots_cld_do(&clds, NULL);
+
+  Universe::oops_do(oops);
+  Management::oops_do(oops);
+  JvmtiExport::oops_do(oops);
+  JNIHandles::oops_do(oops);
+  ObjectSynchronizer::oops_do(oops);
+  SystemDictionary::oops_do(oops);
+
+  // Do thread roots the last. This allows verification code to find
+  // any broken objects from those special roots first, not the accidental
+  // dangling reference from the thread root.
+  Threads::possibly_parallel_oops_do(false, oops, &blobs);
+}
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.hpp	Mon May 27 19:24:42 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.hpp	Mon May 27 14:34:58 2019 -0400
@@ -48,6 +48,9 @@
   void excludes(RootTypes types);
   void oops_do(OopClosure* cl);
 
+  // Used to seed ShenandoahVerifier, do not honor root type filter
+  void roots_do(OopClosure* cl);
+  void strong_roots_do(OopClosure* cl);
 private:
   bool verify(RootTypes type) const;
 };
--- a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp	Mon May 27 19:24:42 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp	Mon May 27 14:34:58 2019 -0400
@@ -458,7 +458,11 @@
         ShenandoahVerifyOopClosure cl(&stack, _bitmap, _ld,
                                       ShenandoahMessageBuffer("%s, Roots", _label),
                                       _options);
-        _verifier->oops_do(&cl);
+        if (_heap->unload_classes()) {
+          _verifier->strong_roots_do(&cl);
+        } else {
+          _verifier->roots_do(&cl);
+        }
     }
 
     size_t processed = 0;