Skip to content

Commit 0fbfe19

Browse files
author
William Kemper
committed
8312321: GenShen: Remembered set scan may encounter garbage objects
Reviewed-by: kdnilsen
1 parent 514fd37 commit 0fbfe19

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,10 @@ bool ShenandoahConcurrentGC::collect(GCCause::Cause cause) {
188188
entry_strong_roots();
189189
}
190190

191-
// Global marking has completed. We need to fill in any unmarked objects in the old generation
192-
// so that subsequent remembered set scans will not walk pointers into reclaimed memory.
193-
if (!heap->cancelled_gc() && heap->mode()->is_generational() && _generation->is_global()) {
191+
// Global marking has completed and we may have collected regions with no live objects.
192+
// We need to fill in any unmarked objects in the old generation so that subsequent
193+
// remembered set scans will not walk pointers into reclaimed memory.
194+
if (heap->mode()->is_generational() && _generation->is_global()) {
194195
entry_global_coalesce_and_fill();
195196
}
196197

@@ -224,7 +225,10 @@ bool ShenandoahConcurrentGC::collect(GCCause::Cause cause) {
224225
// Update references freed up collection set, kick the cleanup to reclaim the space.
225226
entry_cleanup_complete();
226227
} else {
227-
// We chose not to evacuate because we found sufficient immediate garbage.
228+
// We chose not to evacuate because we found sufficient immediate garbage. Note that we
229+
// do not check for cancellation here because, at this point, the cycle is effectively
230+
// complete. If the cycle has been cancelled here, the control thread will detect it
231+
// on its next iteration and run a degenerated young cycle.
228232
vmop_entry_final_roots();
229233
_abbreviated = true;
230234
}

0 commit comments

Comments
 (0)