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