mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
Revert "runtime: get a better g0 stack bound in needm"
This reverts CL 479915. Reason for revert: breaks a lot google internal tests. Change-Id: I13a9422e810af7ba58cbf4a7e6e55f4d8cc0ca51 Reviewed-on: https://go-review.googlesource.com/c/go/+/481055 Reviewed-by: Chressie Himpel <chressie@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
092d43c329
commit
63ef9059a2
10 changed files with 7 additions and 182 deletions
|
|
@ -1889,11 +1889,8 @@ func allocm(pp *p, fn func(), id int64) *m {
|
|||
// 1. when the callback is done with the m in non-pthread platforms,
|
||||
// 2. or when the C thread exiting on pthread platforms.
|
||||
//
|
||||
// The signal argument indicates whether we're called from a signal
|
||||
// handler.
|
||||
//
|
||||
//go:nosplit
|
||||
func needm(signal bool) {
|
||||
func needm() {
|
||||
if (iscgo || GOOS == "windows") && !cgoHasExtraM {
|
||||
// Can happen if C/C++ code calls Go from a global ctor.
|
||||
// Can also happen on Windows if a global ctor uses a
|
||||
|
|
@ -1942,23 +1939,14 @@ func needm(signal bool) {
|
|||
osSetupTLS(mp)
|
||||
|
||||
// Install g (= m->g0) and set the stack bounds
|
||||
// to match the current stack. If we don't actually know
|
||||
// to match the current stack. We don't actually know
|
||||
// how big the stack is, like we don't know how big any
|
||||
// scheduling stack is, but we assume there's at least 32 kB.
|
||||
// If we can get a more accurate stack bound from pthread,
|
||||
// use that.
|
||||
// scheduling stack is, but we assume there's at least 32 kB,
|
||||
// which is more than enough for us.
|
||||
setg(mp.g0)
|
||||
gp := getg()
|
||||
gp.stack.hi = getcallersp() + 1024
|
||||
gp.stack.lo = getcallersp() - 32*1024
|
||||
if !signal && _cgo_getstackbound != nil {
|
||||
// Don't adjust if called from the signal handler.
|
||||
// We are on the signal stack, not the pthread stack.
|
||||
// (We could get the stack bounds from sigaltstack, but
|
||||
// we're getting out of the signal handler very soon
|
||||
// anyway. Not worth it.)
|
||||
asmcgocall(_cgo_getstackbound, unsafe.Pointer(gp))
|
||||
}
|
||||
gp.stackguard0 = gp.stack.lo + _StackGuard
|
||||
|
||||
// Should mark we are already in Go now.
|
||||
|
|
@ -1979,7 +1967,7 @@ func needm(signal bool) {
|
|||
//
|
||||
//go:nosplit
|
||||
func needAndBindM() {
|
||||
needm(false)
|
||||
needm()
|
||||
|
||||
if _cgo_pthread_key_created != nil && *(*uintptr)(_cgo_pthread_key_created) != 0 {
|
||||
cgoBindM()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue