summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorJean Boussier <byroot@ruby-lang.org>2023-02-15 15:18:01 +0100
committerJean Boussier <jean.boussier@gmail.com>2023-02-16 08:14:44 +0100
commit1a4b4cd7f8b53fc52191c1ddcf3f624a5e687c24 (patch)
tree2143cb0a59d5f680d0c2c245b4698f51f75b952d /gc.c
parent1df75d658674d511780e578d3a394e1a9bcee5be (diff)
Move `attached_object` into `rb_classext_struct`
Given that signleton classes don't have an allocator, we can re-use these bytes to store the attached object in `rb_classext_struct` without making it larger.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7309
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/gc.c b/gc.c
index 42de20060b..1db1a13d3e 100644
--- a/gc.c
+++ b/gc.c
@@ -7264,6 +7264,10 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
switch (BUILTIN_TYPE(obj)) {
case T_CLASS:
+ if (FL_TEST(obj, FL_SINGLETON)) {
+ gc_mark(objspace, RCLASS_ATTACHED_OBJECT(obj));
+ }
+ // Continue to the shared T_CLASS/T_MODULE
case T_MODULE:
if (RCLASS_SUPER(obj)) {
gc_mark(objspace, RCLASS_SUPER(obj));
@@ -10566,6 +10570,10 @@ gc_update_object_references(rb_objspace_t *objspace, VALUE obj)
switch (BUILTIN_TYPE(obj)) {
case T_CLASS:
+ if (FL_TEST(obj, FL_SINGLETON)) {
+ UPDATE_IF_MOVED(objspace, RCLASS_ATTACHED_OBJECT(obj));
+ }
+ // Continue to the shared T_CLASS/T_MODULE
case T_MODULE:
if (RCLASS_SUPER((VALUE)obj)) {
UPDATE_IF_MOVED(objspace, RCLASS(obj)->super);