ruby-changes:69198
From: Kevin <ko1@a...>
Date: Thu, 21 Oct 2021 08:23:21 +0900 (JST)
Subject: [ruby-changes:69198] c5acbd0208 (master): Bail out if passing keyword arguments to only positional and/or optional methods
https://git.ruby-lang.org/ruby.git/commit/?id=c5acbd0208 From c5acbd0208aa61e05718f73a093c7c6bdc142091 Mon Sep 17 00:00:00 2001 From: Kevin Newton <kddnewton@g...> Date: Wed, 6 Oct 2021 11:15:25 -0400 Subject: Bail out if passing keyword arguments to only positional and/or optional methods --- yjit_codegen.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/yjit_codegen.c b/yjit_codegen.c index fa66ce4afb..8f49a358cf 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -3373,6 +3373,14 @@ gen_send_iseq(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const r https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L3373 uint32_t start_pc_offset = 0; if (iseq_lead_only_arg_setup_p(iseq)) { + // If we have keyword arguments being passed to a callee that only takes + // positionals, then we need to allocate a hash. For now we're going to + // call that too complex and bail. + if (vm_ci_flag(ci) & VM_CALL_KWARG) { + GEN_COUNTER_INC(cb, send_iseq_complex_callee); + return YJIT_CANT_COMPILE; + } + num_params = iseq->body->param.lead_num; if (num_params != argc) { @@ -3381,6 +3389,14 @@ gen_send_iseq(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const r https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L3389 } } else if (rb_iseq_only_optparam_p(iseq)) { + // If we have keyword arguments being passed to a callee that only takes + // positionals and optionals, then we need to allocate a hash. For now + // we're going to call that too complex and bail. + if (vm_ci_flag(ci) & VM_CALL_KWARG) { + GEN_COUNTER_INC(cb, send_iseq_complex_callee); + return YJIT_CANT_COMPILE; + } + // These are iseqs with 0 or more required parameters followed by 1 // or more optional parameters. // We follow the logic of vm_call_iseq_setup_normal_opt_start() -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/