RJIT: Fix unspecified_bits with locals

This commit is contained in:
Takashi Kokubun 2023-04-26 18:06:16 -07:00
parent 12070005d4
commit cbfb5fbb25
2 changed files with 16 additions and 2 deletions

View File

@ -28,3 +28,17 @@ assert_equal 'bar', %q{
bar(Struct.new(:bar).new(:bar)) bar(Struct.new(:bar).new(:bar))
} }
# kwargs default w/ checkkeyword + locals (which shouldn't overwrite unspecified_bits)
assert_equal '1', %q{
def foo(bar: 1.to_s)
_ = 1
bar
end
def entry
foo
end
entry
}

View File

@ -5548,14 +5548,14 @@ module RubyVM::RJIT
end end
jit_save_pc(jit, asm, comment: 'save PC to caller CFP') jit_save_pc(jit, asm, comment: 'save PC to caller CFP')
sp_offset = ctx.sp_offset + 3 + local_size + (doing_kw_call ? 1 : 0) # callee_sp
local_size.times do |i| local_size.times do |i|
asm.comment('set local variables') if i == 0 asm.comment('set local variables') if i == 0
local_index = ctx.sp_offset + i local_index = sp_offset + i - local_size - 3
asm.mov([SP, C.VALUE.size * local_index], Qnil) asm.mov([SP, C.VALUE.size * local_index], Qnil)
end end
asm.comment('set up EP with managing data') asm.comment('set up EP with managing data')
sp_offset = ctx.sp_offset + 3 + local_size + (doing_kw_call ? 1 : 0)
ep_offset = sp_offset - 1 ep_offset = sp_offset - 1
# ep[-2]: cref_or_me # ep[-2]: cref_or_me
asm.mov(:rax, cme.to_i) asm.mov(:rax, cme.to_i)