diff --git a/src/hotspot/share/gc/parallel/psParallelCompact.cpp b/src/hotspot/share/gc/parallel/psParallelCompact.cpp index 5fcf19f81a2..8aa95226525 100644 --- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp +++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp @@ -1106,16 +1106,28 @@ void PSParallelCompact::summarize_spaces_quick() } void PSParallelCompact::fill_dense_prefix_end(SpaceId id) { - // Since both markword and klass takes 1 heap word, the min-obj-size is 2 - // heap words. - // If min-fill-size decreases to 1, this whole method becomes redundant. - assert(CollectedHeap::min_fill_size() == 2, "inv"); + // Comparing two sizes to decide if filling is required: + // + // The size of the filler (min-obj-size) is 2 heap words with the default + // MinObjAlignment, since both markword and klass take 1 heap word. + // + // The size of the gap (if any) right before dense-prefix-end is + // MinObjAlignment. + // + // Need to fill in the gap only if it's smaller than min-obj-size, and the + // filler obj will extend to next region. + + // Note: If min-fill-size decreases to 1, this whole method becomes redundant. + assert(CollectedHeap::min_fill_size() >= 2, "inv"); #ifndef _LP64 - // In 32-bit system, min-obj-alignment is >= 8 bytes, so the gap (if any) - // right before denses-prefix must be greater than min-fill-size; nothing to - // do. + // In 32-bit system, each heap word is 4 bytes, so MinObjAlignment == 2. + // The gap is always equal to min-fill-size, so nothing to do. return; #endif + if (MinObjAlignment > 1) { + return; + } + assert(CollectedHeap::min_fill_size() == 2, "inv"); HeapWord* const dense_prefix_end = dense_prefix(id); RegionData* const region_after_dense_prefix = _summary_data.addr_to_region_ptr(dense_prefix_end); idx_t const dense_prefix_bit = _mark_bitmap.addr_to_bit(dense_prefix_end);