| 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/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
| 6 #include "src/compiler/control-reducer.h" | 6 #include "src/compiler/control-reducer.h" |
| 7 #include "src/compiler/graph.h" | 7 #include "src/compiler/graph.h" |
| 8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
| 9 #include "src/compiler/node-marker.h" | 9 #include "src/compiler/node-marker.h" |
| 10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 node->op()->mnemonic())); | 289 node->op()->mnemonic())); |
| 290 edge.UpdateTo(NULL); | 290 edge.UpdateTo(NULL); |
| 291 } | 291 } |
| 292 } | 292 } |
| 293 } | 293 } |
| 294 #if DEBUG | 294 #if DEBUG |
| 295 // Verify that no inputs to live nodes are NULL. | 295 // Verify that no inputs to live nodes are NULL. |
| 296 for (size_t j = 0; j < nodes.size(); j++) { | 296 for (size_t j = 0; j < nodes.size(); j++) { |
| 297 Node* node = nodes[j]; | 297 Node* node = nodes[j]; |
| 298 for (Node* const input : node->inputs()) { | 298 for (Node* const input : node->inputs()) { |
| 299 CHECK_NE(NULL, input); | 299 CHECK(input); |
| 300 } | 300 } |
| 301 for (Node* const use : node->uses()) { | 301 for (Node* const use : node->uses()) { |
| 302 CHECK(marked.IsReachableFromEnd(use)); | 302 CHECK(marked.IsReachableFromEnd(use)); |
| 303 } | 303 } |
| 304 } | 304 } |
| 305 #endif | 305 #endif |
| 306 } | 306 } |
| 307 | 307 |
| 308 // Reduce the node on the top of the stack. | 308 // Reduce the node on the top of the stack. |
| 309 // If an input {i} is not yet visited or needs to be revisited, push {i} onto | 309 // If an input {i} is not yet visited or needs to be revisited, push {i} onto |
| 310 // the stack and return. Otherwise, all inputs are visited, so apply | 310 // the stack and return. Otherwise, all inputs are visited, so apply |
| 311 // reductions for {node} and pop it off the stack. | 311 // reductions for {node} and pop it off the stack. |
| 312 void ReduceTop() { | 312 void ReduceTop() { |
| 313 size_t height = stack_.size(); | 313 size_t height = stack_.size(); |
| 314 Node* node = stack_.back(); | 314 Node* node = stack_.back(); |
| 315 | 315 |
| 316 if (node->IsDead()) return Pop(); // Node was killed while on stack. | 316 if (node->IsDead()) return Pop(); // Node was killed while on stack. |
| 317 | 317 |
| 318 TRACE(("ControlReduce: #%d:%s\n", node->id(), node->op()->mnemonic())); | 318 TRACE(("ControlReduce: #%d:%s\n", node->id(), node->op()->mnemonic())); |
| 319 | 319 |
| 320 // Recurse on an input if necessary. | 320 // Recurse on an input if necessary. |
| 321 for (Node* const input : node->inputs()) { | 321 for (Node* const input : node->inputs()) { |
| 322 CHECK_NE(NULL, input); | 322 DCHECK(input); |
| 323 if (Recurse(input)) return; | 323 if (Recurse(input)) return; |
| 324 } | 324 } |
| 325 | 325 |
| 326 // All inputs should be visited or on stack. Apply reductions to node. | 326 // All inputs should be visited or on stack. Apply reductions to node. |
| 327 Node* replacement = ReduceNode(node); | 327 Node* replacement = ReduceNode(node); |
| 328 if (replacement != node) ReplaceNode(node, replacement); | 328 if (replacement != node) ReplaceNode(node, replacement); |
| 329 | 329 |
| 330 // After reducing the node, pop it off the stack. | 330 // After reducing the node, pop it off the stack. |
| 331 CHECK_EQ(static_cast<int>(height), static_cast<int>(stack_.size())); | 331 CHECK_EQ(static_cast<int>(height), static_cast<int>(stack_.size())); |
| 332 Pop(); | 332 Pop(); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 return impl.ReduceIfTrue(node); | 634 return impl.ReduceIfTrue(node); |
| 635 case IrOpcode::kIfFalse: | 635 case IrOpcode::kIfFalse: |
| 636 return impl.ReduceIfFalse(node); | 636 return impl.ReduceIfFalse(node); |
| 637 default: | 637 default: |
| 638 return node; | 638 return node; |
| 639 } | 639 } |
| 640 } | 640 } |
| 641 } | 641 } |
| 642 } | 642 } |
| 643 } // namespace v8::internal::compiler | 643 } // namespace v8::internal::compiler |
| OLD | NEW |