mirror of
https://github.com/golang/go
synced 2024-11-18 06:04:53 -07:00
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>
This commit is contained in:
parent
325c2aa5b6
commit
c242517866
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user