Skip to content

Commit 1ff14a8

Browse files
authored
YJIT: Avoid using a register for unspecified_bits (ruby#7685)
Fix [Bug #19586]
1 parent 4af9bd5 commit 1ff14a8

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

bootstraptest/test_yjit.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3822,3 +3822,22 @@ def calling_my_func
38223822
assert_equal '0', %q{
38233823
3[0, 0]
38243824
}
3825+
3826+
# unspecified_bits + checkkeyword
3827+
assert_equal '2', %q{
3828+
def callee = 1
3829+
3830+
# checkkeyword should see unspecified_bits=0 (use bar), not Integer 1 (set bar = foo).
3831+
def foo(foo, bar: foo) = bar
3832+
3833+
def entry(&block)
3834+
# write 1 at stack[3]. Calling #callee spills stack[3].
3835+
1 + (1 + (1 + (1 + callee)))
3836+
# &block is written to a register instead of stack[3]. When &block is popped and
3837+
# unspecified_bits is pushed, it must be written to stack[3], not to a register.
3838+
foo(1, bar: 2, &block)
3839+
end
3840+
3841+
entry # call branch_stub_hit (spill temps)
3842+
entry # doesn't call branch_stub_hit (not spill temps)
3843+
}

yjit/src/codegen.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6172,6 +6172,7 @@ fn gen_send_iseq(
61726172
// pushed onto the stack that represents the parameters that weren't
61736173
// explicitly given a value and have a non-constant default.
61746174
let unspec_opnd = VALUE::fixnum_from_usize(unspecified_bits).as_u64();
6175+
asm.spill_temps(ctx); // avoid using a register for unspecified_bits
61756176
asm.mov(ctx.stack_opnd(-1), unspec_opnd.into());
61766177
}
61776178

0 commit comments

Comments
 (0)