summaryrefslogtreecommitdiff
path: root/internal/variable.h
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2021-10-18 17:01:40 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:43 -0400
commitb74d6563a665f225f182c4921db68852bbb7e1f1 (patch)
tree14a7131d423549cf1ffc661048e7501d5ce5ae24 /internal/variable.h
parent2e2430564aa32b68f9e2d99e1f1e273bee3defda (diff)
downloadruby-b74d6563a665f225f182c4921db68852bbb7e1f1.tar.gz
Extract yjit_force_iv_index and make it work when object is frozen
In an effort to simplify the logic YJIT generates for accessing instance variable, YJIT ensures that a given name-to-index mapping exists at compile time. In the case that the mapping doesn't exist, it was created by using rb_ivar_set() with Qundef on the sample object we see at compile time. This hack isn't fine if the sample object happens to be frozen, in which case YJIT would raise a FrozenError unexpectedly. To deal with this, make a new function that only reserves the mapping but doesn't touch the object. This is rb_obj_ensure_iv_index_mapping(). This new function superceeds the functionality of rb_iv_index_tbl_lookup() so it was removed. Reported by and includes a test case from John Hawthorn <john@hawthorn.email> Fixes: GH-282
Diffstat (limited to 'internal/variable.h')
-rw-r--r--internal/variable.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/internal/variable.h b/internal/variable.h
index c527bdbd1f..4b67bef907 100644
--- a/internal/variable.h
+++ b/internal/variable.h
@@ -35,6 +35,7 @@ void rb_gvar_ractor_local(const char *name);
static inline bool ROBJ_TRANSIENT_P(VALUE obj);
static inline void ROBJ_TRANSIENT_SET(VALUE obj);
static inline void ROBJ_TRANSIENT_UNSET(VALUE obj);
+uint32_t rb_obj_ensure_iv_index_mapping(VALUE obj, ID id);
RUBY_SYMBOL_EXPORT_BEGIN
/* variable.c (export) */