ruby-changes:66090
From: Matt <ko1@a...>
Date: Thu, 6 May 2021 22:18:44 +0900 (JST)
Subject: [ruby-changes:66090] d1bd4e233c (master): Store rb_classext_t next to RClass slots on the heap
https://git.ruby-lang.org/ruby.git/commit/?id=d1bd4e233c From d1bd4e233cd4c06734173d532eb2215140b26357 Mon Sep 17 00:00:00 2001 From: Matt Valentine-House <matt@e...> Date: Tue, 30 Mar 2021 13:36:58 +0100 Subject: Store rb_classext_t next to RClass slots on the heap --- class.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/class.c b/class.c index e1e1ce0..6784540 100644 --- a/class.c +++ b/class.c @@ -173,8 +173,21 @@ rb_class_detach_module_subclasses(VALUE klass) https://github.com/ruby/ruby/blob/trunk/class.c#L173 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; -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/