From: Josh Bleecher Snyder Date: Mon, 4 May 2015 22:01:03 +0000 (-0700) Subject: cmd/compile: don't generate algs for map buckets X-Git-Tag: go1.7beta1~509 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a6abc1cd70bf561d1e4c10d53499733c502c30b5;p=gostls13.git cmd/compile: don't generate algs for map buckets Note that this is only safe because the compiler generates multiple distinct gc.Types. If we switch to having canonical gc.Types, then this will need to be updated to handle the case in which the user uses both map[T]S and also map[[8]T]S. In that case, the runtime needs algs for [8]T, but this could mark the sole [8]T type as Noalg. This is a general problem with having a single bool to represent whether alg generation is needed for a type. Cuts 5k off cmd/go and 22k off golang.org/x/tools/cmd/godoc, approx 0.04% and 0.12% respectively. For #6853 and #9930 Change-Id: I30a15ec72ecb62e2aa053260a7f0f75015fc0ade Reviewed-on: https://go-review.googlesource.com/19769 Reviewed-by: David Crawshaw Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot --- diff --git a/src/cmd/compile/internal/gc/reflect.go b/src/cmd/compile/internal/gc/reflect.go index 49d55091ff..727b9939e9 100644 --- a/src/cmd/compile/internal/gc/reflect.go +++ b/src/cmd/compile/internal/gc/reflect.go @@ -102,13 +102,18 @@ func mapbucket(t *Type) *Type { valtype = Ptrto(valtype) } + field := make([]*Field, 0, 5) + // The first field is: uint8 topbits[BUCKETSIZE]. arr := typArray(Types[TUINT8], BUCKETSIZE) - field := make([]*Field, 0, 5) field = append(field, makefield("topbits", arr)) + arr = typArray(keytype, BUCKETSIZE) + arr.Noalg = true field = append(field, makefield("keys", arr)) + arr = typArray(valtype, BUCKETSIZE) + arr.Noalg = true field = append(field, makefield("values", arr)) // Make sure the overflow pointer is the last memory in the struct,