From fbd2660af3042217a4c831e9d4e24a4e97c296cb Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Thu, 24 Sep 2015 14:30:09 -0400 Subject: [PATCH] runtime: introduce gcMode type for GC modes Currently, the GC modes constants are untyped and functions pass them around as ints. Clean this up by introducing a proper type for these constant. Change-Id: Ibc022447bdfa203644921fbb548312d7e2272e8d Reviewed-on: https://go-review.googlesource.com/14981 Reviewed-by: Brad Fitzpatrick Run-TryBot: Austin Clements TryBot-Result: Gobot Gobot --- src/runtime/mgc.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index 848e8f6992..a3960852a1 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -803,10 +803,13 @@ func GC() { startGC(gcForceBlockMode, false) } +// gcMode indicates how concurrent a GC cycle should be. +type gcMode int + const ( - gcBackgroundMode = iota // concurrent GC - gcForceMode // stop-the-world GC now - gcForceBlockMode // stop-the-world GC now and wait for sweep + gcBackgroundMode gcMode = iota // concurrent GC and sweep + gcForceMode // stop-the-world GC now, concurrent sweep + gcForceBlockMode // stop-the-world GC now and STW sweep ) // startGC starts a GC cycle. If mode is gcBackgroundMode, this will @@ -814,7 +817,7 @@ const ( // until the new GC cycle is started and finishes. If forceTrigger is // true, it indicates that GC should be started regardless of the // current heap size. -func startGC(mode int, forceTrigger bool) { +func startGC(mode gcMode, forceTrigger bool) { // The gc is turned off (via enablegc) until the bootstrap has completed. // Also, malloc gets called in the guts of a number of libraries that might be // holding locks. To avoid deadlocks during stop-the-world, don't bother @@ -889,7 +892,7 @@ func backgroundgc() { } } -func gc(mode int) { +func gc(mode gcMode) { // Timing/utilization tracking var stwprocs, maxprocs int32 var tSweepTerm, tScan, tInstallWB, tMark, tMarkTerm int64 @@ -1513,7 +1516,7 @@ func gcMark(start_time int64) { } } -func gcSweep(mode int) { +func gcSweep(mode gcMode) { if gcphase != _GCoff { throw("gcSweep being done but phase is not GCoff") } -- 2.48.1