mirror of
https://github.com/golang/go.git
synced 2025-05-25 09:21:21 +00:00
runtime: remove gcStart's mode argument
This argument is always gcBackgroundMode since only debug.gcstoptheworld can trigger a STW GC at this point. Remove the unnecessary argument. Updates #26903. This is preparation for unifying STW GC and concurrent GC. Change-Id: Icb4ba8f10f80c2b69cf51a21e04fa2c761b71c94 Reviewed-on: https://go-review.googlesource.com/c/134775 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rick Hudson <rlh@golang.org>
This commit is contained in:
parent
e25ef35254
commit
918ed88e47
@ -992,7 +992,7 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
|
|||||||
|
|
||||||
if shouldhelpgc {
|
if shouldhelpgc {
|
||||||
if t := (gcTrigger{kind: gcTriggerHeap}); t.test() {
|
if t := (gcTrigger{kind: gcTriggerHeap}); t.test() {
|
||||||
gcStart(gcBackgroundMode, t)
|
gcStart(t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1063,7 +1063,7 @@ func GC() {
|
|||||||
// We're now in sweep N or later. Trigger GC cycle N+1, which
|
// We're now in sweep N or later. Trigger GC cycle N+1, which
|
||||||
// will first finish sweep N if necessary and then enter sweep
|
// will first finish sweep N if necessary and then enter sweep
|
||||||
// termination N+1.
|
// termination N+1.
|
||||||
gcStart(gcBackgroundMode, gcTrigger{kind: gcTriggerCycle, n: n + 1})
|
gcStart(gcTrigger{kind: gcTriggerCycle, n: n + 1})
|
||||||
|
|
||||||
// Wait for mark termination N+1 to complete.
|
// Wait for mark termination N+1 to complete.
|
||||||
gcWaitOnMark(n + 1)
|
gcWaitOnMark(n + 1)
|
||||||
@ -1201,13 +1201,13 @@ func (t gcTrigger) test() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// gcStart transitions the GC from _GCoff to _GCmark (if
|
// gcStart starts the GC. It transitions from _GCoff to _GCmark (if
|
||||||
// !mode.stwMark) or _GCmarktermination (if mode.stwMark) by
|
// debug.gcstoptheworld == 0) or performs all of GC (if
|
||||||
// performing sweep termination and GC initialization.
|
// debug.gcstoptheworld != 0).
|
||||||
//
|
//
|
||||||
// This may return without performing this transition in some cases,
|
// This may return without performing this transition in some cases,
|
||||||
// such as when called on a system stack or with locks held.
|
// such as when called on a system stack or with locks held.
|
||||||
func gcStart(mode gcMode, trigger gcTrigger) {
|
func gcStart(trigger gcTrigger) {
|
||||||
// Since this is called from malloc and malloc is called in
|
// Since this is called from malloc and malloc is called in
|
||||||
// the guts of a number of libraries that might be holding
|
// the guts of a number of libraries that might be holding
|
||||||
// locks, don't attempt to start GC in non-preemptible or
|
// locks, don't attempt to start GC in non-preemptible or
|
||||||
@ -1250,13 +1250,12 @@ func gcStart(mode gcMode, trigger gcTrigger) {
|
|||||||
// We do this after re-checking the transition condition so
|
// We do this after re-checking the transition condition so
|
||||||
// that multiple goroutines that detect the heap trigger don't
|
// that multiple goroutines that detect the heap trigger don't
|
||||||
// start multiple STW GCs.
|
// start multiple STW GCs.
|
||||||
if mode == gcBackgroundMode {
|
mode := gcBackgroundMode
|
||||||
if debug.gcstoptheworld == 1 {
|
if debug.gcstoptheworld == 1 {
|
||||||
mode = gcForceMode
|
mode = gcForceMode
|
||||||
} else if debug.gcstoptheworld == 2 {
|
} else if debug.gcstoptheworld == 2 {
|
||||||
mode = gcForceBlockMode
|
mode = gcForceBlockMode
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Ok, we're doing it! Stop everybody else
|
// Ok, we're doing it! Stop everybody else
|
||||||
semacquire(&worldsema)
|
semacquire(&worldsema)
|
||||||
|
@ -254,7 +254,7 @@ func forcegchelper() {
|
|||||||
println("GC forced")
|
println("GC forced")
|
||||||
}
|
}
|
||||||
// Time-triggered, fully concurrent.
|
// Time-triggered, fully concurrent.
|
||||||
gcStart(gcBackgroundMode, gcTrigger{kind: gcTriggerTime, now: nanotime()})
|
gcStart(gcTrigger{kind: gcTriggerTime, now: nanotime()})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user