Skip to content

Commit 29b9a32

Browse files
committed
runtime: trivial replacements of g in remaining files
Rename g variables to gp for consistency. Change-Id: I09ecdc7e8439637bc0e32f9c5f96f515e6436362 Reviewed-on: https://go-review.googlesource.com/c/go/+/418591 Reviewed-by: Austin Clements <[email protected]> Run-TryBot: Michael Pratt <[email protected]>
1 parent c647264 commit 29b9a32

9 files changed

+40
-40
lines changed

src/runtime/cgocheck.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ func cgoCheckWriteBarrier(dst *uintptr, src uintptr) {
3232

3333
// If we are running on the system stack then dst might be an
3434
// address on the stack, which is OK.
35-
g := getg()
36-
if g == g.m.g0 || g == g.m.gsignal {
35+
gp := getg()
36+
if gp == gp.m.g0 || gp == gp.m.gsignal {
3737
return
3838
}
3939

4040
// Allocating memory can write to various mfixalloc structs
4141
// that look like they are non-Go memory.
42-
if g.m.mallocing != 0 {
42+
if gp.m.mallocing != 0 {
4343
return
4444
}
4545

src/runtime/debug.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ func debug_modinfo() string {
8585
//go:linkname mayMoreStackPreempt
8686
func mayMoreStackPreempt() {
8787
// Don't do anything on the g0 or gsignal stack.
88-
g := getg()
89-
if g == g.m.g0 || g == g.m.gsignal {
88+
gp := getg()
89+
if gp == gp.m.g0 || gp == gp.m.gsignal {
9090
return
9191
}
9292
// Force a preemption, unless the stack is already poisoned.
93-
if g.stackguard0 < stackPoisonMin {
94-
g.stackguard0 = stackPreempt
93+
if gp.stackguard0 < stackPoisonMin {
94+
gp.stackguard0 = stackPreempt
9595
}
9696
}
9797

@@ -104,12 +104,12 @@ func mayMoreStackPreempt() {
104104
//go:linkname mayMoreStackMove
105105
func mayMoreStackMove() {
106106
// Don't do anything on the g0 or gsignal stack.
107-
g := getg()
108-
if g == g.m.g0 || g == g.m.gsignal {
107+
gp := getg()
108+
if gp == gp.m.g0 || gp == gp.m.gsignal {
109109
return
110110
}
111111
// Force stack movement, unless the stack is already poisoned.
112-
if g.stackguard0 < stackPoisonMin {
113-
g.stackguard0 = stackForceMove
112+
if gp.stackguard0 < stackPoisonMin {
113+
gp.stackguard0 = stackForceMove
114114
}
115115
}

src/runtime/export_debuglog_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ func (l *dlogger) S(x string) *dlogger { return l.s(x) }
2525
func (l *dlogger) PC(x uintptr) *dlogger { return l.pc(x) }
2626

2727
func DumpDebugLog() string {
28-
g := getg()
29-
g.writebuf = make([]byte, 0, 1<<20)
28+
gp := getg()
29+
gp.writebuf = make([]byte, 0, 1<<20)
3030
printDebugLog()
31-
buf := g.writebuf
32-
g.writebuf = nil
31+
buf := gp.writebuf
32+
gp.writebuf = nil
3333

3434
return string(buf)
3535
}

src/runtime/export_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,17 +460,17 @@ func MapBucketsPointerIsNil(m map[int]int) bool {
460460
}
461461

462462
func LockOSCounts() (external, internal uint32) {
463-
g := getg()
464-
if g.m.lockedExt+g.m.lockedInt == 0 {
465-
if g.lockedm != 0 {
463+
gp := getg()
464+
if gp.m.lockedExt+gp.m.lockedInt == 0 {
465+
if gp.lockedm != 0 {
466466
panic("lockedm on non-locked goroutine")
467467
}
468468
} else {
469-
if g.lockedm == 0 {
469+
if gp.lockedm == 0 {
470470
panic("nil lockedm on locked goroutine")
471471
}
472472
}
473-
return g.m.lockedExt, g.m.lockedInt
473+
return gp.m.lockedExt, gp.m.lockedInt
474474
}
475475

476476
//go:noinline

src/runtime/malloc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ func nextSample() uintptr {
12451245
}
12461246
if GOOS == "plan9" {
12471247
// Plan 9 doesn't support floating point in note handler.
1248-
if g := getg(); g == g.m.gsignal {
1248+
if gp := getg(); gp == gp.m.gsignal {
12491249
return nextSampleNoFP()
12501250
}
12511251
}

src/runtime/msan.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ const msanenabled = true
3131
//
3232
//go:nosplit
3333
func msanread(addr unsafe.Pointer, sz uintptr) {
34-
g := getg()
35-
if g == nil || g.m == nil || g == g.m.g0 || g == g.m.gsignal {
34+
gp := getg()
35+
if gp == nil || gp.m == nil || gp == gp.m.g0 || gp == gp.m.gsignal {
3636
return
3737
}
3838
domsanread(addr, sz)

src/runtime/os_js.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ func osyield_no_g() {
4949
const _SIGSEGV = 0xb
5050

5151
func sigpanic() {
52-
g := getg()
52+
gp := getg()
5353
if !canpanic() {
5454
throw("unexpected signal during runtime execution")
5555
}
5656

5757
// js only invokes the exception handler for memory faults.
58-
g.sig = _SIGSEGV
58+
gp.sig = _SIGSEGV
5959
panicmem()
6060
}
6161

src/runtime/os_plan9.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ func os_sigpipe() {
7575
}
7676

7777
func sigpanic() {
78-
g := getg()
78+
gp := getg()
7979
if !canpanic() {
8080
throw("unexpected signal during runtime execution")
8181
}
8282

83-
note := gostringnocopy((*byte)(unsafe.Pointer(g.m.notesig)))
84-
switch g.sig {
83+
note := gostringnocopy((*byte)(unsafe.Pointer(gp.m.notesig)))
84+
switch gp.sig {
8585
case _SIGRFAULT, _SIGWFAULT:
8686
i := indexNoFloat(note, "addr=")
8787
if i >= 0 {
@@ -92,17 +92,17 @@ func sigpanic() {
9292
panicmem()
9393
}
9494
addr := note[i:]
95-
g.sigcode1 = uintptr(atolwhex(addr))
96-
if g.sigcode1 < 0x1000 {
95+
gp.sigcode1 = uintptr(atolwhex(addr))
96+
if gp.sigcode1 < 0x1000 {
9797
panicmem()
9898
}
99-
if g.paniconfault {
100-
panicmemAddr(g.sigcode1)
99+
if gp.paniconfault {
100+
panicmemAddr(gp.sigcode1)
101101
}
102-
print("unexpected fault address ", hex(g.sigcode1), "\n")
102+
print("unexpected fault address ", hex(gp.sigcode1), "\n")
103103
throw("fault")
104104
case _SIGTRAP:
105-
if g.paniconfault {
105+
if gp.paniconfault {
106106
panicmem()
107107
}
108108
throw(note)

src/runtime/signal_windows.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,20 +245,20 @@ func winthrow(info *exceptionrecord, r *context, gp *g) {
245245
}
246246

247247
func sigpanic() {
248-
g := getg()
248+
gp := getg()
249249
if !canpanic() {
250250
throw("unexpected signal during runtime execution")
251251
}
252252

253-
switch g.sig {
253+
switch gp.sig {
254254
case _EXCEPTION_ACCESS_VIOLATION:
255-
if g.sigcode1 < 0x1000 {
255+
if gp.sigcode1 < 0x1000 {
256256
panicmem()
257257
}
258-
if g.paniconfault {
259-
panicmemAddr(g.sigcode1)
258+
if gp.paniconfault {
259+
panicmemAddr(gp.sigcode1)
260260
}
261-
print("unexpected fault address ", hex(g.sigcode1), "\n")
261+
print("unexpected fault address ", hex(gp.sigcode1), "\n")
262262
throw("fault")
263263
case _EXCEPTION_INT_DIVIDE_BY_ZERO:
264264
panicdivide()

0 commit comments

Comments
 (0)