summaryrefslogtreecommitdiff
path: root/shape.h
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2025-06-13 11:23:32 +0200
committerJean Boussier <[email protected]>2025-06-13 19:46:29 +0200
commita99d941cacbb9d5d277400abf76f5648f91009ea ()
tree062e514cbaf393b275e5c111c7ace438bfed08be /shape.h
parentfb0dbbc0e660d0c77ebba292578945aca8baafac (diff)
Add SHAPE_ID_HAS_IVAR_MASK for quick ivar check
This allow checking if an object has ivars with just a shape_id mask.
Notes: Merged: https://.com/ruby/ruby/pull/13606
-rw-r--r--shape.h16
1 files changed, 16 insertions, 0 deletions
@@ -23,6 +23,10 @@ STATIC_ASSERT(shape_id_num_bits, SHAPE_ID_NUM_BITS == sizeof(shape_id_t) * CHAR_
#define SHAPE_ID_HEAP_INDEX_MAX ((1 << SHAPE_ID_HEAP_INDEX_BITS) - 1)
#define SHAPE_ID_HEAP_INDEX_MASK (SHAPE_ID_HEAP_INDEX_MAX << SHAPE_ID_HEAP_INDEX_OFFSET)
// The interpreter doesn't care about frozen status or slot size when reading ivars.
// So we normalize shape_id by clearing these bits to improve cache hits.
// JITs however might care about it.
@@ -327,6 +331,18 @@ rb_shape_obj_has_id(VALUE obj)
return rb_shape_has_object_id(RBASIC_SHAPE_ID(obj));
}
// For ext/objspace
RUBY_SYMBOL_EXPORT_BEGIN
typedef void each_shape_callback(shape_id_t shape_id, void *data);