diff options
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/preempt.go | 2 | ||||
| -rw-r--r-- | src/runtime/stack.go | 19 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/runtime/preempt.go b/src/runtime/preempt.go index a6623c0ec2..e19e6d3d7a 100644 --- a/src/runtime/preempt.go +++ b/src/runtime/preempt.go @@ -320,7 +320,7 @@ func init() { total += funcMaxSPDelta(f) // Add some overhead for return PCs, etc. asyncPreemptStack = uintptr(total) + 8*goarch.PtrSize - if asyncPreemptStack > _StackLimit { + if asyncPreemptStack > stackNosplit { // We need more than the nosplit limit. This isn't // unsafe, but it may limit asynchronous preemption. // diff --git a/src/runtime/stack.go b/src/runtime/stack.go index 39dbed5114..708a6ee2e5 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -85,19 +85,18 @@ const ( _FixedStack6 = _FixedStack5 | (_FixedStack5 >> 16) _FixedStack = _FixedStack6 + 1 + // stackNosplit is the maximum number of bytes that a chain of NOSPLIT + // functions can use. + // This arithmetic must match that in cmd/internal/objabi/stack.go:StackNosplit. + stackNosplit = abi.StackNosplitBase * sys.StackGuardMultiplier + // The stack guard is a pointer this many bytes above the // bottom of the stack. // - // The guard leaves enough room for one _StackSmall frame plus - // a _StackLimit chain of NOSPLIT calls plus _StackSystem - // bytes for the OS. - // This arithmetic must match that in cmd/internal/objabi/stack.go:StackLimit. - _StackGuard = 928*sys.StackGuardMultiplier + _StackSystem - - // The maximum number of bytes that a chain of NOSPLIT - // functions can use. + // The guard leaves enough room for a stackNosplit chain of NOSPLIT calls + // plus one stackSmall frame plus stackSystem bytes for the OS. // This arithmetic must match that in cmd/internal/objabi/stack.go:StackLimit. - _StackLimit = _StackGuard - _StackSystem - abi.StackSmall + _StackGuard = stackNosplit + _StackSystem + abi.StackSmall ) const ( @@ -1211,7 +1210,7 @@ func shrinkstack(gp *g) { // down to the SP plus the stack guard space that ensures // there's room for nosplit functions. avail := gp.stack.hi - gp.stack.lo - if used := gp.stack.hi - gp.sched.sp + _StackLimit; used >= avail/4 { + if used := gp.stack.hi - gp.sched.sp + stackNosplit; used >= avail/4 { return } |
