]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: remove dead code
authorDmitriy Vyukov <dvyukov@google.com>
Sun, 4 Aug 2013 19:32:06 +0000 (23:32 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Sun, 4 Aug 2013 19:32:06 +0000 (23:32 +0400)
Remove dead code related to allocation of type metadata with SysAlloc.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12311045

src/pkg/runtime/malloc.goc
src/pkg/runtime/malloc.h
src/pkg/runtime/mgc0.c
src/pkg/runtime/mheap.c

index 67da7ed846168a2c2cefe68b450f9a714ad99312..9ab8e0756da3b5faa6f15130d57c5399c7f70177 100644 (file)
@@ -116,7 +116,7 @@ runtime·mallocgc(uintptr size, uintptr typ, uint32 flag)
 
        m->mallocing = 0;
        if(UseSpanType && !(flag & FlagNoPointers) && typ != 0 && m->settype_bufsize == nelem(m->settype_buf))
-               runtime·settype_flush(m, false);
+               runtime·settype_flush(m);
        m->locks--;
        if(m->locks == 0 && g->preempt)  // restore the preemption request in case we've cleared it in newstack
                g->stackguard0 = StackPreempt;
@@ -563,14 +563,13 @@ runtime·persistentalloc(uintptr size, uintptr align)
 static Lock settype_lock;
 
 void
-runtime·settype_flush(M *mp, bool sysalloc)
+runtime·settype_flush(M *mp)
 {
        uintptr *buf, *endbuf;
        uintptr size, ofs, j, t;
        uintptr ntypes, nbytes2, nbytes3;
        uintptr *data2;
        byte *data3;
-       bool sysalloc3;
        void *v;
        uintptr typ, p;
        MSpan *s;
@@ -605,20 +604,9 @@ runtime·settype_flush(M *mp, bool sysalloc)
                case MTypes_Empty:
                        ntypes = (s->npages << PageShift) / size;
                        nbytes3 = 8*sizeof(uintptr) + 1*ntypes;
-
-                       if(!sysalloc) {
-                               data3 = runtime·mallocgc(nbytes3, 0, FlagNoProfiling|FlagNoPointers|FlagNoInvokeGC);
-                       } else {
-                               data3 = runtime·SysAlloc(nbytes3);
-                               if(data3 == nil)
-                                       runtime·throw("runtime: cannot allocate memory");
-                               if(0) runtime·printf("settype(0->3): SysAlloc(%x) --> %p\n", (uint32)nbytes3, data3);
-                       }
-
+                       data3 = runtime·mallocgc(nbytes3, 0, FlagNoProfiling|FlagNoPointers|FlagNoInvokeGC);
                        s->types.compression = MTypes_Bytes;
-                       s->types.sysalloc = sysalloc;
                        s->types.data = (uintptr)data3;
-
                        ((uintptr*)data3)[1] = typ;
                        data3[8*sizeof(uintptr) + ofs] = 1;
                        break;
@@ -643,20 +631,8 @@ runtime·settype_flush(M *mp, bool sysalloc)
                        } else {
                                ntypes = (s->npages << PageShift) / size;
                                nbytes2 = ntypes * sizeof(uintptr);
-
-                               if(!sysalloc) {
-                                       data2 = runtime·mallocgc(nbytes2, 0, FlagNoProfiling|FlagNoPointers|FlagNoInvokeGC);
-                               } else {
-                                       data2 = runtime·SysAlloc(nbytes2);
-                                       if(data2 == nil)
-                                               runtime·throw("runtime: cannot allocate memory");
-                                       if(0) runtime·printf("settype.(3->2): SysAlloc(%x) --> %p\n", (uint32)nbytes2, data2);
-                               }
-
-                               sysalloc3 = s->types.sysalloc;
-
+                               data2 = runtime·mallocgc(nbytes2, 0, FlagNoProfiling|FlagNoPointers|FlagNoInvokeGC);
                                s->types.compression = MTypes_Words;
-                               s->types.sysalloc = sysalloc;
                                s->types.data = (uintptr)data2;
 
                                // Move the contents of data3 to data2. Then deallocate data3.
@@ -665,12 +641,6 @@ runtime·settype_flush(M *mp, bool sysalloc)
                                        t = ((uintptr*)data3)[t];
                                        data2[j] = t;
                                }
-                               if(sysalloc3) {
-                                       nbytes3 = 8*sizeof(uintptr) + 1*ntypes;
-                                       if(0) runtime·printf("settype.(3->2): SysFree(%p,%x)\n", data3, (uint32)nbytes3);
-                                       runtime·SysFree(data3, nbytes3);
-                               }
-
                                data2[ofs] = typ;
                        }
                        break;
@@ -681,33 +651,6 @@ runtime·settype_flush(M *mp, bool sysalloc)
        mp->settype_bufsize = 0;
 }
 
-void
-runtime·settype_sysfree(MSpan *s)
-{
-       uintptr ntypes, nbytes;
-
-       if(!s->types.sysalloc)
-               return;
-
-       nbytes = (uintptr)-1;
-
-       switch (s->types.compression) {
-       case MTypes_Words:
-               ntypes = (s->npages << PageShift) / s->elemsize;
-               nbytes = ntypes * sizeof(uintptr);
-               break;
-       case MTypes_Bytes:
-               ntypes = (s->npages << PageShift) / s->elemsize;
-               nbytes = 8*sizeof(uintptr) + 1*ntypes;
-               break;
-       }
-
-       if(nbytes != (uintptr)-1) {
-               if(0) runtime·printf("settype: SysFree(%p,%x)\n", (void*)s->types.data, (uint32)nbytes);
-               runtime·SysFree((void*)s->types.data, nbytes);
-       }
-}
-
 uintptr
 runtime·gettype(void *v)
 {
index 584fc83486eed0b26667af61147f081ee485689a..20cf6fb96b04b9fbc51a58f5bb9a0d9e6ff27d2a 100644 (file)
@@ -334,7 +334,6 @@ enum
 struct MTypes
 {
        byte    compression;    // one of MTypes_*
-       bool    sysalloc;       // whether (void*)data is from runtime·SysAlloc
        uintptr data;
 };
 
@@ -459,7 +458,7 @@ void        runtime·purgecachedstats(MCache*);
 void*  runtime·cnew(Type*);
 void*  runtime·cnewarray(Type*, intgo);
 
-void   runtime·settype_flush(M*, bool);
+void   runtime·settype_flush(M*);
 void   runtime·settype_sysfree(MSpan*);
 uintptr        runtime·gettype(void*);
 
index 3f56a799e21e6deb7c4d672d6e0f48cc66d2d8a1..b72199847e343c50524308c34729f6956229ffce 100644 (file)
@@ -2084,7 +2084,7 @@ gc(struct gc_args *args)
                runtime·memclr((byte*)&gcstats, sizeof(gcstats));
 
        for(mp=runtime·allm; mp; mp=mp->alllink)
-               runtime·settype_flush(mp, false);
+               runtime·settype_flush(mp);
 
        heap0 = 0;
        obj0 = 0;
index 6dd5fa9bf9b63d1a42d8f745037cccc98440cd8a..53aa7143361d5d51237f5ad93255c50d8d90ca4b 100644 (file)
@@ -330,8 +330,6 @@ MHeap_FreeLocked(MHeap *h, MSpan *s)
        MSpan *t;
        PageID p;
 
-       if(s->types.sysalloc)
-               runtime·settype_sysfree(s);
        s->types.compression = MTypes_Empty;
 
        if(s->state != MSpanInUse || s->ref != 0) {