Skip to content

Commit

Permalink
runtime: tidy _Stack* constant naming
Browse files Browse the repository at this point in the history
For #59670.

Change-Id: I0efa743edc08e48dc8d906803ba45e9f641369db
Reviewed-on: https://go-review.googlesource.com/c/go/+/486977
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
  • Loading branch information
aclements authored and gopherbot committed Apr 21, 2023
1 parent 0f099a4 commit 87272bd
Show file tree
Hide file tree
Showing 21 changed files with 62 additions and 62 deletions.
2 changes: 1 addition & 1 deletion src/runtime/asm_386.s
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ nocpuinfo:
// update stackguard after _cgo_init
MOVL $runtime·g0(SB), CX
MOVL (g_stack+stack_lo)(CX), AX
ADDL $const__StackGuard, AX
ADDL $const_stackGuard, AX
MOVL AX, g_stackguard0(CX)
MOVL AX, g_stackguard1(CX)

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/asm_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ nocpuinfo:
// update stackguard after _cgo_init
MOVQ $runtime·g0(SB), CX
MOVQ (g_stack+stack_lo)(CX), AX
ADDQ $const__StackGuard, AX
ADDQ $const_stackGuard, AX
MOVQ AX, g_stackguard0(CX)
MOVQ AX, g_stackguard1(CX)

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/asm_arm.s
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ TEXT runtime·rt0_go(SB),NOSPLIT|NOFRAME|TOPFRAME,$0

