diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb index 77742d3bc6..3fbc26cd15 100644 --- a/test/ruby/test_jit.rb +++ b/test/ruby/test_jit.rb @@ -795,6 +795,25 @@ class TestJIT < Test::Unit::TestCase end; end + def test_caller_locations_without_catch_table + out, _ = eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", min_calls: 1) + begin; + def b # 2 + caller_locations.first # 3 + end # 4 + # 5 + def a # 6 + print # <-- don't leave PC here # 7 + b # 8 + end + puts a + puts a + end; + lines = out.lines + assert_equal("-e:8:in `a'\n", lines[0]) + assert_equal("-e:8:in `a'\n", lines[1]) + end + private # Some tests are stil failing on VC++. diff --git a/tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb b/tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb index f97d4263c6..5ff1c96f8e 100644 --- a/tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb +++ b/tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb @@ -7,9 +7,7 @@ % % # JIT: Move pc so that catch table lookup condition is met. If the ISeq might not catch an exception, % # the pc motion is optimized away and thus pc should be set properly before `goto cancel`. - if (body->catch_except_p) { - fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", next_pos); /* ADD_PC(INSN_ATTR(width)); */ - } + fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", next_pos); /* ADD_PC(INSN_ATTR(width)); */ % % # JIT: move sp to use or preserve stack variables if (status->local_stack_p) {