]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: run newproc1 on M stack.
authorDaniel Morsing <daniel.morsing@gmail.com>
Sat, 23 Aug 2014 14:42:30 +0000 (15:42 +0100)
committerDaniel Morsing <daniel.morsing@gmail.com>
Sat, 23 Aug 2014 14:42:30 +0000 (15:42 +0100)
This makes newproc invisible to the GC. This is a pretty simple change since parts of newproc already depends on being run on the M stack.

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews, khr
https://golang.org/cl/129520043

src/pkg/runtime/proc.c
src/pkg/runtime/race.c

index df85042340c3fe51a2a0727e33b0092c549b0f6a..dbe47d2af7179b93d75694e8e96f21e9468460e5 100644 (file)
@@ -1861,13 +1861,31 @@ runtime·malg(int32 stacksize)
        return newg;
 }
 
+static void
+newproc_m(void)
+{
+       byte *argp;
+       void *callerpc;
+       FuncVal *fn;
+       int32 siz;
+       G *spawng;
+
+       siz = g->m->scalararg[0];
+       callerpc = (void*)g->m->scalararg[1];   
+       argp = g->m->ptrarg[0];
+       fn = (FuncVal*)g->m->ptrarg[1];
+
+       runtime·newproc1(fn, argp, siz, 0, callerpc);
+       g->m->ptrarg[0] = nil;
+       g->m->ptrarg[1] = nil;
+}
+
 // Create a new g running fn with siz bytes of arguments.
 // Put it on the queue of g's waiting to run.
 // The compiler turns a go statement into a call to this.
 // Cannot split the stack because it assumes that the arguments
 // are available sequentially after &fn; they would not be
-// copied if a stack split occurred.  It's OK for this to call
-// functions that split the stack.
+// copied if a stack split occurred.
 #pragma textflag NOSPLIT
 void
 runtime·newproc(int32 siz, FuncVal* fn, ...)
@@ -1878,7 +1896,14 @@ runtime·newproc(int32 siz, FuncVal* fn, ...)
                argp = (byte*)(&fn+2);  // skip caller's saved LR
        else
                argp = (byte*)(&fn+1);
-       runtime·newproc1(fn, argp, siz, 0, runtime·getcallerpc(&siz));
+
+       g->m->locks++;
+       g->m->scalararg[0] = siz;
+       g->m->scalararg[1] = (uintptr)runtime·getcallerpc(&siz);
+       g->m->ptrarg[0] = argp;
+       g->m->ptrarg[1] = fn;
+       runtime·onM(newproc_m);
+       g->m->locks--;
 }
 
 // Create a new g running fn with narg bytes of arguments starting
index fa04a39310993ad7c6aff049282462902178d61d..6a4d2803c1f59071f185f4c3b66aeaffca282fcf 100644 (file)
@@ -118,8 +118,14 @@ uintptr
 runtime·racegostart(void *pc)
 {
        uintptr racectx;
+       G *spawng;
 
-       runtime·racecall(__tsan_go_start, g->racectx, &racectx, pc);
+       if(g->m->curg != nil)
+               spawng = g->m->curg;
+       else
+               spawng = g;
+
+       runtime·racecall(__tsan_go_start, spawng->racectx, &racectx, pc);
        return racectx;
 }