Commit f238049a authored by Keith Randall's avatar Keith Randall

cmd/gc: fix special-casing of the printed names of map internal structures.

Shaves 1% off of binary size.

update #6853

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/35940047
parent 0368a7ce
...@@ -702,13 +702,17 @@ typefmt(Fmt *fp, Type *t) ...@@ -702,13 +702,17 @@ typefmt(Fmt *fp, Type *t)
case TSTRUCT: case TSTRUCT:
// Format the bucket struct for map[x]y as map.bucket[x]y. // Format the bucket struct for map[x]y as map.bucket[x]y.
// This avoids a recursive print that generates very long names. // This avoids a recursive print that generates very long names.
if(t->hmap != T) { if(t->map != T) {
t = t->hmap; if(t->map->bucket == t) {
return fmtprint(fp, "map.bucket[%T]%T", t->down, t->type); return fmtprint(fp, "map.bucket[%T]%T", t->map->down, t->map->type);
} }
if(t->hiter != T) { if(t->map->hmap == t) {
t = t->hiter; return fmtprint(fp, "map.hdr[%T]%T", t->map->down, t->map->type);
return fmtprint(fp, "map.iter[%T]%T", t->down, t->type); }
if(t->map->hiter == t) {
return fmtprint(fp, "map.iter[%T]%T", t->map->down, t->map->type);
}
yyerror("unknown internal map type");
} }
if(t->funarg) { if(t->funarg) {
......
...@@ -191,6 +191,7 @@ struct Type ...@@ -191,6 +191,7 @@ struct Type
Type* bucket; // internal type representing a hash bucket Type* bucket; // internal type representing a hash bucket
Type* hmap; // internal type representing a Hmap (map header object) Type* hmap; // internal type representing a Hmap (map header object)
Type* hiter; // internal type representing hash iterator state Type* hiter; // internal type representing hash iterator state
Type* map; // link from the above 3 internal types back to the map type.
int32 maplineno; // first use of TFORW as map key int32 maplineno; // first use of TFORW as map key
int32 embedlineno; // first use of TFORW as embedded type int32 embedlineno; // first use of TFORW as embedded type
......
...@@ -173,6 +173,7 @@ mapbucket(Type *t) ...@@ -173,6 +173,7 @@ mapbucket(Type *t)
bucket->width = offset; bucket->width = offset;
bucket->local = t->local; bucket->local = t->local;
t->bucket = bucket; t->bucket = bucket;
bucket->map = t;
return bucket; return bucket;
} }
...@@ -229,7 +230,7 @@ hmap(Type *t) ...@@ -229,7 +230,7 @@ hmap(Type *t)
h->width = offset; h->width = offset;
h->local = t->local; h->local = t->local;
t->hmap = h; t->hmap = h;
h->hmap = t; h->map = t;
return h; return h;
} }
...@@ -308,7 +309,7 @@ hiter(Type *t) ...@@ -308,7 +309,7 @@ hiter(Type *t)
if(off != 11 * widthptr) if(off != 11 * widthptr)
yyerror("hash_iter size not correct %d %d", off, 11 * widthptr); yyerror("hash_iter size not correct %d %d", off, 11 * widthptr);
t->hiter = i; t->hiter = i;
i->hiter = t; i->map = t;
return i; return i;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment