[前][次][番号順一覧][スレッド一覧]

ruby-changes:61304

From: Aaron <ko1@a...>
Date: Thu, 21 May 2020 07:00:55 +0900 (JST)
Subject: [ruby-changes:61304] 6e7e7c1e57 (master): Only marked objects should be considered movable

https://git.ruby-lang.org/ruby.git/commit/?id=6e7e7c1e57

From 6e7e7c1e577d6c2276e9a8cc85c28c55c46c2618 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Wed, 20 May 2020 13:44:09 -0700
Subject: Only marked objects should be considered movable

Ruby's GC is incremental, meaning that during the mark phase (and also
the sweep phase) programs are allowed to run.  This means that programs
can allocate objects before the mark or sweep phase have actually
completed.  Those objects may not have had a chance to be marked, so we
can't know if they are movable or not. Something that references the
newly created object might have called the pinning function during the
mark phase, but since the mark phase hasn't run we can't know if there
is a "pinning" relationship.

To be conservative, we must only allow objects that are not pinned but
also marked to move.

diff --git a/gc.c b/gc.c
index 6353a7b..b0fa670 100644
--- a/gc.c
+++ b/gc.c
@@ -7599,7 +7599,7 @@ gc_is_moveable_obj(rb_objspace_t *objspace, VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L7599
                 return FALSE;
             }
         }
-        return !RVALUE_PINNED(obj);
+        return RVALUE_MARKED(obj) && !RVALUE_PINNED(obj);
 
       default:
         rb_bug("gc_is_moveable_obj: unreachable (%d)", (int)BUILTIN_TYPE(obj));
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]