Add two new instructions for forwarding calls

This commit adds `sendforward` and `invokesuperforward` for forwarding
parameters to calls

Co-authored-by: Matt Valentine-House <matt@eightbitraptor.com>
This commit is contained in:
Aaron Patterson 2024-06-03 14:20:04 -07:00 committed by Aaron Patterson
parent a25dd5b12c
commit cc97a27008
7 changed files with 301 additions and 206 deletions

View file

@ -866,21 +866,38 @@ send
(VALUE val)
// attr rb_snum_t sp_inc = sp_inc_of_sendish(cd->ci);
// attr rb_snum_t comptime_sp_inc = sp_inc_of_sendish(ci);
{
VALUE bh = vm_caller_setup_arg_block(ec, GET_CFP(), cd->ci, blockiseq, false);
val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_method);
JIT_EXEC(ec, val);
if (UNDEF_P(val)) {
RESTORE_REGS();
NEXT_INSN();
}
}
/* invoke forward method. */
DEFINE_INSN
sendforward
(CALL_DATA cd, ISEQ blockiseq)
(...)
(VALUE val)
// attr rb_snum_t sp_inc = sp_inc_of_sendish(cd->ci);
// attr rb_snum_t comptime_sp_inc = sp_inc_of_sendish(ci);
{
struct rb_forwarding_call_data adjusted_cd;
struct rb_callinfo adjusted_ci;
CALL_DATA _cd = cd;
VALUE bh = vm_caller_setup_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);
JIT_EXEC(ec, val);
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);
}
if (_cd->cc != cd->cc && vm_cc_markable(cd->cc)) {
RB_OBJ_WRITE(GET_ISEQ(), &_cd->cc, cd->cc);
}
if (UNDEF_P(val)) {
@ -1005,20 +1022,37 @@ invokesuper
(VALUE val)
// attr rb_snum_t sp_inc = sp_inc_of_sendish(cd->ci);
// attr rb_snum_t comptime_sp_inc = sp_inc_of_sendish(ci);
{
VALUE bh = vm_caller_setup_arg_block(ec, GET_CFP(), cd->ci, blockiseq, true);
val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_super);
JIT_EXEC(ec, val);
if (UNDEF_P(val)) {
RESTORE_REGS();
NEXT_INSN();
}
}
/* super(args) # args.size => num */
DEFINE_INSN
invokesuperforward
(CALL_DATA cd, ISEQ blockiseq)
(...)
(VALUE val)
// 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_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);
JIT_EXEC(ec, val);
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);
}
if (_cd->cc != cd->cc && vm_cc_markable(cd->cc)) {
RB_OBJ_WRITE(GET_ISEQ(), &_cd->cc, cd->cc);
}
if (UNDEF_P(val)) {