From: Ian Lance Taylor Date: Thu, 4 Dec 2025 21:49:21 +0000 (-0800) Subject: cmd/compile, runtime: set alignment of type descriptors X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a430bc1bd73ab9a7d4a0c740add9760914588396;p=gostls13.git cmd/compile, runtime: set alignment of type descriptors 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 LUCI-TryBot-Result: Go LUCI Reviewed-by: Keith Randall Reviewed-by: Carlos Amedee Reviewed-by: Keith Randall Auto-Submit: Ian Lance Taylor --- diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index c3f041ec57..ea3d0b5b94 100644 --- a/src/cmd/compile/internal/reflectdata/reflect.go +++ b/src/cmd/compile/internal/reflectdata/reflect.go @@ -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 } diff --git a/src/runtime/type.go b/src/runtime/type.go index ae8da3bc29..1abd271c3f 100644 --- a/src/runtime/type.go +++ b/src/runtime/type.go @@ -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)