// update stackguard after _cgo_init
MOVW (g_stack+stack_lo)(g), R0
ADD $const__StackGuard, R0
ADD $const_stackGuard, R0
MOVW R0, g_stackguard0(g)
MOVW R0, g_stackguard1(g)

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/asm_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ nocgo:
BL runtime·save_g(SB)
// update stackguard after _cgo_init
MOVD (g_stack+stack_lo)(g), R0
ADD $const__StackGuard, R0
ADD $const_stackGuard, R0
MOVD R0, g_stackguard0(g)
MOVD R0, g_stackguard1(g)

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/asm_loong64.s
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ TEXT runtime·rt0_go(SB),NOSPLIT|TOPFRAME,$0
nocgo:
// update stackguard after _cgo_init
MOVV (g_stack+stack_lo)(g), R19
ADDV $const__StackGuard, R19
ADDV $const_stackGuard, R19
MOVV R19, g_stackguard0(g)
MOVV R19, g_stackguard1(g)

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/asm_mips64x.s
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ TEXT runtime·rt0_go(SB),NOSPLIT|TOPFRAME,$0
nocgo:
// update stackguard after _cgo_init
MOVV (g_stack+stack_lo)(g), R1
ADDV $const__StackGuard, R1
ADDV $const_stackGuard, R1
MOVV R1, g_stackguard0(g)
MOVV R1, g_stackguard1(g)

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/asm_mipsx.s
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ TEXT runtime·rt0_go(SB),NOSPLIT|TOPFRAME,$0
nocgo:
// update stackguard after _cgo_init
MOVW (g_stack+stack_lo)(g), R1
ADD $const__StackGuard, R1
ADD $const_stackGuard, R1
MOVW R1, g_stackguard0(g)
MOVW R1, g_stackguard1(g)

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/asm_ppc64x.s
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ TEXT runtime·rt0_go(SB),NOSPLIT|TOPFRAME,$0
nocgo:
// update stackguard after _cgo_init
MOVD (g_stack+stack_lo)(g), R3
ADD $const__StackGuard, R3
ADD $const_stackGuard, R3
MOVD R3, g_stackguard0(g)
MOVD R3, g_stackguard1(g)

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/asm_riscv64.s
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TEXT runtime·rt0_go(SB),NOSPLIT|TOPFRAME,$0
nocgo:
// update stackguard after _cgo_init
MOV (g_stack+stack_lo)(g), T0
ADD $const__StackGuard, T0
ADD $const_stackGuard, T0
MOV T0, g_stackguard0(g)
MOV T0, g_stackguard1(g)

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/asm_s390x.s
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ TEXT runtime·rt0_go(SB),NOSPLIT|TOPFRAME,$0
nocgo:
// update stackguard after _cgo_init
MOVD (g_stack+stack_lo)(g), R2
ADD $const__StackGuard, R2
ADD $const_stackGuard, R2
MOVD R2, g_stackguard0(g)
MOVD R2, g_stackguard1(g)

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/os_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ func minit() {
throw("bad g0 stack")
}
g0.stack.lo = base
g0.stackguard0 = g0.stack.lo + _StackGuard
g0.stackguard0 = g0.stack.lo + stackGuard
g0.stackguard1 = g0.stackguard0
// Sanity check the SP.
stackcheck()
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/preempt.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func suspendG(gp *g) suspendGState {
// _Gscan bit and thus own the stack.
gp.preemptStop = false
gp.preempt = false
gp.stackguard0 = gp.stack.lo + _StackGuard
gp.stackguard0 = gp.stack.lo + stackGuard

// The goroutine was already at a safe-point
// and we've now locked that in.
Expand Down
24 changes: 12 additions & 12 deletions src/runtime/proc.go
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ func mcommoninit(mp *m, id int64) {

mpreinit(mp)
if mp.gsignal != nil {
mp.gsignal.stackguard1 = mp.gsignal.stack.lo + _StackGuard
mp.gsignal.stackguard1 = mp.gsignal.stack.lo + stackGuard
}

// Add to allm so garbage collector doesn't free g->m
Expand Down Expand Up @@ -1446,7 +1446,7 @@ func mstart0() {
}
// Initialize stack guard so that we can start calling regular
// Go code.
gp.stackguard0 = gp.stack.lo + _StackGuard
gp.stackguard0 = gp.stack.lo + stackGuard
// This is the g0, so we can also call go:systemstack
// functions, which check stackguard1.
gp.stackguard1 = gp.stackguard0
Expand Down Expand Up @@ -1940,7 +1940,7 @@ func needm() {
gp := getg()
gp.stack.hi = getcallersp() + 1024
gp.stack.lo = getcallersp() - 32*1024
gp.stackguard0 = gp.stack.lo + _StackGuard
gp.stackguard0 = gp.stack.lo + stackGuard

// Initialize this thread to use the m.
asminit()
Expand Down Expand Up @@ -2640,7 +2640,7 @@ func execute(gp *g, inheritTime bool) {
casgstatus(gp, _Grunnable, _Grunning)
gp.waitsince = 0
gp.preempt = false
gp.stackguard0 = gp.stack.lo + _StackGuard
gp.stackguard0 = gp.stack.lo + stackGuard
if !inheritTime {
mp.p.ptr().schedtick++
}
Expand Down Expand Up @@ -3955,8 +3955,8 @@ func exitsyscall() {
// restore the preemption request in case we've cleared it in newstack
gp.stackguard0 = stackPreempt
} else {
// otherwise restore the real _StackGuard, we've spoiled it in entersyscall/entersyscallblock
gp.stackguard0 = gp.stack.lo + _StackGuard
// otherwise restore the real stackGuard, we've spoiled it in entersyscall/entersyscallblock
gp.stackguard0 = gp.stack.lo + stackGuard
}
gp.throwsplit = false

Expand Down Expand Up @@ -4137,7 +4137,7 @@ func syscall_runtime_BeforeFork() {

// This function is called before fork in syscall package.
// Code between fork and exec must not allocate memory nor even try to grow stack.
// Here we spoil g->_StackGuard to reliably detect any attempts to grow stack.
// Here we spoil g.stackguard0 to reliably detect any attempts to grow stack.
// runtime_AfterFork will undo this in parent process, but not in child.
gp.stackguard0 = stackFork
}
Expand All @@ -4150,7 +4150,7 @@ func syscall_runtime_AfterFork() {
gp := getg().m.curg

// See the comments in beforefork.
gp.stackguard0 = gp.stack.lo + _StackGuard
gp.stackguard0 = gp.stack.lo + stackGuard

msigrestore(gp.m.sigmask)

Expand Down Expand Up @@ -4220,11 +4220,11 @@ func syscall_runtime_AfterExec() {
func malg(stacksize int32) *g {
newg := new(g)
if stacksize >= 0 {
stacksize = round2(_StackSystem + stacksize)
stacksize = round2(stackSystem + stacksize)
systemstack(func() {
newg.stack = stackalloc(uint32(stacksize))
})
newg.stackguard0 = newg.stack.lo + _StackGuard
newg.stackguard0 = newg.stack.lo + stackGuard
newg.stackguard1 = ^uintptr(0)
// Clear the bottom word of the stack. We record g
// there on gsignal stack during VDSO on ARM and ARM64.
Expand Down Expand Up @@ -4263,7 +4263,7 @@ func newproc1(fn *funcval, callergp *g, callerpc uintptr) *g {
pp := mp.p.ptr()
newg := gfget(pp)
if newg == nil {
newg = malg(_StackMin)
newg = malg(stackMin)
casgstatus(newg, _Gidle, _Gdead)
allgadd(newg) // publishes with a g->status of Gdead so GC scanner doesn't look at uninitialized stack.
}
Expand Down Expand Up @@ -4467,7 +4467,7 @@ retry:
systemstack(func() {
gp.stack = stackalloc(startingStackSize)
})
gp.stackguard0 = gp.stack.lo + _StackGuard
gp.stackguard0 = gp.stack.lo + stackGuard
} else {
if raceenabled {
racemalloc(unsafe.Pointer(gp.stack.lo), gp.stack.hi-gp.stack.lo)
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/runtime1.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func check() {

testAtomic64()

if _FixedStack != round2(_FixedStack) {
if fixedStack != round2(fixedStack) {
throw("FixedStack is not power-of-2")
}

Expand Down
4 changes: 2 additions & 2 deletions src/runtime/signal_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -1307,8 +1307,8 @@ func setGsignalStack(st *stackt, old *gsignalStack) {
stsp := uintptr(unsafe.Pointer(st.ss_sp))
gp.m.gsignal.stack.lo = stsp
gp.m.gsignal.stack.hi = stsp + st.ss_size
gp.m.gsignal.stackguard0 = stsp + _StackGuard
gp.m.gsignal.stackguard1 = stsp + _StackGuard
gp.m.gsignal.stackguard0 = stsp + stackGuard
gp.m.gsignal.stackguard1 = stsp + stackGuard
}

// restoreGsignalStack restores the gsignal stack to the value it had
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/signal_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func winthrow(info *exceptionrecord, r *context, gp *g) {
// g0 stack bounds so we have room to print the traceback. If
// this somehow overflows the stack, the OS will trap it.
g0.stack.lo = 0
g0.stackguard0 = g0.stack.lo + _StackGuard
g0.stackguard0 = g0.stack.lo + stackGuard
g0.stackguard1 = g0.stackguard0

print("Exception ", hex(info.exceptioncode), " ", hex(info.exceptioninformation[0]), " ", hex(info.exceptioninformation[1]), " ", hex(r.ip()), "\n")
Expand Down
Loading

0 comments on commit 87272bd

Please sign in to comment.