| 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 <functional> | 5 #include <functional> |
| 6 #include <limits> | 6 #include <limits> |
| 7 | 7 |
| 8 #include "src/compiler/graph.h" | 8 #include "src/compiler/graph.h" |
| 9 #include "src/compiler/graph-reducer.h" | 9 #include "src/compiler/graph-reducer.h" |
| 10 #include "src/compiler/node.h" | 10 #include "src/compiler/node.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 } | 161 } |
| 162 } | 162 } |
| 163 | 163 |
| 164 | 164 |
| 165 void GraphReducer::Replace(Node* node, Node* replacement) { | 165 void GraphReducer::Replace(Node* node, Node* replacement) { |
| 166 Replace(node, replacement, std::numeric_limits<NodeId>::max()); | 166 Replace(node, replacement, std::numeric_limits<NodeId>::max()); |
| 167 } | 167 } |
| 168 | 168 |
| 169 | 169 |
| 170 void GraphReducer::Replace(Node* node, Node* replacement, NodeId max_id) { | 170 void GraphReducer::Replace(Node* node, Node* replacement, NodeId max_id) { |
| 171 if (FLAG_trace_turbo_reduction) { |
| 172 OFStream os(stdout); |
| 173 os << "- Replacing " << *node << " with " << *replacement << std::endl; |
| 174 } |
| 171 if (node == graph()->start()) graph()->SetStart(replacement); | 175 if (node == graph()->start()) graph()->SetStart(replacement); |
| 172 if (node == graph()->end()) graph()->SetEnd(replacement); | 176 if (node == graph()->end()) graph()->SetEnd(replacement); |
| 173 if (replacement->id() <= max_id) { | 177 if (replacement->id() <= max_id) { |
| 174 // {replacement} is an old node, so unlink {node} and assume that | 178 // {replacement} is an old node, so unlink {node} and assume that |
| 175 // {replacement} was already reduced and finish. | 179 // {replacement} was already reduced and finish. |
| 176 for (Edge edge : node->use_edges()) { | 180 for (Edge edge : node->use_edges()) { |
| 177 Node* const user = edge.from(); | 181 Node* const user = edge.from(); |
| 178 Verifier::VerifyEdgeInputReplacement(edge, replacement); | 182 Verifier::VerifyEdgeInputReplacement(edge, replacement); |
| 179 edge.UpdateTo(replacement); | 183 edge.UpdateTo(replacement); |
| 180 // Don't revisit this node if it refers to itself. | 184 // Don't revisit this node if it refers to itself. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 void GraphReducer::Revisit(Node* node) { | 269 void GraphReducer::Revisit(Node* node) { |
| 266 if (state_.Get(node) == State::kVisited) { | 270 if (state_.Get(node) == State::kVisited) { |
| 267 state_.Set(node, State::kRevisit); | 271 state_.Set(node, State::kRevisit); |
| 268 revisit_.push(node); | 272 revisit_.push(node); |
| 269 } | 273 } |
| 270 } | 274 } |
| 271 | 275 |
| 272 } // namespace compiler | 276 } // namespace compiler |
| 273 } // namespace internal | 277 } // namespace internal |
| 274 } // namespace v8 | 278 } // namespace v8 |
| OLD | NEW |