// Second, each function becomes two virtual nodes in the graph,
// with numbers n and n+1. We record the function's node number as n
// but search from node n+1. If the search tells us that the component
-// number (min) is n+1, we know that this is a trivial component: one function
+// number (minVisitGen) is n+1, we know that this is a trivial component: one function
// plus its closures. If the search tells us that the component number is
// n, then there was a path from node n+1 back to node n, meaning that
// the function set is mutually recursive. The escape analysis can be
id := v.visitgen
v.nodeID[n] = id
v.visitgen++
- min := v.visitgen
+ minVisitGen := v.visitgen
v.stack = append(v.stack, n)
do := func(defn Node) {
if defn != nil {
- if m := v.visit(defn.(*Func)); m < min {
- min = m
+ if m := v.visit(defn.(*Func)); m < minVisitGen {
+ minVisitGen = m
}
}
}
}
})
- if (min == id || min == id+1) && !n.IsClosure() {
+ if (minVisitGen == id || minVisitGen == id+1) && !n.IsClosure() {
// This node is the root of a strongly connected component.
- // The original min was id+1. If the bottomUpVisitor found its way
+ // The original minVisitGen was id+1. If the bottomUpVisitor found its way
// back to id, then this block is a set of mutually recursive functions.
// Otherwise, it's just a lone function that does not recurse.
- recursive := min == id
+ recursive := minVisitGen == id
// Remove connected component from stack and mark v.nodeID so that future
// visits return a large number, which will not affect the caller's min.
v.analyze(block, recursive)
}
- return min
+ return minVisitGen
}