feat(verify): add Call trampolines for arm64, riscv64, loong64
Assisted-by: MiMo V2.5 Pro
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
// ABI0 JIT trampoline for RISC-V 64.
|
||||
//
|
||||
// enterJIT saves Go SP and RA, switches to the prepared stack, and jumps
|
||||
// to the JIT function. When the function RETs (JALR zero, ra, 0), control
|
||||
// lands in leaveJIT.
|
||||
|
||||
// func enterJIT(fn uintptr, stack uintptr)
|
||||
TEXT ·enterJIT(SB), NOSPLIT, $0-16
|
||||
MOV fn+0(FP), X5 // target function address (T0)
|
||||
MOV X1, savedRA(SB) // save return address
|
||||
MOV X2, savedSP(SB) // save Go stack pointer
|
||||
MOV stack+8(FP), X6 // load prepared stack pointer (T1)
|
||||
LD 0(X6), X1 // load leaveJIT address into RA
|
||||
ADD $8, X6, X6 // advance past return address
|
||||
MOV X6, X2 // switch to prepared stack (SP)
|
||||
JALR X0, 0(X5) // jump to JIT function
|
||||
|
||||
// func leaveJIT()
|
||||
TEXT ·leaveJIT(SB), NOSPLIT, $0-0
|
||||
MOV savedSP(SB), X6 // restore Go stack pointer
|
||||
MOV X6, X2 // restore SP
|
||||
MOV savedRA(SB), X1 // restore return address
|
||||
JALR X0, 0(X1) // return to Go caller
|
||||
|
||||
GLOBL savedRA(SB), NOPTR, $8
|
||||
GLOBL savedSP(SB), NOPTR, $8
|
||||
Reference in New Issue
Block a user