Skip to content

Commit d56e0ba

Browse files
committed
Fix has_sweeping_pages when USE_PARALLEL_SWEEP == 1
1 parent 176ae3c commit d56e0ba

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

gc/default/default.c

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,9 +1245,7 @@ print_lock_stats(void)
12451245
}
12461246
fprintf(stderr, "================================================\n\n");
12471247
}
1248-
#endif /* PSWEEP_LOCK_STATS > 0 */
12491248

1250-
#if PSWEEP_LOCK_STATS > 0
12511249
/*
12521250
* Sweep step contention stats: first incremental step (gc_sweep) vs
12531251
* subsequent steps (gc_sweep_continue), tracking swept_pages_lock trylock
@@ -1296,7 +1294,7 @@ print_sweep_step_contention(void)
12961294

12971295
fprintf(stderr, "=====================================================\n\n");
12981296
}
1299-
#endif /* PSWEEP_LOCK_STATS > 0 (sweep step contention) */
1297+
#endif /* USE_PARALLEL_SWEEP && PSWEEP_LOCK_STATS > 0 */
13001298

13011299

13021300
#if USE_PARALLEL_SWEEP
@@ -1415,15 +1413,26 @@ static bool
14151413
has_sweeping_pages(rb_objspace_t *objspace)
14161414
{
14171415
rb_heap_t *heap_not_finished = NULL;
1418-
if (objspace->sweeping_heap_count > 1) return true;
1419-
for (int i = 0; i < HEAP_COUNT; i++) {
1420-
rb_heap_t *heap = &heaps[i];
1421-
if (!heap->is_finished_sweeping) {
1422-
heap_not_finished = heap;
1423-
break;
1416+
if (ruby_parallel_sweep_enabled) {
1417+
if (objspace->sweeping_heap_count > 1) {
1418+
return true;
1419+
}
1420+
else if (objspace->sweeping_heap_count == 0) {
1421+
return false;
14241422
}
1423+
for (int i = 0; i < HEAP_COUNT; i++) {
1424+
rb_heap_t *heap = &heaps[i];
1425+
if (!heap->is_finished_sweeping) {
1426+
heap_not_finished = heap;
1427+
break;
1428+
}
1429+
}
1430+
GC_ASSERT(heap_not_finished);
1431+
return !heap_is_sweep_done(objspace, heap_not_finished);
1432+
}
1433+
else {
1434+
return objspace->sweeping_heap_count > 0;
14251435
}
1426-
return !heap_is_sweep_done(objspace, heap_not_finished);
14271436
}
14281437
#else
14291438
static bool

0 commit comments

Comments
 (0)