From 15085f89746762e0919fa257feac3eb5b996e6db Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Tue, 1 Dec 2020 13:38:26 -0800 Subject: [PATCH] [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 Run-TryBot: Matthew Dempsky TryBot-Result: Go Bot Reviewed-by: Russ Cox --- src/cmd/compile/internal/gc/reflect.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/compile/internal/gc/reflect.go b/src/cmd/compile/internal/gc/reflect.go index 06b91ddae64..0b860b5f7a4 100644 --- a/src/cmd/compile/internal/gc/reflect.go +++ b/src/cmd/compile/internal/gc/reflect.go @@ -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)