Revert "liblink, cmd/ld, runtime: remove stackguard1"

This reverts commit ab0535ae3fb45ba734d47542cc4845f27f708d1b.

I think it will remain useful to distinguish code that must
run on a system stack from code that can run on either stack,
even if that distinction is no
longer based on the implementation language.

That is, I expect to add a //go:systemstack comment that,
in terms of the old implementation, tells the compiler,
to pretend this function was written in C.

Change-Id: I33d2ebb2f99ae12496484c6ec8ed07233d693275
Reviewed-on: https://go-review.googlesource.com/2275
Reviewed-by: Russ Cox <rsc@golang.org>
diff --git a/src/runtime/stack1.go b/src/runtime/stack1.go
index 8b32eb6d..6c34642 100644
--- a/src/runtime/stack1.go
+++ b/src/runtime/stack1.go
@@ -26,13 +26,13 @@
 	poisonStack = uintptrMask & 0x6868686868686868
 
 	// Goroutine preemption request.
-	// Stored into g->stackguard to cause split stack check failure.
+	// Stored into g->stackguard0 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->stackguard to cause split stack check failure.
+	// Stored into g->stackguard0 to cause split stack check failure.
 	// Must be greater than any real sp.
 	stackFork = uintptrMask & -1234
 )
@@ -566,7 +566,7 @@
 
 	// Swap out old stack for new one
 	gp.stack = new
-	gp.stackguard = new.lo + _StackGuard // NOTE: might clobber a preempt request
+	gp.stackguard0 = new.lo + _StackGuard // NOTE: might clobber a preempt request
 	gp.sched.sp = new.hi - used
 
 	// free old stack
@@ -611,7 +611,7 @@
 func newstack() {
 	thisg := getg()
 	// TODO: double check all gp. shouldn't be getg().
-	if thisg.m.morebuf.g.stackguard == stackFork {
+	if thisg.m.morebuf.g.stackguard0 == stackFork {
 		throw("stack growth after fork")
 	}
 	if thisg.m.morebuf.g != thisg.m.curg {
@@ -674,7 +674,7 @@
 		writebarrierptr_nostore((*uintptr)(unsafe.Pointer(&gp.sched.ctxt)), uintptr(gp.sched.ctxt))
 	}
 
-	if gp.stackguard == stackPreempt {
+	if gp.stackguard0 == stackPreempt {
 		if gp == thisg.m.g0 {
 			throw("runtime: preempt g0")
 		}
@@ -689,7 +689,7 @@
 			gcphasework(gp)
 			casfrom_Gscanstatus(gp, _Gscanwaiting, _Gwaiting)
 			casgstatus(gp, _Gwaiting, _Grunning)
-			gp.stackguard = gp.stack.lo + _StackGuard
+			gp.stackguard0 = 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 @@
 		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.stackguard = gp.stack.lo + _StackGuard
+			gp.stackguard0 = gp.stack.lo + _StackGuard
 			casgstatus(gp, _Gwaiting, _Grunning)
 			gogo(&gp.sched) // never return
 		}
@@ -804,3 +804,10 @@
 		s = t
 	}
 }
+
+//go:nosplit
+func morestackc() {
+	systemstack(func() {
+		throw("attempt to execute C code on Go stack")
+	})
+}