liblink, cmd/ld, runtime: remove stackguard1

Now that we've removed all the C code in runtime and the C compilers,
there is no need to have a separate stackguard field to check for C
code on Go stack.

Remove field g.stackguard1 and rename g.stackguard0 to g.stackguard.
Adjust liblink and cmd/ld as necessary.

Change-Id: I54e75db5a93d783e86af5ff1a6cd497d669d8d33
Reviewed-on: https://go-review.googlesource.com/2144
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Shenghou Ma 2014-12-29 01:08:40 -05:00 committed by Keith Randall
parent 3b76b017ca
commit ab0535ae3f
27 changed files with 72 additions and 192 deletions

View file

@ -26,13 +26,13 @@ const (
poisonStack = uintptrMask & 0x6868686868686868
// Goroutine preemption request.
// Stored into g->stackguard0 to cause split stack check failure.
// Stored into g->stackguard to cause split stack check failure.
// Must be greater than any real sp.
// 0xfffffade in hex.
stackPreempt = uintptrMask & -1314
// Thread is forking.
// Stored into g->stackguard0 to cause split stack check failure.
// Stored into g->stackguard to cause split stack check failure.
// Must be greater than any real sp.
stackFork = uintptrMask & -1234
)
@ -566,7 +566,7 @@ func copystack(gp *g, newsize uintptr) {
// Swap out old stack for new one
gp.stack = new
gp.stackguard0 = new.lo + _StackGuard // NOTE: might clobber a preempt request
gp.stackguard = new.lo + _StackGuard // NOTE: might clobber a preempt request
gp.sched.sp = new.hi - used
// free old stack
@ -611,7 +611,7 @@ func round2(x int32) int32 {
func newstack() {
thisg := getg()
// TODO: double check all gp. shouldn't be getg().
if thisg.m.morebuf.g.stackguard0 == stackFork {
if thisg.m.morebuf.g.stackguard == stackFork {
throw("stack growth after fork")
}
if thisg.m.morebuf.g != thisg.m.curg {
@ -674,7 +674,7 @@ func newstack() {
writebarrierptr_nostore((*uintptr)(unsafe.Pointer(&gp.sched.ctxt)), uintptr(gp.sched.ctxt))
}
if gp.stackguard0 == stackPreempt {
if gp.stackguard == stackPreempt {
if gp == thisg.m.g0 {
throw("runtime: preempt g0")
}
@ -689,7 +689,7 @@ func newstack() {
gcphasework(gp)
casfrom_Gscanstatus(gp, _Gscanwaiting, _Gwaiting)
casgstatus(gp, _Gwaiting, _Grunning)
gp.stackguard0 = gp.stack.lo + _StackGuard
gp.stackguard = gp.stack.lo + _StackGuard
gp.preempt = false
gp.preemptscan = false // Tells the GC premption was successful.
gogo(&gp.sched) // never return
@ -700,7 +700,7 @@ func newstack() {
if thisg.m.locks != 0 || thisg.m.mallocing != 0 || thisg.m.gcing != 0 || thisg.m.p.status != _Prunning {
// Let the goroutine keep running for now.
// gp->preempt is set, so it will be preempted next time.
gp.stackguard0 = gp.stack.lo + _StackGuard
gp.stackguard = gp.stack.lo + _StackGuard
casgstatus(gp, _Gwaiting, _Grunning)
gogo(&gp.sched) // never return
}
@ -804,10 +804,3 @@ func shrinkfinish() {
s = t
}
}
//go:nosplit
func morestackc() {
systemstack(func() {
throw("attempt to execute C code on Go stack")
})
}