Refactor so we don't have _cd

This should make the diff more clean
This commit is contained in:
Aaron Patterson 2024-06-03 15:48:13 -07:00 committed by Aaron Patterson
parent cc97a27008
commit a661c82972
3 changed files with 33 additions and 47 deletions

View File

@ -889,15 +889,13 @@ sendforward
struct rb_forwarding_call_data adjusted_cd; struct rb_forwarding_call_data adjusted_cd;
struct rb_callinfo adjusted_ci; struct rb_callinfo adjusted_ci;
CALL_DATA _cd = cd; VALUE bh = vm_caller_setup_fwd_args(GET_EC(), GET_CFP(), cd, blockiseq, 0, &adjusted_cd, &adjusted_ci);
VALUE bh = vm_caller_setup_fwd_args(GET_EC(), GET_CFP(), &cd, blockiseq, 0, &adjusted_cd, &adjusted_ci); val = vm_sendish(ec, GET_CFP(), &adjusted_cd.cd, bh, mexp_search_method);
val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_method);
JIT_EXEC(ec, val); JIT_EXEC(ec, val);
if (_cd->cc != cd->cc && vm_cc_markable(cd->cc)) { if (cd->cc != adjusted_cd.cd.cc && vm_cc_markable(adjusted_cd.cd.cc)) {
RB_OBJ_WRITE(GET_ISEQ(), &_cd->cc, cd->cc); RB_OBJ_WRITE(GET_ISEQ(), &cd->cc, adjusted_cd.cd.cc);
} }
if (UNDEF_P(val)) { if (UNDEF_P(val)) {
@ -1042,17 +1040,16 @@ invokesuperforward
// attr rb_snum_t sp_inc = sp_inc_of_sendish(cd->ci); // attr rb_snum_t sp_inc = sp_inc_of_sendish(cd->ci);
// attr rb_snum_t comptime_sp_inc = sp_inc_of_sendish(ci); // attr rb_snum_t comptime_sp_inc = sp_inc_of_sendish(ci);
{ {
CALL_DATA _cd = cd;
struct rb_forwarding_call_data adjusted_cd; struct rb_forwarding_call_data adjusted_cd;
struct rb_callinfo adjusted_ci; struct rb_callinfo adjusted_ci;
VALUE bh = vm_caller_setup_fwd_args(GET_EC(), GET_CFP(), &cd, blockiseq, 1, &adjusted_cd, &adjusted_ci); VALUE bh = vm_caller_setup_fwd_args(GET_EC(), GET_CFP(), cd, blockiseq, 1, &adjusted_cd, &adjusted_ci);
val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_super); val = vm_sendish(ec, GET_CFP(), &adjusted_cd.cd, bh, mexp_search_super);
JIT_EXEC(ec, val); JIT_EXEC(ec, val);
if (_cd->cc != cd->cc && vm_cc_markable(cd->cc)) { if (cd->cc != adjusted_cd.cd.cc && vm_cc_markable(adjusted_cd.cd.cc)) {
RB_OBJ_WRITE(GET_ISEQ(), &_cd->cc, cd->cc); RB_OBJ_WRITE(GET_ISEQ(), &cd->cc, adjusted_cd.cd.cc);
} }
if (UNDEF_P(val)) { if (UNDEF_P(val)) {

View File

@ -1062,10 +1062,10 @@ static void vm_adjust_stack_forwarding(const struct rb_execution_context_struct
static VALUE static VALUE
vm_caller_setup_fwd_args(const rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, vm_caller_setup_fwd_args(const rb_execution_context_t *ec, rb_control_frame_t *reg_cfp,
CALL_DATA *cd, const rb_iseq_t *blockiseq, const int is_super, CALL_DATA cd, const rb_iseq_t *blockiseq, const int is_super,
struct rb_forwarding_call_data *adjusted_cd, struct rb_callinfo *adjusted_ci) struct rb_forwarding_call_data *adjusted_cd, struct rb_callinfo *adjusted_ci)
{ {
CALL_INFO site_ci = (*cd)->ci; CALL_INFO site_ci = cd->ci;
VALUE bh = Qundef; VALUE bh = Qundef;
RUBY_ASSERT(ISEQ_BODY(ISEQ_BODY(GET_ISEQ())->local_iseq)->param.flags.forwardable); RUBY_ASSERT(ISEQ_BODY(ISEQ_BODY(GET_ISEQ())->local_iseq)->param.flags.forwardable);
@ -1098,17 +1098,8 @@ vm_caller_setup_fwd_args(const rb_execution_context_t *ec, rb_control_frame_t *r
); );
adjusted_cd->cd.ci = adjusted_ci; adjusted_cd->cd.ci = adjusted_ci;
adjusted_cd->cd.cc = (*cd)->cc; adjusted_cd->cd.cc = cd->cc;
adjusted_cd->caller_ci = caller_ci; adjusted_cd->caller_ci = caller_ci;
*cd = &adjusted_cd->cd;
return bh; return bh;
} }
static VALUE
vm_caller_setup_args(const rb_execution_context_t *ec, rb_control_frame_t *reg_cfp,
CALL_DATA *cd, const rb_iseq_t *blockiseq, const int is_super)
{
return vm_caller_setup_arg_block(ec, GET_CFP(), (*cd)->ci, blockiseq, is_super);
}

View File

@ -5927,23 +5927,22 @@ rb_vm_send(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, CALL_DATA cd
struct rb_forwarding_call_data adjusted_cd; struct rb_forwarding_call_data adjusted_cd;
struct rb_callinfo adjusted_ci; struct rb_callinfo adjusted_ci;
CALL_DATA _cd = cd;
VALUE bh; VALUE bh;
VALUE val;
if (vm_ci_flag(_cd->ci) & VM_CALL_FORWARDING) { if (vm_ci_flag(cd->ci) & VM_CALL_FORWARDING) {
bh = vm_caller_setup_fwd_args(GET_EC(), GET_CFP(), &cd, blockiseq, false, &adjusted_cd, &adjusted_ci); bh = vm_caller_setup_fwd_args(GET_EC(), GET_CFP(), cd, blockiseq, false, &adjusted_cd, &adjusted_ci);
val = vm_sendish(ec, GET_CFP(), &adjusted_cd.cd, bh, mexp_search_method);
if (cd->cc != adjusted_cd.cd.cc && vm_cc_markable(adjusted_cd.cd.cc)) {
RB_OBJ_WRITE(GET_ISEQ(), &cd->cc, adjusted_cd.cd.cc);
}
} }
else { else {
bh = vm_caller_setup_args(ec, GET_CFP(), &cd, blockiseq, false); bh = vm_caller_setup_arg_block(ec, GET_CFP(), cd->ci, blockiseq, false);
} val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_method);
VALUE val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_method);
if (vm_ci_flag(_cd->ci) & VM_CALL_FORWARDING) {
if (_cd->cc != cd->cc && vm_cc_markable(cd->cc)) {
RB_OBJ_WRITE(GET_ISEQ(), &_cd->cc, cd->cc);
}
} }
VM_EXEC(ec, val); VM_EXEC(ec, val);
@ -5966,23 +5965,22 @@ rb_vm_invokesuper(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, CALL_
stack_check(ec); stack_check(ec);
struct rb_forwarding_call_data adjusted_cd; struct rb_forwarding_call_data adjusted_cd;
struct rb_callinfo adjusted_ci; struct rb_callinfo adjusted_ci;
CALL_DATA _cd = cd;
VALUE bh; VALUE bh;
VALUE val;
if (vm_ci_flag(_cd->ci) & VM_CALL_FORWARDING) { if (vm_ci_flag(cd->ci) & VM_CALL_FORWARDING) {
bh = vm_caller_setup_fwd_args(ec, GET_CFP(), &cd, blockiseq, true, &adjusted_cd, &adjusted_ci); bh = vm_caller_setup_fwd_args(GET_EC(), GET_CFP(), cd, blockiseq, true, &adjusted_cd, &adjusted_ci);
val = vm_sendish(ec, GET_CFP(), &adjusted_cd.cd, bh, mexp_search_super);
if (cd->cc != adjusted_cd.cd.cc && vm_cc_markable(adjusted_cd.cd.cc)) {
RB_OBJ_WRITE(GET_ISEQ(), &cd->cc, adjusted_cd.cd.cc);
}
} }
else { else {
bh = vm_caller_setup_args(ec, GET_CFP(), &cd, blockiseq, true); bh = vm_caller_setup_arg_block(ec, GET_CFP(), cd->ci, blockiseq, true);
} val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_super);
VALUE val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_super);
if (vm_ci_flag(_cd->ci) & VM_CALL_FORWARDING) {
if (_cd->cc != cd->cc && vm_cc_markable(cd->cc)) {
RB_OBJ_WRITE(GET_ISEQ(), &_cd->cc, cd->cc);
}
} }
VM_EXEC(ec, val); VM_EXEC(ec, val);