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/branch-elimination.h" | 5 #include "src/compiler/branch-elimination.h" |
6 | 6 |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/node-properties.h" | 8 #include "src/compiler/node-properties.h" |
9 #include "src/compiler/simplified-operator.h" | 9 #include "src/compiler/simplified-operator.h" |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 return Replace(dead()); | 76 return Replace(dead()); |
77 } | 77 } |
78 } | 78 } |
79 return TakeConditionsFromFirstControl(node); | 79 return TakeConditionsFromFirstControl(node); |
80 } | 80 } |
81 | 81 |
82 Reduction BranchElimination::ReduceDeoptimizeConditional(Node* node) { | 82 Reduction BranchElimination::ReduceDeoptimizeConditional(Node* node) { |
83 DCHECK(node->opcode() == IrOpcode::kDeoptimizeIf || | 83 DCHECK(node->opcode() == IrOpcode::kDeoptimizeIf || |
84 node->opcode() == IrOpcode::kDeoptimizeUnless); | 84 node->opcode() == IrOpcode::kDeoptimizeUnless); |
85 bool condition_is_true = node->opcode() == IrOpcode::kDeoptimizeUnless; | 85 bool condition_is_true = node->opcode() == IrOpcode::kDeoptimizeUnless; |
| 86 DeoptimizeReason reason = DeoptimizeReasonOf(node->op()); |
86 Node* condition = NodeProperties::GetValueInput(node, 0); | 87 Node* condition = NodeProperties::GetValueInput(node, 0); |
87 Node* frame_state = NodeProperties::GetValueInput(node, 1); | 88 Node* frame_state = NodeProperties::GetValueInput(node, 1); |
88 Node* effect = NodeProperties::GetEffectInput(node); | 89 Node* effect = NodeProperties::GetEffectInput(node); |
89 Node* control = NodeProperties::GetControlInput(node); | 90 Node* control = NodeProperties::GetControlInput(node); |
90 ControlPathConditions const* conditions = node_conditions_.Get(control); | 91 ControlPathConditions const* conditions = node_conditions_.Get(control); |
91 // If we do not know anything about the predecessor, do not propagate just | 92 // If we do not know anything about the predecessor, do not propagate just |
92 // yet because we will have to recompute anyway once we compute the | 93 // yet because we will have to recompute anyway once we compute the |
93 // predecessor. | 94 // predecessor. |
94 if (conditions == nullptr) { | 95 if (conditions == nullptr) { |
95 return UpdateConditions(node, conditions); | 96 return UpdateConditions(node, conditions); |
96 } | 97 } |
97 Maybe<bool> condition_value = conditions->LookupCondition(condition); | 98 Maybe<bool> condition_value = conditions->LookupCondition(condition); |
98 if (condition_value.IsJust()) { | 99 if (condition_value.IsJust()) { |
99 // If we know the condition we can discard the branch. | 100 // If we know the condition we can discard the branch. |
100 if (condition_is_true == condition_value.FromJust()) { | 101 if (condition_is_true == condition_value.FromJust()) { |
101 // We don't update the conditions here, because we're replacing {node} | 102 // We don't update the conditions here, because we're replacing {node} |
102 // with the {control} node that already contains the right information. | 103 // with the {control} node that already contains the right information. |
103 ReplaceWithValue(node, dead(), effect, control); | 104 ReplaceWithValue(node, dead(), effect, control); |
104 } else { | 105 } else { |
105 control = graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), | 106 control = |
106 frame_state, effect, control); | 107 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager, reason), |
| 108 frame_state, effect, control); |
107 // TODO(bmeurer): This should be on the AdvancedReducer somehow. | 109 // TODO(bmeurer): This should be on the AdvancedReducer somehow. |
108 NodeProperties::MergeControlToEnd(graph(), common(), control); | 110 NodeProperties::MergeControlToEnd(graph(), common(), control); |
109 Revisit(graph()->end()); | 111 Revisit(graph()->end()); |
110 } | 112 } |
111 return Replace(dead()); | 113 return Replace(dead()); |
112 } | 114 } |
113 return UpdateConditions( | 115 return UpdateConditions( |
114 node, conditions->AddCondition(zone_, condition, condition_is_true)); | 116 node, conditions->AddCondition(zone_, condition, condition_is_true)); |
115 } | 117 } |
116 | 118 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 304 |
303 Graph* BranchElimination::graph() const { return jsgraph()->graph(); } | 305 Graph* BranchElimination::graph() const { return jsgraph()->graph(); } |
304 | 306 |
305 CommonOperatorBuilder* BranchElimination::common() const { | 307 CommonOperatorBuilder* BranchElimination::common() const { |
306 return jsgraph()->common(); | 308 return jsgraph()->common(); |
307 } | 309 } |
308 | 310 |
309 } // namespace compiler | 311 } // namespace compiler |
310 } // namespace internal | 312 } // namespace internal |
311 } // namespace v8 | 313 } // namespace v8 |
OLD | NEW |