feat(verify): add Call trampolines for arm64, riscv64, loong64

Assisted-by: MiMo V2.5 Pro
This commit is contained in:
2026-08-21 00:35:21 +02:00
parent 1160c96427
commit 181d8e508c
14 changed files with 643 additions and 27 deletions
+31
View File
@@ -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 LoongArch 64.
//
// enterJIT saves Go SP and RA (R1), switches to the prepared stack, and
// jumps to the JIT function. When the function RETs (JIRL zero, ra, 0),
// control lands in leaveJIT.
// func enterJIT(fn uintptr, stack uintptr)
TEXT ·enterJIT(SB), NOSPLIT, $0-16
MOVV fn+0(FP), R4 // target function address (A0)
MOVV R1, savedRA(SB) // save return address (RA)
MOVV R3, savedSP(SB) // save Go stack pointer (SP)
MOVV stack+8(FP), R5 // load prepared stack pointer (A1)
MOVV 0(R5), R1 // load leaveJIT address into RA
ADDV $8, R5, R5 // advance past return address
MOVV R5, R3 // switch to prepared stack (SP)
JIRL R0, R4, 0 // jump to JIT function
// func leaveJIT()
TEXT ·leaveJIT(SB), NOSPLIT, $0-0
MOVV savedSP(SB), R5 // restore Go stack pointer
MOVV R5, R3 // restore SP
MOVV savedRA(SB), R1 // restore return address
JIRL R0, R1, 0 // return to Go caller
GLOBL savedRA(SB), NOPTR, $8
GLOBL savedSP(SB), NOPTR, $8