github.com/dorkamotorka/go/src@v0.0.0-20230614113921-187095f0e316/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 TEXT ·set_crosscall2(SB),NOSPLIT,$0-0 11 MOVQ _crosscall2_ptr(SB), AX 12 MOVQ $crosscall2(SB), BX 13 MOVQ BX, (AX) 14 RET 15 16 // Called by C code generated by cmd/cgo. 17 // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr) 18 // Saves C callee-saved registers and calls cgocallback with three arguments. 19 // fn is the PC of a func(a unsafe.Pointer) function. 20 // This signature is known to SWIG, so we can't change it. 21 TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0-0 22 PUSH_REGS_HOST_TO_ABI0() 23 24 // Make room for arguments to cgocallback. 25 ADJSP $0x18 26 #ifndef GOOS_windows 27 MOVQ DI, 0x0(SP) /* fn */ 28 MOVQ SI, 0x8(SP) /* arg */ 29 // Skip n in DX. 30 MOVQ CX, 0x10(SP) /* ctxt */ 31 #else 32 MOVQ CX, 0x0(SP) /* fn */ 33 MOVQ DX, 0x8(SP) /* arg */ 34 // Skip n in R8. 35 MOVQ R9, 0x10(SP) /* ctxt */ 36 #endif 37 38 CALL runtime·cgocallback(SB) 39 40 ADJSP $-0x18 41 POP_REGS_HOST_TO_ABI0() 42 RET