diff options
| author | Austin Clements <austin@google.com> | 2021-04-13 23:30:19 -0400 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2021-04-15 12:38:13 +0000 |
| commit | 7ad496b6f5300131d6f1fbafe44ac882897889e4 (patch) | |
| tree | 99f5c84ae8cebe176f35097effee24bc5e93e4bb /src/runtime/sys_linux_amd64.s | |
| parent | dba2eab8267599f5f59f1f586b47f31b6552938c (diff) | |
| download | go-7ad496b6f5300131d6f1fbafe44ac882897889e4.tar.xz | |
runtime: unify C->Go ABI transitions
The previous CL introduced macros for transitions from the Windows ABI
to the Go ABI. This CL does the same for SysV and uses them in almost
all places where we transition from the C ABI to the Go ABI.
Compared to Windows, this transition is much simpler and I didn't find
any places that were getting it wrong. But this does let us unify a
lot of code nicely and introduces some degree of abstraction around
these ABI transitions.
Change-Id: Ib6bdecafce587ce18fca4c8300fcf401284a2bcd
Reviewed-on: https://go-review.googlesource.com/c/go/+/309930
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/sys_linux_amd64.s')
| -rw-r--r-- | src/runtime/sys_linux_amd64.s | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/src/runtime/sys_linux_amd64.s b/src/runtime/sys_linux_amd64.s index 215277a9cf..da8a1f7663 100644 --- a/src/runtime/sys_linux_amd64.s +++ b/src/runtime/sys_linux_amd64.s @@ -9,6 +9,7 @@ #include "go_asm.h" #include "go_tls.h" #include "textflag.h" +#include "cgo/abi_amd64.h" #define AT_FDCWD -100 @@ -397,29 +398,21 @@ TEXT runtime·sigfwd(SB),NOSPLIT,$0-32 RET // Defined as ABIInternal since it does not use the stack-based Go ABI. -TEXT runtime·sigtramp<ABIInternal>(SB),NOSPLIT,$72 - // Save callee-saved C registers, since the caller may be a C signal handler. - MOVQ BX, bx-8(SP) - MOVQ BP, bp-16(SP) // save in case GOEXPERIMENT=noframepointer is set - MOVQ R12, r12-24(SP) - MOVQ R13, r13-32(SP) - MOVQ R14, r14-40(SP) - MOVQ R15, r15-48(SP) - // We don't save mxcsr or the x87 control word because sigtrampgo doesn't - // modify them. +// Called using C ABI. +TEXT runtime·sigtramp<ABIInternal>(SB),NOSPLIT,$0 + // Transition from C ABI to Go ABI. + PUSH_REGS_HOST_TO_ABI0() - MOVQ DX, ctx-56(SP) - MOVQ SI, info-64(SP) - MOVQ DI, signum-72(SP) - MOVQ $runtime·sigtrampgo(SB), AX - CALL AX + // Call into the Go signal handler + NOP SP // disable vet stack checking + ADJSP $24 + MOVQ DI, 0(SP) // sig + MOVQ SI, 8(SP) // info + MOVQ DX, 16(SP) // ctx + CALL ·sigtrampgo(SB) + ADJSP $-24 - MOVQ r15-48(SP), R15 - MOVQ r14-40(SP), R14 - MOVQ r13-32(SP), R13 - MOVQ r12-24(SP), R12 - MOVQ bp-16(SP), BP - MOVQ bx-8(SP), BX + POP_REGS_HOST_TO_ABI0() RET // Used instead of sigtramp in programs that use cgo. |
