Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: test/cctest/compiler/test-node-algorithm.cc

Issue 752263003: Remove deprecated pieces from generic algorithm. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/graph-inl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "graph-tester.h" 9 #include "graph-tester.h"
10 #include "src/compiler/common-operator.h" 10 #include "src/compiler/common-operator.h"
(...skipping 23 matching lines...) Expand all
34 class PostNodeVisitor : public NullNodeVisitor { 34 class PostNodeVisitor : public NullNodeVisitor {
35 public: 35 public:
36 void Post(Node* node) { 36 void Post(Node* node) {
37 printf("NODE ID: %d\n", node->id()); 37 printf("NODE ID: %d\n", node->id());
38 nodes_.push_back(node); 38 nodes_.push_back(node);
39 } 39 }
40 std::vector<Node*> nodes_; 40 std::vector<Node*> nodes_;
41 }; 41 };
42 42
43 43
44 TEST(TestUseNodeVisitEmpty) {
45 GraphWithStartNodeTester graph;
46
47 PreNodeVisitor node_visitor;
48 graph.VisitNodeUsesFromStart(&node_visitor);
49
50 CHECK_EQ(1, static_cast<int>(node_visitor.nodes_.size()));
51 }
52
53
54 TEST(TestUseNodePreOrderVisitSimple) {
55 GraphWithStartNodeTester graph;
56 Node* n2 = graph.NewNode(&dummy_operator, graph.start());
57 Node* n3 = graph.NewNode(&dummy_operator, n2);
58 Node* n4 = graph.NewNode(&dummy_operator, n2, n3);
59 Node* n5 = graph.NewNode(&dummy_operator, n4, n2);
60 graph.SetEnd(n5);
61
62 PreNodeVisitor node_visitor;
63 graph.VisitNodeUsesFromStart(&node_visitor);
64
65 CHECK_EQ(5, static_cast<int>(node_visitor.nodes_.size()));
66 CHECK(graph.start()->id() == node_visitor.nodes_[0]->id());
67 CHECK(n2->id() == node_visitor.nodes_[1]->id());
68 CHECK(n3->id() == node_visitor.nodes_[2]->id());
69 CHECK(n4->id() == node_visitor.nodes_[3]->id());
70 CHECK(n5->id() == node_visitor.nodes_[4]->id());
71 }
72
73
74 TEST(TestInputNodePreOrderVisitSimple) { 44 TEST(TestInputNodePreOrderVisitSimple) {
75 GraphWithStartNodeTester graph; 45 GraphWithStartNodeTester graph;
76 Node* n2 = graph.NewNode(&dummy_operator, graph.start()); 46 Node* n2 = graph.NewNode(&dummy_operator, graph.start());
77 Node* n3 = graph.NewNode(&dummy_operator, n2); 47 Node* n3 = graph.NewNode(&dummy_operator, n2);
78 Node* n4 = graph.NewNode(&dummy_operator, n2, n3); 48 Node* n4 = graph.NewNode(&dummy_operator, n2, n3);
79 Node* n5 = graph.NewNode(&dummy_operator, n4, n2); 49 Node* n5 = graph.NewNode(&dummy_operator, n4, n2);
80 graph.SetEnd(n5); 50 graph.SetEnd(n5);
81 51
82 PreNodeVisitor node_visitor; 52 PreNodeVisitor node_visitor;
83 graph.VisitNodeInputsFromEnd(&node_visitor); 53 graph.VisitNodeInputsFromEnd(&node_visitor);
84 CHECK_EQ(5, static_cast<int>(node_visitor.nodes_.size())); 54 CHECK_EQ(5, static_cast<int>(node_visitor.nodes_.size()));
85 CHECK(n5->id() == node_visitor.nodes_[0]->id()); 55 CHECK(n5->id() == node_visitor.nodes_[0]->id());
86 CHECK(n4->id() == node_visitor.nodes_[1]->id()); 56 CHECK(n4->id() == node_visitor.nodes_[1]->id());
87 CHECK(n2->id() == node_visitor.nodes_[2]->id()); 57 CHECK(n2->id() == node_visitor.nodes_[2]->id());
88 CHECK(graph.start()->id() == node_visitor.nodes_[3]->id()); 58 CHECK(graph.start()->id() == node_visitor.nodes_[3]->id());
89 CHECK(n3->id() == node_visitor.nodes_[4]->id()); 59 CHECK(n3->id() == node_visitor.nodes_[4]->id());
90 } 60 }
91 61
92 62
93 TEST(TestUseNodePostOrderVisitSimple) {
94 GraphWithStartNodeTester graph;
95 Node* n2 = graph.NewNode(&dummy_operator, graph.start());
96 Node* n3 = graph.NewNode(&dummy_operator, graph.start());
97 Node* n4 = graph.NewNode(&dummy_operator, n2);
98 Node* n5 = graph.NewNode(&dummy_operator, n2);
99 Node* n6 = graph.NewNode(&dummy_operator, n2);
100 Node* n7 = graph.NewNode(&dummy_operator, n3);
101 Node* end_dependencies[4] = {n4, n5, n6, n7};
102 Node* n8 = graph.NewNode(&dummy_operator, 4, end_dependencies);
103 graph.SetEnd(n8);
104
105 PostNodeVisitor node_visitor;
106 graph.VisitNodeUsesFromStart(&node_visitor);
107
108 CHECK_EQ(8, static_cast<int>(node_visitor.nodes_.size()));
109 CHECK(graph.end()->id() == node_visitor.nodes_[0]->id());
110 CHECK(n4->id() == node_visitor.nodes_[1]->id());
111 CHECK(n5->id() == node_visitor.nodes_[2]->id());
112 CHECK(n6->id() == node_visitor.nodes_[3]->id());
113 CHECK(n2->id() == node_visitor.nodes_[4]->id());
114 CHECK(n7->id() == node_visitor.nodes_[5]->id());
115 CHECK(n3->id() == node_visitor.nodes_[6]->id());
116 CHECK(graph.start()->id() == node_visitor.nodes_[7]->id());
117 }
118
119
120 TEST(TestUseNodePostOrderVisitLong) {
121 GraphWithStartNodeTester graph;
122 Node* n2 = graph.NewNode(&dummy_operator, graph.start());
123 Node* n3 = graph.NewNode(&dummy_operator, graph.start());
124 Node* n4 = graph.NewNode(&dummy_operator, n2);
125 Node* n5 = graph.NewNode(&dummy_operator, n2);
126 Node* n6 = graph.NewNode(&dummy_operator, n3);
127 Node* n7 = graph.NewNode(&dummy_operator, n3);
128 Node* n8 = graph.NewNode(&dummy_operator, n5);
129 Node* n9 = graph.NewNode(&dummy_operator, n5);
130 Node* n10 = graph.NewNode(&dummy_operator, n9);
131 Node* n11 = graph.NewNode(&dummy_operator, n9);
132 Node* end_dependencies[6] = {n4, n8, n10, n11, n6, n7};
133 Node* n12 = graph.NewNode(&dummy_operator, 6, end_dependencies);
134 graph.SetEnd(n12);
135
136 PostNodeVisitor node_visitor;
137 graph.VisitNodeUsesFromStart(&node_visitor);
138
139 CHECK_EQ(12, static_cast<int>(node_visitor.nodes_.size()));
140 CHECK(graph.end()->id() == node_visitor.nodes_[0]->id());
141 CHECK(n4->id() == node_visitor.nodes_[1]->id());
142 CHECK(n8->id() == node_visitor.nodes_[2]->id());
143 CHECK(n10->id() == node_visitor.nodes_[3]->id());
144 CHECK(n11->id() == node_visitor.nodes_[4]->id());
145 CHECK(n9->id() == node_visitor.nodes_[5]->id());
146 CHECK(n5->id() == node_visitor.nodes_[6]->id());
147 CHECK(n2->id() == node_visitor.nodes_[7]->id());
148 CHECK(n6->id() == node_visitor.nodes_[8]->id());
149 CHECK(n7->id() == node_visitor.nodes_[9]->id());
150 CHECK(n3->id() == node_visitor.nodes_[10]->id());
151 CHECK(graph.start()->id() == node_visitor.nodes_[11]->id());
152 }
153
154
155 TEST(TestUseNodePreOrderVisitCycle) {
156 GraphWithStartNodeTester graph;
157 Node* n0 = graph.start_node();
158 Node* n1 = graph.NewNode(&dummy_operator, n0);
159 Node* n2 = graph.NewNode(&dummy_operator, n1);
160 n0->AppendInput(graph.main_zone(), n2);
161 graph.SetStart(n0);
162 graph.SetEnd(n2);
163
164 PreNodeVisitor node_visitor;
165 graph.VisitNodeUsesFromStart(&node_visitor);
166
167 CHECK_EQ(3, static_cast<int>(node_visitor.nodes_.size()));
168 CHECK(n0->id() == node_visitor.nodes_[0]->id());
169 CHECK(n1->id() == node_visitor.nodes_[1]->id());
170 CHECK(n2->id() == node_visitor.nodes_[2]->id());
171 }
172
173
174 TEST(TestPrintNodeGraphToNodeGraphviz) { 63 TEST(TestPrintNodeGraphToNodeGraphviz) {
175 GraphWithStartNodeTester graph; 64 GraphWithStartNodeTester graph;
176 Node* n2 = graph.NewNode(&dummy_operator, graph.start()); 65 Node* n2 = graph.NewNode(&dummy_operator, graph.start());
177 Node* n3 = graph.NewNode(&dummy_operator, graph.start()); 66 Node* n3 = graph.NewNode(&dummy_operator, graph.start());
178 Node* n4 = graph.NewNode(&dummy_operator, n2); 67 Node* n4 = graph.NewNode(&dummy_operator, n2);
179 Node* n5 = graph.NewNode(&dummy_operator, n2); 68 Node* n5 = graph.NewNode(&dummy_operator, n2);
180 Node* n6 = graph.NewNode(&dummy_operator, n3); 69 Node* n6 = graph.NewNode(&dummy_operator, n3);
181 Node* n7 = graph.NewNode(&dummy_operator, n3); 70 Node* n7 = graph.NewNode(&dummy_operator, n3);
182 Node* n8 = graph.NewNode(&dummy_operator, n5); 71 Node* n8 = graph.NewNode(&dummy_operator, n5);
183 Node* n9 = graph.NewNode(&dummy_operator, n5); 72 Node* n9 = graph.NewNode(&dummy_operator, n5);
184 Node* n10 = graph.NewNode(&dummy_operator, n9); 73 Node* n10 = graph.NewNode(&dummy_operator, n9);
185 Node* n11 = graph.NewNode(&dummy_operator, n9); 74 Node* n11 = graph.NewNode(&dummy_operator, n9);
186 Node* end_dependencies[6] = {n4, n8, n10, n11, n6, n7}; 75 Node* end_dependencies[6] = {n4, n8, n10, n11, n6, n7};
187 Node* n12 = graph.NewNode(&dummy_operator, 6, end_dependencies); 76 Node* n12 = graph.NewNode(&dummy_operator, 6, end_dependencies);
188 graph.SetEnd(n12); 77 graph.SetEnd(n12);
189 78
190 OFStream os(stdout); 79 OFStream os(stdout);
191 os << AsDOT(graph); 80 os << AsDOT(graph);
192 } 81 }
OLDNEW
« no previous file with comments | « src/compiler/graph-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698