]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/runtime/mheap.go
runtime: refactor runtime->tracer API to appear more like a lock
[gostls13.git] / src / runtime / mheap.go
index ab8f5e34e2c3772460ecd2f4b6e6a27eb81b5f16..0bbda4aa3b4a3530057598de4da9c48bc91fa8e2 100644 (file)
@@ -791,8 +791,10 @@ func (h *mheap) reclaim(npage uintptr) {
        // traceGCSweepStart/Done pair on the P.
        mp := acquirem()
 
-       if traceEnabled() {
-               traceGCSweepStart()
+       trace := traceAcquire()
+       if trace.ok() {
+               trace.GCSweepStart()
+               traceRelease(trace)
        }
 
        arenas := h.sweepArenas
@@ -839,8 +841,10 @@ func (h *mheap) reclaim(npage uintptr) {
                unlock(&h.lock)
        }
 
-       if traceEnabled() {
-               traceGCSweepDone()
+       trace = traceAcquire()
+       if trace.ok() {
+               trace.GCSweepDone()
+               traceRelease(trace)
        }
        releasem(mp)
 }
@@ -911,10 +915,12 @@ func (h *mheap) reclaimChunk(arenas []arenaIdx, pageIdx, n uintptr) uintptr {
                n -= uintptr(len(inUse) * 8)
        }
        sweep.active.end(sl)
-       if traceEnabled() {
+       trace := traceAcquire()
+       if trace.ok() {
                unlock(&h.lock)
                // Account for pages scanned but not reclaimed.
-               traceGCSweepSpan((n0 - nFreed) * pageSize)
+               trace.GCSweepSpan((n0 - nFreed) * pageSize)
+               traceRelease(trace)
                lock(&h.lock)
        }