diff options
| author | John Hawthorn <john@hawthorn.email> | 2025-05-14 11:06:46 -0700 |
|---|---|---|
| committer | Jean Boussier <jean.boussier@gmail.com> | 2025-05-26 10:31:54 +0200 |
| commit | f483befd9065d159d3a944b87fe26179c5373c30 (patch) | |
| tree | f1a5c935f88b726b1bd79c71dd53417c08118651 /variable.c | |
| parent | 2295384a5a89cd4acfbec27b19a671bd5301a757 (diff) | |
Add shape_id to RBasic under 32 bit
This makes `RBobject` `4B` larger on 32 bit systems
but simplifies the implementation a lot.
[Feature #21353]
Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13341
Diffstat (limited to 'variable.c')
| -rw-r--r-- | variable.c | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/variable.c b/variable.c index b19e4c0034..1f77976640 100644 --- a/variable.c +++ b/variable.c @@ -1296,28 +1296,6 @@ rb_generic_ivar_memsize(VALUE obj) return 0; } -#if !SHAPE_IN_BASIC_FLAGS -shape_id_t -rb_generic_shape_id(VALUE obj) -{ - struct gen_fields_tbl *fields_tbl = 0; - shape_id_t shape_id = 0; - - RB_VM_LOCKING() { - st_table* global_iv_table = generic_fields_tbl(obj, 0, false); - - if (global_iv_table && st_lookup(global_iv_table, obj, (st_data_t *)&fields_tbl)) { - shape_id = fields_tbl->shape_id; - } - else if (OBJ_FROZEN(obj)) { - shape_id = SPECIAL_CONST_SHAPE_ID; - } - } - - return shape_id; -} -#endif - static size_t gen_fields_tbl_count(VALUE obj, const struct gen_fields_tbl *fields_tbl) { @@ -1400,9 +1378,7 @@ rb_ivar_lookup(VALUE obj, ID id, VALUE undef) VALUE * ivar_list; rb_shape_t * shape; -#if SHAPE_IN_BASIC_FLAGS shape_id = RBASIC_SHAPE_ID(obj); -#endif switch (BUILTIN_TYPE(obj)) { case T_CLASS: @@ -1412,10 +1388,6 @@ rb_ivar_lookup(VALUE obj, ID id, VALUE undef) VALUE val; RB_VM_LOCKING() { -#if !SHAPE_IN_BASIC_FLAGS - shape_id = RCLASS_SHAPE_ID(obj); -#endif - if (rb_shape_id_too_complex_p(shape_id)) { st_table * iv_table = RCLASS_FIELDS_HASH(obj); if (rb_st_lookup(iv_table, (st_data_t)id, (st_data_t *)&val)) { @@ -1453,9 +1425,6 @@ rb_ivar_lookup(VALUE obj, ID id, VALUE undef) } case T_OBJECT: { -#if !SHAPE_IN_BASIC_FLAGS - shape_id = ROBJECT_SHAPE_ID(obj); -#endif if (rb_shape_id_too_complex_p(shape_id)) { st_table * iv_table = ROBJECT_FIELDS_HASH(obj); VALUE val; @@ -1485,10 +1454,6 @@ rb_ivar_lookup(VALUE obj, ID id, VALUE undef) return undef; } } - -#if !SHAPE_IN_BASIC_FLAGS - shape_id = fields_tbl->shape_id; -#endif ivar_list = fields_tbl->as.shape.fields; } else { @@ -1677,11 +1642,7 @@ obj_transition_too_complex(VALUE obj, st_table *table) * and hold the table because the xmalloc could trigger a GC * compaction. We want the table to be updated rather than * the original fields. */ -#if SHAPE_IN_BASIC_FLAGS rb_shape_set_shape_id(obj, shape_id); -#else - old_fields_tbl->shape_id = shape_id; -#endif old_fields_tbl->as.complex.table = table; old_fields = (VALUE *)old_fields_tbl; } @@ -1690,11 +1651,7 @@ obj_transition_too_complex(VALUE obj, st_table *table) fields_tbl->as.complex.table = table; st_insert(gen_ivs, (st_data_t)obj, (st_data_t)fields_tbl); -#if SHAPE_IN_BASIC_FLAGS rb_shape_set_shape_id(obj, shape_id); -#else - fields_tbl->shape_id = shape_id; -#endif } } @@ -1880,11 +1837,7 @@ generic_fields_lookup_ensure_size(st_data_t *k, st_data_t *v, st_data_t u, int e fields_lookup->fields_tbl = fields_tbl; if (fields_lookup->shape_id) { -#if SHAPE_IN_BASIC_FLAGS rb_shape_set_shape_id(fields_lookup->obj, fields_lookup->shape_id); -#else - fields_tbl->shape_id = fields_lookup->shape_id; -#endif } return ST_CONTINUE; @@ -1937,9 +1890,6 @@ generic_ivar_set_too_complex_table(VALUE obj, void *data) struct gen_fields_tbl *fields_tbl; if (!rb_gen_fields_tbl_get(obj, 0, &fields_tbl)) { fields_tbl = xmalloc(sizeof(struct gen_fields_tbl)); -#if !SHAPE_IN_BASIC_FLAGS - fields_tbl->shape_id = rb_shape_transition_complex(obj); -#endif fields_tbl->as.complex.table = st_init_numtable_with_size(1); RB_VM_LOCKING() { @@ -2100,34 +2050,7 @@ rb_shape_set_shape_id(VALUE obj, shape_id_t shape_id) return false; } -#if SHAPE_IN_BASIC_FLAGS RBASIC_SET_SHAPE_ID(obj, shape_id); -#else - switch (BUILTIN_TYPE(obj)) { - case T_OBJECT: - ROBJECT_SET_SHAPE_ID(obj, shape_id); - break; - case T_CLASS: - case T_MODULE: - RCLASS_SET_SHAPE_ID(obj, shape_id); - break; - default: - if (shape_id != SPECIAL_CONST_SHAPE_ID) { - struct gen_fields_tbl *fields_tbl = 0; - RB_VM_LOCKING() { - st_table* global_iv_table = generic_fields_tbl(obj, 0, false); - - if (st_lookup(global_iv_table, obj, (st_data_t *)&fields_tbl)) { - fields_tbl->shape_id = shape_id; - } - else { - rb_bug("Expected shape_id entry in global iv table"); - } - } - } - } -#endif - return true; } @@ -2492,9 +2415,7 @@ rb_copy_generic_ivar(VALUE dest, VALUE obj) clear: if (FL_TEST(dest, FL_EXIVAR)) { -#if SHAPE_IN_BASIC_FLAGS RBASIC_SET_SHAPE_ID(dest, ROOT_SHAPE_ID); -#endif rb_free_generic_ivar(dest); FL_UNSET(dest, FL_EXIVAR); } |
