...
Run Format

Text file src/runtime/cgo/asm_amd64.s

Documentation: runtime/cgo

     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	
     7	// Called by C code generated by cmd/cgo.
     8	// func crosscall2(fn func(a unsafe.Pointer, n int32, ctxt uintptr), a unsafe.Pointer, n int32, ctxt uintptr)
     9	// Saves C callee-saved registers and calls fn with three arguments.
    10	TEXT crosscall2(SB),NOSPLIT,$0
    11	#ifndef GOOS_windows
    12		SUBQ	$0x58, SP	/* keeps stack pointer 32-byte aligned */
    13	#else
    14		SUBQ	$0x118, SP	/* also need to save xmm6 - xmm15 */
    15	#endif
    16		MOVQ	BX, 0x18(SP)
    17		MOVQ	BP, 0x20(SP)
    18		MOVQ	R12, 0x28(SP)
    19		MOVQ	R13, 0x30(SP)
    20		MOVQ	R14, 0x38(SP)
    21		MOVQ	R15, 0x40(SP)
    22	
    23	#ifdef GOOS_windows
    24		// Win64 save RBX, RBP, RDI, RSI, RSP, R12, R13, R14, R15 and XMM6 -- XMM15.
    25		MOVQ	DI, 0x48(SP)
    26		MOVQ	SI, 0x50(SP)
    27		MOVUPS	X6, 0x60(SP)
    28		MOVUPS	X7, 0x70(SP)
    29		MOVUPS	X8, 0x80(SP)
    30		MOVUPS	X9, 0x90(SP)
    31		MOVUPS	X10, 0xa0(SP)
    32		MOVUPS	X11, 0xb0(SP)
    33		MOVUPS	X12, 0xc0(SP)
    34		MOVUPS	X13, 0xd0(SP)
    35		MOVUPS	X14, 0xe0(SP)
    36		MOVUPS	X15, 0xf0(SP)
    37	
    38		MOVQ	DX, 0x0(SP)	/* arg */
    39		MOVQ	R8, 0x8(SP)	/* argsize (includes padding) */
    40		MOVQ	R9, 0x10(SP)	/* ctxt */
    41		
    42		CALL	CX	/* fn */
    43		
    44		MOVQ	0x48(SP), DI
    45		MOVQ	0x50(SP), SI
    46		MOVUPS	0x60(SP), X6
    47		MOVUPS	0x70(SP), X7
    48		MOVUPS	0x80(SP), X8
    49		MOVUPS	0x90(SP), X9
    50		MOVUPS	0xa0(SP), X10
    51		MOVUPS	0xb0(SP), X11
    52		MOVUPS	0xc0(SP), X12
    53		MOVUPS	0xd0(SP), X13
    54		MOVUPS	0xe0(SP), X14
    55		MOVUPS	0xf0(SP), X15
    56	#else
    57		MOVQ	SI, 0x0(SP)	/* arg */
    58		MOVQ	DX, 0x8(SP)	/* argsize (includes padding) */
    59		MOVQ	CX, 0x10(SP)	/* ctxt */
    60	
    61		CALL	DI	/* fn */
    62	#endif
    63	
    64		MOVQ	0x18(SP), BX
    65		MOVQ	0x20(SP), BP
    66		MOVQ	0x28(SP), R12
    67		MOVQ	0x30(SP), R13
    68		MOVQ	0x38(SP), R14
    69		MOVQ	0x40(SP), R15
    70		
    71	#ifndef GOOS_windows
    72		ADDQ	$0x58, SP
    73	#else
    74		ADDQ	$0x118, SP
    75	#endif
    76		RET

View as plain text