Skip to content

Commit 918ed88

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Rick Hudson <[email protected]>
1 parent e25ef35 commit 918ed88

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

src/runtime/malloc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
992992

993993
if shouldhelpgc {
994994
if t := (gcTrigger{kind: gcTriggerHeap}); t.test() {
995-
gcStart(gcBackgroundMode, t)
995+
gcStart(t)
996996
}
997997
}
998998

src/runtime/mgc.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ func GC() {
10631063
// We're now in sweep N or later. Trigger GC cycle N+1, which
10641064
// will first finish sweep N if necessary and then enter sweep
10651065
// termination N+1.
1066-
gcStart(gcBackgroundMode, gcTrigger{kind: gcTriggerCycle, n: n + 1})
1066+
gcStart(gcTrigger{kind: gcTriggerCycle, n: n + 1})
10671067

10681068
// Wait for mark termination N+1 to complete.
10691069
gcWaitOnMark(n + 1)
@@ -1201,13 +1201,13 @@ func (t gcTrigger) test() bool {
12011201
return true
12021202
}
12031203

1204-
// gcStart transitions the GC from _GCoff to _GCmark (if
1205-
// !mode.stwMark) or _GCmarktermination (if mode.stwMark) by
1206-
// performing sweep termination and GC initialization.
1204+
// gcStart starts the GC. It transitions from _GCoff to _GCmark (if
1205+
// debug.gcstoptheworld == 0) or performs all of GC (if
1206+
// debug.gcstoptheworld != 0).
12071207
//
12081208
// This may return without performing this transition in some cases,
12091209
// such as when called on a system stack or with locks held.
1210-
func gcStart(mode gcMode, trigger gcTrigger) {
1210+
func gcStart(trigger gcTrigger) {
12111211
// Since this is called from malloc and malloc is called in
12121212
// the guts of a number of libraries that might be holding
12131213
// locks, don't attempt to start GC in non-preemptible or
@@ -1250,12 +1250,11 @@ func gcStart(mode gcMode, trigger gcTrigger) {
12501250
// We do this after re-checking the transition condition so
12511251
// that multiple goroutines that detect the heap trigger don't
12521252
// start multiple STW GCs.
1253-
if mode == gcBackgroundMode {
1254-
if debug.gcstoptheworld == 1 {
1255-
mode = gcForceMode
1256-
} else if debug.gcstoptheworld == 2 {
1257-
mode = gcForceBlockMode
1258-
}
1253+
mode := gcBackgroundMode
1254+
if debug.gcstoptheworld == 1 {
1255+
mode = gcForceMode
1256+
} else if debug.gcstoptheworld == 2 {
1257+
mode = gcForceBlockMode
12591258
}
12601259

12611260
// Ok, we're doing it! Stop everybody else

src/runtime/proc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ func forcegchelper() {
254254
println("GC forced")
255255
}
256256
// Time-triggered, fully concurrent.
257-
gcStart(gcBackgroundMode, gcTrigger{kind: gcTriggerTime, now: nanotime()})
257+
gcStart(gcTrigger{kind: gcTriggerTime, now: nanotime()})
258258
}
259259
}
260260

0 commit comments

Comments
 (0)