Commit e2560ace authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: move Node.Initorder to flags

Grand savings: 6 bits.

Change-Id: I364be54cc41534689e01672ed0fe2c10a560d3d4
Reviewed-on: https://go-review.googlesource.com/41794
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent af7da9a5
......@@ -55,7 +55,7 @@ func init1(n *Node, out *[]*Node) {
switch n.Class {
case PEXTERN, PFUNC:
default:
if isblank(n) && n.Name.Curfn == nil && n.Name.Defn != nil && n.Name.Defn.Initorder == InitNotStarted {
if isblank(n) && n.Name.Curfn == nil && n.Name.Defn != nil && n.Name.Defn.Initorder() == InitNotStarted {
// blank names initialization is part of init() but not
// when they are inside a function.
break
......@@ -63,10 +63,10 @@ func init1(n *Node, out *[]*Node) {
return
}
if n.Initorder == InitDone {
if n.Initorder() == InitDone {
return
}
if n.Initorder == InitPending {
if n.Initorder() == InitPending {
// Since mutually recursive sets of functions are allowed,
// we don't necessarily raise an error if n depends on a node
// which is already waiting for its dependencies to be visited.
......@@ -95,7 +95,7 @@ func init1(n *Node, out *[]*Node) {
}
// reached a new unvisited node.
n.Initorder = InitPending
n.SetInitorder(InitPending)
initlist = append(initlist, n)
// make sure that everything n depends on is initialized.
......@@ -133,10 +133,10 @@ func init1(n *Node, out *[]*Node) {
}
case OAS2FUNC, OAS2MAPR, OAS2DOTTYPE, OAS2RECV:
if defn.Initorder == InitDone {
if defn.Initorder() == InitDone {
break
}
defn.Initorder = InitPending
defn.SetInitorder(InitPending)
for _, n2 := range defn.Rlist.Slice() {
init1(n2, out)
}
......@@ -144,7 +144,7 @@ func init1(n *Node, out *[]*Node) {
Dump("nonstatic", defn)
}
*out = append(*out, defn)
defn.Initorder = InitDone
defn.SetInitorder(InitDone)
}
}
......@@ -155,7 +155,7 @@ func init1(n *Node, out *[]*Node) {
initlist[last] = nil // allow GC
initlist = initlist[:last]
n.Initorder = InitDone
n.SetInitorder(InitDone)
return
}
......@@ -197,7 +197,7 @@ func foundinitloop(node, visited *Node) {
// recurse over n, doing init1 everywhere.
func init2(n *Node, out *[]*Node) {
if n == nil || n.Initorder == InitDone {
if n == nil || n.Initorder() == InitDone {
return
}
......
......@@ -59,7 +59,6 @@ type Node struct {
Etype types.EType // op for OASOP, etype for OTYPE, exclam for export, 6g saved reg, ChanDir for OTCHAN, for OINDEXMAP 1=LHS,0=RHS
Class Class // PPARAM, PAUTO, PEXTERN, etc
Typecheck uint8 // tracks state during typechecking; 2 == loop detected
Initorder uint8
}
// IsAutoTmp indicates if n was created by the compiler as a temporary,
......@@ -72,8 +71,10 @@ func (n *Node) IsAutoTmp() bool {
}
const (
nodeWalkdef, _ = iota, 1 << iota // tracks state during typecheckdef; 2 == loop detected; two bits
_, _ // second nodeWalkdef bit
nodeWalkdef, _ = iota, 1 << iota // tracks state during typecheckdef; 2 == loop detected; two bits
_, _ // second nodeWalkdef bit
nodeInitorder, _ // tracks state during init1; two bits
_, _ // second nodeInitorder bit
_, nodeHasBreak
_, nodeIsClosureVar
_, nodeIsOutputParamHeapAddr
......@@ -97,7 +98,8 @@ const (
_, nodeEmbedded // ODCLFIELD embedded type
)
func (n *Node) Walkdef() uint8 { return n.flags.get2(nodeWalkdef) }
func (n *Node) Walkdef() uint8 { return n.flags.get2(nodeWalkdef) }
func (n *Node) Initorder() uint8 { return n.flags.get2(nodeInitorder) }
func (n *Node) HasBreak() bool { return n.flags&nodeHasBreak != 0 }
func (n *Node) IsClosureVar() bool { return n.flags&nodeIsClosureVar != 0 }
......@@ -121,7 +123,8 @@ func (n *Node) HasVal() bool { return n.flags&nodeHasVal != 0 }
func (n *Node) HasOpt() bool { return n.flags&nodeHasOpt != 0 }
func (n *Node) Embedded() bool { return n.flags&nodeEmbedded != 0 }
func (n *Node) SetWalkdef(b uint8) { n.flags.set2(nodeWalkdef, b) }
func (n *Node) SetWalkdef(b uint8) { n.flags.set2(nodeWalkdef, b) }
func (n *Node) SetInitorder(b uint8) { n.flags.set2(nodeInitorder, b) }
func (n *Node) SetHasBreak(b bool) { n.flags.set(nodeHasBreak, b) }
func (n *Node) SetIsClosureVar(b bool) { n.flags.set(nodeIsClosureVar, b) }
......
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