YJIT: Fix staying in invalidated code after proc calls

Previously, there is no instruction boundary patch point after
the call to a non-leaf C function we generate for
OPTIMIZED_METHOD_TYPE_CALL. This meant that if code GC is triggered
while inside the C function, we would keep running invalidated code when
we return from the C function. This had the effect of running
stale branch stubs, jumping to bad code, etc.

Use jit_prepare_routine_call() to make sure we exit from the invalidated
region as soon as possible after the C call in case of invalidation.
This commit is contained in:
Alan Wu 2022-11-10 17:24:10 -05:00
parent 90bbc891b1
commit 04c5adf806
Notes: git 2022-11-11 16:13:39 +00:00

View File

@ -5555,11 +5555,8 @@ fn gen_send_general(
let sp = asm.lea(ctx.sp_opnd(0)); let sp = asm.lea(ctx.sp_opnd(0));
// Write interpreter SP into CFP. // Save the PC and SP because the callee can make Ruby calls
// Needed in case the callee yields to the block. jit_prepare_routine_call(jit, ctx, asm);
jit_save_pc(jit, asm);
// Store incremented PC into current control frame in case callee raises.
gen_save_sp(jit, asm, ctx);
let kw_splat = flags & VM_CALL_KW_SPLAT; let kw_splat = flags & VM_CALL_KW_SPLAT;
let stack_argument_pointer = asm.lea(Opnd::mem(64, sp, -(argc) * SIZEOF_VALUE_I32)); let stack_argument_pointer = asm.lea(Opnd::mem(64, sp, -(argc) * SIZEOF_VALUE_I32));