aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/objabi/stack.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2023-04-19 14:01:05 -0400
committerAustin Clements <austin@google.com>2023-04-20 16:05:21 +0000
commit921699fe5f67a2e5246badc8f626cc70a615ad1c (patch)
tree16cec2ce81c3263a8ee09490f850dce56db71244 /src/cmd/internal/objabi/stack.go
parentf5f7755da878934c3b0799f511f5c1d5711a0296 (diff)
downloadgo-921699fe5f67a2e5246badc8f626cc70a615ad1c.tar.xz
runtime, cmd: rationalize StackLimit and StackGuard
The current definitions of StackLimit and StackGuard only indirectly specify the NOSPLIT stack limit and duplicate a literal constant (928). Currently, they define the stack guard delta, and from there compute the NOSPLIT limit. Rationalize these by defining a new constant, abi.StackNosplitBase, which consolidates and directly specifies the NOSPLIT stack limit (in the default case). From this we then compute the stack guard delta, inverting the relationship between these two constants. While we're here, we rename StackLimit to StackNosplit to make it clearer what's being limited. This change does not affect the values of these constants in the default configuration. It does slightly change how StackGuardMultiplier values other than 1 affect the constants, but this multiplier is a pretty rough heuristic anyway. before after stackNosplit 800 800 _StackGuard 928 928 stackNosplit -race 1728 1600 _StackGuard -race 1856 1728 For #59670. Change-Id: Ibe20825ebe0076bbd7b0b7501177b16c9dbcb79e Reviewed-on: https://go-review.googlesource.com/c/go/+/486380 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/cmd/internal/objabi/stack.go')
-rw-r--r--src/cmd/internal/objabi/stack.go15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/cmd/internal/objabi/stack.go b/src/cmd/internal/objabi/stack.go
index 5a2f641a75..7c7ff4e058 100644
--- a/src/cmd/internal/objabi/stack.go
+++ b/src/cmd/internal/objabi/stack.go
@@ -9,18 +9,9 @@ import (
"internal/buildcfg"
)
-// For the linkers. Must match Go definitions.
-
-const (
- STACKSYSTEM = 0
- StackSystem = STACKSYSTEM
-)
-
-func StackLimit(race bool) int {
- // This arithmetic must match that in runtime/stack.go:{_StackGuard,_StackLimit}.
- stackGuard := 928*stackGuardMultiplier(race) + StackSystem
- stackLimit := stackGuard - StackSystem - abi.StackSmall
- return stackLimit
+func StackNosplit(race bool) int {
+ // This arithmetic must match that in runtime/stack.go:stackNosplit.
+ return abi.StackNosplitBase * stackGuardMultiplier(race)
}
// stackGuardMultiplier returns a multiplier to apply to the default