]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/runtime/mgc.go
runtime: refactor runtime->tracer API to appear more like a lock
[gostls13.git] / src / runtime / mgc.go
index 8a4c58888ed4745bb1e6151434160193474a2fba..30d2f1d3852b4430c6ac2039e5a0f3d1dcf43ba3 100644 (file)
@@ -647,8 +647,10 @@ func gcStart(trigger gcTrigger) {
        // Update it under gcsema to avoid gctrace getting wrong values.
        work.userForced = trigger.kind == gcTriggerCycle
 
-       if traceEnabled() {
-               traceGCStart()
+       trace := traceAcquire()
+       if trace.ok() {
+               trace.GCStart()
+               traceRelease(trace)
        }
 
        // Check that all Ps have finished deferred mcache flushes.
@@ -989,8 +991,10 @@ func gcMarkTermination() {
        mp.traceback = 0
        casgstatus(curgp, _Gwaiting, _Grunning)
 
-       if traceEnabled() {
-               traceGCDone()
+       trace := traceAcquire()
+       if trace.ok() {
+               trace.GCDone()
+               traceRelease(trace)
        }
 
        // all done