]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/runtime/debugcall.go
runtime: refactor runtime->tracer API to appear more like a lock
[gostls13.git] / src / runtime / debugcall.go
index 98ab413ff49cc84b008cd02241248a122d29a6f0..5dd83063ff9cb8bb88f6e34d42ab162c9f106812 100644 (file)
@@ -166,10 +166,12 @@ func debugCallWrap(dispatch uintptr) {
                gp.schedlink = 0
 
                // Park the calling goroutine.
-               if traceEnabled() {
-                       traceGoPark(traceBlockDebugCall, 1)
-               }
+               trace := traceAcquire()
                casGToWaiting(gp, _Grunning, waitReasonDebugCall)
+               if trace.ok() {
+                       trace.GoPark(traceBlockDebugCall, 1)
+                       traceRelease(trace)
+               }
                dropg()
 
                // Directly execute the new goroutine. The debug
@@ -225,19 +227,23 @@ func debugCallWrap1() {
                // Switch back to the calling goroutine. At some point
                // the scheduler will schedule us again and we'll
                // finish exiting.
-               if traceEnabled() {
-                       traceGoSched()
-               }
+               trace := traceAcquire()
                casgstatus(gp, _Grunning, _Grunnable)
+               if trace.ok() {
+                       trace.GoSched()
+                       traceRelease(trace)
+               }
                dropg()
                lock(&sched.lock)
                globrunqput(gp)
                unlock(&sched.lock)
 
-               if traceEnabled() {
-                       traceGoUnpark(callingG, 0)
-               }
+               trace = traceAcquire()
                casgstatus(callingG, _Gwaiting, _Grunnable)
+               if trace.ok() {
+                       trace.GoUnpark(callingG, 0)
+                       traceRelease(trace)
+               }
                execute(callingG, true)
        })
 }