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

Side by Side Diff: test/unittests/compiler/node-unittest.cc

Issue 1132353004: [turbofan] Fix Node::TrimInputCount() followed by Node::AppendInput() bug. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Update comments. Created 5 years, 7 months 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/node.cc ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 "src/compiler/node.h" 5 #include "src/compiler/node.h"
6 #include "src/compiler/operator.h" 6 #include "src/compiler/operator.h"
7 #include "test/unittests/test-utils.h" 7 #include "test/unittests/test-utils.h"
8 #include "testing/gmock-support.h" 8 #include "testing/gmock-support.h"
9 9
10 using testing::ElementsAre; 10 using testing::ElementsAre;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 node->AppendInput(zone(), n1); 159 node->AppendInput(zone(), n1);
160 EXPECT_THAT(node->inputs(), ElementsAre(n0, n1)); 160 EXPECT_THAT(node->inputs(), ElementsAre(n0, n1));
161 node->AppendInput(zone(), n0); 161 node->AppendInput(zone(), n0);
162 EXPECT_THAT(node->inputs(), ElementsAre(n0, n1, n0)); 162 EXPECT_THAT(node->inputs(), ElementsAre(n0, n1, n0));
163 node->AppendInput(zone(), n0); 163 node->AppendInput(zone(), n0);
164 EXPECT_THAT(node->inputs(), ElementsAre(n0, n1, n0, n0)); 164 EXPECT_THAT(node->inputs(), ElementsAre(n0, n1, n0, n0));
165 node->AppendInput(zone(), n1); 165 node->AppendInput(zone(), n1);
166 EXPECT_THAT(node->inputs(), ElementsAre(n0, n1, n0, n0, n1)); 166 EXPECT_THAT(node->inputs(), ElementsAre(n0, n1, n0, n0, n1));
167 } 167 }
168 168
169
170 TEST_F(NodeTest, TrimThenAppend) {
171 Node* n0 = Node::New(zone(), 0, &kOp0, 0, nullptr, false);
172 Node* n1 = Node::New(zone(), 1, &kOp0, 0, nullptr, false);
173 Node* n2 = Node::New(zone(), 2, &kOp0, 0, nullptr, false);
174 Node* n3 = Node::New(zone(), 3, &kOp0, 0, nullptr, false);
175 Node* n4 = Node::New(zone(), 4, &kOp0, 0, nullptr, false);
176 Node* n5 = Node::New(zone(), 5, &kOp0, 0, nullptr, false);
177 Node* n6 = Node::New(zone(), 6, &kOp0, 0, nullptr, false);
178 Node* n7 = Node::New(zone(), 7, &kOp0, 0, nullptr, false);
179 Node* n8 = Node::New(zone(), 8, &kOp0, 0, nullptr, false);
180 Node* n9 = Node::New(zone(), 9, &kOp0, 0, nullptr, false);
181 Node* node = Node::New(zone(), 12345, &kOp0, 0, nullptr, true);
182
183 EXPECT_TRUE(node->inputs().empty());
184
185 node->AppendInput(zone(), n0);
186 EXPECT_FALSE(node->inputs().empty());
187 EXPECT_THAT(node->inputs(), ElementsAre(n0));
188
189 node->TrimInputCount(0);
190 EXPECT_TRUE(node->inputs().empty());
191
192 node->AppendInput(zone(), n1);
193 EXPECT_FALSE(node->inputs().empty());
194 EXPECT_THAT(node->inputs(), ElementsAre(n1));
195
196 node->AppendInput(zone(), n2);
197 EXPECT_FALSE(node->inputs().empty());
198 EXPECT_THAT(node->inputs(), ElementsAre(n1, n2));
199
200 node->TrimInputCount(1);
201 EXPECT_FALSE(node->inputs().empty());
202 EXPECT_THAT(node->inputs(), ElementsAre(n1));
203
204 node->AppendInput(zone(), n3);
205 EXPECT_FALSE(node->inputs().empty());
206 EXPECT_THAT(node->inputs(), ElementsAre(n1, n3));
207
208 node->AppendInput(zone(), n4);
209 EXPECT_FALSE(node->inputs().empty());
210 EXPECT_THAT(node->inputs(), ElementsAre(n1, n3, n4));
211
212 node->AppendInput(zone(), n5);
213 EXPECT_FALSE(node->inputs().empty());
214 EXPECT_THAT(node->inputs(), ElementsAre(n1, n3, n4, n5));
215
216 node->AppendInput(zone(), n6);
217 EXPECT_FALSE(node->inputs().empty());
218 EXPECT_THAT(node->inputs(), ElementsAre(n1, n3, n4, n5, n6));
219
220 node->AppendInput(zone(), n7);
221 EXPECT_FALSE(node->inputs().empty());
222 EXPECT_THAT(node->inputs(), ElementsAre(n1, n3, n4, n5, n6, n7));
223
224 node->TrimInputCount(4);
225 EXPECT_THAT(node->inputs(), ElementsAre(n1, n3, n4, n5));
226
227 node->AppendInput(zone(), n8);
228 EXPECT_FALSE(node->inputs().empty());
229 EXPECT_THAT(node->inputs(), ElementsAre(n1, n3, n4, n5, n8));
230
231 node->AppendInput(zone(), n9);
232 EXPECT_FALSE(node->inputs().empty());
233 EXPECT_THAT(node->inputs(), ElementsAre(n1, n3, n4, n5, n8, n9));
234 }
235
169 } // namespace compiler 236 } // namespace compiler
170 } // namespace internal 237 } // namespace internal
171 } // namespace v8 238 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/node.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698