summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author卜部昌平 <[email protected]>2020-08-17 13:51:23 +0900
committer卜部昌平 <[email protected]>2020-08-19 14:30:57 +0900
commit6649677eb93a101a5411a942ca1b84b541262537 ()
tree63c8e41c4bcb5ffed7782ca1651b3019796c5276
parente2c2283a80843f6011a3d7665725ff0c5aed27c5 (diff)
ROBJECT_IV_INDEX_TBL: convert into an inline function
Former ROBJECT_IV_INDEX_TBL macro included RCLASS_IV_INDEX_TBL, which is not disclosed to extension libraies. The macro was kind of broken. Why not just deprecate it, and convert the internal use into an inline function.
Notes: Merged: https://.com/ruby/ruby/pull/3427
-rw-r--r--include/ruby/internal/core/robject.h26
-rw-r--r--internal.h3
-rw-r--r--internal/object.h22
-rw-r--r--object.c8
-rw-r--r--variable.c1
5 files changed, 55 insertions, 5 deletions
@@ -27,6 +27,7 @@
#endif
#include "ruby/internal/attr/artificial.h"
#include "ruby/internal/attr/pure.h"
#include "ruby/internal/cast.h"
#include "ruby/internal/fl_type.h"
@@ -39,24 +40,31 @@
/** @cond INTERNAL_MACRO */
#define ROBJECT_NUMIV ROBJECT_NUMIV
#define ROBJECT_IVPTR ROBJECT_IVPTR
/** @endcond */
enum ruby_robject_flags { ROBJECT_EMBED = RUBY_FL_USER1 };
enum ruby_robject_consts { ROBJECT_EMBED_LEN_MAX = RBIMPL_EMBED_LEN_MAX_OF(VALUE) };
struct RObject {
struct RBasic basic;
union {
struct {
uint32_t numiv;
VALUE *ivptr;
- void *iv_index_tbl; /* shortcut for RCLASS_IV_INDEX_TBL(rb_obj_class(obj)) */
} heap;
VALUE ary[ROBJECT_EMBED_LEN_MAX];
} as;
};
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
RBIMPL_ATTR_ARTIFICIAL()
static inline uint32_t
@@ -89,9 +97,17 @@ ROBJECT_IVPTR(VALUE obj)
}
}
-#define ROBJECT_IV_INDEX_TBL(o) \
- ((RBASIC(o)->flags & ROBJECT_EMBED) ? \
- RCLASS_IV_INDEX_TBL(rb_obj_class(o)) : \
- ROBJECT(o)->as.heap.iv_index_tbl)
#endif /* RBIMPL_ROBJECT_H */
@@ -47,6 +47,9 @@
#undef RHASH_IFNONE
#undef RHASH_SIZE
/* internal/struct.h */
#undef RSTRUCT_LEN
#undef RSTRUCT_PTR
@@ -10,6 +10,11 @@
* @brief Internal header for Object.
*/
#include "ruby/ruby.h" /* for VALUE */
/* object.c */
VALUE rb_class_search_ancestor(VALUE klass, VALUE super);
@@ -22,6 +27,7 @@ int rb_bool_expected(VALUE, const char *);
static inline void RBASIC_CLEAR_CLASS(VALUE obj);
static inline void RBASIC_SET_CLASS_RAW(VALUE obj, VALUE klass);
static inline void RBASIC_SET_CLASS(VALUE obj, VALUE klass);
RUBY_SYMBOL_EXPORT_BEGIN
/* object.c (export) */
@@ -58,4 +64,20 @@ RBASIC_SET_CLASS(VALUE obj, VALUE klass)
RBASIC_SET_CLASS_RAW(obj, klass);
RB_OBJ_WRITTEN(obj, oldv, klass);
}
#endif /* INTERNAL_OBJECT_H */
@@ -320,6 +320,14 @@ rb_obj_singleton_class(VALUE obj)
return rb_singleton_class(obj);
}
/*! \private */
MJIT_FUNC_EXPORTED void
rb_obj_copy_ivar(VALUE dest, VALUE obj)
@@ -25,6 +25,7 @@
#include "internal/error.h"
#include "internal/eval.h"
#include "internal/hash.h"
#include "internal/re.h"
#include "internal/symbol.h"
#include "internal/thread.h"