summaryrefslogtreecommitdiff
path: root/shape.h
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2022-10-31 14:05:37 -0700
committerGitHub <noreply@github.com>2022-10-31 14:05:37 -0700
commit02f15542245222ee392e68fb244b3b8c4a12ad82 (patch)
treeebf3180364aaba5893a17b932605911072189e3d /shape.h
parent2b39640b0bbf7459b305d8a98bb01f197975b8d9 (diff)
downloadruby-02f15542245222ee392e68fb244b3b8c4a12ad82.tar.gz
Implement object shapes for T_CLASS and T_MODULE (#6637)
* Avoid RCLASS_IV_TBL in marshal.c * Avoid RCLASS_IV_TBL for class names * Avoid RCLASS_IV_TBL for autoload * Avoid RCLASS_IV_TBL for class variables * Avoid copying RCLASS_IV_TBL onto ICLASSes * Use object shapes for Class and Module IVs
Diffstat (limited to 'shape.h')
-rw-r--r--shape.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/shape.h b/shape.h
index 1470cdd4aa..8e1bf46ec9 100644
--- a/shape.h
+++ b/shape.h
@@ -90,6 +90,13 @@ ROBJECT_SET_SHAPE_ID(VALUE obj, shape_id_t shape_id)
RBASIC_SET_SHAPE_ID(obj, shape_id);
}
+static inline shape_id_t
+RCLASS_SHAPE_ID(VALUE obj)
+{
+ RUBY_ASSERT(RB_TYPE_P(obj, T_CLASS) || RB_TYPE_P(obj, T_MODULE));
+ return RBASIC_SHAPE_ID(obj);
+}
+
#else
static inline shape_id_t
@@ -105,6 +112,15 @@ ROBJECT_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);
}
+
+MJIT_SYMBOL_EXPORT_BEGIN
+shape_id_t rb_rclass_shape_id(VALUE obj);
+MJIT_SYMBOL_EXPORT_END
+
+static inline shape_id_t RCLASS_SHAPE_ID(VALUE obj) {
+ return rb_rclass_shape_id(obj);
+}
+
#endif
bool rb_shape_root_shape_p(rb_shape_t* shape);
@@ -134,6 +150,14 @@ ROBJECT_IV_COUNT(VALUE obj)
return ivc;
}
+static inline uint32_t
+RCLASS_IV_COUNT(VALUE obj)
+{
+ RUBY_ASSERT(RB_TYPE_P(obj, RUBY_T_CLASS) || RB_TYPE_P(obj, RUBY_T_MODULE));
+ uint32_t ivc = rb_shape_get_shape_by_id(RCLASS_SHAPE_ID(obj))->next_iv_index;
+ return ivc;
+}
+
rb_shape_t * rb_shape_alloc(ID edge_name, rb_shape_t * parent);
rb_shape_t * rb_shape_alloc_with_parent_id(ID edge_name, shape_id_t parent_id);