diff options
author | Austin Clements <austin@google.com> | 2021-04-09 13:55:18 -0400 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2021-04-09 18:11:15 +0000 |
commit | fcf8a6640b1bfb2444749b558f926321841922fa (patch) | |
tree | 86af757d4a098169bfd2328f2316c4748d1b5b6f /src/cmd/compile/abi-internal.md | |
parent | 0ad46889a140c3b2e72b8aa4a47ac242571c521f (diff) | |
download | go-fcf8a6640b1bfb2444749b558f926321841922fa.tar.gz go-fcf8a6640b1bfb2444749b558f926321841922fa.zip |
cmd/compile/abi-internal: declare R14 completely fixed
Currently, we allow R14, the current goroutine pointer, to be
clobbered in function bodies as long as the function restores it. This
is unnecessary complexity and could lead to confusing inconsistencies
with other architectures that can't simply restore it from TLS.
Updates #40724.
Change-Id: I4c052f0dd0b31d31afeb0c5aff05c314d7a852f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/309009
Trust: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/cmd/compile/abi-internal.md')
-rw-r--r-- | src/cmd/compile/abi-internal.md | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cmd/compile/abi-internal.md b/src/cmd/compile/abi-internal.md index aa61fcc544..f901e707be 100644 --- a/src/cmd/compile/abi-internal.md +++ b/src/cmd/compile/abi-internal.md @@ -408,7 +408,7 @@ Special-purpose registers are as follows: | RDX | Closure context pointer | Scratch | Scratch | | R12 | Scratch | Scratch | Scratch | | R13 | Scratch | Scratch | Scratch | -| R14 | Current goroutine | Same | Scratch | +| R14 | Current goroutine | Same | Same | | R15 | GOT reference temporary if dynlink | Same | Same | | X15 | Zero value | Same | Scratch | @@ -424,6 +424,13 @@ While this adds one byte to every function prologue, it is hardly ever accessed outside the function prologue and we expect making more single-byte registers available to be a net win. +*Rationale*: We could allow R14 (the current goroutine pointer) to be +a scratch register in function bodies because it can always be +restored from TLS on amd64. +However, we designate it as a fixed register for simplicity and for +consistency with other architectures that may not have a copy of the +current goroutine pointer in TLS. + *Rationale*: We designate X15 as a fixed zero register because functions often have to bulk zero their stack frames, and this is more efficient with a designated zero register. |