summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2025-06-04 11:11:24 +0200
committerJean Boussier <[email protected]>2025-06-05 07:44:44 +0200
commit772fc1f18785dd3f15dfd815977c9a796e9a3592 (patch)
tree80850028e11eb7390425409c3fa118c374d35cf2 /variable.c
parent111986f8b0604156e139d96476e06a0d1d645e04 (diff)
Get rid of `rb_shape_t.flags`
Now all flags are only in the `shape_id_t`, and can all be checked without needing to dereference a pointer.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13515
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/variable.c b/variable.c
index 7c7f793073..288692ed4d 100644
--- a/variable.c
+++ b/variable.c
@@ -1343,6 +1343,13 @@ rb_obj_field_get(VALUE obj, shape_id_t target_shape_id)
}
VALUE value = Qundef;
st_lookup(fields_hash, RSHAPE(target_shape_id)->edge_name, &value);
+
+#if RUBY_DEBUG
+ if (UNDEF_P(value)) {
+ rb_bug("Object's shape includes object_id, but it's missing %s", rb_obj_info(obj));
+ }
+#endif
+
RUBY_ASSERT(!UNDEF_P(value));
return value;
}
@@ -1617,13 +1624,13 @@ obj_transition_too_complex(VALUE obj, st_table *table)
if (!(RBASIC(obj)->flags & ROBJECT_EMBED)) {
old_fields = ROBJECT_FIELDS(obj);
}
- rb_obj_set_shape_id(obj, shape_id);
+ RBASIC_SET_SHAPE_ID(obj, shape_id);
ROBJECT_SET_FIELDS_HASH(obj, table);
break;
case T_CLASS:
case T_MODULE:
old_fields = RCLASS_PRIME_FIELDS(obj);
- rb_obj_set_shape_id(obj, shape_id);
+ RBASIC_SET_SHAPE_ID(obj, shape_id);
RCLASS_SET_FIELDS_HASH(obj, table);
break;
default:
@@ -1647,7 +1654,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);
- rb_obj_set_shape_id(obj, shape_id);
+ RBASIC_SET_SHAPE_ID(obj, shape_id);
}
}
@@ -1776,8 +1783,9 @@ general_field_set(VALUE obj, shape_id_t target_shape_id, VALUE val, void *data,
}
st_table *table = too_complex_table_func(obj, data);
+
if (RSHAPE_LEN(target_shape_id) > RSHAPE_LEN(current_shape_id)) {
- set_shape_id_func(obj, target_shape_id, data);
+ RBASIC_SET_SHAPE_ID(obj, target_shape_id);
}
st_insert(table, (st_data_t)RSHAPE_EDGE_NAME(target_shape_id), (st_data_t)val);