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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 Node::Uses::iterator i(n0->uses().begin()); | 111 Node::Uses::iterator i(n0->uses().begin()); |
112 CHECK_EQ(n1, *i); | 112 CHECK_EQ(n1, *i); |
113 ++i; | 113 ++i; |
114 CHECK(n0->uses().end() == i); | 114 CHECK(n0->uses().end() == i); |
115 } | 115 } |
116 | 116 |
117 | 117 |
118 TEST(NodeUseIteratorReplaceNoUses) { | 118 TEST(NodeUseIteratorReplaceNoUses) { |
119 GraphTester graph; | 119 GraphTester graph; |
120 Node* n0 = graph.NewNode(&dummy_operator); | 120 Node* n0 = graph.NewNode(&dummy_operator); |
121 Node* n3 = graph.NewNode(&dummy_operator); | 121 Node* n1 = graph.NewNode(&dummy_operator); |
122 n0->ReplaceUses(n3); | 122 Node* n2 = graph.NewNode(&dummy_operator); |
| 123 Node* n3 = graph.NewNode(&dummy_operator, n2); |
| 124 n0->ReplaceUses(n1); |
123 CHECK(n0->uses().begin() == n0->uses().end()); | 125 CHECK(n0->uses().begin() == n0->uses().end()); |
| 126 n0->ReplaceUses(n2); |
| 127 CHECK(n0->uses().begin() == n0->uses().end()); |
| 128 USE(n3); |
124 } | 129 } |
125 | 130 |
126 | 131 |
127 TEST(NodeUseIteratorReplaceUses) { | 132 TEST(NodeUseIteratorReplaceUses) { |
128 GraphTester graph; | 133 GraphTester graph; |
129 Node* n0 = graph.NewNode(&dummy_operator); | 134 Node* n0 = graph.NewNode(&dummy_operator); |
130 Node* n1 = graph.NewNode(&dummy_operator, n0); | 135 Node* n1 = graph.NewNode(&dummy_operator, n0); |
131 Node* n2 = graph.NewNode(&dummy_operator, n0); | 136 Node* n2 = graph.NewNode(&dummy_operator, n0); |
132 Node* n3 = graph.NewNode(&dummy_operator); | 137 Node* n3 = graph.NewNode(&dummy_operator); |
133 Node::Uses::iterator i1(n0->uses().begin()); | 138 Node::Uses::iterator i1(n0->uses().begin()); |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 n1->ReplaceInput(0, n1); // self-reference. | 811 n1->ReplaceInput(0, n1); // self-reference. |
807 | 812 |
808 CHECK_EQ(0, n0->UseCount()); | 813 CHECK_EQ(0, n0->UseCount()); |
809 CHECK_EQ(1, n1->UseCount()); | 814 CHECK_EQ(1, n1->UseCount()); |
810 n1->RemoveAllInputs(); | 815 n1->RemoveAllInputs(); |
811 CHECK_EQ(1, n1->InputCount()); | 816 CHECK_EQ(1, n1->InputCount()); |
812 CHECK_EQ(0, n1->UseCount()); | 817 CHECK_EQ(0, n1->UseCount()); |
813 CHECK_EQ(NULL, n1->InputAt(0)); | 818 CHECK_EQ(NULL, n1->InputAt(0)); |
814 } | 819 } |
815 } | 820 } |
OLD | NEW |