From: Alessandro Arzilli Date: Mon, 16 Oct 2017 11:57:54 +0000 (+0200) Subject: runtime/cgo: declare crosscall2 frame using TEXT for amd64 and 386 X-Git-Tag: go1.10beta1~694 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=913fb18e7e16b95ef4f3c491c3079c4f80e4c562;p=gostls13.git 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 TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- diff --git a/src/runtime/cgo/asm_386.s b/src/runtime/cgo/asm_386.s index dc8897d353..7293c20bf8 100644 --- a/src/runtime/cgo/asm_386.s +++ b/src/runtime/cgo/asm_386.s @@ -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 - - SUBL $12, SP - MOVL 20(BP), AX +TEXT crosscall2(SB),NOSPLIT,$28-16 + MOVL BP, 24(SP) + MOVL BX, 20(SP) + MOVL SI, 16(SP) + MOVL DI, 12(SP) + + 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 diff --git a/src/runtime/cgo/asm_amd64.s b/src/runtime/cgo/asm_amd64.s index 541bd9ea01..0e33fc4796 100644 --- a/src/runtime/cgo/asm_amd64.s +++ b/src/runtime/cgo/asm_amd64.s @@ -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