github.com/bir3/gocompiler@v0.9.2202/src/cmd/internal/objabi/stack.go (about)

     1  // Copyright 2011 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package objabi
     6  
     7  import (
     8  	"github.com/bir3/gocompiler/src/internal/abi"
     9  	"github.com/bir3/gocompiler/src/internal/buildcfg"
    10  )
    11  
    12  func StackNosplit(race bool) int {
    13  	// This arithmetic must match that in runtime/stack.go:stackNosplit.
    14  	return abi.StackNosplitBase * stackGuardMultiplier(race)
    15  }
    16  
    17  // stackGuardMultiplier returns a multiplier to apply to the default
    18  // stack guard size. Larger multipliers are used for non-optimized
    19  // builds that have larger stack frames or for specific targets.
    20  func stackGuardMultiplier(race bool) int {
    21  	// This arithmetic must match that in runtime/internal/sys/consts.go:StackGuardMultiplier.
    22  	n := 1
    23  	// On AIX, a larger stack is needed for syscalls.
    24  	if buildcfg.GOOS == "aix" {
    25  		n += 1
    26  	}
    27  	// The race build also needs more stack.
    28  	if race {
    29  		n += 1
    30  	}
    31  	return n
    32  }