diff options
author | Jeremy Evans <[email protected]> | 2024-08-16 16:47:11 -0700 |
---|---|---|
committer | Jeremy Evans <[email protected]> | 2024-08-16 17:59:05 -0700 |
commit | d56470a27c5a8a2e7aee7a76cea445c2d29c0c59 (patch) | |
tree | 18fe6dc4b17464881276c0dcb5d499bc80101e6e /vm_args.c | |
parent | 2fe6a4f84d2bcf97d3be9bffa5f3232604201f55 (diff) |
Revert "Avoid hash allocation for certain proc calls"
This reverts commit abc04e898b627ab37fa9dd5e330f239768778d8b.
This caused problems in a Rails test.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11394
Diffstat (limited to 'vm_args.c')
-rw-r--r-- | vm_args.c | 37 |
1 files changed, 12 insertions, 25 deletions
@@ -571,22 +571,6 @@ check_kwrestarg(VALUE keyword_hash, unsigned int *kw_flag) } } -static void -flatten_rest_args(rb_execution_context_t * const ec, struct args_info *args, VALUE * const locals, unsigned int *ci_flag) -{ - const VALUE *argv = RARRAY_CONST_PTR(args->rest); - int j, i=args->argc, rest_len = RARRAY_LENINT(args->rest)-1; - args->argc += rest_len; - if (rest_len) { - CHECK_VM_STACK_OVERFLOW(ec->cfp, rest_len+1); - for (i, j=0; rest_len > 0; rest_len--, i++, j++) { - locals[i] = argv[j]; - } - } - args->rest = Qfalse; - *ci_flag &= ~VM_CALL_ARGS_SPLAT; -} - static int setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * const iseq, struct rb_calling_info *const calling, @@ -743,24 +727,27 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co args->rest_dupped = false; if (ignore_keyword_hash_p(rest_last, iseq, &kw_flag, &converted_keyword_hash)) { - if (ISEQ_BODY(iseq)->param.flags.has_rest) { + if (ISEQ_BODY(iseq)->param.flags.has_rest || arg_setup_type != arg_setup_method) { // Only duplicate/modify splat array if it will be used arg_rest_dup(args); rb_ary_pop(args->rest); } - else if (arg_setup_type == arg_setup_block && !ISEQ_BODY(iseq)->param.flags.has_kwrest) { - // Avoid hash allocation for empty hashes - // Copy rest elements except empty keyword hash directly to VM stack - flatten_rest_args(ec, args, locals, &ci_flag); - keyword_hash = Qnil; - kw_flag = 0; - } given_argc--; } else if (!ISEQ_BODY(iseq)->param.flags.has_rest) { // Avoid duping rest when not necessary // Copy rest elements and converted keyword hash directly to VM stack - flatten_rest_args(ec, args, locals, &ci_flag); + const VALUE *argv = RARRAY_CONST_PTR(args->rest); + int j, i=args->argc, rest_len = RARRAY_LENINT(args->rest)-1; + args->argc += rest_len; + if (rest_len) { + CHECK_VM_STACK_OVERFLOW(ec->cfp, rest_len+1); + for (i, j=0; rest_len > 0; rest_len--, i++, j++) { + locals[i] = argv[j]; + } + } + args->rest = Qfalse; + ci_flag &= ~VM_CALL_ARGS_SPLAT; if (ISEQ_BODY(iseq)->param.flags.has_kw || ISEQ_BODY(iseq)->param.flags.has_kwrest) { given_argc--; |