]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: tweak hash bucket type descriptor
authorMatthew Dempsky <mdempsky@google.com>
Tue, 1 Dec 2020 21:38:26 +0000 (13:38 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 2 Dec 2020 06:37:47 +0000 (06:37 +0000)
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>
src/cmd/compile/internal/gc/reflect.go

index 06b91ddae64bc1f997c322e07bbc9ecf15df03b4..0b860b5f7a404d9e391eebf5f45501d977a4bc98 100644 (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)