summaryrefslogtreecommitdiff
path: root/shape.h
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2025-06-13 15:22:28 +0200
committerJean Boussier <[email protected]>2025-06-13 23:50:30 +0200
commitb51078f82ee35d532dfd5b6981733f757d410d79 ()
treeb028c5779563fb86ba83ef1c1905d51496da0fc2 /shape.h
parentf2d7c6afee45cd7db86fbe2508556f88518a3bdb (diff)
Enforce consistency between shape_id and FL_EXIVAR
The FL_EXIVAR is a bit redundant with the shape_id. Now that the `shape_id` is embedded in all objects on all archs, we can cheaply check if an object has any fields with a simple bitmask.
Notes: Merged: https://.com/ruby/ruby/pull/13612
-rw-r--r--shape.h31
1 files changed, 29 insertions, 2 deletions
@@ -136,8 +136,6 @@ RBASIC_SET_SHAPE_ID(VALUE obj, shape_id_t shape_id)
{
RUBY_ASSERT(!RB_SPECIAL_CONST_P(obj));
RUBY_ASSERT(!RB_TYPE_P(obj, T_IMEMO) || IMEMO_TYPE_P(obj, imemo_class_fields));
- RUBY_ASSERT(rb_shape_verify_consistency(obj, shape_id));
-
#if RBASIC_SHAPE_ID_FIELD
RBASIC(obj)->shape_id = (VALUE)shape_id;
#else
@@ -145,6 +143,7 @@ RBASIC_SET_SHAPE_ID(VALUE obj, shape_id_t shape_id)
RBASIC(obj)->flags &= SHAPE_FLAG_MASK;
RBASIC(obj)->flags |= ((VALUE)(shape_id) << SHAPE_FLAG_SHIFT);
#endif
}
static inline rb_shape_t *
@@ -343,6 +342,34 @@ rb_shape_obj_has_ivars(VALUE obj)
return rb_shape_has_ivars(RBASIC_SHAPE_ID(obj));
}
// For ext/objspace
RUBY_SYMBOL_EXPORT_BEGIN
typedef void each_shape_callback(shape_id_t shape_id, void *data);