1
0
mirror of https://github.com/golang/go synced 2024-11-19 15:24:46 -07:00

runtime/cgo: declare crosscall2 frame using TEXT for amd64 and 386

Use TEXT pseudo-instruction to adjust SP instead of a SUB instruction
so that the assembler knows how to fill in the pcsp table and the frame
description entry correctly.

Updates #21569

Change-Id: I436c840b2af99bbb3042ecd38a7d7c1ab4d7372a
Reviewed-on: https://go-review.googlesource.com/70937
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Alessandro Arzilli 2017-10-16 13:57:54 +02:00 committed by Ian Lance Taylor
parent b79e99bfb4
commit 913fb18e7e
2 changed files with 17 additions and 28 deletions

View File

@ -7,26 +7,23 @@
// Called by C code generated by cmd/cgo.
// func crosscall2(fn func(a unsafe.Pointer, n int32, ctxt uintptr), a unsafe.Pointer, n int32, ctxt uintptr)
// Saves C callee-saved registers and calls fn with three arguments.
TEXT crosscall2(SB),NOSPLIT,$0
PUSHL BP
MOVL SP, BP
PUSHL BX
PUSHL SI
PUSHL DI
TEXT crosscall2(SB),NOSPLIT,$28-16
MOVL BP, 24(SP)
MOVL BX, 20(SP)
MOVL SI, 16(SP)
MOVL DI, 12(SP)
SUBL $12, SP
MOVL 20(BP), AX
MOVL ctxt+12(FP), AX
MOVL AX, 8(SP)
MOVL 16(BP), AX
MOVL n+8(FP), AX
MOVL AX, 4(SP)
MOVL 12(BP), AX
MOVL a+4(FP), AX
MOVL AX, 0(SP)
MOVL 8(BP), AX
MOVL fn+0(FP), AX
CALL AX
ADDL $12, SP
POPL DI
POPL SI
POPL BX
POPL BP
MOVL 12(SP), DI
MOVL 16(SP), SI
MOVL 20(SP), BX
MOVL 24(SP), BP
RET

View File

@ -7,14 +7,12 @@
// Called by C code generated by cmd/cgo.
// func crosscall2(fn func(a unsafe.Pointer, n int32, ctxt uintptr), a unsafe.Pointer, n int32, ctxt uintptr)
// Saves C callee-saved registers and calls fn with three arguments.
TEXT crosscall2(SB),NOSPLIT,$0
#ifndef GOOS_windows
SUBQ $0x58, SP /* keeps stack pointer 32-byte aligned */
TEXT crosscall2(SB),NOSPLIT,$0x50-0 /* keeps stack pointer 32-byte aligned */
#else
SUBQ $0x118, SP /* also need to save xmm6 - xmm15 */
TEXT crosscall2(SB),NOSPLIT,$0x110-0 /* also need to save xmm6 - xmm15 */
#endif
MOVQ BX, 0x18(SP)
MOVQ BP, 0x20(SP)
MOVQ R12, 0x28(SP)
MOVQ R13, 0x30(SP)
MOVQ R14, 0x38(SP)
@ -62,15 +60,9 @@ TEXT crosscall2(SB),NOSPLIT,$0
#endif
MOVQ 0x18(SP), BX
MOVQ 0x20(SP), BP
MOVQ 0x28(SP), R12
MOVQ 0x30(SP), R13
MOVQ 0x38(SP), R14
MOVQ 0x40(SP), R15
#ifndef GOOS_windows
ADDQ $0x58, SP
#else
ADDQ $0x118, SP
#endif
RET