From a7489b864879e89182ddf32d4a108c6967aa0522 Mon Sep 17 00:00:00 2001 From: Mateusz Poliwczak Date: Tue, 18 Feb 2025 20:40:58 +0000 Subject: [PATCH] cmd/compile/internal/ir: 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: I4b1d4471cf905f998b26d235980e40ca91446f45 GitHub-Last-Rev: 6dea0bd27c38d9118d13d55052efcb4070b26751 GitHub-Pull-Request: golang/go#71823 Reviewed-on: https://go-review.googlesource.com/c/go/+/650435 LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Knyszek Reviewed-by: Robert Griesemer Auto-Submit: Robert Griesemer --- src/cmd/compile/internal/ir/expr.go | 4 ++-- src/cmd/compile/internal/ir/sizeof_test.go | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cmd/compile/internal/ir/expr.go b/src/cmd/compile/internal/ir/expr.go index 4a2e996569..5bd26fc145 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 ( diff --git a/src/cmd/compile/internal/ir/sizeof_test.go b/src/cmd/compile/internal/ir/sizeof_test.go index ea74296315..1715bad0c1 100644 --- a/src/cmd/compile/internal/ir/sizeof_test.go +++ b/src/cmd/compile/internal/ir/sizeof_test.go @@ -21,7 +21,8 @@ func TestSizeof(t *testing.T) { _64bit uintptr // size on 64bit platforms }{ {Func{}, 184, 312}, - {Name{}, 96, 168}, + {Name{}, 96, 160}, + {miniExpr{}, 32, 48}, } for _, tt := range tests { -- 2.51.0