aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_windows_amd64.s
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2021-02-01 22:58:28 -0500
committerRuss Cox <rsc@golang.org>2021-02-19 00:02:06 +0000
commit01f05d8ff1a88c4a63bdaaff5a095a92ce476f58 (patch)
tree6c853387466cc13722025b1e5f4c880d0031960e /src/runtime/sys_windows_amd64.s
parent229695a2833ead7bbee53071f52f34e2ce1c2802 (diff)
downloadgo-01f05d8ff1a88c4a63bdaaff5a095a92ce476f58.tar.xz
runtime: unify asmcgocall and systemstack traceback setup
Both asmcgocall and systemstack need to save the calling Go code's context for use by traceback, but they do it differently. Systemstack's appraoch is better, because it doesn't require a special case in traceback. So make them both use that. While we are here, the fake mstart caller in systemstack is no longer needed and can be removed. (traceback knows to stop in systemstack because of the writes to SP.) Also remove the fake mstarts in sys_windows_*.s. And while we are there, fix the control flow guard code in sys_windows_arm.s. The current code is using pointers to a stack frame that technically is gone once we hit the RET instruction. Clearly it's working OK, but better not to depend on data below SP being preserved, even for just a few instructions. Store the value we need in other registers instead. (This code is only used for pushing a sigpanic call, which does not actually return to the site of the fault and therefore doesn't need to preserve any of the registers.) This CL is part of a stack adding windows/arm64 support (#36439), intended to land in the Go 1.17 cycle. This CL is, however, not windows/arm64-specific. It is cleanup meant to make the port (and future ports) easier. Change-Id: Id1e3ef5e54f7ad786e4b87043f2626eba7c3bbd9 Reviewed-on: https://go-review.googlesource.com/c/go/+/288799 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/runtime/sys_windows_amd64.s')
-rw-r--r--src/runtime/sys_windows_amd64.s12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/runtime/sys_windows_amd64.s b/src/runtime/sys_windows_amd64.s
index 9cd14016b0..6f2abb5444 100644
--- a/src/runtime/sys_windows_amd64.s
+++ b/src/runtime/sys_windows_amd64.s
@@ -151,16 +151,10 @@ TEXT sigtramp<>(SB),NOSPLIT|NOFRAME,$0-0
get_tls(BP)
MOVQ BX, g(BP)
MOVQ (g_sched+gobuf_sp)(BX), DI
- // make it look like mstart called us on g0, to stop traceback
- SUBQ $8, DI
- MOVQ $runtime·mstart(SB), SI
- MOVQ SI, 0(DI)
- // traceback will think that we've done PUSHFQ and SUBQ
- // on this stack, so subtract them here to match.
- // (we need room for sighandler arguments anyway).
+ // make room for sighandler arguments
// and re-save old SP for restoring later.
- SUBQ $(112+8), DI
- // save g, save old stack pointer.
+ // (note that the 104(DI) here must match the 104(SP) above.)
+ SUBQ $120, DI
MOVQ SP, 104(DI)
MOVQ DI, SP