diff options
author | Aaron Patterson <tenderlove@ruby-lang.org> | 2019-10-03 17:52:00 -0700 |
---|---|---|
committer | Aaron Patterson <tenderlove@ruby-lang.org> | 2019-10-04 11:11:59 -0700 |
commit | a20ed0565efd2f47845c890d1ebea341d43ee5e6 (patch) | |
tree | 4359b8f78c2ea20dbbd476699b4784e1e00afb7b /gc.c | |
parent | cbf88064f5bd433c13345bbc2ce509b4e8509c7a (diff) | |
download | ruby-a20ed0565efd2f47845c890d1ebea341d43ee5e6.tar.gz |
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.
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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 |