Remove deprecated pieces from generic algorithm.
R=titzer@chromium.org Review URL: https://codereview.chromium.org/752263003 Cr-Commit-Position: refs/heads/master@{#25565}
This commit is contained in:
parent
5ef3698903
commit
e6b4b8dc55
@ -29,20 +29,8 @@ class NodeInputIterationTraits {
|
||||
static Node* from(Iterator iterator) { return iterator.edge().from(); }
|
||||
};
|
||||
|
||||
template <class N>
|
||||
class NodeUseIterationTraits {
|
||||
public:
|
||||
typedef N Node;
|
||||
typedef typename N::Uses::iterator Iterator;
|
||||
|
||||
static Iterator begin(Node* node) { return node->uses().begin(); }
|
||||
static Iterator end(Node* node) { return node->uses().end(); }
|
||||
static int max_id(GenericGraphBase* graph) { return graph->NodeCount(); }
|
||||
static Node* to(Iterator iterator) { return *iterator; }
|
||||
static Node* from(Iterator iterator) { return iterator.edge().to(); }
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace v8::internal::compiler
|
||||
} // namespace compiler
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_COMPILER_GENERIC_ALGORITHM_INL_H_
|
||||
|
@ -12,28 +12,15 @@ namespace v8 {
|
||||
namespace internal {
|
||||
namespace compiler {
|
||||
|
||||
template <class Visitor>
|
||||
void Graph::VisitNodeUsesFrom(Node* node, Visitor* visitor) {
|
||||
Zone tmp_zone(zone()->isolate());
|
||||
GenericGraphVisit::Visit<Visitor, NodeUseIterationTraits<Node> >(
|
||||
this, &tmp_zone, node, visitor);
|
||||
}
|
||||
|
||||
|
||||
template <class Visitor>
|
||||
void Graph::VisitNodeUsesFromStart(Visitor* visitor) {
|
||||
VisitNodeUsesFrom(start(), visitor);
|
||||
}
|
||||
|
||||
|
||||
template <class Visitor>
|
||||
void Graph::VisitNodeInputsFromEnd(Visitor* visitor) {
|
||||
Zone tmp_zone(zone()->isolate());
|
||||
GenericGraphVisit::Visit<Visitor, NodeInputIterationTraits<Node> >(
|
||||
this, &tmp_zone, end(), visitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace v8::internal::compiler
|
||||
|
||||
} // namespace compiler
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_COMPILER_GRAPH_INL_H_
|
||||
|
@ -61,12 +61,6 @@ class Graph : public GenericGraph<Node> {
|
||||
return NewNode(op, arraysize(nodes), nodes);
|
||||
}
|
||||
|
||||
template <class Visitor>
|
||||
void VisitNodeUsesFrom(Node* node, Visitor* visitor);
|
||||
|
||||
template <class Visitor>
|
||||
void VisitNodeUsesFromStart(Visitor* visitor);
|
||||
|
||||
template <class Visitor>
|
||||
void VisitNodeInputsFromEnd(Visitor* visitor);
|
||||
|
||||
|
@ -41,36 +41,6 @@ class PostNodeVisitor : public NullNodeVisitor {
|
||||
};
|
||||
|
||||
|
||||
TEST(TestUseNodeVisitEmpty) {
|
||||
GraphWithStartNodeTester graph;
|
||||
|
||||
PreNodeVisitor node_visitor;
|
||||
graph.VisitNodeUsesFromStart(&node_visitor);
|
||||
|
||||
CHECK_EQ(1, static_cast<int>(node_visitor.nodes_.size()));
|
||||
}
|
||||
|
||||
|
||||
TEST(TestUseNodePreOrderVisitSimple) {
|
||||
GraphWithStartNodeTester graph;
|
||||
Node* n2 = graph.NewNode(&dummy_operator, graph.start());
|
||||
Node* n3 = graph.NewNode(&dummy_operator, n2);
|
||||
Node* n4 = graph.NewNode(&dummy_operator, n2, n3);
|
||||
Node* n5 = graph.NewNode(&dummy_operator, n4, n2);
|
||||
graph.SetEnd(n5);
|
||||
|
||||
PreNodeVisitor node_visitor;
|
||||
graph.VisitNodeUsesFromStart(&node_visitor);
|
||||
|
||||
CHECK_EQ(5, static_cast<int>(node_visitor.nodes_.size()));
|
||||
CHECK(graph.start()->id() == node_visitor.nodes_[0]->id());
|
||||
CHECK(n2->id() == node_visitor.nodes_[1]->id());
|
||||
CHECK(n3->id() == node_visitor.nodes_[2]->id());
|
||||
CHECK(n4->id() == node_visitor.nodes_[3]->id());
|
||||
CHECK(n5->id() == node_visitor.nodes_[4]->id());
|
||||
}
|
||||
|
||||
|
||||
TEST(TestInputNodePreOrderVisitSimple) {
|
||||
GraphWithStartNodeTester graph;
|
||||
Node* n2 = graph.NewNode(&dummy_operator, graph.start());
|
||||
@ -90,87 +60,6 @@ TEST(TestInputNodePreOrderVisitSimple) {
|
||||
}
|
||||
|
||||
|
||||
TEST(TestUseNodePostOrderVisitSimple) {
|
||||
GraphWithStartNodeTester graph;
|
||||
Node* n2 = graph.NewNode(&dummy_operator, graph.start());
|
||||
Node* n3 = graph.NewNode(&dummy_operator, graph.start());
|
||||
Node* n4 = graph.NewNode(&dummy_operator, n2);
|
||||
Node* n5 = graph.NewNode(&dummy_operator, n2);
|
||||
Node* n6 = graph.NewNode(&dummy_operator, n2);
|
||||
Node* n7 = graph.NewNode(&dummy_operator, n3);
|
||||
Node* end_dependencies[4] = {n4, n5, n6, n7};
|
||||
Node* n8 = graph.NewNode(&dummy_operator, 4, end_dependencies);
|
||||
graph.SetEnd(n8);
|
||||
|
||||
PostNodeVisitor node_visitor;
|
||||
graph.VisitNodeUsesFromStart(&node_visitor);
|
||||
|
||||
CHECK_EQ(8, static_cast<int>(node_visitor.nodes_.size()));
|
||||
CHECK(graph.end()->id() == node_visitor.nodes_[0]->id());
|
||||
CHECK(n4->id() == node_visitor.nodes_[1]->id());
|
||||
CHECK(n5->id() == node_visitor.nodes_[2]->id());
|
||||
CHECK(n6->id() == node_visitor.nodes_[3]->id());
|
||||
CHECK(n2->id() == node_visitor.nodes_[4]->id());
|
||||
CHECK(n7->id() == node_visitor.nodes_[5]->id());
|
||||
CHECK(n3->id() == node_visitor.nodes_[6]->id());
|
||||
CHECK(graph.start()->id() == node_visitor.nodes_[7]->id());
|
||||
}
|
||||
|
||||
|
||||
TEST(TestUseNodePostOrderVisitLong) {
|
||||
GraphWithStartNodeTester graph;
|
||||
Node* n2 = graph.NewNode(&dummy_operator, graph.start());
|
||||
Node* n3 = graph.NewNode(&dummy_operator, graph.start());
|
||||
Node* n4 = graph.NewNode(&dummy_operator, n2);
|
||||
Node* n5 = graph.NewNode(&dummy_operator, n2);
|
||||
Node* n6 = graph.NewNode(&dummy_operator, n3);
|
||||
Node* n7 = graph.NewNode(&dummy_operator, n3);
|
||||
Node* n8 = graph.NewNode(&dummy_operator, n5);
|
||||
Node* n9 = graph.NewNode(&dummy_operator, n5);
|
||||
Node* n10 = graph.NewNode(&dummy_operator, n9);
|
||||
Node* n11 = graph.NewNode(&dummy_operator, n9);
|
||||
Node* end_dependencies[6] = {n4, n8, n10, n11, n6, n7};
|
||||
Node* n12 = graph.NewNode(&dummy_operator, 6, end_dependencies);
|
||||
graph.SetEnd(n12);
|
||||
|
||||
PostNodeVisitor node_visitor;
|
||||
graph.VisitNodeUsesFromStart(&node_visitor);
|
||||
|
||||
CHECK_EQ(12, static_cast<int>(node_visitor.nodes_.size()));
|
||||
CHECK(graph.end()->id() == node_visitor.nodes_[0]->id());
|
||||
CHECK(n4->id() == node_visitor.nodes_[1]->id());
|
||||
CHECK(n8->id() == node_visitor.nodes_[2]->id());
|
||||
CHECK(n10->id() == node_visitor.nodes_[3]->id());
|
||||
CHECK(n11->id() == node_visitor.nodes_[4]->id());
|
||||
CHECK(n9->id() == node_visitor.nodes_[5]->id());
|
||||
CHECK(n5->id() == node_visitor.nodes_[6]->id());
|
||||
CHECK(n2->id() == node_visitor.nodes_[7]->id());
|
||||
CHECK(n6->id() == node_visitor.nodes_[8]->id());
|
||||
CHECK(n7->id() == node_visitor.nodes_[9]->id());
|
||||
CHECK(n3->id() == node_visitor.nodes_[10]->id());
|
||||
CHECK(graph.start()->id() == node_visitor.nodes_[11]->id());
|
||||
}
|
||||
|
||||
|
||||
TEST(TestUseNodePreOrderVisitCycle) {
|
||||
GraphWithStartNodeTester graph;
|
||||
Node* n0 = graph.start_node();
|
||||
Node* n1 = graph.NewNode(&dummy_operator, n0);
|
||||
Node* n2 = graph.NewNode(&dummy_operator, n1);
|
||||
n0->AppendInput(graph.main_zone(), n2);
|
||||
graph.SetStart(n0);
|
||||
graph.SetEnd(n2);
|
||||
|
||||
PreNodeVisitor node_visitor;
|
||||
graph.VisitNodeUsesFromStart(&node_visitor);
|
||||
|
||||
CHECK_EQ(3, static_cast<int>(node_visitor.nodes_.size()));
|
||||
CHECK(n0->id() == node_visitor.nodes_[0]->id());
|
||||
CHECK(n1->id() == node_visitor.nodes_[1]->id());
|
||||
CHECK(n2->id() == node_visitor.nodes_[2]->id());
|
||||
}
|
||||
|
||||
|
||||
TEST(TestPrintNodeGraphToNodeGraphviz) {
|
||||
GraphWithStartNodeTester graph;
|
||||
Node* n2 = graph.NewNode(&dummy_operator, graph.start());
|
||||
|
Loading…
Reference in New Issue
Block a user