# HG changeset patch
# User shade
# Date 1518803134 -3600
#      Fri Feb 16 18:45:34 2018 +0100
# Node ID f4089c39c6cd891afec7ec32d2af3dd508b9e73e
# Parent  19b13a2f5d8e04e9153340830e388ea2fd54706c
Roots verification should take the special roots first

diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp
@@ -72,12 +72,9 @@
 }
 
 void ShenandoahRootProcessor::process_all_roots_slow(OopClosure* oops) {
-  ShenandoahAlwaysTrueClosure always_true;
-
   CLDToOopClosure clds(oops);
   CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
 
-  Threads::possibly_parallel_oops_do(false, oops, &blobs);
   CodeCache::blobs_do(&blobs);
   ClassLoaderDataGraph::cld_do(&clds);
   Universe::oops_do(oops);
@@ -92,6 +89,11 @@
   if (ShenandoahStringDedup::is_enabled()) {
     ShenandoahStringDedup::parallel_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);
 }
 
 void ShenandoahRootProcessor::process_strong_roots(OopClosure* oops,