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/stack.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'libgo/runtime/stack.c') diff --git a/libgo/runtime/stack.c b/libgo/runtime/stack.c index 1ce30db..900ca64 100644 --- a/libgo/runtime/stack.c +++ b/libgo/runtime/stack.c @@ -60,12 +60,12 @@ static void doscanstack1(G *gp, void *gcw) { // as schedlock and may have needed to start a new stack segment. // Use the stack segment and stack pointer at the time of // the system call instead, since that won't change underfoot. - if(gp->gcstack != nil) { - sp = gp->gcstack; + if(gp->gcstack != 0) { + sp = (void*)(gp->gcstack); spsize = gp->gcstacksize; - next_segment = gp->gcnextsegment; - next_sp = gp->gcnextsp; - initial_sp = gp->gcinitialsp; + next_segment = (void*)(gp->gcnextsegment); + next_sp = (void*)(gp->gcnextsp); + initial_sp = (void*)(gp->gcinitialsp); } else { sp = __splitstack_find_context((void**)(&gp->stackcontext[0]), &spsize, &next_segment, @@ -89,11 +89,11 @@ static void doscanstack1(G *gp, void *gcw) { } else { // Scanning another goroutine's stack. // The goroutine is usually asleep (the world is stopped). - bottom = (byte*)gp->gcnextsp; + bottom = (void*)gp->gcnextsp; if(bottom == nil) return; } - top = (byte*)gp->gcinitialsp + gp->gcstacksize; + top = (byte*)(void*)(gp->gcinitialsp) + gp->gcstacksize; if(top > bottom) scanstackblock(bottom, (uintptr)(top - bottom), gcw); else -- cgit v1.1