1
0
mirror of https://github.com/golang/go synced 2024-11-23 21:20:03 -07:00

[dev.regabi] cmd/compile: tweak hash bucket type descriptor

There's no need for the bucket type to be precise. The compiler
doesn't actually generate code that references these fields; it just
needs it for size and GC bitmap calculations.

However, changing the type field does alter the runtime type
descriptor and relocations emitted by the compiler, so this change
isn't safe for toolstash.

Change-Id: Icf79d6c4326515889b13435a575d618e3bbfbcd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/274712
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Matthew Dempsky 2020-12-01 13:38:26 -08:00
parent 1408d26ccc
commit 15085f8974

View File

@ -85,7 +85,6 @@ func bmap(t *types.Type) *types.Type {
return t.MapType().Bucket
}
bucket := types.New(types.TSTRUCT)
keytype := t.Key()
elemtype := t.Elem()
dowidth(keytype)
@ -119,7 +118,7 @@ func bmap(t *types.Type) *types.Type {
// Arrange for the bucket to have no pointers by changing
// the type of the overflow field to uintptr in this case.
// See comment on hmap.overflow in runtime/map.go.
otyp := types.NewPtr(bucket)
otyp := types.Types[types.TUNSAFEPTR]
if !elemtype.HasPointers() && !keytype.HasPointers() {
otyp = types.Types[types.TUINTPTR]
}
@ -127,6 +126,7 @@ func bmap(t *types.Type) *types.Type {
field = append(field, overflow)
// link up fields
bucket := types.New(types.TSTRUCT)
bucket.SetNoalg(true)
bucket.SetFields(field[:])
dowidth(bucket)