ruby-changes:58120
From: Aaron <ko1@a...>
Date: Sat, 5 Oct 2019 03:12:19 +0900 (JST)
Subject: [ruby-changes:58120] a20ed0565e (master): Don't allocate objects in `gc_compact`
https://git.ruby-lang.org/ruby.git/commit/?id=a20ed0565e From a20ed0565efd2f47845c890d1ebea341d43ee5e6 Mon Sep 17 00:00:00 2001 From: Aaron Patterson <tenderlove@r...> Date: Thu, 3 Oct 2019 17:52:00 -0700 Subject: 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. diff --git a/gc.c b/gc.c index fe01d2b..48e8bec 100644 --- a/gc.c +++ b/gc.c @@ -8279,7 +8279,7 @@ gc_compact_stats(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L8279 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, https://github.com/ruby/ruby/blob/trunk/gc.c#L8291 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) https://github.com/ruby/ruby/blob/trunk/gc.c#L8299 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) https://github.com/ruby/ruby/blob/trunk/gc.c#L8465 } } - 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/