github.com/jwijenbergh/purego@v0.0.0-20240126093400-70ff3a61df13/internal/fakecgo/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  // Called by C code generated by cmd/cgo.
     9  // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
    10  // Saves C callee-saved registers and calls cgocallback with three arguments.
    11  // fn is the PC of a func(a unsafe.Pointer) function.
    12  TEXT crosscall2(SB), NOSPLIT|NOFRAME, $0
    13  /*
    14   * We still need to save all callee save register as before, and then
    15   *  push 3 args for fn (R0, R1, R3), skipping R2.
    16   * Also note that at procedure entry in gc world, 8(RSP) will be the
    17   *  first arg.
    18   */
    19  	SUB  $(8*24), RSP
    20  	STP  (R0, R1), (8*1)(RSP)
    21  	MOVD R3, (8*3)(RSP)
    22  
    23  	SAVE_R19_TO_R28(8*4)
    24  	SAVE_F8_TO_F15(8*14)
    25  	STP (R29, R30), (8*22)(RSP)
    26  
    27  	// Initialize Go ABI environment
    28  	BL runtimeĀ·load_g(SB)
    29  	BL runtimeĀ·cgocallback(SB)
    30  
    31  	RESTORE_R19_TO_R28(8*4)
    32  	RESTORE_F8_TO_F15(8*14)
    33  	LDP (8*22)(RSP), (R29, R30)
    34  
    35  	ADD $(8*24), RSP
    36  	RET