diff options
author | Alan Wu <XrXr@users.noreply.github.com> | 2021-09-21 18:16:23 -0400 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2021-10-20 18:19:41 -0400 |
commit | 78b5e95e41cefd36702c37293bab95fdede38369 (patch) | |
tree | 78d3d6817438758aeaa9bd09eaaeaf04b74be43c /vm_insnhelper.c | |
parent | f1eb48cb23c949ce8163c6b6d2042cecd0d79ea9 (diff) |
Add a slowpath for opt_getinlinecache
Before this change, when we encounter a constant cache that is specific
to a lexical scope, we unconditionally exit. This change falls back to
the interpreter's cache in this situation.
This should help constant expressions in `class << self`, which is popular
at Shopify due to the style guide.
This change relies on the cache being warm while compiling to detect the
need for checking the lexical scope for simplicity.
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r-- | vm_insnhelper.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 6c2458f32e..a33f6b5ea3 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -4778,6 +4778,12 @@ vm_ic_hit_p(const struct iseq_inline_constant_cache_entry *ice, const VALUE *reg return vm_inlined_ic_hit_p(ice->flags, ice->value, ice->ic_cref, ice->ic_serial, reg_ep); } +bool +rb_vm_ic_hit_p(IC ic, const VALUE *reg_ep) +{ + return ic->entry && vm_ic_hit_p(ic->entry, reg_ep); +} + static void vm_ic_update(const rb_iseq_t *iseq, IC ic, VALUE val, const VALUE *reg_ep) { |