Commit 29d1b211 authored by Keith Randall's avatar Keith Randall

runtime: clean up scanning of Gs

Use a real type for Gs instead of scanning them conservatively.
Zero the schedlink pointer when it is dead.

Update #7820

LGTM=rsc
R=rsc, dvyukov
CC=golang-codereviews
https://golang.org/cl/89360043
parent 573cfe95
...@@ -631,6 +631,7 @@ BitVector runtime·stackmapdata(StackMap *stackmap, int32 n); ...@@ -631,6 +631,7 @@ BitVector runtime·stackmapdata(StackMap *stackmap, int32 n);
// defined in mgc0.go // defined in mgc0.go
void runtime·gc_m_ptr(Eface*); void runtime·gc_m_ptr(Eface*);
void runtime·gc_g_ptr(Eface*);
void runtime·gc_itab_ptr(Eface*); void runtime·gc_itab_ptr(Eface*);
void runtime·memorydump(void); void runtime·memorydump(void);
......
...@@ -9,6 +9,11 @@ func gc_m_ptr(ret *interface{}) { ...@@ -9,6 +9,11 @@ func gc_m_ptr(ret *interface{}) {
*ret = (*m)(nil) *ret = (*m)(nil)
} }
// Called from C. Returns the Go type *g.
func gc_g_ptr(ret *interface{}) {
*ret = (*g)(nil)
}
// Called from C. Returns the Go type *itab. // Called from C. Returns the Go type *itab.
func gc_itab_ptr(ret *interface{}) { func gc_itab_ptr(ret *interface{}) {
*ret = (*itab)(nil) *ret = (*itab)(nil)
......
...@@ -687,6 +687,21 @@ runtime·allocm(P *p) ...@@ -687,6 +687,21 @@ runtime·allocm(P *p)
return mp; return mp;
} }
static G*
allocg(void)
{
G *gp;
static Type *gtype;
if(gtype == nil) {
Eface e;
runtime·gc_g_ptr(&e);
gtype = ((PtrType*)e.type)->elem;
}
gp = runtime·cnew(gtype);
return gp;
}
static M* lockextra(bool nilokay); static M* lockextra(bool nilokay);
static void unlockextra(M*); static void unlockextra(M*);
...@@ -1746,7 +1761,7 @@ runtime·malg(int32 stacksize) ...@@ -1746,7 +1761,7 @@ runtime·malg(int32 stacksize)
runtime·throw("runtime: bad stack.h"); runtime·throw("runtime: bad stack.h");
} }
newg = runtime·malloc(sizeof(G)); newg = allocg();
if(stacksize >= 0) { if(stacksize >= 0) {
stacksize = runtime·round2(StackSystem + stacksize); stacksize = runtime·round2(StackSystem + stacksize);
if(g == m->g0) { if(g == m->g0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment