diff --git a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp index 5b5fe2c1af6..fda97c4836e 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp @@ -415,10 +415,6 @@ void ShenandoahConcurrentGC::entry_reset() { msg); op_reset(); } - - if (heap->mode()->is_generational()) { - heap->old_generation()->card_scan()->mark_read_table_as_clean(); - } } void ShenandoahConcurrentGC::entry_scan_remembered_set() { @@ -644,6 +640,10 @@ void ShenandoahConcurrentGC::op_reset() { } else { _generation->prepare_gc(); } + + if (heap->mode()->is_generational()) { + heap->old_generation()->card_scan()->mark_read_table_as_clean(); + } } class ShenandoahInitMarkUpdateRegionStateClosure : public ShenandoahHeapRegionClosure { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp index 7aaf7bd9f48..c941379d576 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp @@ -136,9 +136,15 @@ void ShenandoahDegenGC::op_degenerated() { heap->set_unload_classes(_generation->heuristics()->can_unload_classes() && (!heap->mode()->is_generational() || _generation->is_global())); - if (heap->mode()->is_generational() && _generation->is_young()) { - // Swap remembered sets for young - _generation->swap_card_tables(); + if (heap->mode()->is_generational()) { + // Clean the read table before swapping it. The end goal here is to have a clean + // write table, and to have the read table updated with the previous write table. + heap->old_generation()->card_scan()->mark_read_table_as_clean(); + + if (_generation->is_young()) { + // Swap remembered sets for young + _generation->swap_card_tables(); + } } case _degenerated_roots: