runtime: change g's in systemstack

The systemstack function in the gc toolchain changes to a different g.
This is often used to get more stack space; the gofrontend uses a
different stack growth mechanism that does not require changing g's,
so we've been running with a version of systemstack that keeps the
same g.  However, the garbage collector has various tests to verify
that it is running on g0 rather than on a normal g.  For simplicity,
change the gofrontend version of systemstack to change to a different
g just as the gc toolchain does.

This permits us to uncomment some sanity checks in notetsleep.
Doing that requires us to fix up a couple of places where C code calls
{start,stop}TheWorldWithSema while not on g0.

Note that this does slow down some code in the runtime package unnecessarily.
It may be useful to find some places where the runtime calls
systemstack only to get more stack space and change it to use some
other function.  That other function would act like systemstack in the
gc toolchain but simply call the argument in the gofrontend.

Change-Id: I6ec58c70bcca91d518d250ec338677b26bb7e5a6
Reviewed-on: https://go-review.googlesource.com/40973
Reviewed-by: Than McIntosh <thanm@google.com>
7 files changed