From: Austin Clements Date: Wed, 19 Oct 2016 20:01:02 +0000 (-0400) Subject: runtime: replace *g with guintptr in trace X-Git-Tag: go1.8beta1~729 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c2425178669c0c6a26f58f90b59086d7e4313c64;p=gostls13.git 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 Reviewed-by: Rick Hudson --- 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 }