mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
ZJIT: Inline attr_reader/attr_accessor (#14126)
We can rewrite SendWithoutBlock to GetIvar.
This commit is contained in:
parent
4a70f946a7
commit
ba4a36e226
2 changed files with 144 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue