From: Russ Cox Date: Thu, 19 Feb 2015 21:21:00 +0000 (-0500) Subject: runtime: unroll gc_m loop X-Git-Tag: go1.5beta1~1935 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=929597b9e956b0231140db741dc437feee95a65a;p=gostls13.git runtime: unroll gc_m loop The loop made more sense when gc_m was not its own function. Change-Id: I71a7f21d777e69c1924e3b534c507476daa4dfdd Reviewed-on: https://go-review.googlesource.com/5332 Reviewed-by: Austin Clements --- diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index 079856ed70..4adc0f4fbe 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -362,20 +362,9 @@ func gc(mode int) { // the root set down a bit (g0 stacks are not scanned, and // we don't need to scan gc's internal state). We also // need to switch to g0 so we can shrink the stack. - n := 1 - if debug.gctrace > 1 { - n = 2 - } - for i := 0; i < n; i++ { - if i > 0 { - // refresh start time if doing a second GC - startTime = nanotime() - } - // switch to g0, call gc, then switch back - systemstack(func() { - gc_m(startTime, mode == gcForceBlockMode) - }) - } + systemstack(func() { + gc_m(startTime, mode == gcForceBlockMode) + }) systemstack(func() { // Called from malloc.go using systemstack. @@ -397,6 +386,13 @@ func gc(mode int) { gc_m(startTime, mode == gcForceBlockMode) // turns off checkmarkphase + calls clearcheckmarkbits }) + if debug.gctrace > 1 { + startTime = nanotime() + systemstack(func() { + gc_m(startTime, mode == gcForceBlockMode) + }) + } + if trace.enabled { traceGCDone() traceGoStart()