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
This commit is contained in:
parent
d7b9b0805d
commit
c130ab6aad
5 changed files with 16 additions and 8 deletions
|
@ -1,4 +1,4 @@
|
||||||
76ab85364745e445498fe53f9ca8e37b49650779
|
5c2c4743980556c041561533ef31762f524737ca
|
||||||
|
|
||||||
The first line of this file holds the git revision number of the last
|
The first line of this file holds the git revision number of the last
|
||||||
merge done from the gofrontend repository.
|
merge done from the gofrontend repository.
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
//go:linkname acquirep runtime.acquirep
|
//go:linkname acquirep runtime.acquirep
|
||||||
//go:linkname releasep runtime.releasep
|
//go:linkname releasep runtime.releasep
|
||||||
//go:linkname incidlelocked runtime.incidlelocked
|
//go:linkname incidlelocked runtime.incidlelocked
|
||||||
|
//go:linkname ginit runtime.ginit
|
||||||
//go:linkname schedinit runtime.schedinit
|
//go:linkname schedinit runtime.schedinit
|
||||||
//go:linkname ready runtime.ready
|
//go:linkname ready runtime.ready
|
||||||
//go:linkname stopm runtime.stopm
|
//go:linkname stopm runtime.stopm
|
||||||
|
@ -515,6 +516,15 @@ func cpuinit() {
|
||||||
cpu.Initialize(env)
|
cpu.Initialize(env)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ginit() {
|
||||||
|
_m_ := &m0
|
||||||
|
_g_ := &g0
|
||||||
|
_m_.g0 = _g_
|
||||||
|
_m_.curg = _g_
|
||||||
|
_g_.m = _m_
|
||||||
|
setg(_g_)
|
||||||
|
}
|
||||||
|
|
||||||
// The bootstrap sequence is:
|
// The bootstrap sequence is:
|
||||||
//
|
//
|
||||||
// call osinit
|
// call osinit
|
||||||
|
@ -524,13 +534,7 @@ func cpuinit() {
|
||||||
//
|
//
|
||||||
// The new G calls runtime·main.
|
// The new G calls runtime·main.
|
||||||
func schedinit() {
|
func schedinit() {
|
||||||
_m_ := &m0
|
_g_ := getg()
|
||||||
_g_ := &g0
|
|
||||||
_m_.g0 = _g_
|
|
||||||
_m_.curg = _g_
|
|
||||||
_g_.m = _m_
|
|
||||||
setg(_g_)
|
|
||||||
|
|
||||||
sched.maxmcount = 10000
|
sched.maxmcount = 10000
|
||||||
|
|
||||||
usestackmaps = probestackmaps()
|
usestackmaps = probestackmaps()
|
||||||
|
|
|
@ -225,6 +225,7 @@ gostart (void *arg)
|
||||||
return NULL;
|
return NULL;
|
||||||
runtime_isstarted = true;
|
runtime_isstarted = true;
|
||||||
|
|
||||||
|
runtime_ginit ();
|
||||||
runtime_check ();
|
runtime_check ();
|
||||||
runtime_args (a->argc, (byte **) a->argv);
|
runtime_args (a->argc, (byte **) a->argv);
|
||||||
setncpu (getproccount ());
|
setncpu (getproccount ());
|
||||||
|
|
|
@ -48,6 +48,7 @@ main (int argc, char **argv)
|
||||||
setIsCgo ();
|
setIsCgo ();
|
||||||
|
|
||||||
__go_end = (uintptr)_end;
|
__go_end = (uintptr)_end;
|
||||||
|
runtime_ginit ();
|
||||||
runtime_cpuinit ();
|
runtime_cpuinit ();
|
||||||
runtime_check ();
|
runtime_check ();
|
||||||
runtime_args (argc, (byte **) argv);
|
runtime_args (argc, (byte **) argv);
|
||||||
|
|
|
@ -240,6 +240,8 @@ int32 runtime_snprintf(byte*, int32, const char*, ...);
|
||||||
#define runtime_memmove(a, b, s) __builtin_memmove((a), (b), (s))
|
#define runtime_memmove(a, b, s) __builtin_memmove((a), (b), (s))
|
||||||
String runtime_gostringnocopy(const byte*)
|
String runtime_gostringnocopy(const byte*)
|
||||||
__asm__ (GOSYM_PREFIX "runtime.gostringnocopy");
|
__asm__ (GOSYM_PREFIX "runtime.gostringnocopy");
|
||||||
|
void runtime_ginit(void)
|
||||||
|
__asm__ (GOSYM_PREFIX "runtime.ginit");
|
||||||
void runtime_schedinit(void)
|
void runtime_schedinit(void)
|
||||||
__asm__ (GOSYM_PREFIX "runtime.schedinit");
|
__asm__ (GOSYM_PREFIX "runtime.schedinit");
|
||||||
void runtime_initsig(bool)
|
void runtime_initsig(bool)
|
||||||
|
|
Loading…
Add table
Reference in a new issue