Commit 11322d45 authored by Russ Cox's avatar Russ Cox

cmd/compile: move Node.Vargen, Node.Iota into Node.Name

$ sizeof -p cmd/compile/internal/gc Node
Node 192
$

Change-Id: I8f0c1a3cc2bf9c8eff02bbd8d061ff98affc9eb0
Reviewed-on: https://go-review.googlesource.com/10529Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
parent 3007e953
...@@ -229,7 +229,7 @@ func declare(n *Node, ctxt uint8) { ...@@ -229,7 +229,7 @@ func declare(n *Node, ctxt uint8) {
s.Block = block s.Block = block
s.Lastlineno = int32(parserline()) s.Lastlineno = int32(parserline())
s.Def = n s.Def = n
n.Vargen = int32(gen) n.Name.Vargen = int32(gen)
n.Funcdepth = Funcdepth n.Funcdepth = Funcdepth
n.Class = uint8(ctxt) n.Class = uint8(ctxt)
...@@ -423,9 +423,8 @@ func oldname(s *Sym) *Node { ...@@ -423,9 +423,8 @@ func oldname(s *Sym) *Node {
// walkdef will check s->def again once // walkdef will check s->def again once
// all the input source has been processed. // all the input source has been processed.
n = newname(s) n = newname(s)
n.Op = ONONAME n.Op = ONONAME
n.Iota = iota_ // save current iota value in const declarations n.Name.Iota = iota_ // save current iota value in const declarations
} }
if Curfn != nil && n.Funcdepth > 0 && n.Funcdepth != Funcdepth && n.Op == ONAME { if Curfn != nil && n.Funcdepth > 0 && n.Funcdepth != Funcdepth && n.Op == ONAME {
...@@ -624,7 +623,7 @@ func funcargs(nt *Node) { ...@@ -624,7 +623,7 @@ func funcargs(nt *Node) {
declare(n.Left, PPARAM) declare(n.Left, PPARAM)
if dclcontext == PAUTO { if dclcontext == PAUTO {
vargen++ vargen++
n.Left.Vargen = int32(vargen) n.Left.Name.Vargen = int32(vargen)
} }
} }
} }
...@@ -641,7 +640,7 @@ func funcargs(nt *Node) { ...@@ -641,7 +640,7 @@ func funcargs(nt *Node) {
declare(n.Left, PPARAM) declare(n.Left, PPARAM)
if dclcontext == PAUTO { if dclcontext == PAUTO {
vargen++ vargen++
n.Left.Vargen = int32(vargen) n.Left.Name.Vargen = int32(vargen)
} }
} }
} }
...@@ -688,7 +687,7 @@ func funcargs(nt *Node) { ...@@ -688,7 +687,7 @@ func funcargs(nt *Node) {
declare(n.Left, PPARAMOUT) declare(n.Left, PPARAMOUT)
if dclcontext == PAUTO { if dclcontext == PAUTO {
i++ i++
n.Left.Vargen = int32(i) n.Left.Name.Vargen = int32(i)
} }
} }
} }
......
...@@ -1627,7 +1627,7 @@ func escwalk(e *EscState, level Level, dst *Node, src *Node) { ...@@ -1627,7 +1627,7 @@ func escwalk(e *EscState, level Level, dst *Node, src *Node) {
if src.Esc&EscMask != EscReturn { if src.Esc&EscMask != EscReturn {
src.Esc = EscReturn | src.Esc&EscContentEscapes src.Esc = EscReturn | src.Esc&EscContentEscapes
} }
src.Esc = escNoteOutputParamFlow(src.Esc, dst.Vargen, level) src.Esc = escNoteOutputParamFlow(src.Esc, dst.Name.Vargen, level)
goto recurse goto recurse
} }
......
...@@ -205,8 +205,8 @@ func Jconv(n *Node, flag int) string { ...@@ -205,8 +205,8 @@ func Jconv(n *Node, flag int) string {
fmt.Fprintf(&buf, " a(%v)", n.Addable) fmt.Fprintf(&buf, " a(%v)", n.Addable)
} }
if c == 0 && n.Vargen != 0 { if c == 0 && n.Name != nil && n.Name.Vargen != 0 {
fmt.Fprintf(&buf, " g(%d)", n.Vargen) fmt.Fprintf(&buf, " g(%d)", n.Name.Vargen)
} }
if n.Lineno != 0 { if n.Lineno != 0 {
...@@ -1130,8 +1130,8 @@ func exprfmt(n *Node, prec int) string { ...@@ -1130,8 +1130,8 @@ func exprfmt(n *Node, prec int) string {
if (fmtmode == FExp || fmtmode == FErr) && n.Sym != nil && n.Sym.Name[0] == '~' && n.Sym.Name[1] == 'b' { if (fmtmode == FExp || fmtmode == FErr) && n.Sym != nil && n.Sym.Name[0] == '~' && n.Sym.Name[1] == 'b' {
return "_" return "_"
} }
if fmtmode == FExp && n.Sym != nil && !isblank(n) && n.Vargen > 0 { if fmtmode == FExp && n.Sym != nil && !isblank(n) && n.Name.Vargen > 0 {
return fmt.Sprintf("%v·%d", n.Sym, n.Vargen) return fmt.Sprintf("%v·%d", n.Sym, n.Name.Vargen)
} }
// Special case: explicit name of func (*T) method(...) is turned into pkg.(*T).method, // Special case: explicit name of func (*T) method(...) is turned into pkg.(*T).method,
...@@ -1538,7 +1538,7 @@ func nodedump(n *Node, flag int) string { ...@@ -1538,7 +1538,7 @@ func nodedump(n *Node, flag int) string {
} }
if n.Sym != nil && n.Op != ONAME { if n.Sym != nil && n.Op != ONAME {
fmt.Fprintf(&buf, " %v G%d", n.Sym, n.Vargen) fmt.Fprintf(&buf, " %v G%d", n.Sym, n.Name.Vargen)
} }
if n.Type != nil { if n.Type != nil {
......
...@@ -771,12 +771,13 @@ func treecopy(n *Node, lineno int32) *Node { ...@@ -771,12 +771,13 @@ func treecopy(n *Node, lineno int32) *Node {
// so that all the copies of this const definition // so that all the copies of this const definition
// don't have the same iota value. // don't have the same iota value.
m = Nod(OXXX, nil, nil) m = Nod(OXXX, nil, nil)
*m = *n *m = *n
m.Iota = iota_
if lineno != 0 { if lineno != 0 {
m.Lineno = lineno m.Lineno = lineno
} }
m.Name = new(Name)
*m.Name = *n.Name
m.Name.Iota = iota_
break break
} }
fallthrough fallthrough
...@@ -1630,7 +1631,7 @@ func frame(context int) { ...@@ -1630,7 +1631,7 @@ func frame(context int) {
} }
switch n.Op { switch n.Op {
case ONAME: case ONAME:
fmt.Printf("%v %v G%d %v width=%d\n", Oconv(int(n.Op), 0), n.Sym, n.Vargen, n.Type, w) fmt.Printf("%v %v G%d %v width=%d\n", Oconv(int(n.Op), 0), n.Sym, n.Name.Vargen, n.Type, w)
case OTYPE: case OTYPE:
fmt.Printf("%v %v width=%d\n", Oconv(int(n.Op), 0), n.Type, w) fmt.Printf("%v %v width=%d\n", Oconv(int(n.Op), 0), n.Type, w)
......
...@@ -42,9 +42,7 @@ type Node struct { ...@@ -42,9 +42,7 @@ type Node struct {
Xoffset int64 Xoffset int64
Vargen int32 // unique name for OTYPE/ONAME within a function. Function outputs are numbered starting at one.
Lineno int32 Lineno int32
Iota int32
Walkgen uint32 Walkgen uint32
Funcdepth int32 Funcdepth int32
...@@ -87,6 +85,8 @@ type Name struct { ...@@ -87,6 +85,8 @@ type Name struct {
Inlvar *Node // ONAME substitute while inlining Inlvar *Node // ONAME substitute while inlining
Defn *Node // initializing assignment Defn *Node // initializing assignment
Decldepth int32 // declaration loop depth, increased for every loop or label Decldepth int32 // declaration loop depth, increased for every loop or label
Vargen int32 // unique name for OTYPE/ONAME within a function. Function outputs are numbered starting at one.
Iota int32 // value if this name is iota
Method bool // OCALLMETH name Method bool // OCALLMETH name
Readonly bool Readonly bool
Captured bool // is the variable captured by a closure Captured bool // is the variable captured by a closure
......
...@@ -29,8 +29,8 @@ func resolve(n *Node) *Node { ...@@ -29,8 +29,8 @@ func resolve(n *Node) *Node {
if r != nil { if r != nil {
if r.Op != OIOTA { if r.Op != OIOTA {
n = r n = r
} else if n.Iota >= 0 { } else if n.Name.Iota >= 0 {
n = Nodintconst(int64(n.Iota)) n = Nodintconst(int64(n.Name.Iota))
} }
} }
} }
...@@ -3565,7 +3565,9 @@ func copytype(n *Node, t *Type) { ...@@ -3565,7 +3565,9 @@ func copytype(n *Node, t *Type) {
t = n.Type t = n.Type
t.Sym = n.Sym t.Sym = n.Sym
t.Local = n.Local t.Local = n.Local
t.Vargen = n.Vargen if n.Name != nil {
t.Vargen = n.Name.Vargen
}
t.Siggen = 0 t.Siggen = 0
t.Method = nil t.Method = nil
t.Xmethod = nil t.Xmethod = nil
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment