From a661c82972d1b4e3fc26662639b3a55c673ecb5e Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 3 Jun 2024 15:48:13 -0700 Subject: [PATCH] Refactor so we don't have _cd This should make the diff more clean --- insns.def | 19 ++++++++----------- vm_args.c | 15 +++------------ vm_insnhelper.c | 46 ++++++++++++++++++++++------------------------ 3 files changed, 33 insertions(+), 47 deletions(-) diff --git a/insns.def b/insns.def index d0a46969a8..5c96e3f394 100644 --- a/insns.def +++ b/insns.def @@ -889,15 +889,13 @@ sendforward struct rb_forwarding_call_data adjusted_cd; 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(), cd, bh, mexp_search_method); + val = vm_sendish(ec, GET_CFP(), &adjusted_cd.cd, bh, mexp_search_method); JIT_EXEC(ec, val); - if (_cd->cc != cd->cc && vm_cc_markable(cd->cc)) { - RB_OBJ_WRITE(GET_ISEQ(), &_cd->cc, cd->cc); + 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); } 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 comptime_sp_inc = sp_inc_of_sendish(ci); { - CALL_DATA _cd = cd; struct rb_forwarding_call_data adjusted_cd; 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); - if (_cd->cc != cd->cc && vm_cc_markable(cd->cc)) { - RB_OBJ_WRITE(GET_ISEQ(), &_cd->cc, cd->cc); + 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); } if (UNDEF_P(val)) { diff --git a/vm_args.c b/vm_args.c index 4d35b00e4a..3428e1530e 100644 --- a/vm_args.c +++ b/vm_args.c @@ -1062,10 +1062,10 @@ static void vm_adjust_stack_forwarding(const struct rb_execution_context_struct static VALUE 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) { - CALL_INFO site_ci = (*cd)->ci; + CALL_INFO site_ci = cd->ci; VALUE bh = Qundef; 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.cc = (*cd)->cc; + adjusted_cd->cd.cc = cd->cc; adjusted_cd->caller_ci = caller_ci; - *cd = &adjusted_cd->cd; - 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); -} diff --git a/vm_insnhelper.c b/vm_insnhelper.c index c65520a940..0ee52d4f83 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -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_callinfo adjusted_ci; - CALL_DATA _cd = cd; VALUE bh; + VALUE val; - 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); + 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); + + 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 { - bh = vm_caller_setup_args(ec, GET_CFP(), &cd, blockiseq, false); - } - - 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); - } + bh = vm_caller_setup_arg_block(ec, GET_CFP(), cd->ci, blockiseq, false); + val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_method); } 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); struct rb_forwarding_call_data adjusted_cd; struct rb_callinfo adjusted_ci; - CALL_DATA _cd = cd; VALUE bh; + VALUE val; - 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); + if (vm_ci_flag(cd->ci) & VM_CALL_FORWARDING) { + 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 { - bh = vm_caller_setup_args(ec, GET_CFP(), &cd, blockiseq, true); - } - - 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); - } + bh = vm_caller_setup_arg_block(ec, GET_CFP(), cd->ci, blockiseq, true); + val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_super); } VM_EXEC(ec, val);