From 8c98b395a1b819fbae0e3c08407e3ed12e936ce8 Mon Sep 17 00:00:00 2001 From: Mateusz Poliwczak Date: Tue, 18 Feb 2025 20:44:34 +0100 Subject: [PATCH 1/3] cmd/compile: reduce size of miniExpr by 8 bytes By moving the bit field, we can reduce the miniExpr size by 8 bytes, reducing the sizes of Exprs embedding this type. Hopefully we get a few types to a lower memory size class. Change-Id: Idc03cbc7107458f1f3ae04be402edeefc599bff6 --- src/cmd/compile/internal/ir/expr.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/compile/internal/ir/expr.go b/src/cmd/compile/internal/ir/expr.go index 4a2e996569450d..5bd26fc14562f6 100644 --- a/src/cmd/compile/internal/ir/expr.go +++ b/src/cmd/compile/internal/ir/expr.go @@ -24,12 +24,12 @@ type Expr interface { // A miniExpr is a miniNode with extra fields common to expressions. // TODO(rsc): Once we are sure about the contents, compact the bools // into a bit field and leave extra bits available for implementations -// embedding miniExpr. Right now there are ~60 unused bits sitting here. +// embedding miniExpr. Right now there are ~24 unused bits sitting here. type miniExpr struct { miniNode + flags bitset8 typ *types.Type init Nodes // TODO(rsc): Don't require every Node to have an init - flags bitset8 } const ( From 142a8de6dd9c861cec081c1c6c34f7c27e3aced6 Mon Sep 17 00:00:00 2001 From: Mateusz Poliwczak Date: Tue, 18 Feb 2025 21:09:04 +0100 Subject: [PATCH 2/3] update test Change-Id: I586c4e3395d36464a657e8fa8256f74290630af3 --- src/cmd/compile/internal/ir/sizeof_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/ir/sizeof_test.go b/src/cmd/compile/internal/ir/sizeof_test.go index ea7429631527b5..e69a501bc59b46 100644 --- a/src/cmd/compile/internal/ir/sizeof_test.go +++ b/src/cmd/compile/internal/ir/sizeof_test.go @@ -21,7 +21,7 @@ func TestSizeof(t *testing.T) { _64bit uintptr // size on 64bit platforms }{ {Func{}, 184, 312}, - {Name{}, 96, 168}, + {Name{}, 96, 160}, } for _, tt := range tests { From 6dea0bd27c38d9118d13d55052efcb4070b26751 Mon Sep 17 00:00:00 2001 From: Mateusz Poliwczak Date: Tue, 18 Feb 2025 21:37:07 +0100 Subject: [PATCH 3/3] test miniExpr size Change-Id: I882e007614c48a4cff6f0c44bafb76ee9fa246e1 --- src/cmd/compile/internal/ir/sizeof_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cmd/compile/internal/ir/sizeof_test.go b/src/cmd/compile/internal/ir/sizeof_test.go index e69a501bc59b46..1715bad0c147b8 100644 --- a/src/cmd/compile/internal/ir/sizeof_test.go +++ b/src/cmd/compile/internal/ir/sizeof_test.go @@ -22,6 +22,7 @@ func TestSizeof(t *testing.T) { }{ {Func{}, 184, 312}, {Name{}, 96, 160}, + {miniExpr{}, 32, 48}, } for _, tt := range tests {