aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/runtime2.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2015-05-20 16:16:04 -0400
committerAustin Clements <austin@google.com>2015-06-02 19:57:57 +0000
commit3f6e69aca585ceaf82595170e5aea5b25a9d29ec (patch)
tree85922a987e5800d2d6baf9bd5c1f118ec38bca33 /src/runtime/runtime2.go
parente610c25df05246efa807e4724a9b2b0d00847604 (diff)
downloadgo-3f6e69aca585ceaf82595170e5aea5b25a9d29ec.tar.xz
runtime: steal space for stack barrier tracking from stack
The stack barrier code will need a bookkeeping structure to keep track of the overwritten return PCs. This commit introduces and allocates this structure, but does not yet use the structure. We don't want to allocate space for this structure during garbage collection, so this commit allocates it along with the allocation of the corresponding stack. However, we can't do a regular allocation in newstack because mallocgc may itself grow the stack (which would lead to a recursive allocation). Hence, this commit makes the bookkeeping structure part of the stack allocation itself by stealing the necessary space from the top of the stack allocation. Since the size of this bookkeeping structure is logarithmic in the size of the stack, this has minimal impact on stack behavior. Change-Id: Ia14408be06aafa9ca4867f4e70bddb3fe0e96665 Reviewed-on: https://go-review.googlesource.com/10313 Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/runtime2.go')
-rw-r--r--src/runtime/runtime2.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go
index 1954d42a17..8b0e1081da 100644
--- a/src/runtime/runtime2.go
+++ b/src/runtime/runtime2.go
@@ -202,6 +202,12 @@ type stack struct {
hi uintptr
}
+// stkbar records the state of a G's stack barrier.
+type stkbar struct {
+ savedLRPtr uintptr // location overwritten by stack barrier PC
+ savedLRVal uintptr // value overwritten at savedLRPtr
+}
+
type g struct {
// Stack parameters.
// stack describes the actual stack memory: [stack.lo, stack.hi).
@@ -220,6 +226,8 @@ type g struct {
sched gobuf
syscallsp uintptr // if status==Gsyscall, syscallsp = sched.sp to use during gc
syscallpc uintptr // if status==Gsyscall, syscallpc = sched.pc to use during gc
+ stkbar []stkbar // stack barriers, from low to high
+ stkbarPos uintptr // index of lowest stack barrier not hit
param unsafe.Pointer // passed parameter on wakeup
atomicstatus uint32
goid int64