aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/runtime2.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2016-10-19 15:49:31 -0400
committerAustin Clements <austin@google.com>2016-10-28 20:48:02 +0000
commit70c107c68dca7d57a24b35dd81420fb889aa1031 (patch)
tree3f913f89ecd72a10cda5ccd22fefdb6ab6808a93 /src/runtime/runtime2.go
parent8f81dfe8b47e975b90bb4a2f8dd314d32c633176 (diff)
downloadgo-70c107c68dca7d57a24b35dd81420fb889aa1031.tar.xz
runtime: add deletion barriers on gobuf.ctxt
gobuf.ctxt is set to nil from many places in assembly code and these assignments require write barriers with the hybrid barrier. Conveniently, in most of these places ctxt should already be nil, in which case we don't need the barrier. This commit changes these places to assert that ctxt is already nil. gogo is more complicated, since ctxt may not already be nil. For gogo, we manually perform the write barrier if ctxt is not nil. Updates #17503. Change-Id: I9d75e27c75a1b7f8b715ad112fc5d45ffa856d30 Reviewed-on: https://go-review.googlesource.com/31764 Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/runtime/runtime2.go')
-rw-r--r--src/runtime/runtime2.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go
index 49f6e6f649..696ea81e00 100644
--- a/src/runtime/runtime2.go
+++ b/src/runtime/runtime2.go
@@ -239,6 +239,15 @@ func setMNoWB(mp **m, new *m) {
type gobuf struct {
// The offsets of sp, pc, and g are known to (hard-coded in) libmach.
+ //
+ // ctxt is unusual with respect to GC: it may be a
+ // heap-allocated funcval so write require a write barrier,
+ // but gobuf needs to be cleared from assembly. We take
+ // advantage of the fact that the only path that uses a
+ // non-nil ctxt is morestack. As a result, gogo is the only
+ // place where it may not already be nil, so gogo uses an
+ // explicit write barrier. Everywhere else that resets the
+ // gobuf asserts that ctxt is already nil.
sp uintptr
pc uintptr
g guintptr