1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Store rb_classext_t next to RClass slots on the heap

This commit is contained in:
Matt Valentine-House 2021-03-30 13:36:58 +01:00 committed by Peter Zhu
parent 8bbd319806
commit d1bd4e233c
Notes: git 2021-05-06 22:18:49 +09:00

15
class.c
View file

@ -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;