cmd/internal/obj: replace Addr.U struct {...} with Val interface{}
An interface{} is more in the spirit of the original union.
By my calculations, on 64-bit systems this reduces
Addr from 120 to 80 bytes, and Prog from 592 to 424 bytes.
Change-Id: I0d7b0981513c2a3c94c9ac76bb4f8816485b5a3c
Reviewed-on: https://go-review.googlesource.com/7744
Reviewed-by: Rob Pike <r@golang.org>
diff --git a/src/cmd/internal/gc/gsubr.go b/src/cmd/internal/gc/gsubr.go
index 626a16b..f5d7621 100644
--- a/src/cmd/internal/gc/gsubr.go
+++ b/src/cmd/internal/gc/gsubr.go
@@ -79,7 +79,7 @@
func Gbranch(as int, t *Type, likely int) *obj.Prog {
p := Prog(as)
p.To.Type = obj.TYPE_BRANCH
- p.To.U.Branch = nil
+ p.To.Val = nil
if as != obj.AJMP && likely != 0 && Thearch.Thechar != '9' && Thearch.Thechar != '7' {
p.From.Type = obj.TYPE_CONST
p.From.Offset = int64(bool2int(likely > 0))
@@ -400,7 +400,7 @@
case CTFLT:
a.Type = obj.TYPE_FCONST
- a.U.Dval = mpgetflt(n.Val.U.Fval)
+ a.Val = mpgetflt(n.Val.U.Fval)
case CTINT,
CTRUNE:
@@ -585,7 +585,7 @@
if p.To.Type != obj.TYPE_BRANCH {
Fatal("patch: not a branch")
}
- p.To.U.Branch = to
+ p.To.Val = to
p.To.Offset = to.Pc
}
@@ -593,8 +593,8 @@
if p.To.Type != obj.TYPE_BRANCH {
Fatal("unpatch: not a branch")
}
- q := p.To.U.Branch
- p.To.U.Branch = nil
+ q, _ := p.To.Val.(*obj.Prog)
+ p.To.Val = nil
p.To.Offset = 0
return q
}