ZJIT: Inline attr_reader/attr_accessor (#14126)

We can rewrite SendWithoutBlock to GetIvar.
This commit is contained in:
Max Bernstein 2025-08-06 13:56:01 -07:00 committed by GitHub
parent 4a70f946a7
commit ba4a36e226
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 144 additions and 13 deletions

View file

@ -887,6 +887,38 @@ class TestZJIT < Test::Unit::TestCase
}
end
def test_attr_reader
assert_compiles '[4, 4]', %q{
class C
attr_reader :foo
def initialize
@foo = 4
end
end
def test(c) = c.foo
c = C.new
[test(c), test(c)]
}, call_threshold: 2, insns: [:opt_send_without_block]
end
def test_attr_accessor
assert_compiles '[4, 4]', %q{
class C
attr_accessor :foo
def initialize
@foo = 4
end
end
def test(c) = c.foo
c = C.new
[test(c), test(c)]
}, call_threshold: 2, insns: [:opt_send_without_block]
end
def test_uncached_getconstant_path
assert_compiles RUBY_COPYRIGHT.dump, %q{
def test = RUBY_COPYRIGHT