| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/graph-reducer.h" | 5 #include "src/compiler/graph-reducer.h" |
| 6 | 6 |
| 7 #include <functional> | 7 #include <functional> |
| 8 | 8 |
| 9 #include "src/compiler/graph-inl.h" | 9 #include "src/compiler/graph-inl.h" |
| 10 | 10 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 if (node == graph()->end()) graph()->SetEnd(replacement); | 147 if (node == graph()->end()) graph()->SetEnd(replacement); |
| 148 // If {node} was replaced by an old node, unlink {node} and assume that | 148 // If {node} was replaced by an old node, unlink {node} and assume that |
| 149 // {replacement} was already reduced and finish. | 149 // {replacement} was already reduced and finish. |
| 150 if (replacement->id() < node_count) { | 150 if (replacement->id() < node_count) { |
| 151 node->ReplaceUses(replacement); | 151 node->ReplaceUses(replacement); |
| 152 node->Kill(); | 152 node->Kill(); |
| 153 } else { | 153 } else { |
| 154 // Otherwise {node} was replaced by a new node. Replace all old uses of | 154 // Otherwise {node} was replaced by a new node. Replace all old uses of |
| 155 // {node} with {replacement}. New nodes created by this reduction can | 155 // {node} with {replacement}. New nodes created by this reduction can |
| 156 // use {node}. | 156 // use {node}. |
| 157 node->ReplaceUsesIf( | 157 for (Edge edge : node->use_edges()) { |
| 158 [node_count](Node* const node) { return node->id() < node_count; }, | 158 if (edge.from()->id() < node_count) { |
| 159 replacement); | 159 edge.UpdateTo(replacement); |
| 160 } |
| 161 } |
| 160 // Unlink {node} if it's no longer used. | 162 // Unlink {node} if it's no longer used. |
| 161 if (node->uses().empty()) { | 163 if (node->uses().empty()) { |
| 162 node->Kill(); | 164 node->Kill(); |
| 163 } | 165 } |
| 164 | 166 |
| 165 // If there was a replacement, reduce it after popping {node}. | 167 // If there was a replacement, reduce it after popping {node}. |
| 166 Recurse(replacement); | 168 Recurse(replacement); |
| 167 } | 169 } |
| 168 } | 170 } |
| 169 } | 171 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 193 void GraphReducer::Revisit(Node* node) { | 195 void GraphReducer::Revisit(Node* node) { |
| 194 if (state_.Get(node) == State::kVisited) { | 196 if (state_.Get(node) == State::kVisited) { |
| 195 state_.Set(node, State::kRevisit); | 197 state_.Set(node, State::kRevisit); |
| 196 revisit_.push(node); | 198 revisit_.push(node); |
| 197 } | 199 } |
| 198 } | 200 } |
| 199 | 201 |
| 200 } // namespace compiler | 202 } // namespace compiler |
| 201 } // namespace internal | 203 } // namespace internal |
| 202 } // namespace v8 | 204 } // namespace v8 |
| OLD | NEW |