LEFT | RIGHT |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 /* | 5 /* |
6 Stack layout parameters. | 6 Stack layout parameters. |
7 Included both by runtime (compiled via 6c) and linkers (compiled via gcc). | 7 Included both by runtime (compiled via 6c) and linkers (compiled via gcc). |
8 | 8 |
9 The per-goroutine g->stackguard is set to point StackGuard bytes | 9 The per-goroutine g->stackguard is set to point StackGuard bytes |
10 above the bottom of the stack. Each function compares its stack | 10 above the bottom of the stack. Each function compares its stack |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 section of the stack. On amd64, morestack's frame is 40 bytes, and | 48 section of the stack. On amd64, morestack's frame is 40 bytes, and |
49 deferproc's frame is 56 bytes. That fits well within the | 49 deferproc's frame is 56 bytes. That fits well within the |
50 StackGuard - StackSmall = 128 bytes at the bottom.·· | 50 StackGuard - StackSmall = 128 bytes at the bottom.·· |
51 The linkers explore all possible call traces involving non-splitting | 51 The linkers explore all possible call traces involving non-splitting |
52 functions to make sure that this limit cannot be violated. | 52 functions to make sure that this limit cannot be violated. |
53 */ | 53 */ |
54 | 54 |
55 enum { | 55 enum { |
56 // StackSystem is a number of additional bytes to add | 56 // StackSystem is a number of additional bytes to add |
57 // to each stack below the usual guard area for OS-specific | 57 // to each stack below the usual guard area for OS-specific |
58 » // purposes like signal handling. Used on Windows because | 58 » // purposes like signal handling. Used on Windows and on |
59 » // it does not use a separate stack. | 59 » // Plan 9 because they do not use a separate stack. |
60 #ifdef GOOS_windows | 60 #ifdef GOOS_windows |
61 StackSystem = 512 * sizeof(uintptr), | 61 StackSystem = 512 * sizeof(uintptr), |
62 #else | 62 #else |
63 #ifdef GOOS_plan9 | 63 #ifdef GOOS_plan9 |
| 64 // The size of the note handler frame varies among architectures, |
| 65 // but 512 bytes should be enough for every implementation. |
64 StackSystem = 512, | 66 StackSystem = 512, |
65 #else | 67 #else |
66 StackSystem = 0, | 68 StackSystem = 0, |
67 #endif // Plan 9 | 69 #endif // Plan 9 |
68 #endif // Windows | 70 #endif // Windows |
69 | 71 |
70 // The amount of extra stack to allocate beyond the size | 72 // The amount of extra stack to allocate beyond the size |
71 // needed for the single frame that triggered the split. | 73 // needed for the single frame that triggered the split. |
72 StackExtra = 1024, | 74 StackExtra = 1024, |
73 | 75 |
(...skipping 23 matching lines...) Expand all Loading... |
97 | 99 |
98 // The maximum number of bytes that a chain of NOSPLIT | 100 // The maximum number of bytes that a chain of NOSPLIT |
99 // functions can use. | 101 // functions can use. |
100 StackLimit = StackGuard - StackSystem - StackSmall, | 102 StackLimit = StackGuard - StackSystem - StackSmall, |
101 ········ | 103 ········ |
102 // The assumed size of the top-of-stack data block. | 104 // The assumed size of the top-of-stack data block. |
103 // The actual size can be smaller than this but cannot be larger. | 105 // The actual size can be smaller than this but cannot be larger. |
104 // Checked in proc.c's runtime.malg. | 106 // Checked in proc.c's runtime.malg. |
105 StackTop = 72, | 107 StackTop = 72, |
106 }; | 108 }; |
LEFT | RIGHT |