diff options
| author | John Hawthorn <john@hawthorn.email> | 2026-03-24 01:40:51 -0700 |
|---|---|---|
| committer | John Hawthorn <john@hawthorn.email> | 2026-03-27 10:09:30 -0700 |
| commit | 2e753bf278b414b247d55928819fd8bd93ace62c (patch) | |
| tree | 5eceb66ea99775e45f0a0a3a3972dfa2f1807ec5 /object.c | |
| parent | f8a9d28cd1ed42316cfd6d3980ca2101440f110a (diff) | |
Move rb_class_allocate_instance into gc.c
Diffstat (limited to 'object.c')
| -rw-r--r-- | object.c | 35 |
1 files changed, 0 insertions, 35 deletions
@@ -90,11 +90,6 @@ static ID id_instance_variables_to_inspect; /*! \endcond */ -size_t -rb_obj_embedded_size(uint32_t fields_count) -{ - return offsetof(struct RObject, as.ary) + (sizeof(VALUE) * fields_count); -} VALUE rb_obj_hide(VALUE obj) @@ -114,36 +109,6 @@ rb_obj_reveal(VALUE obj, VALUE klass) return obj; } -VALUE -rb_class_allocate_instance(VALUE klass) -{ - uint32_t index_tbl_num_entries = RCLASS_MAX_IV_COUNT(klass); - - size_t size = rb_obj_embedded_size(index_tbl_num_entries); - if (!rb_gc_size_allocatable_p(size)) { - size = sizeof(struct RObject); - } - - // There might be a NEWOBJ tracepoint callback, and it may set fields. - // So the shape must be passed to `NEWOBJ_OF`. - VALUE flags = T_OBJECT | (RGENGC_WB_PROTECTED_OBJECT ? FL_WB_PROTECTED : 0); - NEWOBJ_OF_WITH_SHAPE(o, struct RObject, klass, flags, rb_shape_root(rb_gc_heap_id_for_size(size)), size, 0); - VALUE obj = (VALUE)o; - -#if RUBY_DEBUG - RUBY_ASSERT(!rb_shape_obj_too_complex_p(obj)); - VALUE *ptr = ROBJECT_FIELDS(obj); - size_t fields_count = RSHAPE_LEN(RBASIC_SHAPE_ID(obj)); - for (size_t i = fields_count; i < ROBJECT_FIELDS_CAPACITY(obj); i++) { - ptr[i] = Qundef; - } - if (rb_obj_class(obj) != rb_class_real(klass)) { - rb_bug("Expected rb_class_allocate_instance to set the class correctly"); - } -#endif - - return obj; -} VALUE rb_obj_setup(VALUE obj, VALUE klass, VALUE type) |
