diff options
author | NARUSE, Yui <naruse@airemix.jp> | 2022-01-30 19:01:49 +0900 |
---|---|---|
committer | NARUSE, Yui <naruse@airemix.jp> | 2022-01-30 19:01:49 +0900 |
commit | 2640161df5cf18d08ec86a0c1b913d4ee99e102a (patch) | |
tree | 391cd9a4c88f530009d87a1c1a7347de3a3f87c5 /yjit_codegen.c | |
parent | 20091ccad34904cb5ded13a8787f6662a8e2df68 (diff) |
merge revision(s) 5414de4b6e4372af832e338f8eb7a9fe8de17c84: [Backport #18453]
YJIT: Fix SP index with optarg and unordered kwarg
Previously when we were calling a method with an optional argument and
multiple keywords arguments which weren't in the order the receiver
expected we would use the wrong SP index to rearrange them.
Fixes Bug #18453
---
bootstraptest/test_yjit.rb | 16 ++++++++++++++++
yjit_codegen.c | 7 +++++--
2 files changed, 21 insertions(+), 2 deletions(-)
Diffstat (limited to 'yjit_codegen.c')
-rw-r--r-- | yjit_codegen.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/yjit_codegen.c b/yjit_codegen.c index 8a547d2ef6..21e4813c19 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -3671,7 +3671,10 @@ gen_send_iseq(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const r if (doing_kw_call) { // Here we're calling a method with keyword arguments and specifying // keyword arguments at this call site. - const int lead_num = iseq->body->param.lead_num; + + // Number of positional arguments the callee expects before the first + // keyword argument + const int args_before_kw = required_num + opt_num; // This struct represents the metadata about the caller-specified // keyword arguments. @@ -3761,7 +3764,7 @@ gen_send_iseq(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const r if (callee_kwarg == caller_kwargs[swap_idx]) { // First we're going to generate the code that is going // to perform the actual swapping at runtime. - stack_swap(ctx, cb, argc - 1 - swap_idx - lead_num, argc - 1 - kwarg_idx - lead_num, REG1, REG0); + stack_swap(ctx, cb, argc - 1 - swap_idx - args_before_kw, argc - 1 - kwarg_idx - args_before_kw, REG1, REG0); // Next we're going to do some bookkeeping on our end so // that we know the order that the arguments are |