mirror of
https://github.com/golang/go
synced 2024-11-12 00:20:22 -07:00
cmd/compile/internal/gc: remove remaining Nod(OXXX, ...)
Remove almost all the remaining Nod(OXXX, ... ) uses. The performance change is due entirely to the changes to func temp(*Type). The other cleanups have no effect, as expected. I'll address the remaining Nod(OXXX, ...) uses in a followup CL as they are very sensitive to change. lucky(~/go/src/cmd/compile) % benchstat /tmp/{old,new}.txt name old time/op new time/op delta Template 391ms ± 6% 385ms ± 6% ~ (p=0.127 n=19+20) GoTypes 1.27s ± 2% 1.27s ± 2% ~ (p=0.172 n=19+19) Compiler 6.17s ± 2% 6.15s ± 2% ~ (p=0.647 n=19+20) name old alloc/op new alloc/op delta Template 63.7MB ± 0% 63.4MB ± 0% -0.35% (p=0.000 n=16+20) GoTypes 219MB ± 0% 218MB ± 0% -0.38% (p=0.000 n=20+20) Compiler 980MB ± 0% 976MB ± 0% -0.38% (p=0.000 n=20+20) name old allocs/op new allocs/op delta Template 586k ± 0% 584k ± 0% -0.30% (p=0.000 n=20+20) GoTypes 1.80M ± 0% 1.79M ± 0% -0.31% (p=0.000 n=20+20) Compiler 7.74M ± 0% 7.71M ± 0% -0.34% (p=0.000 n=20+20) Change-Id: Ie21a5443c33a23ce30f987bdddec9fe350365d35 Reviewed-on: https://go-review.googlesource.com/21017 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
babc73547e
commit
edca4cda88
@ -117,9 +117,8 @@ func convlit1(n *Node, t *Type, explicit bool) *Node {
|
||||
}
|
||||
|
||||
if n.Op == OLITERAL {
|
||||
nn := Nod(OXXX, nil, nil)
|
||||
*nn = *n
|
||||
n = nn
|
||||
nn := *n
|
||||
n = &nn
|
||||
}
|
||||
|
||||
switch n.Op {
|
||||
@ -559,11 +558,10 @@ func evconst(n *Node) {
|
||||
i2++
|
||||
}
|
||||
|
||||
nl := Nod(OXXX, nil, nil)
|
||||
*nl = *s[i1]
|
||||
nl.Orig = nl
|
||||
nl := *s[i1]
|
||||
nl.Orig = &nl
|
||||
nl.SetVal(Val{strings.Join(strs, "")})
|
||||
s[i1] = nl
|
||||
s[i1] = &nl
|
||||
s = append(s[:i1+1], s[i2:]...)
|
||||
}
|
||||
}
|
||||
@ -1250,9 +1248,8 @@ func defaultlit(n *Node, t *Type) *Node {
|
||||
}
|
||||
|
||||
if n.Op == OLITERAL {
|
||||
nn := Nod(OXXX, nil, nil)
|
||||
*nn = *n
|
||||
n = nn
|
||||
nn := *n
|
||||
n = &nn
|
||||
}
|
||||
|
||||
lno := setlineno(n)
|
||||
|
@ -605,7 +605,6 @@ func funcargs(nt *Node) {
|
||||
// declare the out arguments.
|
||||
gen := nt.List.Len()
|
||||
var i int = 0
|
||||
var nn *Node
|
||||
for _, n = range nt.Rlist.Slice() {
|
||||
if n.Op != ODCLFIELD {
|
||||
Fatalf("funcargs out %v", Oconv(n.Op, 0))
|
||||
@ -629,13 +628,11 @@ func funcargs(nt *Node) {
|
||||
// So the two cases must be distinguished.
|
||||
// We do not record a pointer to the original node (n->orig).
|
||||
// Having multiple names causes too much confusion in later passes.
|
||||
nn = Nod(OXXX, nil, nil)
|
||||
|
||||
*nn = *n.Left
|
||||
nn.Orig = nn
|
||||
nn := *n.Left
|
||||
nn.Orig = &nn
|
||||
nn.Sym = LookupN("~b", gen)
|
||||
gen++
|
||||
n.Left = nn
|
||||
n.Left = &nn
|
||||
}
|
||||
|
||||
n.Left.Name.Param.Ntype = n.Right
|
||||
|
@ -522,9 +522,8 @@ func importconst(s *Sym, t *Type, n *Node) {
|
||||
}
|
||||
|
||||
if n.Sym != nil {
|
||||
n1 := Nod(OXXX, nil, nil)
|
||||
*n1 = *n
|
||||
n = n1
|
||||
n1 := *n
|
||||
n = &n1
|
||||
}
|
||||
|
||||
n.Orig = newname(s)
|
||||
|
@ -613,8 +613,8 @@ func Tempname(nn *Node, t *Type) {
|
||||
}
|
||||
|
||||
func temp(t *Type) *Node {
|
||||
n := Nod(OXXX, nil, nil)
|
||||
Tempname(n, t)
|
||||
var n Node
|
||||
Tempname(&n, t)
|
||||
n.Sym.Def.Used = true
|
||||
return n.Orig
|
||||
}
|
||||
|
@ -249,8 +249,7 @@ func inlcopy(n *Node) *Node {
|
||||
return n
|
||||
}
|
||||
|
||||
m := Nod(OXXX, nil, nil)
|
||||
*m = *n
|
||||
m := *n
|
||||
if m.Func != nil {
|
||||
m.Func.Inl.Set(nil)
|
||||
}
|
||||
@ -261,7 +260,7 @@ func inlcopy(n *Node) *Node {
|
||||
m.Ninit.Set(inlcopylist(n.Ninit.Slice()))
|
||||
m.Nbody.Set(inlcopylist(n.Nbody.Slice()))
|
||||
|
||||
return m
|
||||
return &m
|
||||
}
|
||||
|
||||
// Inlcalls/nodelist/node walks fn's statements and expressions and substitutes any
|
||||
@ -967,25 +966,25 @@ func (subst *inlsubst) node(n *Node) *Node {
|
||||
p := fmt.Sprintf("%s·%d", n.Left.Sym.Name, inlgen)
|
||||
m.Left = newname(Lookup(p))
|
||||
|
||||
return m
|
||||
default:
|
||||
m := Nod(OXXX, nil, nil)
|
||||
*m = *n
|
||||
m.Ninit.Set(nil)
|
||||
|
||||
if n.Op == OCLOSURE {
|
||||
Fatalf("cannot inline function containing closure: %v", Nconv(n, FmtSign))
|
||||
}
|
||||
|
||||
m.Left = subst.node(n.Left)
|
||||
m.Right = subst.node(n.Right)
|
||||
m.List.Set(subst.list(n.List))
|
||||
m.Rlist.Set(subst.list(n.Rlist))
|
||||
m.Ninit.Set(append(m.Ninit.Slice(), subst.list(n.Ninit)...))
|
||||
m.Nbody.Set(subst.list(n.Nbody))
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
m := Nod(OXXX, nil, nil)
|
||||
*m = *n
|
||||
m.Ninit.Set(nil)
|
||||
|
||||
if n.Op == OCLOSURE {
|
||||
Fatalf("cannot inline function containing closure: %v", Nconv(n, FmtSign))
|
||||
}
|
||||
|
||||
m.Left = subst.node(n.Left)
|
||||
m.Right = subst.node(n.Right)
|
||||
m.List.Set(subst.list(n.List))
|
||||
m.Rlist.Set(subst.list(n.Rlist))
|
||||
m.Ninit.Set(append(m.Ninit.Slice(), subst.list(n.Ninit)...))
|
||||
m.Nbody.Set(subst.list(n.Nbody))
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// Plaster over linenumbers
|
||||
|
@ -107,12 +107,10 @@ func ordercheapexpr(n *Node, order *Order) *Node {
|
||||
if l == n.Left {
|
||||
return n
|
||||
}
|
||||
a := Nod(OXXX, nil, nil)
|
||||
*a = *n
|
||||
a.Orig = a
|
||||
a := *n
|
||||
a.Orig = &a
|
||||
a.Left = l
|
||||
a = typecheck(a, Erv)
|
||||
return a
|
||||
return typecheck(&a, Erv)
|
||||
}
|
||||
|
||||
return ordercopyexpr(n, n.Type, order, 0)
|
||||
@ -135,24 +133,20 @@ func ordersafeexpr(n *Node, order *Order) *Node {
|
||||
if l == n.Left {
|
||||
return n
|
||||
}
|
||||
a := Nod(OXXX, nil, nil)
|
||||
*a = *n
|
||||
a.Orig = a
|
||||
a := *n
|
||||
a.Orig = &a
|
||||
a.Left = l
|
||||
a = typecheck(a, Erv)
|
||||
return a
|
||||
return typecheck(&a, Erv)
|
||||
|
||||
case ODOTPTR, OIND:
|
||||
l := ordercheapexpr(n.Left, order)
|
||||
if l == n.Left {
|
||||
return n
|
||||
}
|
||||
a := Nod(OXXX, nil, nil)
|
||||
*a = *n
|
||||
a.Orig = a
|
||||
a := *n
|
||||
a.Orig = &a
|
||||
a.Left = l
|
||||
a = typecheck(a, Erv)
|
||||
return a
|
||||
return typecheck(&a, Erv)
|
||||
|
||||
case OINDEX, OINDEXMAP:
|
||||
var l *Node
|
||||
@ -165,17 +159,15 @@ func ordersafeexpr(n *Node, order *Order) *Node {
|
||||
if l == n.Left && r == n.Right {
|
||||
return n
|
||||
}
|
||||
a := Nod(OXXX, nil, nil)
|
||||
*a = *n
|
||||
a.Orig = a
|
||||
a := *n
|
||||
a.Orig = &a
|
||||
a.Left = l
|
||||
a.Right = r
|
||||
a = typecheck(a, Erv)
|
||||
return a
|
||||
return typecheck(&a, Erv)
|
||||
default:
|
||||
Fatalf("ordersafeexpr %v", Oconv(n.Op, 0))
|
||||
return nil // not reached
|
||||
}
|
||||
|
||||
Fatalf("ordersafeexpr %v", Oconv(n.Op, 0))
|
||||
return nil // not reached
|
||||
}
|
||||
|
||||
// Istemp reports whether n is a temporary variable.
|
||||
|
@ -65,12 +65,10 @@ func instrument(fn *Node) {
|
||||
// nodpc is the PC of the caller as extracted by
|
||||
// getcallerpc. We use -widthptr(FP) for x86.
|
||||
// BUG: this will not work on arm.
|
||||
nodpc := Nod(OXXX, nil, nil)
|
||||
|
||||
*nodpc = *nodfp
|
||||
nodpc := *nodfp
|
||||
nodpc.Type = Types[TUINTPTR]
|
||||
nodpc.Xoffset = int64(-Widthptr)
|
||||
nd := mkcall("racefuncenter", nil, nil, nodpc)
|
||||
nd := mkcall("racefuncenter", nil, nil, &nodpc)
|
||||
fn.Func.Enter.Set(append([]*Node{nd}, fn.Func.Enter.Slice()...))
|
||||
nd = mkcall("racefuncexit", nil, nil)
|
||||
fn.Func.Exit.Append(nd)
|
||||
|
@ -516,12 +516,10 @@ func treecopy(n *Node, lineno int32) *Node {
|
||||
return nil
|
||||
}
|
||||
|
||||
var m *Node
|
||||
switch n.Op {
|
||||
default:
|
||||
m = Nod(OXXX, nil, nil)
|
||||
*m = *n
|
||||
m.Orig = m
|
||||
m := *n
|
||||
m.Orig = &m
|
||||
m.Left = treecopy(n.Left, lineno)
|
||||
m.Right = treecopy(n.Right, lineno)
|
||||
m.List.Set(listtreecopy(n.List.Slice(), lineno))
|
||||
@ -532,6 +530,7 @@ func treecopy(n *Node, lineno int32) *Node {
|
||||
Dump("treecopy", n)
|
||||
Fatalf("treecopy Name")
|
||||
}
|
||||
return &m
|
||||
|
||||
case ONONAME:
|
||||
if n.Sym == Lookup("iota") {
|
||||
@ -539,23 +538,20 @@ func treecopy(n *Node, lineno int32) *Node {
|
||||
// but make a copy of the Node* just in case,
|
||||
// so that all the copies of this const definition
|
||||
// don't have the same iota value.
|
||||
m = Nod(OXXX, nil, nil)
|
||||
*m = *n
|
||||
m := *n
|
||||
if lineno != 0 {
|
||||
m.Lineno = lineno
|
||||
}
|
||||
m.Name = new(Name)
|
||||
*m.Name = *n.Name
|
||||
m.Name.Iota = iota_
|
||||
break
|
||||
return &m
|
||||
}
|
||||
fallthrough
|
||||
return n
|
||||
|
||||
case ONAME, OLITERAL, OTYPE:
|
||||
m = n
|
||||
return n
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// isnil reports whether n represents the universal untyped zero value "nil".
|
||||
@ -1085,8 +1081,7 @@ func assignconvfn(n *Node, t *Type, context func() string) *Node {
|
||||
// The result of substArgTypes MUST be assigned back to old, e.g.
|
||||
// n.Left = substArgTypes(n.Left, t1, t2)
|
||||
func substArgTypes(old *Node, types ...*Type) *Node {
|
||||
n := Nod(OXXX, nil, nil)
|
||||
*n = *old // make shallow copy
|
||||
n := *old // make shallow copy
|
||||
|
||||
for _, t := range types {
|
||||
dowidth(t)
|
||||
@ -1095,7 +1090,7 @@ func substArgTypes(old *Node, types ...*Type) *Node {
|
||||
if len(types) > 0 {
|
||||
Fatalf("substArgTypes: too many argument types")
|
||||
}
|
||||
return n
|
||||
return &n
|
||||
}
|
||||
|
||||
// substAny walks t, replacing instances of "any" with successive
|
||||
|
Loading…
Reference in New Issue
Block a user