mirror of
https://github.com/golang/go
synced 2024-11-11 22:20:22 -07:00
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>
This commit is contained in:
parent
2698be4905
commit
0ad46889a1
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user