Commit 6ed58c29 authored by Daniel Morsing's avatar Daniel Morsing

runtime: run newproc1 on M stack.

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
parent d2165672
...@@ -1861,13 +1861,31 @@ runtime·malg(int32 stacksize) ...@@ -1861,13 +1861,31 @@ runtime·malg(int32 stacksize)
return newg; 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. // Create a new g running fn with siz bytes of arguments.
// Put it on the queue of g's waiting to run. // Put it on the queue of g's waiting to run.
// The compiler turns a go statement into a call to this. // The compiler turns a go statement into a call to this.
// Cannot split the stack because it assumes that the arguments // Cannot split the stack because it assumes that the arguments
// are available sequentially after &fn; they would not be // are available sequentially after &fn; they would not be
// copied if a stack split occurred. It's OK for this to call // copied if a stack split occurred.
// functions that split the stack.
#pragma textflag NOSPLIT #pragma textflag NOSPLIT
void void
runtime·newproc(int32 siz, FuncVal* fn, ...) runtime·newproc(int32 siz, FuncVal* fn, ...)
...@@ -1878,7 +1896,14 @@ 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 argp = (byte*)(&fn+2); // skip caller's saved LR
else else
argp = (byte*)(&fn+1); 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 // Create a new g running fn with narg bytes of arguments starting
......
...@@ -118,8 +118,14 @@ uintptr ...@@ -118,8 +118,14 @@ uintptr
runtime·racegostart(void *pc) runtime·racegostart(void *pc)
{ {
uintptr racectx; 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; return racectx;
} }
......
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