runtime: tricky replacements of _g_ in mgc.go

getg() is used primarily for gp.m, so use mp. gp.m.curg is also used,
name that curgp.

Change-Id: I9db2dc4adce2b17d6b41c60d4f2dfbc9aa41fac1
Reviewed-on: https://go-review.googlesource.com/c/go/+/418578
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
Michael Pratt 2022-07-20 12:59:03 -04:00
parent e9d7f54a1a
commit 222799fde6

View file

@ -929,11 +929,10 @@ func gcMarkTermination() {
mp := acquirem() mp := acquirem()
mp.preemptoff = "gcing" mp.preemptoff = "gcing"
_g_ := getg() mp.traceback = 2
_g_.m.traceback = 2 curgp := mp.curg
gp := _g_.m.curg casgstatus(curgp, _Grunning, _Gwaiting)
casgstatus(gp, _Grunning, _Gwaiting) curgp.waitreason = waitReasonGarbageCollection
gp.waitreason = waitReasonGarbageCollection
// Run gc on the g0 stack. We do this so that the g stack // Run gc on the g0 stack. We do this so that the g stack
// we're currently running on will no longer change. Cuts // we're currently running on will no longer change. Cuts
@ -972,8 +971,8 @@ func gcMarkTermination() {
gcSweep(work.mode) gcSweep(work.mode)
}) })
_g_.m.traceback = 0 mp.traceback = 0
casgstatus(gp, _Gwaiting, _Grunning) casgstatus(curgp, _Gwaiting, _Grunning)
if trace.enabled { if trace.enabled {
traceGCDone() traceGCDone()