aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2021-04-08 17:38:25 -0400
committerAustin Clements <austin@google.com>2021-04-09 17:56:50 +0000
commit0ad46889a140c3b2e72b8aa4a47ac242571c521f (patch)
treebf88bdf3f1d2d7db0738a0f40ae39022917f0cbd /src
parent2698be4905c9d54a0d6a7d7d6e90284a9d76b82a (diff)
downloadgo-0ad46889a140c3b2e72b8aa4a47ac242571c521f.tar.xz
cmd/compile/abi-internal: declare X15 scratch in function bodies
X15 must be zero at function calls and returns, but can be used as scratch in the middle of a function. This allows things like memmove and the hashing functions to use X15 temporarily, as long as they set it back to 0 before returning. This CL also clarifies the distinction between register meanings on function call versus function return, since some of them have fixed meanings at both call and return, while others only have a fixed meaning at calls. Updates #40724. Change-Id: I9dad3abde42cd4d2788e8435cde6d55073dd75a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/308929 Trust: Austin Clements <austin@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/abi-internal.md22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/cmd/compile/abi-internal.md b/src/cmd/compile/abi-internal.md
index b457f6ee74..aa61fcc544 100644
--- a/src/cmd/compile/abi-internal.md
+++ b/src/cmd/compile/abi-internal.md
@@ -401,16 +401,16 @@ without corrupting arguments or results.
Special-purpose registers are as follows:
-| Register | Call meaning | Body meaning |
+| Register | Call meaning | Return meaning | Body meaning |
| --- | --- | --- |
-| RSP | Stack pointer | Fixed |
-| RBP | Frame pointer | Fixed |
-| RDX | Closure context pointer | Scratch |
-| R12 | None | Scratch |
-| R13 | None | Scratch |
-| R14 | Current goroutine | Scratch |
-| R15 | GOT reference temporary | Fixed if dynlink |
-| X15 | Zero value | Fixed |
+| RSP | Stack pointer | Same | Same |
+| RBP | Frame pointer | Same | Same |
+| RDX | Closure context pointer | Scratch | Scratch |
+| R12 | Scratch | Scratch | Scratch |
+| R13 | Scratch | Scratch | Scratch |
+| R14 | Current goroutine | Same | Scratch |
+| R15 | GOT reference temporary if dynlink | Same | Same |
+| X15 | Zero value | Same | Scratch |
*Rationale*: These register meanings are compatible with Go’s
stack-based calling convention except for R14 and X15, which will have
@@ -428,6 +428,10 @@ single-byte registers available to be a net win.
functions often have to bulk zero their stack frames, and this is more
efficient with a designated zero register.
+*Implementation note*: Registers with fixed meaning at calls but not
+in function bodies must be initialized by "injected" calls such as
+signal-based panics.
+
#### Stack layout
The stack pointer, RSP, grows down and is always aligned to 8 bytes.