aboutsummaryrefslogtreecommitdiffstats
path: root/gc.c
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2023-11-27 10:23:31 -0500
committerPeter Zhu <peter@peterzhu.ca>2023-11-27 10:23:43 -0500
commit7835ebce97a6e6132d2bc7bdbef115f3f47cc6c2 (patch)
tree4a42770a699733107963506e7865e562fbf82200 /gc.c
parentca4755b59a7bdaaffbaef05474c8d8ee187e8d7d (diff)
downloadruby-7835ebce97a6e6132d2bc7bdbef115f3f47cc6c2.tar.gz
Set compaction after major GC has been determined
do_full_mark can change in gc_start, so we want to set auto-compaction only after do_full_mark has been properly set.
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/gc.c b/gc.c
index 2d7eb4de93..7daddd5364 100644
--- a/gc.c
+++ b/gc.c
@@ -9409,14 +9409,6 @@ gc_start(rb_objspace_t *objspace, unsigned int reason)
/* reason may be clobbered, later, so keep set immediate_sweep here */
objspace->flags.immediate_sweep = !!(reason & GPR_FLAG_IMMEDIATE_SWEEP);
- /* Explicitly enable compaction (GC.compact) */
- if (do_full_mark && ruby_enable_autocompact) {
- objspace->flags.during_compacting = TRUE;
- }
- else {
- objspace->flags.during_compacting = !!(reason & GPR_FLAG_COMPACT);
- }
-
if (!heap_allocated_pages) return FALSE; /* heap is not ready */
if (!(reason & GPR_FLAG_METHOD) && !ready_to_gc(objspace)) return TRUE; /* GC is not allowed */
@@ -9464,6 +9456,14 @@ gc_start(rb_objspace_t *objspace, unsigned int reason)
objspace->flags.during_incremental_marking = do_full_mark;
}
+ /* Explicitly enable compaction (GC.compact) */
+ if (do_full_mark && ruby_enable_autocompact) {
+ objspace->flags.during_compacting = TRUE;
+ }
+ else {
+ objspace->flags.during_compacting = !!(reason & GPR_FLAG_COMPACT);
+ }
+
if (!GC_ENABLE_LAZY_SWEEP || objspace->flags.dont_incremental) {
objspace->flags.immediate_sweep = TRUE;
}