diff options
author | Matt Valentine-House <[email protected]> | 2021-03-30 13:36:58 +0100 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2021-05-06 09:18:17 -0400 |
commit | d1bd4e233cd4c06734173d532eb2215140b26357 (patch) | |
tree | 40f11151024597b2b76ea3b47f87f351a381073c /class.c | |
parent | 8bbd3198068f5e8335ab01f0b29cdae225b25b5b (diff) |
Store rb_classext_t next to RClass slots on the heap
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4391
Diffstat (limited to 'class.c')
-rw-r--r-- | class.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -173,8 +173,21 @@ rb_class_detach_module_subclasses(VALUE klass) static VALUE class_alloc(VALUE flags, VALUE klass) { - NEWOBJ_OF(obj, struct RClass, klass, (flags & T_MASK) | FL_PROMOTED1 /* start from age == 2 */ | (RGENGC_WB_PROTECTED_CLASS ? FL_WB_PROTECTED : 0)); + size_t payload_size = 0; + +#if USE_RVARGC + payload_size = sizeof(rb_classext_t); +#endif + + RVARGC_NEWOBJ_OF(obj, struct RClass, klass, (flags & T_MASK) | FL_PROMOTED1 /* start from age == 2 */ | (RGENGC_WB_PROTECTED_CLASS ? FL_WB_PROTECTED : 0), payload_size); + +#if USE_RVARGC + obj->ptr = (rb_classext_t *)rb_rvargc_payload_data_ptr((VALUE)obj + rb_slot_size()); + RB_OBJ_WRITTEN(obj, Qundef, (VALUE)obj + rb_slot_size()); +#else obj->ptr = ZALLOC(rb_classext_t); +#endif + /* ZALLOC RCLASS_IV_TBL(obj) = 0; RCLASS_CONST_TBL(obj) = 0; |