Avoid 1-2 array allocations for zsuper calls with post arguments
These previously resulted in 2 array allocations, one for newarray and one for concatarray. This replaces newarray and concatarray with pushtoarray, and changes splatarray false to splatarray true, which reduces it to 1 array allocation, in splatarray true. This also sets VM_CALL_ARGS_SPLAT_MUT, so if the super method accepts a positional splat, this will avoid an additional array allocation on the callee side.
This commit is contained in:
parent
32c58753af
commit
73371450c3
@ -9520,7 +9520,7 @@ compile_super(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
|
||||
/* rest argument */
|
||||
int idx = local_body->local_table_size - local_body->param.rest_start;
|
||||
ADD_GETLOCAL(args, node, idx, lvar_level);
|
||||
ADD_INSN1(args, node, splatarray, Qfalse);
|
||||
ADD_INSN1(args, node, splatarray, local_body->param.flags.has_post ? Qtrue : Qfalse);
|
||||
|
||||
argc = local_body->param.rest_start + 1;
|
||||
flag |= VM_CALL_ARGS_SPLAT;
|
||||
@ -9529,6 +9529,7 @@ compile_super(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
|
||||
/* post arguments */
|
||||
int post_len = local_body->param.post_num;
|
||||
int post_start = local_body->param.post_start;
|
||||
flag |= VM_CALL_ARGS_SPLAT_MUT;
|
||||
|
||||
if (local_body->param.flags.has_rest) {
|
||||
int j;
|
||||
@ -9536,8 +9537,7 @@ compile_super(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
|
||||
int idx = local_body->local_table_size - (post_start + j);
|
||||
ADD_GETLOCAL(args, node, idx, lvar_level);
|
||||
}
|
||||
ADD_INSN1(args, node, newarray, INT2FIX(j));
|
||||
ADD_INSN (args, node, concatarray);
|
||||
ADD_INSN1(args, node, pushtoarray, INT2FIX(j));
|
||||
/* argc is settled at above */
|
||||
}
|
||||
else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user