YJIT: Avoid using a register for unspecified_bits (#7685)

Fix [Bug #19586]
This commit is contained in:
Takashi Kokubun 2023-04-10 16:35:48 -07:00 committed by GitHub
parent 4af9bd52cb
commit 1ff14a855a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
Notes: git 2023-04-10 23:36:14 +00:00
Merged-By: k0kubun <takashikkbn@gmail.com>
2 changed files with 20 additions and 0 deletions

View File

@ -3822,3 +3822,22 @@ assert_equal '[true, true, true, true]', %q{
assert_equal '0', %q{
3[0, 0]
}
# unspecified_bits + checkkeyword
assert_equal '2', %q{
def callee = 1
# checkkeyword should see unspecified_bits=0 (use bar), not Integer 1 (set bar = foo).
def foo(foo, bar: foo) = bar
def entry(&block)
# write 1 at stack[3]. Calling #callee spills stack[3].
1 + (1 + (1 + (1 + callee)))
# &block is written to a register instead of stack[3]. When &block is popped and
# unspecified_bits is pushed, it must be written to stack[3], not to a register.
foo(1, bar: 2, &block)
end
entry # call branch_stub_hit (spill temps)
entry # doesn't call branch_stub_hit (not spill temps)
}

View File

@ -6172,6 +6172,7 @@ fn gen_send_iseq(
// pushed onto the stack that represents the parameters that weren't
// explicitly given a value and have a non-constant default.
let unspec_opnd = VALUE::fixnum_from_usize(unspecified_bits).as_u64();
asm.spill_temps(ctx); // avoid using a register for unspecified_bits
asm.mov(ctx.stack_opnd(-1), unspec_opnd.into());
}