Skip to content

Commit a6abc1c

Browse files
committed
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 <[email protected]> Run-TryBot: Josh Bleecher Snyder <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent b6b144b commit a6abc1c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/cmd/compile/internal/gc/reflect.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,18 @@ func mapbucket(t *Type) *Type {
102102
valtype = Ptrto(valtype)
103103
}
104104

105+
field := make([]*Field, 0, 5)
106+
105107
// The first field is: uint8 topbits[BUCKETSIZE].
106108
arr := typArray(Types[TUINT8], BUCKETSIZE)
107-
field := make([]*Field, 0, 5)
108109
field = append(field, makefield("topbits", arr))
110+
109111
arr = typArray(keytype, BUCKETSIZE)
112+
arr.Noalg = true
110113
field = append(field, makefield("keys", arr))
114+
111115
arr = typArray(valtype, BUCKETSIZE)
116+
arr.Noalg = true
112117
field = append(field, makefield("values", arr))
113118

114119
// Make sure the overflow pointer is the last memory in the struct,

0 commit comments

Comments
 (0)