diff options
author | Russ Cox <rsc@golang.org> | 2021-01-27 11:34:42 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2021-02-19 00:04:22 +0000 |
commit | 09e059afb1270498f416f5b5c75a6a5683b6d1da (patch) | |
tree | cec3165dd2d1b93fb9a3a95188faca0433aca990 /src/runtime/traceback.go | |
parent | b19e7b518e564cd309d3eb68dfd2da8839a7433b (diff) | |
download | go-09e059afb1270498f416f5b5c75a6a5683b6d1da.tar.gz go-09e059afb1270498f416f5b5c75a6a5683b6d1da.zip |
runtime: enable framepointer on all arm64
Frame pointers were already enabled on linux, darwin, ios,
but not freebsd, android, openbsd, netbsd.
But the space was reserved on all platforms, leading to
two different arm64 framepointer conditions in different
parts of the code, one of which had no name
(framepointer_enabled || GOARCH == "arm64",
which might have been "framepointer_space_reserved").
So on the disabled systems, the stack layouts were still
set up for frame pointers and the only difference was not
actually maintaining the FP register in the generated code.
Reduce complexity by just enabling the frame pointer
completely on all the arm64 systems.
This commit passes on freebsd, android, netbsd.
I have not been able to try it on openbsd.
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: I83bd23369d24b76db4c6a648fa74f6917819a093
Reviewed-on: https://go-review.googlesource.com/c/go/+/288814
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/runtime/traceback.go')
-rw-r--r-- | src/runtime/traceback.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/runtime/traceback.go b/src/runtime/traceback.go index 7321790b78..eb185eecd3 100644 --- a/src/runtime/traceback.go +++ b/src/runtime/traceback.go @@ -275,7 +275,22 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in // For architectures with frame pointers, if there's // a frame, then there's a saved frame pointer here. - if frame.varp > frame.sp && (GOARCH == "amd64" || GOARCH == "arm64") { + // + // NOTE: This code is not as general as it looks. + // On x86, the ABI is to save the frame pointer word at the + // top of the stack frame, so we have to back down over it. + // On arm64, the frame pointer should be at the bottom of + // the stack (with R29 (aka FP) = RSP), in which case we would + // not want to do the subtraction here. But we started out without + // any frame pointer, and when we wanted to add it, we didn't + // want to break all the assembly doing direct writes to 8(RSP) + // to set the first parameter to a called function. + // So we decided to write the FP link *below* the stack pointer + // (with R29 = RSP - 8 in Go functions). + // This is technically ABI-compatible but not standard. + // And it happens to end up mimicking the x86 layout. + // Other architectures may make different decisions. + if frame.varp > frame.sp && framepointer_enabled { frame.varp -= sys.PtrSize } |