github.com/ice-blockchain/go/src@v0.0.0-20240403114104-1564d284e521/runtime/cgo/asm_amd64.s (about) 1 // Copyright 2009 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 #include "textflag.h" 6 #include "abi_amd64.h" 7 8 // Set the x_crosscall2_ptr C function pointer variable point to crosscall2. 9 // It's such a pointer chain: _crosscall2_ptr -> x_crosscall2_ptr -> crosscall2 10 // Use a local trampoline, to avoid taking the address of a dynamically exported 11 // function. 12 TEXT ·set_crosscall2(SB),NOSPLIT,$0-0 13 MOVQ _crosscall2_ptr(SB), AX 14 MOVQ $crosscall2_trampoline<>(SB), BX 15 MOVQ BX, (AX) 16 RET 17 18 TEXT crosscall2_trampoline<>(SB),NOSPLIT,$0-0 19 JMP crosscall2(SB) 20 21 // Called by C code generated by cmd/cgo. 22 // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr) 23 // Saves C callee-saved registers and calls cgocallback with three arguments. 24 // fn is the PC of a func(a unsafe.Pointer) function. 25 // This signature is known to SWIG, so we can't change it. 26 TEXT crosscall2(SB),NOSPLIT,$0-0 27 PUSH_REGS_HOST_TO_ABI0() 28 29 // Make room for arguments to cgocallback. 30 ADJSP $0x18 31 #ifndef GOOS_windows 32 MOVQ DI, 0x0(SP) /* fn */ 33 MOVQ SI, 0x8(SP) /* arg */ 34 // Skip n in DX. 35 MOVQ CX, 0x10(SP) /* ctxt */ 36 #else 37 MOVQ CX, 0x0(SP) /* fn */ 38 MOVQ DX, 0x8(SP) /* arg */ 39 // Skip n in R8. 40 MOVQ R9, 0x10(SP) /* ctxt */ 41 #endif 42 43 CALL runtime·cgocallback(SB) 44 45 ADJSP $-0x18 46 POP_REGS_HOST_TO_ABI0() 47 RET