]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile, runtime: set alignment of type descriptors
authorIan Lance Taylor <iant@golang.org>
Thu, 4 Dec 2025 21:49:21 +0000 (13:49 -0800)
committerGopher Robot <gobot@golang.org>
Wed, 11 Feb 2026 05:27:59 +0000 (21:27 -0800)
This trivial change reduces the size of cmd/go by 88K.

For #6853
For #36313

Change-Id: I5e74acf118bd1c63cbdd256879d8aa8d72a50505
Reviewed-on: https://go-review.googlesource.com/c/go/+/727021
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

src/cmd/compile/internal/reflectdata/reflect.go
src/runtime/type.go

index c3f041ec572910f5b2052ea0e6c07fc17c09b9ad..ea3d0b5b9482c3596c84332d310c6ca69b2f80b2 100644 (file)
@@ -963,6 +963,7 @@ func writeType(t *types.Type) *obj.LSym {
                keep = false
        }
        lsym.Set(obj.AttrMakeTypelink, keep)
+       lsym.Align = int16(types.PtrSize)
 
        return lsym
 }
index ae8da3bc2927813f5827ae561bd792a213728106..1abd271c3fe845c63231c6a725d5f85ff919d81e 100644 (file)
@@ -535,16 +535,7 @@ func moduleTypelinks(md *moduledata) []*_type {
 
        etypedesc := md.types + md.typedesclen
        for td < etypedesc {
-               // TODO: The fact that type descriptors are aligned to
-               // 0x20 does not make sense.
-               if GOARCH == "arm" {
-                       td = alignUp(td, 0x8)
-               } else if GOOS == "aix" {
-                       // The alignment of 8 is forced in the linker on AIX.
-                       td = alignUp(td, 0x8)
-               } else {
-                       td = alignUp(td, 0x20)
-               }
+               td = alignUp(td, goarch.PtrSize)
 
                typ := (*_type)(unsafe.Pointer(td))
                ret = append(ret, typ)