summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2023-04-26 18:06:16 -0700
committerTakashi Kokubun <takashikkbn@gmail.com>2023-04-26 18:12:53 -0700
commitcbfb5fbb25a8b73127f69f47940c8d380270e6af (patch)
treec307f941db798c13810ea703951368612b9a08da
parent12070005d46c23c47763a20d871d9de76a8022b3 (diff)
downloadruby-cbfb5fbb25a8b73127f69f47940c8d380270e6af.tar.gz
RJIT: Fix unspecified_bits with locals
-rw-r--r--bootstraptest/test_rjit.rb14
-rw-r--r--lib/ruby_vm/rjit/insn_compiler.rb4
2 files changed, 16 insertions, 2 deletions
diff --git a/bootstraptest/test_rjit.rb b/bootstraptest/test_rjit.rb
index a8a1524fe2..464af7a6e6 100644
--- a/bootstraptest/test_rjit.rb
+++ b/bootstraptest/test_rjit.rb
@@ -28,3 +28,17 @@ assert_equal 'bar', %q{
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
+}
diff --git a/lib/ruby_vm/rjit/insn_compiler.rb b/lib/ruby_vm/rjit/insn_compiler.rb
index f9debaa40b..619f5078dc 100644
--- a/lib/ruby_vm/rjit/insn_compiler.rb
+++ b/lib/ruby_vm/rjit/insn_compiler.rb
@@ -5548,14 +5548,14 @@ module RubyVM::RJIT
end
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|
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)
end
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[-2]: cref_or_me
asm.mov(:rax, cme.to_i)