summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)