feat(verify): add Call trampolines for arm64, riscv64, loong64
Assisted-by: MiMo V2.5 Pro
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
// 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 arm64.
|
||||
//
|
||||
// enterJIT saves the Go SP and LR, switches to the prepared stack, and
|
||||
// branches to the JIT function. When the function RETs (BR LR), control
|
||||
// lands in leaveJIT, which restores the Go stack and returns.
|
||||
//
|
||||
// The prepared stack layout:
|
||||
// [0] leaveJIT address (loaded into LR before jumping to fn)
|
||||
// [8] ABI0 argument area
|
||||
|
||||
// func enterJIT(fn uintptr, stack uintptr)
|
||||
TEXT ·enterJIT(SB), NOSPLIT, $0-16
|
||||
MOVD fn+0(FP), R0 // target function address
|
||||
MOVD R30, savedLR(SB) // save link register
|
||||
MOVD R3, savedSP(SB) // save Go stack pointer
|
||||
MOVD stack+8(FP), R3 // load prepared stack pointer
|
||||
MOVD 0(R3), R30 // load leaveJIT address into LR
|
||||
ADD $8, R3, R3 // advance past return address
|
||||
MOVD R3, RSP // switch to prepared stack
|
||||
JMP (R0) // branch to JIT function
|
||||
|
||||
// func leaveJIT()
|
||||
TEXT ·leaveJIT(SB), NOSPLIT, $0-0
|
||||
MOVD savedSP(SB), R3 // restore Go stack pointer
|
||||
MOVD R3, RSP
|
||||
MOVD savedLR(SB), R30 // restore link register
|
||||
RET // return to Go caller
|
||||
|
||||
// Package-level storage for saved registers.
|
||||
GLOBL savedLR(SB), NOPTR, $8
|
||||
GLOBL savedSP(SB), NOPTR, $8
|
||||
Reference in New Issue
Block a user