diff options
author | Jean Boussier <byroot@ruby-lang.org> | 2023-02-15 15:18:01 +0100 |
---|---|---|
committer | Jean Boussier <jean.boussier@gmail.com> | 2023-02-16 08:14:44 +0100 |
commit | 1a4b4cd7f8b53fc52191c1ddcf3f624a5e687c24 (patch) | |
tree | 2143cb0a59d5f680d0c2c245b4698f51f75b952d /gc.c | |
parent | 1df75d658674d511780e578d3a394e1a9bcee5be (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.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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); |