aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/proc.go
diff options
context:
space:
mode:
authorJoel Sing <joel@sing.id.au>2020-08-24 18:04:13 +1000
committerJoel Sing <joel@sing.id.au>2021-01-19 12:07:43 +0000
commit9fed39d2814073a9389a614342f603bab9963bff (patch)
tree0f7d8784ae2cf66e3ca98b8b7aae1b34026c14b3 /src/runtime/proc.go
parentdbab07983596c705d2ef12806e0f9d630063e571 (diff)
downloadgo-9fed39d2814073a9389a614342f603bab9963bff.tar.gz
go-9fed39d2814073a9389a614342f603bab9963bff.zip
runtime: factor out mStackIsSystemAllocated
Rather than repeat long lists of GOOS values, factor out the code that checks if a runtime starts on a system allocated stack. Note that this adds aix to one case, which appears to have been previously missed. Change-Id: I5cecb0bb47dd79cde8d723e5a42ba541e43cbfff Reviewed-on: https://go-review.googlesource.com/c/go/+/250179 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Zhang <cherryyz@google.com> Run-TryBot: Joel Sing <joel@sing.id.au> TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/runtime/proc.go')
-rw-r--r--src/runtime/proc.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
index b776f88936..477152d899 100644
--- a/src/runtime/proc.go
+++ b/src/runtime/proc.go
@@ -1206,6 +1206,16 @@ func startTheWorldWithSema(emitTraceEvent bool) int64 {
return startTime
}
+// mStackIsSystemAllocated indicates whether this runtime starts on a
+// system-allocated stack.
+func mStackIsSystemAllocated() bool {
+ switch GOOS {
+ case "aix", "darwin", "plan9", "illumos", "ios", "solaris", "windows":
+ return true
+ }
+ return false
+}
+
// mstart is the entry-point for new Ms.
//
// This must not split the stack because we may not even have stack
@@ -1240,8 +1250,7 @@ func mstart() {
mstart1()
// Exit this thread.
- switch GOOS {
- case "windows", "solaris", "illumos", "plan9", "darwin", "ios", "aix":
+ if mStackIsSystemAllocated() {
// Windows, Solaris, illumos, Darwin, AIX and Plan 9 always system-allocate
// the stack, but put it in _g_.stack before mstart,
// so the logic above hasn't set osStack yet.
@@ -1724,7 +1733,7 @@ func allocm(_p_ *p, fn func(), id int64) *m {
// In case of cgo or Solaris or illumos or Darwin, pthread_create will make us a stack.
// Windows and Plan 9 will layout sched stack on OS stack.
- if iscgo || GOOS == "solaris" || GOOS == "illumos" || GOOS == "windows" || GOOS == "plan9" || GOOS == "darwin" || GOOS == "ios" {
+ if iscgo || mStackIsSystemAllocated() {
mp.g0 = malg(-1)
} else {
mp.g0 = malg(8192 * sys.StackGuardMultiplier)