]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/ir: reduce size of miniExpr by 8 bytes
authorMateusz Poliwczak <mpoliwczak34@gmail.com>
Tue, 18 Feb 2025 20:40:58 +0000 (20:40 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 19 Feb 2025 01:51:54 +0000 (17:51 -0800)
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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

src/cmd/compile/internal/ir/expr.go
src/cmd/compile/internal/ir/sizeof_test.go

index 4a2e996569450dbf81e3d629753ae14032ff6cb6..5bd26fc14562f6b0741cff8ccb1ff480bcccaa2f 100644 (file)
@@ -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 (
index ea7429631527b54a78d8a888980480322250c2d7..1715bad0c147b845467d03b9ed397c3fbefa0894 100644 (file)
@@ -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 {