mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
2e2430564a
commit
b74d6563a6
5 changed files with 51 additions and 32 deletions
|
@ -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) */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue