]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: update field types in preparation for GC changes
authorJan Ziak <0xe2.0x9a.0x9b@gmail.com>
Wed, 30 May 2012 17:07:52 +0000 (13:07 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 30 May 2012 17:07:52 +0000 (13:07 -0400)
R=rsc, remyoudompheng, minux.ma, ality
CC=golang-dev
https://golang.org/cl/6242061

12 files changed:
src/pkg/runtime/cgocall.c
src/pkg/runtime/mgc0.c
src/pkg/runtime/mprof.goc
src/pkg/runtime/proc.c
src/pkg/runtime/runtime.h
src/pkg/runtime/thread_darwin.c
src/pkg/runtime/thread_freebsd.c
src/pkg/runtime/thread_linux.c
src/pkg/runtime/thread_netbsd.c
src/pkg/runtime/thread_openbsd.c
src/pkg/runtime/traceback_arm.c
src/pkg/runtime/traceback_x86.c

index 537a845886d3267894e481e63eb9f1074ba96e65..d9090ba67f8fc12c28abe565d12277ce3ccf4afc 100644 (file)
@@ -235,7 +235,7 @@ unwindm(void)
        case '8':
        case '6':
        case '5':
-               m->g0->sched.sp = *(void**)m->g0->sched.sp;
+               m->g0->sched.sp = *(uintptr*)m->g0->sched.sp;
                break;
        }
 }
index 5fde535a5e34527f3394db372fcc17e13768018b..5f3d20b05bb7c43bd5bcf222425ad73075e7ec41 100644 (file)
@@ -539,7 +539,7 @@ addstackroots(G *gp)
        byte *sp, *guard;
 
        stk = (Stktop*)gp->stackbase;
-       guard = gp->stackguard;
+       guard = (byte*)gp->stackguard;
 
        if(gp == g) {
                // Scanning our own stack: start at &gp.
@@ -550,17 +550,17 @@ addstackroots(G *gp)
        } else {
                // Scanning another goroutine's stack.
                // The goroutine is usually asleep (the world is stopped).
-               sp = gp->sched.sp;
+               sp = (byte*)gp->sched.sp;
 
                // The exception is that if the goroutine is about to enter or might
                // have just exited a system call, it may be executing code such
                // 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) {
+               if(gp->gcstack != (uintptr)nil) {
                        stk = (Stktop*)gp->gcstack;
-                       sp = gp->gcsp;
-                       guard = gp->gcguard;
+                       sp = (byte*)gp->gcsp;
+                       guard = (byte*)gp->gcguard;
                }
        }
 
@@ -571,7 +571,7 @@ addstackroots(G *gp)
                        runtime·throw("scanstack");
                }
                addroot(sp, (byte*)stk - sp);
-               sp = stk->gobuf.sp;
+               sp = (byte*)stk->gobuf.sp;
                guard = stk->stackguard;
                stk = (Stktop*)stk->stackbase;
                n++;
index dac897e3bbfa92716807a7a41fc90e815ecb8f8d..061cd06681980f40f94aebe4fd5529fd6afc25d6 100644 (file)
@@ -392,7 +392,7 @@ func GoroutineProfile(b Slice) (n int32, ok bool) {
                        for(gp = runtime·allg; gp != nil; gp = gp->alllink) {
                                if(gp == g || gp->status == Gdead)
                                        continue;
-                               saveg(gp->sched.pc, gp->sched.sp, gp, r++);
+                               saveg(gp->sched.pc, (byte*)gp->sched.sp, gp, r++);
                        }
                }
        
index fbc262904b1d5f36c05cd4fcdf0998fc12a95202..2c0a93dff72cae010a81eb1319b25c3df0b4b80d 100644 (file)
@@ -318,7 +318,7 @@ runtime·tracebackothers(G *me)
                        continue;
                runtime·printf("\n");
                runtime·goroutineheader(g);
-               runtime·traceback(g->sched.pc, g->sched.sp, 0, g);
+               runtime·traceback(g->sched.pc, (byte*)g->sched.sp, 0, g);
        }
 }
 
@@ -849,7 +849,7 @@ runtime·newm(void)
                        m->g0 = runtime·malg(-1);
                else
                        m->g0 = runtime·malg(8192);
