diff --git a/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp b/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp index 951c66d0439..d3a378bcd33 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp @@ -219,10 +219,8 @@ void ShenandoahOldGeneration::prepare_gc() { // Make the old generation regions parseable, so they can be safely // scanned when looking for objects in memory indicated by dirty cards. - entry_coalesce_and_fill(); - - // Now that we have made the old generation parseable, it is safe to reset the mark bitmap. - { + if (entry_coalesce_and_fill()) { + // Now that we have made the old generation parseable, it is safe to reset the mark bitmap. static const char* msg = "Concurrent reset (OLD)"; ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_reset_old); ShenandoahWorkerScope scope(ShenandoahHeap::heap()->workers(), @@ -230,6 +228,9 @@ void ShenandoahOldGeneration::prepare_gc() { msg); ShenandoahGeneration::prepare_gc(); } + // Else, coalesce-and-fill has been preempted and we'll finish that effort in the future. Do not invoke + // ShenandoahGeneration::prepare_gc() until coalesce-and-fill is done because it resets the mark bitmap + // and invokes set_mark_incomplete(). Coalesce-and-fill depends on the mark bitmap. } bool ShenandoahOldGeneration::entry_coalesce_and_fill() {