OLD | NEW |
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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 CHECK(current != uses.end()); | 331 CHECK(current != uses.end()); |
332 CHECK(*current == n5); | 332 CHECK(*current == n5); |
333 ++current; | 333 ++current; |
334 CHECK(current != uses.end()); | 334 CHECK(current != uses.end()); |
335 CHECK(*current == n3); | 335 CHECK(*current == n3); |
336 ++current; | 336 ++current; |
337 CHECK(current == uses.end()); | 337 CHECK(current == uses.end()); |
338 } | 338 } |
339 | 339 |
340 | 340 |
| 341 TEST(RemoveInput) { |
| 342 GraphTester graph; |
| 343 |
| 344 Node* n0 = graph.NewNode(&dummy_operator); |
| 345 Node* n1 = graph.NewNode(&dummy_operator, n0); |
| 346 Node* n2 = graph.NewNode(&dummy_operator, n0, n1); |
| 347 |
| 348 n1->RemoveInput(0); |
| 349 CHECK_EQ(0, n1->InputCount()); |
| 350 CHECK_EQ(1, n0->UseCount()); |
| 351 |
| 352 n2->RemoveInput(0); |
| 353 CHECK_EQ(1, n2->InputCount()); |
| 354 CHECK_EQ(0, n0->UseCount()); |
| 355 CHECK_EQ(1, n1->UseCount()); |
| 356 |
| 357 n2->RemoveInput(0); |
| 358 CHECK_EQ(0, n2->InputCount()); |
| 359 } |
| 360 |
| 361 |
341 TEST(AppendInputsAndIterator) { | 362 TEST(AppendInputsAndIterator) { |
342 GraphTester graph; | 363 GraphTester graph; |
343 | 364 |
344 Node* n0 = graph.NewNode(&dummy_operator); | 365 Node* n0 = graph.NewNode(&dummy_operator); |
345 Node* n1 = graph.NewNode(&dummy_operator, n0); | 366 Node* n1 = graph.NewNode(&dummy_operator, n0); |
346 Node* n2 = graph.NewNode(&dummy_operator, n0, n1); | 367 Node* n2 = graph.NewNode(&dummy_operator, n0, n1); |
347 | 368 |
348 Node::Inputs inputs(n2->inputs()); | 369 Node::Inputs inputs(n2->inputs()); |
349 Node::Inputs::iterator current = inputs.begin(); | 370 Node::Inputs::iterator current = inputs.begin(); |
350 CHECK(current != inputs.end()); | 371 CHECK(current != inputs.end()); |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 n1->ReplaceInput(0, n1); // self-reference. | 832 n1->ReplaceInput(0, n1); // self-reference. |
812 | 833 |
813 CHECK_EQ(0, n0->UseCount()); | 834 CHECK_EQ(0, n0->UseCount()); |
814 CHECK_EQ(1, n1->UseCount()); | 835 CHECK_EQ(1, n1->UseCount()); |
815 n1->RemoveAllInputs(); | 836 n1->RemoveAllInputs(); |
816 CHECK_EQ(1, n1->InputCount()); | 837 CHECK_EQ(1, n1->InputCount()); |
817 CHECK_EQ(0, n1->UseCount()); | 838 CHECK_EQ(0, n1->UseCount()); |
818 CHECK_EQ(NULL, n1->InputAt(0)); | 839 CHECK_EQ(NULL, n1->InputAt(0)); |
819 } | 840 } |
820 } | 841 } |
OLD | NEW |