// complete the cycle and because runtime.GC() is often used
// as part of tests and benchmarks to get the system into a
// relatively stable and isolated state.
- for atomic.Load(&work.cycles) == n+1 && gosweepone() != ^uintptr(0) {
+ for atomic.Load(&work.cycles) == n+1 && sweepone() != ^uintptr(0) {
sweep.nbgsweep++
Gosched()
}
//
// We check the transition condition continuously here in case
// this G gets delayed in to the next GC cycle.
- for trigger.test() && gosweepone() != ^uintptr(0) {
+ for trigger.test() && sweepone() != ^uintptr(0) {
sweep.nbgsweep++
}
goparkunlock(&sweep.lock, waitReasonGCSweepWait, traceEvGoBlock, 1)
for {
- for gosweepone() != ^uintptr(0) {
+ for sweepone() != ^uintptr(0) {
sweep.nbgsweep++
Gosched()
}
}
}
-// sweeps one span
-// returns number of pages returned to heap, or ^uintptr(0) if there is nothing to sweep
-//go:nowritebarrier
+// sweepone sweeps one span and returns the number of pages returned
+// to the heap, or ^uintptr(0) if there was nothing to sweep.
func sweepone() uintptr {
_g_ := getg()
sweepRatio := mheap_.sweepPagesPerByte // For debugging
return npages
}
-//go:nowritebarrier
-func gosweepone() uintptr {
- var ret uintptr
- systemstack(func() {
- ret = sweepone()
- })
- return ret
-}
-
//go:nowritebarrier
func gosweepdone() bool {
return mheap_.sweepdone != 0
newHeapLive := uintptr(atomic.Load64(&memstats.heap_live)-mheap_.sweepHeapLiveBasis) + spanBytes
pagesTarget := int64(mheap_.sweepPagesPerByte*float64(newHeapLive)) - int64(callerSweepPages)
for pagesTarget > int64(atomic.Load64(&mheap_.pagesSwept)-sweptBasis) {
- if gosweepone() == ^uintptr(0) {
+ if sweepone() == ^uintptr(0) {
mheap_.sweepPagesPerByte = 0
break
}