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

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