Skip to content

Commit 83a1cd8

Browse files
committed
Deconstruct ci in one place
Putting these calls next to each other lets the compiler combine "packed ci" checks
1 parent 7646d64 commit 83a1cd8

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

vm_args.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ vm_caller_setup_arg_block(const rb_execution_context_t *ec, rb_control_frame_t *
10531053
}
10541054
}
10551055

1056-
static void vm_adjust_stack_forwarding(const struct rb_execution_context_struct *ec, struct rb_control_frame_struct *cfp, CALL_INFO callers_info, VALUE splat);
1056+
static void vm_adjust_stack_forwarding(const struct rb_execution_context_struct *ec, struct rb_control_frame_struct *cfp, int argc, VALUE splat);
10571057

10581058
static VALUE
10591059
vm_caller_setup_fwd_args(const rb_execution_context_t *ec, rb_control_frame_t *reg_cfp,
@@ -1066,13 +1066,20 @@ vm_caller_setup_fwd_args(const rb_execution_context_t *ec, rb_control_frame_t *r
10661066
RUBY_ASSERT(ISEQ_BODY(ISEQ_BODY(GET_ISEQ())->local_iseq)->param.flags.forwardable);
10671067
CALL_INFO caller_ci = (CALL_INFO)TOPN(0);
10681068

1069-
unsigned int forwarding_argc = vm_ci_argc(site_ci);
1069+
unsigned int site_argc = vm_ci_argc(site_ci);
1070+
unsigned int site_flag = vm_ci_flag(site_ci);
1071+
ID site_mid = vm_ci_mid(site_ci);
1072+
1073+
unsigned int caller_argc = vm_ci_argc(caller_ci);
1074+
unsigned int caller_flag = vm_ci_flag(caller_ci);
1075+
const struct rb_callinfo_kwarg * kw = vm_ci_kwarg(caller_ci);
1076+
10701077
VALUE splat = Qfalse;
10711078

1072-
if (vm_ci_flag(site_ci) & VM_CALL_ARGS_SPLAT) {
1079+
if (site_flag & VM_CALL_ARGS_SPLAT) {
10731080
// If we're called with args_splat, the top 1 should be an array
10741081
splat = TOPN(1);
1075-
forwarding_argc += (RARRAY_LEN(splat) - 1);
1082+
site_argc += (RARRAY_LEN(splat) - 1);
10761083
}
10771084

10781085
// Need to setup the block in case of e.g. `super { :block }`
@@ -1083,13 +1090,13 @@ vm_caller_setup_fwd_args(const rb_execution_context_t *ec, rb_control_frame_t *r
10831090
bh = VM_ENV_BLOCK_HANDLER(GET_LEP());
10841091
}
10851092

1086-
vm_adjust_stack_forwarding(ec, GET_CFP(), caller_ci, splat);
1093+
vm_adjust_stack_forwarding(ec, GET_CFP(), caller_argc, splat);
10871094

10881095
*adjusted_ci = VM_CI_ON_STACK(
1089-
vm_ci_mid(site_ci),
1090-
(vm_ci_flag(caller_ci) | (vm_ci_flag(site_ci) & (VM_CALL_FCALL | VM_CALL_FORWARDING))),
1091-
forwarding_argc + vm_ci_argc(caller_ci),
1092-
vm_ci_kwarg(caller_ci)
1096+
site_mid,
1097+
(caller_flag | (site_flag & (VM_CALL_FCALL | VM_CALL_FORWARDING))),
1098+
site_argc + caller_argc,
1099+
kw
10931100
);
10941101

10951102
adjusted_cd->cd.ci = adjusted_ci;

vm_insnhelper.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3225,7 +3225,7 @@ vm_callee_setup_arg(rb_execution_context_t *ec, struct rb_calling_info *calling,
32253225
}
32263226

32273227
static void
3228-
vm_adjust_stack_forwarding(const struct rb_execution_context_struct *ec, struct rb_control_frame_struct *cfp, CALL_INFO callers_info, VALUE splat)
3228+
vm_adjust_stack_forwarding(const struct rb_execution_context_struct *ec, struct rb_control_frame_struct *cfp, int argc, VALUE splat)
32293229
{
32303230
// This case is when the caller is using a ... parameter.
32313231
// For example `bar(...)`. The call info will have VM_CALL_FORWARDING
@@ -3250,9 +3250,6 @@ vm_adjust_stack_forwarding(const struct rb_execution_context_struct *ec, struct
32503250
// > ( SP points here )
32513251
const VALUE * lep = VM_CF_LEP(cfp);
32523252

3253-
// We'll need to copy argc args to this SP
3254-
int argc = vm_ci_argc(callers_info);
3255-
32563253
const rb_iseq_t *iseq;
32573254

32583255
// If we're in an escaped environment (lambda for example), get the iseq

0 commit comments

Comments
 (0)