diff options
author | Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> | 2022-12-09 17:12:15 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-09 14:12:15 -0800 |
commit | daa893db412c6ae814d0291b4ac6fc62a466d394 (patch) | |
tree | 055ea7d05c1b94be296bcb31bf03e28f14d5d885 /test | |
parent | 1c057cfc2fd84369a2ebff048c4a5fdf5fa08fff (diff) |
YJIT: implement `getconstant` YARV instruction (#6884)
* YJIT: implement getconstant YARV instruction
* Constant id is not a pointer
* Stack operands must be read after jit_prepare_routine_call
Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
Notes
Notes:
Merged-By: k0kubun <takashikkbn@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_yjit.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb index 1020257580..3a5792cab4 100644 --- a/test/ruby/test_yjit.rb +++ b/test/ruby/test_yjit.rb @@ -389,6 +389,29 @@ class TestYJIT < Test::Unit::TestCase assert_compiles("'foo' =~ /(o)./; $2", insns: %i[getspecial], result: nil) end + def test_compile_getconstant + assert_compiles(<<~RUBY, insns: %i[getconstant], result: [], call_threshold: 1) + def get_argv(klass) + klass::ARGV + end + + get_argv(Object) + RUBY + end + + def test_compile_getconstant_with_sp_offset + assert_compiles(<<~RUBY, insns: %i[getconstant], result: 2, call_threshold: 1) + class Foo + Bar = 1 + end + + 2.times do + s = Foo # this opt_getconstant_path needs warmup, so 2.times is needed + Class.new(Foo).const_set(:Bar, s::Bar) + end + RUBY + end + def test_compile_opt_getconstant_path assert_compiles(<<~RUBY, insns: %i[opt_getconstant_path], result: 123, call_threshold: 2) def get_foo |