From c130ab6aad57e0309ec02f58f383aece584ac8cb Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Sat, 11 May 2019 01:12:37 +0000 Subject: runtime: set up g early runtime.throw needs a g to work properly. Set up g early, to ensure that if something goes wrong in the runtime startup (e.g. runtime.check fails), the program terminates in a reasonable way. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/176657 From-SVN: r271088 --- libgo/go/runtime/proc.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'libgo/go/runtime') diff --git a/libgo/go/runtime/proc.go b/libgo/go/runtime/proc.go index 8146c1d0206..b40198e9d3e 100644 --- a/libgo/go/runtime/proc.go +++ b/libgo/go/runtime/proc.go @@ -18,6 +18,7 @@ import ( //go:linkname acquirep runtime.acquirep //go:linkname releasep runtime.releasep //go:linkname incidlelocked runtime.incidlelocked +//go:linkname ginit runtime.ginit //go:linkname schedinit runtime.schedinit //go:linkname ready runtime.ready //go:linkname stopm runtime.stopm @@ -515,6 +516,15 @@ func cpuinit() { cpu.Initialize(env) } +func ginit() { + _m_ := &m0 + _g_ := &g0 + _m_.g0 = _g_ + _m_.curg = _g_ + _g_.m = _m_ + setg(_g_) +} + // The bootstrap sequence is: // // call osinit @@ -524,13 +534,7 @@ func cpuinit() { // // The new G calls runtimeĀ·main. func schedinit() { - _m_ := &m0 - _g_ := &g0 - _m_.g0 = _g_ - _m_.curg = _g_ - _g_.m = _m_ - setg(_g_) - + _g_ := getg() sched.maxmcount = 10000 usestackmaps = probestackmaps() -- cgit v1.2.3