| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/control-flow-optimizer.h" | 5 #include "src/compiler/control-flow-optimizer.h" |
| 6 | 6 |
| 7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
| 8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
| 9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
| 10 | 10 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 Int32BinopMatcher m(cond); | 61 Int32BinopMatcher m(cond); |
| 62 Node* index = m.left().node(); | 62 Node* index = m.left().node(); |
| 63 if (!m.right().HasValue()) return VisitNode(node); | 63 if (!m.right().HasValue()) return VisitNode(node); |
| 64 int32_t value = m.right().Value(); | 64 int32_t value = m.right().Value(); |
| 65 ZoneSet<int32_t> values(zone()); | 65 ZoneSet<int32_t> values(zone()); |
| 66 values.insert(value); | 66 values.insert(value); |
| 67 | 67 |
| 68 Node* if_false; | 68 Node* if_false; |
| 69 Node* if_true; | 69 Node* if_true; |
| 70 while (true) { | 70 while (true) { |
| 71 // TODO(turbofan): use NodeProperties::CollectSuccessorProjections() here | 71 Node* control_projections[2]; |
| 72 // once available. | 72 NodeProperties::CollectControlProjections(branch, control_projections, 2); |
| 73 auto it = branch->uses().begin(); | 73 if_true = control_projections[0]; |
| 74 DCHECK(it != branch->uses().end()); | 74 if_false = control_projections[1]; |
| 75 if_true = *it++; | |
| 76 DCHECK(it != branch->uses().end()); | |
| 77 if_false = *it++; | |
| 78 DCHECK(it == branch->uses().end()); | |
| 79 if (if_true->opcode() != IrOpcode::kIfTrue) std::swap(if_true, if_false); | |
| 80 DCHECK_EQ(IrOpcode::kIfTrue, if_true->opcode()); | 75 DCHECK_EQ(IrOpcode::kIfTrue, if_true->opcode()); |
| 81 DCHECK_EQ(IrOpcode::kIfFalse, if_false->opcode()); | 76 DCHECK_EQ(IrOpcode::kIfFalse, if_false->opcode()); |
| 82 | 77 |
| 83 it = if_false->uses().begin(); | 78 auto it = if_false->uses().begin(); |
| 84 if (it == if_false->uses().end()) break; | 79 if (it == if_false->uses().end()) break; |
| 85 Node* branch1 = *it++; | 80 Node* branch1 = *it++; |
| 86 if (branch1->opcode() != IrOpcode::kBranch) break; | 81 if (branch1->opcode() != IrOpcode::kBranch) break; |
| 87 if (it != if_false->uses().end()) break; | 82 if (it != if_false->uses().end()) break; |
| 88 Node* cond1 = branch1->InputAt(0); | 83 Node* cond1 = branch1->InputAt(0); |
| 89 if (cond1->opcode() != IrOpcode::kWord32Equal) break; | 84 if (cond1->opcode() != IrOpcode::kWord32Equal) break; |
| 90 Int32BinopMatcher m1(cond1); | 85 Int32BinopMatcher m1(cond1); |
| 91 if (m1.left().node() != index) break; | 86 if (m1.left().node() != index) break; |
| 92 if (!m1.right().HasValue()) break; | 87 if (!m1.right().HasValue()) break; |
| 93 int32_t value1 = m1.right().Value(); | 88 int32_t value1 = m1.right().Value(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 Graph* ControlFlowOptimizer::graph() const { return jsgraph()->graph(); } | 133 Graph* ControlFlowOptimizer::graph() const { return jsgraph()->graph(); } |
| 139 | 134 |
| 140 | 135 |
| 141 MachineOperatorBuilder* ControlFlowOptimizer::machine() const { | 136 MachineOperatorBuilder* ControlFlowOptimizer::machine() const { |
| 142 return jsgraph()->machine(); | 137 return jsgraph()->machine(); |
| 143 } | 138 } |
| 144 | 139 |
| 145 } // namespace compiler | 140 } // namespace compiler |
| 146 } // namespace internal | 141 } // namespace internal |
| 147 } // namespace v8 | 142 } // namespace v8 |
| OLD | NEW |