]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: don't generate algs for internal map types.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Sat, 14 Sep 2013 07:30:36 +0000 (09:30 +0200)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Sat, 14 Sep 2013 07:30:36 +0000 (09:30 +0200)
Fake types describing the internal structure of hashmaps are
generated for use by precise GC.

Generating hash and eq functions for these fake types slows down
the build and wastes space: the go tool binary size is 13MB
instead of 12MB, and the package size on amd64 is 48.7MB instead
of 45.3MB.

R=golang-dev, daniel.morsing, r, khr, rsc, iant
CC=golang-dev
https://golang.org/cl/13698043

src/cmd/gc/go.h
src/cmd/gc/reflect.c
src/cmd/gc/subr.c

index ba73508b8f71bbd35d127815bf5e2c9b1b38b027..59e241bbe3209f1515864e1d2cb7763422107104 100644 (file)
@@ -141,6 +141,7 @@ struct      Type
 {
        uchar   etype;
        uchar   nointerface;
+       uchar   noalg;
        uchar   chan;
        uchar   trecur;         // to detect loops
        uchar   printed;
index d204301b595a0380a19995752e2153af97eae9a7..ea66eb94b202cc234869bc3a62698177dfd46ffa 100644 (file)
@@ -131,6 +131,7 @@ mapbucket(Type *t)
                valtype = ptrto(valtype);
 
        bucket = typ(TSTRUCT);
+       bucket->noalg = 1;
 
        // The first field is: uint8 topbits[BUCKETSIZE].
        // We don't need to encode it as GC doesn't care about it.
@@ -192,6 +193,7 @@ hmap(Type *t)
 
        bucket = mapbucket(t);
        h = typ(TSTRUCT);
+       h->noalg = 1;
 
        offset = widthint; // count
        offset += 4;       // flags
index 3b3b576312fab0fa70d17db14d3ab473f94061e2..b529e2cc9aa93c4eebe98b982d5c515ad012d4f1 100644 (file)
@@ -547,6 +547,9 @@ algtype1(Type *t, Type **bad)
        if(bad)
                *bad = T;
 
+       if(t->noalg)
+               return ANOEQ;
+
        switch(t->etype) {
        case TANY:
        case TFORW: