diff options
Diffstat (limited to 'test/ruby/test_jit.rb')
-rw-r--r-- | test/ruby/test_jit.rb | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb index 7d12b7c130..5af79bc76e 100644 --- a/test/ruby/test_jit.rb +++ b/test/ruby/test_jit.rb @@ -131,7 +131,15 @@ class TestJIT < Test::Unit::TestCase assert_compile_once('/#{true}/ =~ "true"', result_inspect: '0') end - def test_compile_insn_intern_newarray_duparray + def test_compile_insn_newarray + assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: '[1, 2, 3]') + begin; + a, b, c = 1, 2, 3 + [a, b, c] + end; + end + + def test_compile_insn_intern_duparray assert_compile_once('[:"#{0}"] + [1,2,3]', result_inspect: '[:"0", 1, 2, 3]') end @@ -462,6 +470,46 @@ class TestJIT < Test::Unit::TestCase assert_match(/^Successful MJIT finish$/, err) end + def test_local_stack_on_exception + assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '3', success_count: 2) + begin; + def b + raise + rescue + 2 + end + + def a + # Calling #b should be vm_exec, not direct mjit_exec. + # Otherwise `1` on local variable would be purged. + 1 + b + end + + print a + end; + end + + def test_local_stack_with_sp_motion_by_blockargs + assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '1', success_count: 2) + begin; + def b(base) + 1 + end + + # This method is simple enough to have false in catch_except_p. + # So local_stack_p would be true in JIT compiler. + def a + m = method(:b) + + # ci->flag has VM_CALL_ARGS_BLOCKARG and cfp->sp is moved in vm_caller_setup_arg_block. + # So, for this send insn, JIT-ed code should use cfp->sp instead of local variables for stack. + Module.module_eval(&m) + end + + print a + end; + end + private # The shortest way to test one proc |