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

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

Issue 765983002: Clean up node iteration (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix comment 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
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 <functional> 5 #include <functional>
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/generic-node-inl.h" 10 #include "src/compiler/generic-node-inl.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 CHECK_EQ(1, n1->InputCount()); 86 CHECK_EQ(1, n1->InputCount());
87 CHECK_EQ(n0, *i); 87 CHECK_EQ(n0, *i);
88 ++i; 88 ++i;
89 CHECK(n1->inputs().end() == i); 89 CHECK(n1->inputs().end() == i);
90 } 90 }
91 91
92 92
93 TEST(NodeUseIteratorEmpty) { 93 TEST(NodeUseIteratorEmpty) {
94 GraphTester graph; 94 GraphTester graph;
95 Node* n1 = graph.NewNode(&dummy_operator); 95 Node* n1 = graph.NewNode(&dummy_operator);
96 Node::Uses::iterator i(n1->uses().begin());
97 int use_count = 0; 96 int use_count = 0;
98 for (; i != n1->uses().end(); ++i) { 97 for (auto const edge : n1->use_edges()) {
99 Node::Edge edge(i.edge());
100 USE(edge); 98 USE(edge);
101 use_count++; 99 use_count++;
102 } 100 }
103 CHECK_EQ(0, use_count); 101 CHECK_EQ(0, use_count);
104 } 102 }
105 103
106 104
107 TEST(NodeUseIteratorOne) { 105 TEST(NodeUseIteratorOne) {
108 GraphTester graph; 106 GraphTester graph;
109 Node* n0 = graph.NewNode(&dummy_operator); 107 Node* n0 = graph.NewNode(&dummy_operator);
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 } 357 }
360 358
361 359
362 TEST(AppendInputsAndIterator) { 360 TEST(AppendInputsAndIterator) {
363 GraphTester graph; 361 GraphTester graph;
364 362
365 Node* n0 = graph.NewNode(&dummy_operator); 363 Node* n0 = graph.NewNode(&dummy_operator);
366 Node* n1 = graph.NewNode(&dummy_operator, n0); 364 Node* n1 = graph.NewNode(&dummy_operator, n0);
367 Node* n2 = graph.NewNode(&dummy_operator, n0, n1); 365 Node* n2 = graph.NewNode(&dummy_operator, n0, n1);
368 366
369 Node::Inputs inputs(n2->inputs()); 367 auto inputs(n2->input_edges());
370 Node::Inputs::iterator current = inputs.begin(); 368 auto current = inputs.begin();
371 CHECK(current != inputs.end()); 369 CHECK(current != inputs.end());
372 CHECK(*current == n0); 370 CHECK((*current).to() == n0);
373 ++current; 371 ++current;
374 CHECK(current != inputs.end()); 372 CHECK(current != inputs.end());
375 CHECK(*current == n1); 373 CHECK((*current).to() == n1);
376 ++current; 374 ++current;
377 CHECK(current == inputs.end()); 375 CHECK(current == inputs.end());
378 376
379 Node* n3 = graph.NewNode(&dummy_operator); 377 Node* n3 = graph.NewNode(&dummy_operator);
380 n2->AppendInput(graph.zone(), n3); 378 n2->AppendInput(graph.zone(), n3);
381 inputs = n2->inputs(); 379 inputs = n2->input_edges();
382 current = inputs.begin(); 380 current = inputs.begin();
383 CHECK(current != inputs.end()); 381 CHECK(current != inputs.end());
384 CHECK(*current == n0); 382 CHECK((*current).to() == n0);
385 CHECK_EQ(0, current.index()); 383 CHECK_EQ(0, (*current).index());
386 ++current; 384 ++current;
387 CHECK(current != inputs.end()); 385 CHECK(current != inputs.end());
388 CHECK(*current == n1); 386 CHECK((*current).to() == n1);
389 CHECK_EQ(1, current.index()); 387 CHECK_EQ(1, (*current).index());
390 ++current; 388 ++current;
391 CHECK(current != inputs.end()); 389 CHECK(current != inputs.end());
392 CHECK(*current == n3); 390 CHECK((*current).to() == n3);
393 CHECK_EQ(2, current.index()); 391 CHECK_EQ(2, (*current).index());
394 ++current; 392 ++current;
395 CHECK(current == inputs.end()); 393 CHECK(current == inputs.end());
396 } 394 }
397 395
398 396
399 TEST(NullInputsSimple) { 397 TEST(NullInputsSimple) {
400 GraphTester graph; 398 GraphTester graph;
401 399
402 Node* n0 = graph.NewNode(&dummy_operator); 400 Node* n0 = graph.NewNode(&dummy_operator);
403 Node* n1 = graph.NewNode(&dummy_operator, n0); 401 Node* n1 = graph.NewNode(&dummy_operator, n0);
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 n1->ReplaceInput(0, n1); // self-reference. 830 n1->ReplaceInput(0, n1); // self-reference.
833 831
834 CHECK_EQ(0, n0->UseCount()); 832 CHECK_EQ(0, n0->UseCount());
835 CHECK_EQ(1, n1->UseCount()); 833 CHECK_EQ(1, n1->UseCount());
836 n1->RemoveAllInputs(); 834 n1->RemoveAllInputs();
837 CHECK_EQ(1, n1->InputCount()); 835 CHECK_EQ(1, n1->InputCount());
838 CHECK_EQ(0, n1->UseCount()); 836 CHECK_EQ(0, n1->UseCount());
839 CHECK_EQ(NULL, n1->InputAt(0)); 837 CHECK_EQ(NULL, n1->InputAt(0));
840 } 838 }
841 } 839 }
OLDNEW
« src/compiler/control-reducer.cc ('K') | « test/cctest/compiler/test-control-reducer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698