From b74d6563a665f225f182c4921db68852bbb7e1f1 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Mon, 18 Oct 2021 17:01:40 -0400 Subject: 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 Fixes: GH-282 --- vm_insnhelper.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'vm_insnhelper.c') diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 3b99f7c350..5d83d3dfd5 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1105,12 +1105,6 @@ iv_index_tbl_lookup(struct st_table *iv_index_tbl, ID id, struct rb_iv_index_tbl return found ? true : false; } -bool -rb_iv_index_tbl_lookup(struct st_table *iv_index_tbl, ID id, struct rb_iv_index_tbl_entry **ent) -{ - return iv_index_tbl_lookup(iv_index_tbl, id, ent); -} - ALWAYS_INLINE(static void fill_ivar_cache(const rb_iseq_t *iseq, IVC ic, const struct rb_callcache *cc, int is_attr, struct rb_iv_index_tbl_entry *ent)); static inline void -- cgit v1.2.3