]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: simplify code
authorDmitriy Vyukov <dvyukov@google.com>
Mon, 21 Jul 2014 21:56:01 +0000 (01:56 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Mon, 21 Jul 2014 21:56:01 +0000 (01:56 +0400)
LGTM=khr
R=golang-codereviews, dave, khr
CC=golang-codereviews, rsc
https://golang.org/cl/116950043

src/pkg/runtime/mgc0.c

index 2d478acdc4d02df1a2fc54e6edc71a0317a3874c..79eaca61cb4b27118f51700a66819f398b89e3f1 100644 (file)
@@ -219,10 +219,6 @@ static struct {
        volatile uint32 ndone;
        Note    alldone;
        ParFor  *markfor;
-
-       Lock;
-       byte    *chunk;
-       uintptr nchunk;
 } work;
 
 enum {
@@ -1310,20 +1306,8 @@ getempty(Workbuf *b)
        if(b != nil)
                runtime·lfstackpush(&work.full, &b->node);
        b = (Workbuf*)runtime·lfstackpop(&work.empty);
-       if(b == nil) {
-               // Need to allocate.
-               runtime·lock(&work);
-               if(work.nchunk < sizeof *b) {
-                       work.nchunk = 1<<20;
-                       work.chunk = runtime·SysAlloc(work.nchunk, &mstats.gc_sys);
-                       if(work.chunk == nil)
-                               runtime·throw("runtime: cannot allocate memory");
-               }
-               b = (Workbuf*)work.chunk;
-               work.chunk += sizeof *b;
-               work.nchunk -= sizeof *b;
-               runtime·unlock(&work);
-       }
+       if(b == nil)
+               b = runtime·persistentalloc(sizeof(*b), CacheLineSize, &mstats.gc_sys);
        b->nobj = 0;
        return b;
 }