summaryrefslogtreecommitdiff
path: root/include/ruby
diff options
context:
space:
mode:
authorJemma Issroff <jemmaissroff@gmail.com>2022-11-08 14:09:43 -0500
committerPeter Zhu <peter@peterzhu.ca>2022-11-10 10:11:34 -0500
commitc726c48a3dacd9ca1cb0d96fee98890cb74b37d3 (patch)
treef2bbd9f9797ee63e8666fffd18c47e04571b7a6f /include/ruby
parent5246f4027ec574e77809845e1b1f7822cc2a5cef (diff)
Remove numiv from RObject
Since object shapes store the capacity of an object, we no longer need the numiv field on RObjects. This gives us one extra slot which we can use to give embedded objects one more instance variable (for a total of 3 ivs). This commit removes the concept of numiv from RObject.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6699
Diffstat (limited to 'include/ruby')
-rw-r--r--include/ruby/internal/core/robject.h59
1 files changed, 1 insertions, 58 deletions
diff --git a/include/ruby/internal/core/robject.h b/include/ruby/internal/core/robject.h
index e0514d7dd2..f51c524081 100644
--- a/include/ruby/internal/core/robject.h
+++ b/include/ruby/internal/core/robject.h
@@ -44,7 +44,7 @@
/** @cond INTERNAL_MACRO */
#define ROBJECT_EMBED_LEN_MAX ROBJECT_EMBED_LEN_MAX
#define ROBJECT_EMBED ROBJECT_EMBED
-#define ROBJECT_NUMIV ROBJECT_NUMIV
+#define ROBJECT_IV_CAPACITY ROBJECT_IV_CAPACITY
#define ROBJECT_IVPTR ROBJECT_IVPTR
/** @endcond */
@@ -96,14 +96,6 @@ struct RObject {
/** Basic part, including flags and class. */
struct RBasic basic;
-#if USE_RVARGC
- /**
- * Number of instance variables. This is per object; objects might
- * differ in this field even if they have the identical classes.
- */
- uint32_t numiv;
-#endif
-
/** Object's specific fields. */
union {
@@ -112,14 +104,6 @@ struct RObject {
* this pattern.
*/
struct {
-#if !USE_RVARGC
- /**
- * Number of instance variables. This is per object; objects might
- * differ in this field even if they have the identical classes.
- */
- uint32_t numiv;
-#endif
-
/** Pointer to a C array that holds instance variables. */
VALUE *ivptr;
@@ -156,11 +140,6 @@ struct RObject {
/* Offsets for YJIT */
#ifndef __cplusplus
-# if USE_RVARGC
-static const int32_t ROBJECT_OFFSET_NUMIV = offsetof(struct RObject, numiv);
-# else
-static const int32_t ROBJECT_OFFSET_NUMIV = offsetof(struct RObject, as.heap.numiv);
-# endif
static const int32_t ROBJECT_OFFSET_AS_HEAP_IVPTR = offsetof(struct RObject, as.heap.ivptr);
static const int32_t ROBJECT_OFFSET_AS_HEAP_IV_INDEX_TBL = offsetof(struct RObject, as.heap.iv_index_tbl);
static const int32_t ROBJECT_OFFSET_AS_ARY = offsetof(struct RObject, as.ary);
@@ -169,42 +148,6 @@ static const int32_t ROBJECT_OFFSET_AS_ARY = offsetof(struct RObject, as.ary);
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
RBIMPL_ATTR_ARTIFICIAL()
/**
- * Queries the number of instance variables.
- *
- * @param[in] obj Object in question.
- * @return Its number of instance variables.
- * @pre `obj` must be an instance of ::RObject.
- */
-static inline uint32_t
-ROBJECT_NUMIV(VALUE obj)
-{
- RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
-
-#if USE_RVARGC
- return ROBJECT(obj)->numiv;
-#else
- if (RB_FL_ANY_RAW(obj, ROBJECT_EMBED)) {
- return ROBJECT_EMBED_LEN_MAX;
- }
- else {
- return ROBJECT(obj)->as.heap.numiv;
- }
-#endif
-}
-
-static inline void
-ROBJECT_SET_NUMIV(VALUE obj, uint32_t capacity)
-{
-#if USE_RVARGC
- ROBJECT(obj)->numiv = capacity;
-#else
- ROBJECT(obj)->as.heap.numiv = capacity;
-#endif
-}
-
-RBIMPL_ATTR_PURE_UNLESS_DEBUG()
-RBIMPL_ATTR_ARTIFICIAL()
-/**
* Queries the instance variables.
*
* @param[in] obj Object in question.