@@ -1891,7 +1891,22 @@ gen_return_branch(codeblock_t* cb, uint8_t* target0, uint8_t* target1, uint8_t s
18911891 }
18921892}
18931893
1894- bool rb_simple_iseq_p (const rb_iseq_t * iseq );
1894+ // Returns whether the iseq only needs positional (lead) argument setup.
1895+ static bool
1896+ iseq_lead_only_arg_setup_p (const rb_iseq_t * iseq )
1897+ {
1898+ // When iseq->body->local_iseq == iseq, setup_parameters_complex()
1899+ // doesn't do anything to setup the block parameter.
1900+ bool takes_block = iseq -> body -> param .flags .has_block ;
1901+ return (!takes_block || iseq -> body -> local_iseq == iseq ) &&
1902+ iseq -> body -> param .flags .has_opt == false &&
1903+ iseq -> body -> param .flags .has_rest == false &&
1904+ iseq -> body -> param .flags .has_post == false &&
1905+ iseq -> body -> param .flags .has_kw == false &&
1906+ iseq -> body -> param .flags .has_kwrest == false &&
1907+ iseq -> body -> param .flags .accepts_no_kwarg == false;
1908+ }
1909+
18951910bool rb_iseq_only_optparam_p (const rb_iseq_t * iseq );
18961911bool rb_iseq_only_kwparam_p (const rb_iseq_t * iseq );
18971912
@@ -1909,7 +1924,9 @@ gen_send_iseq(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const r
19091924 // Arity handling and optional parameter setup
19101925 int num_params = iseq -> body -> param .size ;
19111926 uint32_t start_pc_offset = 0 ;
1912- if (rb_simple_iseq_p (iseq )) {
1927+ if (iseq_lead_only_arg_setup_p (iseq )) {
1928+ num_params = iseq -> body -> param .lead_num ;
1929+
19131930 if (num_params != argc ) {
19141931 GEN_COUNTER_INC (cb , send_iseq_arity_error );
19151932 return YJIT_CANT_COMPILE ;
0 commit comments