Skip to content

Commit 7eef045

Browse files
committed
Deconstruct ci in one place
Putting these calls next to each other lets the compiler combine "packed ci" checks
1 parent b5048ea commit 7eef045

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
@@ -1058,7 +1058,7 @@ vm_caller_setup_arg_block(const rb_execution_context_t *ec, rb_control_frame_t *
10581058
}
10591059
}
10601060

1061-
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);
1061+
static void vm_adjust_stack_forwarding(const struct rb_execution_context_struct *ec, struct rb_control_frame_struct *cfp, int argc, VALUE splat);
10621062

10631063
static VALUE
10641064
vm_caller_setup_fwd_args(const rb_execution_context_t *ec, rb_control_frame_t *reg_cfp,
@@ -1071,13 +1071,20 @@ vm_caller_setup_fwd_args(const rb_execution_context_t *ec, rb_control_frame_t *r
10711071
RUBY_ASSERT(ISEQ_BODY(ISEQ_BODY(GET_ISEQ())->local_iseq)->param.flags.forwardable);
10721072
CALL_INFO caller_ci = (CALL_INFO)TOPN(0);
10731073

1074-
unsigned int forwarding_argc = vm_ci_argc(site_ci);
1074+
unsigned int site_argc = vm_ci_argc(site_ci);
1075+
unsigned int site_flag = vm_ci_flag(site_ci);
1076+
ID site_mid = vm_ci_mid(site_ci);
1077+
1078+
unsigned int caller_argc = vm_ci_argc(caller_ci);
1079+
unsigned int caller_flag = vm_ci_flag(caller_ci);
1080+
const struct rb_callinfo_kwarg * kw = vm_ci_kwarg(caller_ci);
1081+
10751082
VALUE splat = Qfalse;
10761083

1077-
if (vm_ci_flag(site_ci) & VM_CALL_ARGS_SPLAT) {
1084+
if (site_flag & VM_CALL_ARGS_SPLAT) {
10781085
// If we're called with args_splat, the top 1 should be an array
10791086
splat = TOPN(1);
1080-
forwarding_argc += (RARRAY_LEN(splat) - 1);
1087+
site_argc += (RARRAY_LEN(splat) - 1);
10811088
}
10821089

10831090
// Need to setup the block in case of e.g. `super { :block }`
@@ -1088,13 +1095,13 @@ vm_caller_setup_fwd_args(const rb_execution_context_t *ec, rb_control_frame_t *r
10881095
bh = VM_ENV_BLOCK_HANDLER(GET_LEP());
10891096
}
10901097

1091-
vm_adjust_stack_forwarding(ec, GET_CFP(), caller_ci, splat);
1098+
vm_adjust_stack_forwarding(ec, GET_CFP(), caller_argc, splat);
10921099

10931100
*adjusted_ci = VM_CI_ON_STACK(
1094-
vm_ci_mid(site_ci),
1095-
(vm_ci_flag(caller_ci) | (vm_ci_flag(site_ci) & (VM_CALL_FCALL | VM_CALL_FORWARDING))),
1096-
forwarding_argc + vm_ci_argc(caller_ci),
1097-
vm_ci_kwarg(caller_ci)
1101+
site_mid,
1102+
(caller_flag | (site_flag & (VM_CALL_FCALL | VM_CALL_FORWARDING))),
1103+
site_argc + caller_argc,
1104+
kw
10981105
);
10991106

11001107
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)