// The algorithm (known as Tarjan's algorithm) for doing that is taken from
// Sedgewick, Algorithms, Second Edition, p. 482, with two adaptations.
//
-// First, a hidden closure function (n.Func.FCurfn != nil) cannot be the
+// First, a hidden closure function (n.Func.IsHiddenClosure) cannot be the
// root of a connected component. Refusing to use it as a root
// forces it into the component of the function in which it appears.
// This is more convenient for escape analysis.
v.analyze = analyze
v.nodeID = make(map[*Node]uint32)
for _, n := range list {
- if n.Op == ODCLFUNC && n.Func.FCurfn == nil {
+ if n.Op == ODCLFUNC && !n.Func.IsHiddenClosure {
v.visit(n)
}
}
v.stack = append(v.stack, n)
min = v.visitcodelist(n.Nbody, min)
- if (min == id || min == id+1) && n.Func.FCurfn == nil {
+ if (min == id || min == id+1) && !n.Func.IsHiddenClosure {
// This node is the root of a strongly connected component.
// The original min passed to visitcodelist was v.nodeID[n]+1.
Ntype *Node // signature
Top int // top context (Ecall, Eproc, etc)
Closure *Node // OCLOSURE <-> ODCLFUNC
- FCurfn *Node
Nname *Node
Inl Nodes // copy of the body for use in inlining
Endlineno int32
WBLineno int32 // line number of first write barrier
- Pragma Pragma // go:xxx function annotations
- Dupok bool // duplicate definitions ok
- Wrapper bool // is method wrapper
- Needctxt bool // function uses context register (has closure variables)
- ReflectMethod bool // function calls reflect.Type.Method or MethodByName
+ Pragma Pragma // go:xxx function annotations
+ Dupok bool // duplicate definitions ok
+ Wrapper bool // is method wrapper
+ Needctxt bool // function uses context register (has closure variables)
+ ReflectMethod bool // function calls reflect.Type.Method or MethodByName
+ IsHiddenClosure bool
}
type Op uint8