8231293: Shenandoah: Traversal should not revive dead weak roots
authorzgu
Mon, 23 Sep 2019 07:45:12 -0400
changeset 58266 501df37ce76b
parent 58265 577e17cab93f
child 58267 acc7ea6bf0b4
8231293: Shenandoah: Traversal should not revive dead weak roots Reviewed-by: shade
src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp
src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp
--- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp	Mon Sep 23 12:32:13 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp	Mon Sep 23 07:45:12 2019 -0400
@@ -266,9 +266,19 @@
     return NULL;
   }
 
-  if (_heap->is_evacuation_in_progress() &&
-      !_heap->complete_marking_context()->is_marked(obj)) {
-    return NULL;
+  ShenandoahMarkingContext* const marking_context = _heap->marking_context();
+
+  if (_heap->is_evacuation_in_progress()) {
+    // Normal GC
+    if (!marking_context->is_marked(obj)) {
+      return NULL;
+    }
+  } else if (_heap->is_concurrent_traversal_in_progress()) {
+    // Traversal GC
+    if (marking_context->is_complete() &&
+        !marking_context->is_marked(resolve_forwarded_not_null(obj))) {
+      return NULL;
+    }
   }
 
   return load_reference_barrier_not_null(obj);
--- a/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp	Mon Sep 23 12:32:13 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp	Mon Sep 23 07:45:12 2019 -0400
@@ -594,11 +594,6 @@
   }
 
   if (!_heap->cancelled_gc()) {
-    fixup_roots();
-    _heap->parallel_cleaning(false);
-  }
-
-  if (!_heap->cancelled_gc()) {
     assert(_task_queues->is_empty(), "queues must be empty after traversal GC");
     TASKQUEUE_STATS_ONLY(_task_queues->print_taskqueue_stats());
     TASKQUEUE_STATS_ONLY(_task_queues->reset_taskqueue_stats());
@@ -606,6 +601,9 @@
     // No more marking expected
     _heap->mark_complete_marking_context();
 
+    fixup_roots();
+    _heap->parallel_cleaning(false);
+
     // Resize metaspace
     MetaspaceGC::compute_new_size();