Don't allocate objects in gc_compact

I'd like to call `gc_compact` after major GC, but before the GC
finishes.  This means we can't allocate any objects inside `gc_compact`.
So in this commit I'm just pulling the compaction statistics allocation
outside the `gc_compact` function so we can safely call it.
This commit is contained in:
Aaron Patterson 2019-10-03 17:52:00 -07:00
parent cbf88064f5
commit a20ed0565e
No known key found for this signature in database
GPG Key ID: 953170BCB4FFAFC6

9
gc.c
View File

@ -8279,7 +8279,7 @@ gc_compact_stats(rb_objspace_t *objspace)
static void gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_double_pages, int use_verifier);
static VALUE
static void
gc_compact(rb_objspace_t *objspace, int use_toward_empty, int use_double_pages, int use_verifier)
{
@ -8291,7 +8291,6 @@ gc_compact(rb_objspace_t *objspace, int use_toward_empty, int use_double_pages,
gc_compact_after_gc(objspace, use_toward_empty, use_double_pages, TRUE);
}
objspace->flags.during_compacting = FALSE;
return gc_compact_stats(objspace);
}
static VALUE
@ -8300,7 +8299,8 @@ rb_gc_compact(VALUE mod)
rb_objspace_t *objspace = &rb_objspace;
if (dont_gc) return Qnil;
return gc_compact(objspace, FALSE, FALSE, FALSE);
gc_compact(objspace, FALSE, FALSE, FALSE);
return gc_compact_stats(objspace);
}
static void
@ -8465,7 +8465,8 @@ gc_verify_compaction_references(int argc, VALUE *argv, VALUE mod)
}
}
return gc_compact(objspace, use_toward_empty, use_double_pages, TRUE);
gc_compact(objspace, use_toward_empty, use_double_pages, TRUE);
return gc_compact_stats(objspace);
}
VALUE