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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // yet because we will have to recompute anyway once we compute the | 92 // yet because we will have to recompute anyway once we compute the |
93 // predecessor. | 93 // predecessor. |
94 if (conditions == nullptr) { | 94 if (conditions == nullptr) { |
95 DCHECK_NULL(node_conditions_.Get(node)); | 95 DCHECK_NULL(node_conditions_.Get(node)); |
96 return NoChange(); | 96 return NoChange(); |
97 } | 97 } |
98 Maybe<bool> condition_value = conditions->LookupCondition(condition); | 98 Maybe<bool> condition_value = conditions->LookupCondition(condition); |
99 if (condition_value.IsJust()) { | 99 if (condition_value.IsJust()) { |
100 // If we know the condition we can discard the branch. | 100 // If we know the condition we can discard the branch. |
101 if (condition_is_true == condition_value.FromJust()) { | 101 if (condition_is_true == condition_value.FromJust()) { |
102 // We don't to update the conditions here, because we're replacing with | 102 // We don't update the conditions here, because we're replacing {node} |
103 // the {control} node that already contains the right information. | 103 // with the {control} node that already contains the right information. |
104 return Replace(control); | 104 ReplaceWithValue(node, dead(), effect, control); |
105 } else { | 105 } else { |
106 control = graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), | 106 control = graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), |
107 frame_state, effect, control); | 107 frame_state, effect, control); |
108 // TODO(bmeurer): This should be on the AdvancedReducer somehow. | 108 // TODO(bmeurer): This should be on the AdvancedReducer somehow. |
109 NodeProperties::MergeControlToEnd(graph(), common(), control); | 109 NodeProperties::MergeControlToEnd(graph(), common(), control); |
110 Revisit(graph()->end()); | 110 Revisit(graph()->end()); |
111 return Replace(dead()); | |
112 } | 111 } |
| 112 return Replace(dead()); |
113 } | 113 } |
114 return UpdateConditions( | 114 return UpdateConditions( |
115 node, conditions->AddCondition(zone_, condition, condition_is_true)); | 115 node, conditions->AddCondition(zone_, condition, condition_is_true)); |
116 } | 116 } |
117 | 117 |
118 Reduction BranchElimination::ReduceIf(Node* node, bool is_true_branch) { | 118 Reduction BranchElimination::ReduceIf(Node* node, bool is_true_branch) { |
119 // Add the condition to the list arriving from the input branch. | 119 // Add the condition to the list arriving from the input branch. |
120 Node* branch = NodeProperties::GetControlInput(node, 0); | 120 Node* branch = NodeProperties::GetControlInput(node, 0); |
121 const ControlPathConditions* from_branch = node_conditions_.Get(branch); | 121 const ControlPathConditions* from_branch = node_conditions_.Get(branch); |
122 // If we do not know anything about the predecessor, do not propagate just | 122 // If we do not know anything about the predecessor, do not propagate just |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 | 304 |
305 Graph* BranchElimination::graph() const { return jsgraph()->graph(); } | 305 Graph* BranchElimination::graph() const { return jsgraph()->graph(); } |
306 | 306 |
307 CommonOperatorBuilder* BranchElimination::common() const { | 307 CommonOperatorBuilder* BranchElimination::common() const { |
308 return jsgraph()->common(); | 308 return jsgraph()->common(); |
309 } | 309 } |
310 | 310 |
311 } // namespace compiler | 311 } // namespace compiler |
312 } // namespace internal | 312 } // namespace internal |
313 } // namespace v8 | 313 } // namespace v8 |
OLD | NEW |