private void visitForward(NodeBitMap visited, Node node) { if (node != null && !visited.isMarked(node)) { visited.mark(node); if (node.predecessor() != null) { visitForward(visited, node.predecessor()); } if (node instanceof MergeNode) { // make sure that the cfg predecessors of a MergeNode are processed first MergeNode merge = (MergeNode) node; for (int i = 0; i < merge.forwardEndCount(); i++) { visitForward(visited, merge.forwardEndAt(i)); } } for (Node input : node.inputs()) { visitForward(visited, input); } if (node instanceof LoopBeginNode) { LoopBeginNode loopBegin = (LoopBeginNode) node; for (LoopEndNode loopEnd : loopBegin.loopEnds()) { visitForward(visited, loopEnd); } } nodes.add(node); } }
private boolean accept(T n) { if (n == null) { return true; } if (visited == null) { visited = n.graph().createNodeBitMap(); } boolean accept = !visited.isMarked(n); visited.mark(n); return accept; }
private void visitBackward(NodeBitMap visited, Node node) { if (node != null && !visited.isMarked(node)) { visited.mark(node); for (Node successor : node.successors()) { visitBackward(visited, successor); } for (Node usage : node.usages()) { visitBackward(visited, usage); } nodes.add(node); } }