-               runtime·newosproc(m, m->g0, m->g0->stackbase, runtime·mstart);
+               runtime·newosproc(m, m->g0, (byte*)m->g0->stackbase, runtime·mstart);
        }
 
        return m;
@@ -1034,7 +1034,7 @@ runtime·exitsyscall(void)
                g->status = Grunning;
                // Garbage collector isn't running (since we are),
                // so okay to clear gcstack.
-               g->gcstack = nil;
+               g->gcstack = (uintptr)nil;
 
                if(m->profilehz > 0)
                        runtime·setprof(true);
@@ -1059,7 +1059,7 @@ runtime·exitsyscall(void)
        // Must wait until now because until gosched returns
        // we don't know for sure that the garbage collector
        // is not running.
-       g->gcstack = nil;
+       g->gcstack = (uintptr)nil;
 }
 
 // Called from runtime·lessstack when returning from a function which
@@ -1090,9 +1090,9 @@ runtime·oldstack(void)
        USED(goid);
 
        if(old.free != 0)
-               runtime·stackfree(g1->stackguard - StackGuard, old.free);
-       g1->stackbase = old.stackbase;
-       g1->stackguard = old.stackguard;
+               runtime·stackfree((byte*)g1->stackguard - StackGuard, old.free);
+       g1->stackbase = (uintptr)old.stackbase;
+       g1->stackguard = (uintptr)old.stackguard;
 
        cret = m->cret;
        m->cret = 0;  // drop reference
@@ -1139,7 +1139,7 @@ runtime·newstack(void)
                // the new Stktop* is necessary to unwind, but
                // we don't need to create a new segment.
                top = (Stktop*)(m->morebuf.sp - sizeof(*top));
-               stk = g1->stackguard - StackGuard;
+               stk = (byte*)g1->stackguard - StackGuard;
                free = 0;
        } else {
                // allocate new segment.
@@ -1156,22 +1156,22 @@ runtime·newstack(void)
 //runtime·printf("newstack framesize=%d argsize=%d morepc=%p moreargp=%p gobuf=%p, %p top=%p old=%p\n",
 //framesize, argsize, m->morepc, m->moreargp, m->morebuf.pc, m->morebuf.sp, top, g1->stackbase);
 
-       top->stackbase = g1->stackbase;
-       top->stackguard = g1->stackguard;
+       top->stackbase = (byte*)g1->stackbase;
+       top->stackguard = (byte*)g1->stackguard;
        top->gobuf = m->morebuf;
        top->argp = m->moreargp;
        top->argsize = argsize;
        top->free = free;
        m->moreargp = nil;
        m->morebuf.pc = nil;
-       m->morebuf.sp = nil;
+       m->morebuf.sp = (uintptr)nil;
 
        // copy flag from panic
        top->panic = g1->ispanic;
        g1->ispanic = false;
 
-       g1->stackbase = (byte*)top;
-       g1->stackguard = stk + StackGuard;
+       g1->stackbase = (uintptr)top;
+       g1->stackguard = (uintptr)stk + StackGuard;
 
        sp = (byte*)top;
        if(argsize > 0) {
@@ -1186,7 +1186,7 @@ runtime·newstack(void)
 
        // Continue as if lessstack had just called m->morepc
        // (the PC that decided to grow the stack).
-       label.sp = sp;
+       label.sp = (uintptr)sp;
        label.pc = (byte*)runtime·lessstack;
        label.g = m->curg;
        runtime·gogocall(&label, m->morepc);
@@ -1229,10 +1229,10 @@ runtime·malg(int32 stacksize)
                        stk = g->param;
                        g->param = nil;
                }
-               newg->stack0 = stk;
-               newg->stackguard = stk + StackGuard;
-               newg->stackbase = stk + StackSystem + stacksize - sizeof(Stktop);
-               runtime·memclr(newg->stackbase, sizeof(Stktop));
+               newg->stack0 = (uintptr)stk;
+               newg->stackguard = (uintptr)stk + StackGuard;
+               newg->stackbase = (uintptr)stk + StackSystem + stacksize - sizeof(Stktop);
+               runtime·memclr((byte*)newg->stackbase, sizeof(Stktop));
        }
        return newg;
 }
