summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2024-02-13 11:44:03 -0500
committerAlan Wu <XrXr@users.noreply.github.com>2024-02-13 12:16:36 -0500
commitfdaef7a72e8611ffd4889aa1a1dbc6ebaf5b3095 (patch)
treef8cfd1599536c811ae4ccc9cb3fd47a803e8fb86
parentc35fea8509551aefe257986c937ea7147f436bdf (diff)
YJIT: Fixup kwrest stack base
I was a little rushed and didn't notice that it was still using the final stack size even though we don't grow the stack before kwrest handling anymore. Oh well, we got a new test out of it. Fix: cbdabd5890
-rw-r--r--bootstraptest/test_yjit.rb11
-rw-r--r--yjit/src/codegen.rs4
2 files changed, 13 insertions, 2 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index d5427588e0..753b1920d7 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -4538,3 +4538,14 @@ assert_normal_exit %q{
Foo.new.try
}
+
+# a kwrest case
+assert_equal '[1, 2, {:complete=>false}]', %q{
+ def rest(foo: 1, bar: 2, **kwrest)
+ [foo, bar, kwrest]
+ end
+
+ def callsite = rest(complete: false)
+
+ callsite
+}
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index 327e4fc05c..1180210aa3 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -7085,7 +7085,7 @@ fn gen_send_iseq(
gen_save_sp(asm);
// Build the kwrest hash. `struct rb_callinfo_kwarg` is malloc'd, so no GC concerns.
- let kwargs_start = asm.lea(asm.ctx.sp_opnd(-(kwargs_order.len() as i32 * SIZEOF_VALUE_I32) as isize));
+ let kwargs_start = asm.lea(asm.ctx.sp_opnd(-(caller_keyword_len_i32 * SIZEOF_VALUE_I32) as isize));
let kwrest = asm.ccall(
build_kw_rest as _,
vec![rest_mask.into(), kwargs_start, Opnd::const_ptr(ci_kwarg.cast())]
@@ -7098,7 +7098,7 @@ fn gen_send_iseq(
// first before putting kwrest there. Use `rest_collected_idx` because that value went
// into kwrest so the slot is now free.
let kwrest_idx = callee_kw_count + usize::from(callee_kw_count > 0);
- if let (Some(rest_collected_idx), true) = (rest_collected_idx, kwrest_idx < kwargs_order.len()) {
+ if let (Some(rest_collected_idx), true) = (rest_collected_idx, kwrest_idx < caller_keyword_len) {
let rest_collected = asm.stack_opnd(kwargs_stack_base - rest_collected_idx);
let mapping = asm.ctx.get_opnd_mapping(stack_kwrest.into());
asm.mov(rest_collected, stack_kwrest);