From 3b0ddadf74ec9c7aa404765ec50bb55d255dbec7 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 22 Jun 2017 14:44:30 +0000 Subject: runtime: change some stack fields to uintptr Because of how gccgo implements cgo calls, the code in dropm may not have any write barriers. As a step toward implementing that, change the gcstack, gcnextsegment, and gcnextsp fields of the g struct to uintptr, so that assignments to them do not require write barriers. The gcinitialsp field remains unsafe.Pointer, as on 32-bit systems that do not support split stack it points to a heap allocated space used for the goroutine stack. The test for this is runtime tests like TestCgoCallbackGC, which are not run today but will be run with a future gotools patch. Reviewed-on: https://go-review.googlesource.com/46396 From-SVN: r249561 --- libgo/runtime/proc.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'libgo/runtime/proc.c') diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c index 14ee673..303a1b5 100644 --- a/libgo/runtime/proc.c +++ b/libgo/runtime/proc.c @@ -316,7 +316,7 @@ runtime_mcall(FuncVal *fv) #else // We have to point to an address on the stack that is // below the saved registers. - gp->gcnextsp = &afterregs; + gp->gcnextsp = (uintptr)(&afterregs); #endif gp->fromgogo = false; getcontext(ucontext_arg(&gp->context[0])); @@ -489,7 +489,7 @@ runtime_mstart(void *arg) // Setting gcstacksize to 0 is a marker meaning that gcinitialsp // is the top of the stack, not the bottom. gp->gcstacksize = 0; - gp->gcnextsp = &arg; + gp->gcnextsp = (uintptr)(&arg); #endif // Save the currently active context. This will return @@ -558,9 +558,9 @@ setGContext() __splitstack_block_signals(&val, nil); #else gp->gcinitialsp = &val; - gp->gcstack = nil; + gp->gcstack = 0; gp->gcstacksize = 0; - gp->gcnextsp = &val; + gp->gcnextsp = (uintptr)(&val); #endif getcontext(ucontext_arg(&gp->context[0])); @@ -628,16 +628,17 @@ doentersyscall(uintptr pc, uintptr sp) #ifdef USING_SPLIT_STACK { size_t gcstacksize; - g->gcstack = __splitstack_find(nil, nil, &gcstacksize, - &g->gcnextsegment, &g->gcnextsp, - &g->gcinitialsp); + g->gcstack = (uintptr)(__splitstack_find(nil, nil, &gcstacksize, + (void**)(&g->gcnextsegment), + (void**)(&g->gcnextsp), + &g->gcinitialsp)); g->gcstacksize = (uintptr)gcstacksize; } #else { void *v; - g->gcnextsp = (byte *) &v; + g->gcnextsp = (uintptr)(&v); } #endif @@ -667,9 +668,10 @@ doentersyscallblock(uintptr pc, uintptr sp) #ifdef USING_SPLIT_STACK { size_t gcstacksize; - g->gcstack = __splitstack_find(nil, nil, &gcstacksize, - &g->gcnextsegment, &g->gcnextsp, - &g->gcinitialsp); + g->gcstack = (uintptr)(__splitstack_find(nil, nil, &gcstacksize, + (void**)(&g->gcnextsegment), + (void**)(&g->gcnextsp), + &g->gcinitialsp)); g->gcstacksize = (uintptr)gcstacksize; } #else @@ -765,7 +767,7 @@ resetNewG(G *newg, void **sp, uintptr *spsize) *spsize = newg->gcstacksize; if(*spsize == 0) runtime_throw("bad spsize in resetNewG"); - newg->gcnextsp = *sp; + newg->gcnextsp = (uintptr)(*sp); #endif } -- cgit v1.1