aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2016-10-19 16:01:02 -0400
committerAustin Clements <austin@google.com>2016-10-21 16:00:20 +0000
commitc2425178669c0c6a26f58f90b59086d7e4313c64 (patch)
tree52582c56c65c6cfbc4f61d71e52e42a433e78cb2 /src/runtime
parent325c2aa5b6f12ccc82e8472beec0e1511e975bd4 (diff)
downloadgo-c2425178669c0c6a26f58f90b59086d7e4313c64.tar.xz
runtime: replace *g with guintptr in trace
trace's reader *g is going to cause write barriers in unfortunate places, so replace it with a guintptr. Change-Id: Ie8fb13bb89a78238f9d2a77ec77da703e96df8af Reviewed-on: https://go-review.googlesource.com/31469 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Rick Hudson <rlh@golang.org>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/trace.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/runtime/trace.go b/src/runtime/trace.go
index 4c0f1de44b..1eff814506 100644
--- a/src/runtime/trace.go
+++ b/src/runtime/trace.go
@@ -112,7 +112,7 @@ var trace struct {
empty traceBufPtr // stack of empty buffers
fullHead traceBufPtr // queue of full buffers
fullTail traceBufPtr
- reader *g // goroutine that called ReadTrace, or nil
+ reader guintptr // goroutine that called ReadTrace, or nil
stackTab traceStackTable // maps stack traces to unique ids
// Dictionary for traceEvString.
@@ -313,7 +313,7 @@ func StopTrace() {
if trace.fullHead != 0 || trace.fullTail != 0 {
throw("trace: non-empty full trace buffer")
}
- if trace.reading != 0 || trace.reader != nil {
+ if trace.reading != 0 || trace.reader != 0 {
throw("trace: reading after shutdown")
}
for trace.empty != 0 {
@@ -341,7 +341,7 @@ func ReadTrace() []byte {
lock(&trace.lock)
trace.lockOwner = getg()
- if trace.reader != nil {
+ if trace.reader != 0 {
// More than one goroutine reads trace. This is bad.
// But we rather do not crash the program because of tracing,
// because tracing can be enabled at runtime on prod servers.
@@ -365,7 +365,7 @@ func ReadTrace() []byte {
}
// Wait for new data.
if trace.fullHead == 0 && !trace.shutdown {
- trace.reader = getg()
+ trace.reader.set(getg())
goparkunlock(&trace.lock, "trace reader (blocked)", traceEvGoBlock, 2)
lock(&trace.lock)
}
@@ -419,16 +419,16 @@ func ReadTrace() []byte {
// traceReader returns the trace reader that should be woken up, if any.
func traceReader() *g {
- if trace.reader == nil || (trace.fullHead == 0 && !trace.shutdown) {
+ if trace.reader == 0 || (trace.fullHead == 0 && !trace.shutdown) {
return nil
}
lock(&trace.lock)
- if trace.reader == nil || (trace.fullHead == 0 && !trace.shutdown) {
+ if trace.reader == 0 || (trace.fullHead == 0 && !trace.shutdown) {
unlock(&trace.lock)
return nil
}
- gp := trace.reader
- trace.reader = nil
+ gp := trace.reader.ptr()
+ trace.reader.set(nil)
unlock(&trace.lock)
return gp
}