From e58f798c0c97c252e0b800a4223d20790ef6b166 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 12 Jun 2013 08:49:38 -0400 Subject: runtime: adjust traceback / garbage collector boundary The garbage collection routine addframeroots is duplicating logic in the traceback routine that calls it, sometimes correctly, sometimes incorrectly, sometimes incompletely. Pass necessary information to addframeroots instead of deriving it anew. Should make addframeroots significantly more robust. It's certainly smaller. Also try to standardize on uintptr for saved pc, sp values. Will make CL 10036044 trivial. R=golang-dev, dave, dvyukov CC=golang-dev https://golang.org/cl/10169045 --- src/pkg/runtime/stack.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/pkg/runtime/stack.c') diff --git a/src/pkg/runtime/stack.c b/src/pkg/runtime/stack.c index a033d6b012..68477ad8da 100644 --- a/src/pkg/runtime/stack.c +++ b/src/pkg/runtime/stack.c @@ -155,8 +155,8 @@ runtime·oldstack(void) USED(goid); label = top->gobuf; - gp->stackbase = (uintptr)top->stackbase; - gp->stackguard = (uintptr)top->stackguard; + gp->stackbase = top->stackbase; + gp->stackguard = top->stackguard; gp->stackguard0 = gp->stackguard; if(top->free != 0) runtime·stackfree(old, top->free); @@ -176,7 +176,8 @@ runtime·newstack(void) { int32 framesize, minalloc, argsize; Stktop *top; - byte *stk, *sp; + byte *stk; + uintptr sp; uintptr *src, *dst, *dstend; G *gp; Gobuf label; @@ -234,14 +235,14 @@ runtime·newstack(void) framesize, argsize, m->morepc, m->moreargp, m->morebuf.pc, m->morebuf.sp, top, gp->stackbase); } - top->stackbase = (byte*)gp->stackbase; - top->stackguard = (byte*)gp->stackguard; + top->stackbase = gp->stackbase; + top->stackguard = gp->stackguard; top->gobuf = m->morebuf; top->argp = m->moreargp; top->argsize = argsize; top->free = free; m->moreargp = nil; - m->morebuf.pc = nil; + m->morebuf.pc = (uintptr)nil; m->morebuf.sp = (uintptr)nil; // copy flag from panic @@ -252,7 +253,7 @@ runtime·newstack(void) gp->stackguard = (uintptr)stk + StackGuard; gp->stackguard0 = gp->stackguard; - sp = (byte*)top; + sp = (uintptr)top; if(argsize > 0) { sp -= argsize; dst = (uintptr*)sp; @@ -269,8 +270,8 @@ runtime·newstack(void) // Continue as if lessstack had just called m->morepc // (the PC that decided to grow the stack). - label.sp = (uintptr)sp; - label.pc = (byte*)runtime·lessstack; + label.sp = sp; + label.pc = (uintptr)runtime·lessstack; label.g = m->curg; if(reflectcall) runtime·gogocallfn(&label, (FuncVal*)m->morepc); -- cgit v1.3-5-g9baa