aboutsummaryrefslogtreecommitdiffstats
path: root/vm_args.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2023-11-23 10:47:24 -0800
committerJeremy Evans <code@jeremyevans.net>2024-01-24 18:25:55 -0800
commit22e488464a412afa58f201c49e54773aa8011320 (patch)
tree77f5adf2d7761cbcf1eb87e375663195e40fda44 /vm_args.c
parentef276858d9295208add48e27208c69184dc50472 (diff)
downloadruby-22e488464a412afa58f201c49e54773aa8011320.tar.gz
Add VM_CALL_ARGS_SPLAT_MUT callinfo flag
This flag is set when the caller has already created a new array to handle a splat, such as for `f(*a, b)` and `f(*a, *b)`. Previously, if `f` was defined as `def f(*a)`, these calls would create an extra array on the callee side, instead of using the new array created by the caller. This modifies `setup_args_core` to set the flag whenver it would add a `splatarray true` instruction. However, when `splatarray true` is changed to `splatarray false` in the peephole optimizer, to avoid unnecessary allocations on the caller side, the flag must be removed. Add `optimize_args_splat_no_copy` and have the peephole optimizer call that. This significantly simplifies the related peephole optimizer code. On the callee side, in `setup_parameters_complex`, set `args->rest_dupped` to true if the flag is set. This takes a similar approach for optimizing regular splats that was previiously used for keyword splats in d2c41b1bff1f3102544bb0d03d4e82356d034d33 (via VM_CALL_KW_SPLAT_MUT).
Diffstat (limited to 'vm_args.c')
-rw-r--r--vm_args.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/vm_args.c b/vm_args.c
index 37b765a41d..8171dcb8e0 100644
--- a/vm_args.c
+++ b/vm_args.c
@@ -510,7 +510,7 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co
args = &args_body;
given_argc = args->argc = calling->argc;
args->argv = locals;
- args->rest_dupped = FALSE;
+ args->rest_dupped = vm_ci_flag(ci) & VM_CALL_ARGS_SPLAT_MUT;
if (kw_flag & VM_CALL_KWARG) {
args->kw_arg = vm_ci_kwarg(ci);