github.com/lovishpuri/go-40569/src@v0.0.0-20230519171745-f8623e7c56cf/runtime/cgo/asm_arm64.s (about) 1 // Copyright 2015 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_arm64.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 MOVD _crosscall2_ptr(SB), R1 12 MOVD $crosscall2(SB), R2 13 MOVD R2, (R1) 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 TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0 21 /* 22 * We still need to save all callee save register as before, and then 23 * push 3 args for fn (R0, R1, R3), skipping R2. 24 * Also note that at procedure entry in gc world, 8(RSP) will be the 25 * first arg. 26 */ 27 SUB $(8*24), RSP 28 STP (R0, R1), (8*1)(RSP) 29 MOVD R3, (8*3)(RSP) 30 31 SAVE_R19_TO_R28(8*4) 32 SAVE_F8_TO_F15(8*14) 33 STP (R29, R30), (8*22)(RSP) 34 35 36 // Initialize Go ABI environment 37 BL runtime·load_g(SB) 38 BL runtime·cgocallback(SB) 39 40 RESTORE_R19_TO_R28(8*4) 41 RESTORE_F8_TO_F15(8*14) 42 LDP (8*22)(RSP), (R29, R30) 43 44 ADD $(8*24), RSP 45 RET