Description
The compiler supports SetNoAlg on types. This brings binary space savings by not needing to generate equality functions for those types. Applying this setting to backing arrays of slices (#32595) and maps (#47068) has introduced bugs into go binaries in the past because values of types that should be equal didnt compare equal as internally they were different types.
The general fix and even better space saving impact would be to have the compiler/linker deduplicate noalg with alg type descriptors giving preference to alg descriptors that link algorithms. See discussion with @mdempsky #47068 (comment)
Alternatively the compiler and linker combination could be smart enough to understand if algs can ever be used because the type is never exposed directly to user code. While this is more general and automatic, it would be more complex and require more work during compilation/linking instead of annotating the places where it is the case manually using SetNoAlg in the compiler.
Once this is ready we can save binary space by:
- not storing type descriptors for alg and noalg types that are otherwise the same
- avoid backing array type algs of slice literals (
go/src/cmd/compile/internal/walk/complit.go
Line 306 in 457418b
- avoid backing array type algs of slices used for map initialisation (
go/src/cmd/compile/internal/walk/complit.go
Line 443 in 457418b
- internally generated backing arrays of defer checks
- ... (more)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status