summaryrefslogtreecommitdiff
path: root/libgo/go/runtime
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2019-05-11 01:12:37 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-05-11 01:12:37 +0000
commitc130ab6aad57e0309ec02f58f383aece584ac8cb (patch)
tree0a5fd2bf4f6ad9b59a03ff33d2758937064fc015 /libgo/go/runtime
parentd7b9b0805d5ab514c43e1fe57e43a10394d5d965 (diff)
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
Diffstat (limited to 'libgo/go/runtime')
-rw-r--r--libgo/go/runtime/proc.go18
1 files changed, 11 insertions, 7 deletions
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()