diff options
author | Alan Wu <[email protected]> | 2021-09-21 18:16:23 -0400 |
---|---|---|
committer | Alan Wu <[email protected]> | 2021-10-20 18:19:41 -0400 |
commit | 78b5e95e41cefd36702c37293bab95fdede38369 (patch) | |
tree | 78d3d6817438758aeaa9bd09eaaeaf04b74be43c /test | |
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 'test')
-rw-r--r-- | test/ruby/test_yjit.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb index e6325a4d1c..e00f15ecf5 100644 --- a/test/ruby/test_yjit.rb +++ b/test/ruby/test_yjit.rb @@ -289,6 +289,34 @@ class TestYJIT < Test::Unit::TestCase RUBY end + def test_opt_getinlinecache_slowpath + assert_compiles(<<~RUBY, exits: { opt_getinlinecache: 1 }, result: [42, 42, 1, 1], min_calls: 2) + class A + FOO = 42 + class << self + def foo + _foo = nil + FOO + end + end + end + + result = [] + + result << A.foo + result << A.foo + + class << A + FOO = 1 + end + + result << A.foo + result << A.foo + + result + RUBY + end + def test_string_interpolation assert_compiles(<<~'RUBY', insns: %i[checktype concatstrings], result: "foobar", min_calls: 2) def make_str(foo, bar) |