# HG changeset patch # User shade # Date 1569937107 -7200 # Node ID eba8b29bf528c90c2835a86f764e55aceb71cbff # Parent 9b644c06226f96e676d13a919da153706b415300 8231667: Shenandoah: Full GC should take empty regions into slices for compaction Reviewed-by: rkennke diff -r 9b644c06226f -r eba8b29bf528 src/hotspot/share/gc/shenandoah/shenandoahMarkCompact.cpp --- a/src/hotspot/share/gc/shenandoah/shenandoahMarkCompact.cpp Tue Oct 01 15:38:26 2019 +0200 +++ b/src/hotspot/share/gc/shenandoah/shenandoahMarkCompact.cpp Tue Oct 01 15:38:27 2019 +0200 @@ -327,14 +327,25 @@ ShenandoahHeapRegion* next_from_region(ShenandoahHeapRegionSet* slice) { ShenandoahHeapRegion* from_region = _heap_regions.next(); - while (from_region != NULL && (!from_region->is_move_allowed() || from_region->is_humongous())) { + // Look for next candidate for this slice: + while (from_region != NULL) { + // Empty region: get it into the slice to defragment the slice itself. + // We could have skipped this without violating correctness, but we really + // want to compact all live regions to the start of the heap, which sometimes + // means moving them into the fully empty regions. + if (from_region->is_empty()) break; + + // Can move the region, and this is not the humongous region. Humongous + // moves are special cased here, because their moves are handled separately. + if (from_region->is_move_allowed() && !from_region->is_humongous()) break; + from_region = _heap_regions.next(); } if (from_region != NULL) { assert(slice != NULL, "sanity"); assert(!from_region->is_humongous(), "this path cannot handle humongous regions"); - assert(from_region->is_move_allowed(), "only regions that can be moved in mark-compact"); + assert(from_region->is_empty() || from_region->is_move_allowed(), "only regions that can be moved in mark-compact"); slice->add_region(from_region); }