aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/proc.c
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2014-04-28 12:47:09 -0400
committerKeith Randall <khr@golang.org>2014-04-28 12:47:09 -0400
commit29d1b211fdece82b3c4ccdb549ac394e71132643 (patch)
tree9d5f7700ef6123ce0fe963c0cad4be13aa925f92 /src/pkg/runtime/proc.c
parent573cfe95615faac43b9fc0841f13b74640584305 (diff)
downloadgo-29d1b211fdece82b3c4ccdb549ac394e71132643.tar.xz
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
Diffstat (limited to 'src/pkg/runtime/proc.c')
-rw-r--r--src/pkg/runtime/proc.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c
index 52b02d94bb..7500e8a5f9 100644
--- a/src/pkg/runtime/proc.c
+++ b/src/pkg/runtime/proc.c
@@ -687,6 +687,21 @@ runtime·allocm(P *p)
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 void unlockextra(M*);
@@ -1746,7 +1761,7 @@ runtime·malg(int32 stacksize)
runtime·throw("runtime: bad stack.h");
}
- newg = runtime·malloc(sizeof(G));
+ newg = allocg();
if(stacksize >= 0) {
stacksize = runtime·round2(StackSystem + stacksize);
if(g == m->g0) {