@@ -1295,7 +1295,7 @@ runtime·newproc1(byte *fn, byte *argp, int32 narg, int32 nret, void *callerpc)
        newg->status = Gwaiting;
        newg->waitreason = "new goroutine";
 
-       sp = newg->stackbase;
+       sp = (byte*)newg->stackbase;
        sp -= siz;
        runtime·memmove(sp, argp, narg);
        if(thechar == '5') {
@@ -1304,7 +1304,7 @@ runtime·newproc1(byte *fn, byte *argp, int32 narg, int32 nret, void *callerpc)
                *(void**)sp = nil;
        }
 
-       newg->sched.sp = sp;
+       newg->sched.sp = (uintptr)sp;
        newg->sched.pc = (byte*)runtime·goexit;
        newg->sched.g = newg;
        newg->entry = fn;
@@ -1332,8 +1332,12 @@ uintptr
 runtime·deferproc(int32 siz, byte* fn, ...)
 {
        Defer *d;
-
-       d = runtime·malloc(sizeof(*d) + siz - sizeof(d->args));
+       int32 mallocsiz;
+       mallocsiz = sizeof(*d);
+       if(siz > sizeof(d->args))
+               mallocsiz += siz - sizeof(d->args);
+       d = runtime·malloc(mallocsiz);
        d->fn = fn;
        d->siz = siz;
        d->pc = runtime·getcallerpc(&siz);
@@ -1394,7 +1398,7 @@ rundefer(void)
 
        while((d = g->defer) != nil) {
                g->defer = d->link;
-               reflect·call(d->fn, d->args, d->siz);
+               reflect·call(d->fn, (byte*)d->args, d->siz);
                if(!d->nofree)
                        runtime·free(d);
        }
@@ -1413,16 +1417,16 @@ unwindstack(G *gp, byte *sp)
                runtime·throw("unwindstack on self");
 
        while((top = (Stktop*)gp->stackbase) != nil && top->stackbase != nil) {
-               stk = gp->stackguard - StackGuard;
-               if(stk <= sp && sp < gp->stackbase)
+               stk = (byte*)gp->stackguard - StackGuard;
+               if(stk <= sp && sp < (byte*)gp->stackbase)
                        break;
-               gp->stackbase = top->stackbase;
-               gp->stackguard = top->stackguard;
+               gp->stackbase = (uintptr)top->stackbase;
+               gp->stackguard = (uintptr)top->stackguard;
                if(top->free != 0)
                        runtime·stackfree(stk, top->free);
        }
 
-       if(sp != nil && (sp < gp->stackguard - StackGuard || gp->stackbase < sp)) {
+       if(sp != nil && (sp < (byte*)gp->stackguard - StackGuard || (byte*)gp->stackbase < sp)) {
                runtime·printf("recover: %p not in [%p, %p]\n", sp, gp->stackguard - StackGuard, gp->stackbase);
                runtime·throw("bad unwindstack");
        }
@@ -1455,7 +1459,7 @@ runtime·panic(Eface e)
        p = runtime·mal(sizeof *p);
        p->arg = e;
        p->link = g->panic;
-       p->stackbase = g->stackbase;
+       p->stackbase = (byte*)g->stackbase;
        g->panic = p;
 
        for(;;) {
@@ -1465,7 +1469,7 @@ runtime·panic(Eface e)
                // take defer off list in case of recursive panic
                g->defer = d->link;
                g->ispanic = true;      // rock for newstack, where reflect.call ends up
-               reflect·call(d->fn, d->args, d->siz);
+               reflect·call(d->fn, (byte*)d->args, d->siz);
                if(p->recovered) {
                        g->panic = p->link;
                        if(g->panic == nil)     // must be done with signal
@@ -1513,9 +1517,9 @@ recovery(G *gp)
        // before it tests the return value.)
        // On the arm there are 2 saved LRs mixed in too.
        if(thechar == '5')
-               gp->sched.sp = (byte*)d->argp - 4*sizeof(uintptr);
+               gp->sched.sp = (uintptr)d->argp - 4*sizeof(uintptr);
        else
-               gp->sched.sp = (byte*)d->argp - 2*sizeof(uintptr);
+               gp->sched.sp = (uintptr)d->argp - 2*sizeof(uintptr);
        gp->sched.pc = d->pc;
        if(!d->nofree)
                runtime·free(d);
index 8a7c9c68a51756ea513590ca461571658935044e..cdd71726e5aa9e881e8170a61dbb45a577d32b51 100644 (file)
@@ -167,7 +167,7 @@ struct      Slice
 struct Gobuf
 {
        // The offsets of these fields are known to (hard-coded in) libmach.
-       byte*   sp;
+       uintptr sp;
        byte*   pc;
        G*      g;
 };
@@ -183,15 +183,15 @@ struct    GCStats
 };
 struct G
 {
-       byte*   stackguard;     // cannot move - also known to linker, libmach, runtime/cgo
-       byte*   stackbase;      // cannot move - also known to libmach, runtime/cgo
+       uintptr stackguard;     // cannot move - also known to linker, libmach, runtime/cgo
+       uintptr stackbase;      // cannot move - also known to libmach, runtime/cgo
        Defer*  defer;
        Panic*  panic;
        Gobuf   sched;
-       byte*   gcstack;                // if status==Gsyscall, gcstack = stackbase to use during gc
-       byte*   gcsp;           // if status==Gsyscall, gcsp = sched.sp to use during gc
-       byte*   gcguard;                // if status==Gsyscall, gcguard = stackguard to use during gc
-       byte*   stack0;
+       uintptr gcstack;                // if status==Gsyscall, gcstack = stackbase to use during gc
+       uintptr gcsp;           // if status==Gsyscall, gcsp = sched.sp to use during gc
+       uintptr gcguard;                // if status==Gsyscall, gcguard = stackguard to use during gc
+       uintptr stack0;
        byte*   entry;          // initial function
        G*      alllink;        // on allg
        void*   param;          // passed parameter on wakeup
@@ -486,7 +486,7 @@ struct Defer
        byte*   pc;
        byte*   fn;
        Defer*  link;
-       byte    args[8];        // padded to actual size
+       void*   args[1];        // padded to actual size
 };
 
 /*
index a0fb5272f7c4073af60defc05d33461f13b5e919..bfdd9873ea8bc4d9c90c53a7389d76272f3114ed 100644 (file)
@@ -114,7 +114,7 @@ runtime·minit(void)
 {
        // Initialize signal handling.
        m->gsignal = runtime·malg(32*1024);    // OS X wants >=8K, Linux >=2K
-       runtime·signalstack(m->gsignal->stackguard - StackGuard, 32*1024);
+       runtime·signalstack((byte*)m->gsignal->stackguard - StackGuard, 32*1024);
 
        if(m->profilehz > 0)
                runtime·sigprocmask(SIG_SETMASK, &sigset_none, nil);
index 4c546178f45b3c89573110bcc16d895aae7e6277..1597b1e88b10eae186bb6c1eef6bb68f2f6de0aa 100644 (file)
@@ -126,7 +126,7 @@ runtime·minit(void)
 {
        // Initialize signal handling
        m->gsignal = runtime·malg(32*1024);
-       runtime·signalstack(m->gsignal->stackguard - StackGuard, 32*1024);
+       runtime·signalstack((byte*)m->gsignal->stackguard - StackGuard, 32*1024);
        runtime·sigprocmask(&sigset_none, nil);
 }
 
index 858be70360a8d232080eaff3422aaa74f9e8567b..5db074175c91cdc99ed7e76877e0625fa209aa8e 100644 (file)
@@ -186,7 +186,7 @@ runtime·minit(void)
 {
        // Initialize signal handling.
        m->gsignal = runtime·malg(32*1024);    // OS X wants >=8K, Linux >=2K
-       runtime·signalstack(m->gsignal->stackguard - StackGuard, 32*1024);
+       runtime·signalstack((byte*)m->gsignal->stackguard - StackGuard, 32*1024);
        runtime·rtsigprocmask(SIG_SETMASK, &sigset_none, nil, sizeof sigset_none);
 }
 
index 72557c713e66468e0da5f5e56c2883599d01fdcf..d87c6b003e73da4efad3ddc135c298712bcd58ad 100644 (file)
@@ -198,7 +198,7 @@ runtime·minit(void)
 {
        // Initialize signal handling
        m->gsignal = runtime·malg(32*1024);
-       runtime·signalstack(m->gsignal->stackguard - StackGuard, 32*1024);
+       runtime·signalstack((byte*)m->gsignal->stackguard - StackGuard, 32*1024);
        runtime·sigprocmask(SIG_SETMASK, &sigset_none, nil);
 }
 
index 56bb1c8ebffed8aca5eae2a9bb6112ebfe3f2b6f..4e4db747457bc21da41874e88104342abe018e6e 100644 (file)
@@ -171,7 +171,7 @@ runtime·minit(void)
 {
        // Initialize signal handling
        m->gsignal = runtime·malg(32*1024);
-       runtime·signalstack(m->gsignal->stackguard - StackGuard, 32*1024);
+       runtime·signalstack((byte*)m->gsignal->stackguard - StackGuard, 32*1024);
        runtime·sigprocmask(SIG_SETMASK, sigset_none);
 }
 
index 22e0bc3a66377369e4b3645a308a419e8aac0d48..9ca54784ff9f43b025a1985a530d7a82f73886df 100644 (file)
@@ -57,7 +57,7 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
                if(pc == (uintptr)runtime·lessstack) {
                        // Hit top of stack segment.  Unwind to next segment.
                        pc = (uintptr)stk->gobuf.pc;
-                       sp = stk->gobuf.sp;
+                       sp = (byte*)stk->gobuf.sp;
                        lr = 0;
                        fp = nil;
                        if(pcbuf == nil)
@@ -151,7 +151,7 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
                        pc = (uintptr)m->morepc;
                        sp = (byte*)m->moreargp - sizeof(void*);
                        lr = (uintptr)m->morebuf.pc;
-                       fp = m->morebuf.sp;
+                       fp = (byte*)m->morebuf.sp;
                        g = m->curg;
                        stk = (Stktop*)g->stackbase;
                        continue;
@@ -161,7 +161,7 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
                        runtime·printf("----- lessstack called from goroutine %d -----\n", m->curg->goid);
                        g = m->curg;
                        stk = (Stktop*)g->stackbase;
-                       sp = stk->gobuf.sp;
+                       sp = (byte*)stk->gobuf.sp;
                        pc = (uintptr)stk->gobuf.pc;
                        fp = nil;
                        lr = 0;
index be35bab002500e54cb2a266d8f246f2e6e5924b1..5a307de3b5268a0f1c5bd6336d4a9744ebf6ae7c 100644 (file)
@@ -40,7 +40,7 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
        waspanic = false;
        
        // If the PC is goexit, the goroutine hasn't started yet.
-       if(pc0 == g->sched.pc && sp == g->sched.sp && pc0 == (byte*)runtime·goexit) {
+       if(pc0 == g->sched.pc && sp == (byte*)g->sched.sp && pc0 == (byte*)runtime·goexit) {
                fp = sp;
                lr = pc;
                pc = (uintptr)g->entry;
@@ -74,7 +74,7 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
                if(pc == (uintptr)runtime·lessstack) {
                        // Hit top of stack segment.  Unwind to next segment.
                        pc = (uintptr)stk->gobuf.pc;
-                       sp = stk->gobuf.sp;
+                       sp = (byte*)stk->gobuf.sp;
                        lr = 0;
                        fp = nil;
                        if(pcbuf == nil)
@@ -167,9 +167,9 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
                        // use it to keep unwinding the stack.
                        runtime·printf("----- morestack called from goroutine %d -----\n", m->curg->goid);
                        pc = (uintptr)m->morepc;
-                       sp = m->morebuf.sp - sizeof(void*);
+                       sp = (byte*)m->morebuf.sp - sizeof(void*);
                        lr = (uintptr)m->morebuf.pc;
-                       fp = m->morebuf.sp;
+                       fp = (byte*)m->morebuf.sp;
                        sawnewstack = 0;
                        g = m->curg;
                        stk = (Stktop*)g->stackbase;
@@ -181,7 +181,7 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
                        runtime·printf("----- lessstack called from goroutine %d -----\n", m->curg->goid);
                        g = m->curg;
                        stk = (Stktop*)g->stackbase;
-                       sp = stk->gobuf.sp;
+                       sp = (byte*)stk->gobuf.sp;
                        pc = (uintptr)stk->gobuf.pc;
                        fp = nil;
                        lr = 0;