< prev index next >

src/share/vm/gc/shenandoah/shenandoahConcurrentThread.cpp

Print this page
rev 14453 : Remove secondary marking bitmap.

@@ -174,10 +174,22 @@
 
   GCIdMark gc_id_mark;
   TraceCollectorStats tcs(heap->monitoring_support()->concurrent_collection_counters());
   TraceMemoryManagerStats tmms(false, GCCause::_no_cause_specified);
 
+  // Mark requires clean bitmaps. Clear them here, before diving into STW.
+  // There is a potential race from this moment on to TAMS reset in init mark: the bitmaps
+  // would be clear, but TAMS not yet updated.
+  {
+    GCTraceTime(Info, gc) time("Concurrent cleanup", gc_timer, GCCause::_no_gc, true);
+    ShenandoahGCPhase phase(ShenandoahPhaseTimings::conc_cleanup);
+    ShenandoahGCPhase phase_reset(ShenandoahPhaseTimings::conc_cleanup_reset_bitmaps);
+    WorkGang *workers = heap->workers();
+    ShenandoahPushWorkerScope scope(workers, ConcGCThreads);
+    heap->reset_mark_bitmap(workers);
+  }
+
   // Start initial mark under STW:
   {
     // Workers are setup by VM_ShenandoahInitMark
     TraceCollectorStats tcs(heap->monitoring_support()->stw_collection_counters());
     ShenandoahGCPhase total_phase(ShenandoahPhaseTimings::total_pause_gross);

@@ -324,10 +336,21 @@
       ShenandoahGCPhase total(ShenandoahPhaseTimings::total_pause_gross);
       ShenandoahGCPhase final_update_refs_phase(ShenandoahPhaseTimings::final_update_refs_gross);
       VM_ShenandoahFinalUpdateRefs final_update_refs;
       VMThread::execute(&final_update_refs);
     }
+
+    if (do_it) {
+      GCTraceTime(Info, gc) time("Concurrent cleanup", gc_timer, GCCause::_no_gc, true);
+      ShenandoahGCPhase phase(ShenandoahPhaseTimings::conc_cleanup);
+      ShenandoahGCPhase phase_recycle(ShenandoahPhaseTimings::conc_cleanup_recycle);
+      heap->recycle_trash();
+    }
+
+    // Allocations happen during bitmap cleanup, record peak after the phase:
+    heap->shenandoahPolicy()->record_peak_occupancy();
+
   } else {
     // If update-refs were skipped, need to do another verification pass after evacuation.
     if (ShenandoahVerify && !check_cancellation()) {
       VM_ShenandoahVerifyHeapAfterEvacuation verify_after_evacuation;
       VMThread::execute(&verify_after_evacuation);

@@ -339,30 +362,10 @@
 
   if (clear_full_gc) {
     reset_full_gc();
   }
 
-  {
-    GCTraceTime(Info, gc) time("Concurrent cleanup", gc_timer, GCCause::_no_gc, true);
-    ShenandoahGCPhase phase(ShenandoahPhaseTimings::conc_cleanup);
-
-    {
-      ShenandoahGCPhase phase_recycle(ShenandoahPhaseTimings::conc_cleanup_recycle);
-      heap->recycle_trash();
-    }
-
-    {
-      ShenandoahGCPhase phase_reset(ShenandoahPhaseTimings::conc_cleanup_reset_bitmaps);
-      WorkGang *workers = heap->workers();
-      ShenandoahPushWorkerScope scope(workers, ConcGCThreads);
-      heap->reset_next_mark_bitmap(workers);
-    }
-  }
-
-  // Allocations happen during bitmap cleanup, record peak after the phase:
-  heap->shenandoahPolicy()->record_peak_occupancy();
-
   // Cycle is complete
   heap->shenandoahPolicy()->record_cycle_end();
 
   // TODO: Call this properly with Shenandoah*CycleMark
   heap->set_used_at_last_gc();
< prev index next >