cmd/internal/gc: convert Val.U to interface{}
This CL was generated by updating Val in go.go
and then running:
sed -i "" 's/\.U\.[SBXFC]val = /.U = /' *.go
sed -i "" 's/\.U\.Sval/.U.\(string\)/g' *.go *.y
sed -i "" 's/\.U\.Bval/.U.\(bool\)/g' *.go *.y
sed -i "" 's/\.U\.Xval/.U.\(\*Mpint\)/g' *.go *.y
sed -i "" 's/\.U\.Fval/.U.\(\*Mpflt\)/g' *.go *.y
sed -i "" 's/\.U\.Cval/.U.\(\*Mpcplx\)/g' *.go *.y
No functional changes. Passes toolstash -cmp.
This reduces the size of gc.Node from 424 to 392 bytes.
This in turn reduces the permanent (pprof -inuse_space)
memory usage while compiling the test/rotate?.go tests:
test old(MB) new(MB) change
rotate0 379.49 364.78 -3.87%
rotate1 373.42 359.07 -3.84%
rotate2 381.17 366.24 -3.91%
rotate3 374.30 359.95 -3.83%
CL 8445 was similar to this; gri asked that Val's implementation
be hidden first. CLs 8912, 9263, and 9267 have at least
isolated the changes to the cmd/internal/gc package.
Updates #9933.
Change-Id: I83ddfe003d48e0a73c92e819edd3b5e620023084
Reviewed-on: https://go-review.googlesource.com/10059
Reviewed-by: Russ Cox <rsc@golang.org>
diff --git a/src/cmd/internal/gc/subr.go b/src/cmd/internal/gc/subr.go
index dd84214..b09f423 100644
--- a/src/cmd/internal/gc/subr.go
+++ b/src/cmd/internal/gc/subr.go
@@ -666,8 +666,8 @@
func Nodintconst(v int64) *Node {
c := Nod(OLITERAL, nil, nil)
c.Addable = true
- c.Val.U.Xval = new(Mpint)
- Mpmovecfix(c.Val.U.Xval, v)
+ c.Val.U = new(Mpint)
+ Mpmovecfix(c.Val.U.(*Mpint), v)
c.Val.Ctype = CTINT
c.Type = Types[TIDEAL]
ullmancalc(c)
@@ -677,8 +677,8 @@
func nodfltconst(v *Mpflt) *Node {
c := Nod(OLITERAL, nil, nil)
c.Addable = true
- c.Val.U.Fval = newMpflt()
- mpmovefltflt(c.Val.U.Fval, v)
+ c.Val.U = newMpflt()
+ mpmovefltflt(c.Val.U.(*Mpflt), v)
c.Val.Ctype = CTFLT
c.Type = Types[TIDEAL]
ullmancalc(c)
@@ -690,8 +690,8 @@
n.Op = OLITERAL
n.Addable = true
ullmancalc(n)
- n.Val.U.Xval = new(Mpint)
- Mpmovecfix(n.Val.U.Xval, v)
+ n.Val.U = new(Mpint)
+ Mpmovecfix(n.Val.U.(*Mpint), v)
n.Val.Ctype = CTINT
n.Type = t
@@ -710,7 +710,7 @@
func Nodbool(b bool) *Node {
c := Nodintconst(0)
c.Val.Ctype = CTBOOL
- c.Val.U.Bval = b
+ c.Val.U = b
c.Type = idealbool
return c
}
@@ -724,7 +724,7 @@
Yyerror("array bound must be an integer expression")
case CTINT, CTRUNE:
- bound = Mpgetfix(b.Val.U.Xval)
+ bound = Mpgetfix(b.Val.U.(*Mpint))
if bound < 0 {
Yyerror("array bound must be non negative")
}
@@ -2422,11 +2422,11 @@
var v Val
v.Ctype = CTSTR
- v.U.Sval = rcvr.Type.Sym.Pkg.Name // package name
+ v.U = rcvr.Type.Sym.Pkg.Name // package name
l = list(l, nodlit(v))
- v.U.Sval = rcvr.Type.Sym.Name // type name
+ v.U = rcvr.Type.Sym.Name // type name
l = list(l, nodlit(v))
- v.U.Sval = method.Sym.Name
+ v.U = method.Sym.Name
l = list(l, nodlit(v)) // method name
call := Nod(OCALL, syslook("panicwrap", 0), nil)
call.List = l
@@ -3139,7 +3139,7 @@
return -1
}
- v := uint64(Mpgetfix(n.Val.U.Xval))
+ v := uint64(Mpgetfix(n.Val.U.(*Mpint)))
b := uint64(1)
for i := 0; i < 64; i++ {
if b == v {