diff options
Diffstat (limited to 'zjit')
| -rw-r--r-- | zjit/src/codegen.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/zjit/src/codegen.rs b/zjit/src/codegen.rs index 6ce3915978..54346e0778 100644 --- a/zjit/src/codegen.rs +++ b/zjit/src/codegen.rs @@ -898,6 +898,10 @@ fn gen_return(jit: &JITState, asm: &mut Assembler, val: lir::Opnd) -> Option<()> asm.mov(CFP, incr_cfp); asm.mov(Opnd::mem(64, EC, RUBY_OFFSET_EC_CFP), CFP); + // Order here is important. Because we're about to tear down the frame, + // we need to load the return value, which might be part of the frame. + asm.load_into(C_RET_OPND, val); + // Restore the C stack pointer bumped for basic block arguments if jit.c_stack_bytes > 0 { asm_comment!(asm, "restore C stack pointer"); @@ -908,7 +912,7 @@ fn gen_return(jit: &JITState, asm: &mut Assembler, val: lir::Opnd) -> Option<()> asm.frame_teardown(); // Return from the function - asm.cret(val); + asm.cret(C_RET_OPND); Some(()) } |
