summaryrefslogtreecommitdiff
path: root/shape.h
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2025-06-11 14:32:35 +0200
committerJean Boussier <jean.boussier@gmail.com>2025-06-11 16:38:38 +0200
commit95201299fd7bf0918dfbd8c127ce2b5b33ffa537 (patch)
treeb6659cd0932fa3f0cb71c8cf8c2aba382d86cf6b /shape.h
parent4463ac264dc44979ea74bbca3de58ae72d5eea71 (diff)
Refactor the last references to `rb_shape_t`
The type isn't opaque because Ruby isn't often compiled with LTO, so for optimization purpose it's better to allow as much inlining as possible. However ideally only `shape.c` and `shape.h` should deal with the actual struct, and everything else should just deal with opaque `shape_id_t`.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13586
Diffstat (limited to 'shape.h')
-rw-r--r--shape.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/shape.h b/shape.h
index 6cb5075523..65e7595923 100644
--- a/shape.h
+++ b/shape.h
@@ -158,6 +158,9 @@ shape_id_t rb_shape_get_next_iv_shape(shape_id_t shape_id, ID id);
bool rb_shape_get_iv_index(shape_id_t shape_id, ID id, attr_index_t *value);
bool rb_shape_get_iv_index_with_hint(shape_id_t shape_id, ID id, attr_index_t *value, shape_id_t *shape_id_hint);
+typedef int rb_shape_foreach_transition_callback(shape_id_t shape_id, void *data);
+bool rb_shape_foreach_field(shape_id_t shape_id, rb_shape_foreach_transition_callback func, void *data);
+
shape_id_t rb_shape_transition_frozen(VALUE obj);
shape_id_t rb_shape_transition_complex(VALUE obj);
shape_id_t rb_shape_transition_remove_ivar(VALUE obj, ID id, shape_id_t *removed_shape_id);
@@ -211,10 +214,22 @@ rb_shape_root(size_t heap_id)
return ROOT_SHAPE_ID | ((heap_index + 1) << SHAPE_ID_HEAP_INDEX_OFFSET);
}
+static inline shape_id_t
+RSHAPE_PARENT(shape_id_t shape_id)
+{
+ return RSHAPE(shape_id)->parent_id;
+}
+
+static inline enum shape_type
+RSHAPE_TYPE(shape_id_t shape_id)
+{
+ return RSHAPE(shape_id)->type;
+}
+
static inline bool
RSHAPE_TYPE_P(shape_id_t shape_id, enum shape_type type)
{
- return RSHAPE(shape_id)->type == type;
+ return RSHAPE_TYPE(shape_id) == type;
}
static inline attr_index_t