diff options
| author | Shenghou Ma <minux.ma@gmail.com> | 2014-03-07 15:11:16 -0500 |
|---|---|---|
| committer | Shenghou Ma <minux.ma@gmail.com> | 2014-03-07 15:11:16 -0500 |
| commit | 84570aa9a18fa46dba1402004a54cedc7cf5e043 (patch) | |
| tree | f1cae531ab508b4f3ff452d9bba885eb1fdb0d98 /src/pkg/runtime/stack.h | |
| parent | 3d5e219e020115e98762821ac688e77b1b50787d (diff) | |
| download | go-84570aa9a18fa46dba1402004a54cedc7cf5e043.tar.xz | |
runtime: round stack size to power of 2.
Fixes build on windows/386 and plan9/386.
Fixes #7487.
LGTM=mattn.jp, dvyukov, rsc
R=golang-codereviews, mattn.jp, dvyukov, 0intro, rsc
CC=golang-codereviews
https://golang.org/cl/72360043
Diffstat (limited to 'src/pkg/runtime/stack.h')
| -rw-r--r-- | src/pkg/runtime/stack.h | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/pkg/runtime/stack.h b/src/pkg/runtime/stack.h index f2e4e43198..a3a5d83a64 100644 --- a/src/pkg/runtime/stack.h +++ b/src/pkg/runtime/stack.h @@ -57,15 +57,13 @@ enum { // to each stack below the usual guard area for OS-specific // purposes like signal handling. Used on Windows and on // Plan 9 because they do not use a separate stack. - // The new stack code requires stacks to be a power of two, - // and the default start size is 4k, so make StackSystem also 4k - // to keep the sum a power of two. StackSystem used to be - // 512*sizeof(uintptr) on Windows and 512 bytes on Plan 9. #ifdef GOOS_windows - StackSystem = 4096, + StackSystem = 512 * sizeof(uintptr), #else #ifdef GOOS_plan9 - StackSystem = 4096, + // The size of the note handler frame varies among architectures, + // but 512 bytes should be enough for every implementation. + StackSystem = 512, #else StackSystem = 0, #endif // Plan 9 @@ -79,7 +77,8 @@ enum { // If the amount needed for the splitting frame + StackExtra // is less than this number, the stack will have this size instead. StackMin = 4096, - FixedStack = StackMin + StackSystem, + StackSystemRounded = StackSystem + (-StackSystem & (StackMin-1)), + FixedStack = StackMin + StackSystemRounded, // Functions that need frames bigger than this use an extra // instruction to do the stack split check, to avoid overflow |
