Skip to content

Commit cbf9c08

Browse files
authored
YJIT: End the block after OPTIMIZE_METHOD_TYPE_CALL (ruby#13245)
1 parent 4621feb commit cbf9c08

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

test/-ext-/debug/test_debug.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,19 @@ def test_lazy_block
7575
end
7676
assert_equal true, x, '[Bug #15105]'
7777
end
78+
79+
# This is a YJIT test, but we can't test this without a C extension that calls
80+
# rb_debug_inspector_open(), so we're testing it using "-test-/debug" here.
81+
def test_yjit_invalidates_setlocal_after_inspector_call
82+
val = setlocal_after_proc_call(proc { Bug::Debug.inspector; :ok })
83+
assert_equal :ok, val
84+
end if defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?
85+
86+
private
87+
88+
def setlocal_after_proc_call(block)
89+
local = block.call # setlocal followed by OPTIMIZED_METHOD_TYPE_CALL
90+
itself # split a block using a C call
91+
local # getlocal
92+
end
7893
end

yjit/src/codegen.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9375,7 +9375,6 @@ fn gen_send_general(
93759375

93769376
}
93779377
OPTIMIZED_METHOD_TYPE_CALL => {
9378-
93799378
if block.is_some() {
93809379
gen_counter_incr(jit, asm, Counter::send_call_block);
93819380
return None;
@@ -9427,8 +9426,9 @@ fn gen_send_general(
94279426

94289427
let stack_ret = asm.stack_push(Type::Unknown);
94299428
asm.mov(stack_ret, ret);
9430-
return Some(KeepCompiling);
94319429

9430+
// End the block to allow invalidating the next instruction
9431+
return jump_to_next_insn(jit, asm);
94329432
}
94339433
OPTIMIZED_METHOD_TYPE_BLOCK_CALL => {
94349434
gen_counter_incr(jit, asm, Counter::send_optimized_method_block_call);

0 commit comments

Comments
 (0)