| 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-reducer.h" | 5 #include "src/compiler/common-operator-reducer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
| 10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 UNREACHABLE(); | 115 UNREACHABLE(); |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 return Replace(dead()); | 118 return Replace(dead()); |
| 119 } | 119 } |
| 120 | 120 |
| 121 Reduction CommonOperatorReducer::ReduceDeoptimizeConditional(Node* node) { | 121 Reduction CommonOperatorReducer::ReduceDeoptimizeConditional(Node* node) { |
| 122 DCHECK(node->opcode() == IrOpcode::kDeoptimizeIf || | 122 DCHECK(node->opcode() == IrOpcode::kDeoptimizeIf || |
| 123 node->opcode() == IrOpcode::kDeoptimizeUnless); | 123 node->opcode() == IrOpcode::kDeoptimizeUnless); |
| 124 bool condition_is_true = node->opcode() == IrOpcode::kDeoptimizeUnless; | 124 bool condition_is_true = node->opcode() == IrOpcode::kDeoptimizeUnless; |
| 125 DeoptimizeReason reason = DeoptimizeReasonOf(node->op()); |
| 125 Node* condition = NodeProperties::GetValueInput(node, 0); | 126 Node* condition = NodeProperties::GetValueInput(node, 0); |
| 126 Node* frame_state = NodeProperties::GetValueInput(node, 1); | 127 Node* frame_state = NodeProperties::GetValueInput(node, 1); |
| 127 Node* effect = NodeProperties::GetEffectInput(node); | 128 Node* effect = NodeProperties::GetEffectInput(node); |
| 128 Node* control = NodeProperties::GetControlInput(node); | 129 Node* control = NodeProperties::GetControlInput(node); |
| 129 // Swap DeoptimizeIf/DeoptimizeUnless on {node} if {cond} is a BooleaNot | 130 // Swap DeoptimizeIf/DeoptimizeUnless on {node} if {cond} is a BooleaNot |
| 130 // and use the input to BooleanNot as new condition for {node}. Note we | 131 // and use the input to BooleanNot as new condition for {node}. Note we |
| 131 // assume that {cond} was already properly optimized before we get here | 132 // assume that {cond} was already properly optimized before we get here |
| 132 // (as guaranteed by the graph reduction logic). | 133 // (as guaranteed by the graph reduction logic). |
| 133 if (condition->opcode() == IrOpcode::kBooleanNot) { | 134 if (condition->opcode() == IrOpcode::kBooleanNot) { |
| 134 NodeProperties::ReplaceValueInput(node, condition->InputAt(0), 0); | 135 NodeProperties::ReplaceValueInput(node, condition->InputAt(0), 0); |
| 135 NodeProperties::ChangeOp(node, condition_is_true | 136 NodeProperties::ChangeOp(node, condition_is_true |
| 136 ? common()->DeoptimizeIf() | 137 ? common()->DeoptimizeIf(reason) |
| 137 : common()->DeoptimizeUnless()); | 138 : common()->DeoptimizeUnless(reason)); |
| 138 return Changed(node); | 139 return Changed(node); |
| 139 } | 140 } |
| 140 Decision const decision = DecideCondition(condition); | 141 Decision const decision = DecideCondition(condition); |
| 141 if (decision == Decision::kUnknown) return NoChange(); | 142 if (decision == Decision::kUnknown) return NoChange(); |
| 142 if (condition_is_true == (decision == Decision::kTrue)) { | 143 if (condition_is_true == (decision == Decision::kTrue)) { |
| 143 ReplaceWithValue(node, dead(), effect, control); | 144 ReplaceWithValue(node, dead(), effect, control); |
| 144 } else { | 145 } else { |
| 145 control = graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), | 146 control = |
| 146 frame_state, effect, control); | 147 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager, reason), |
| 148 frame_state, effect, control); |
| 147 // TODO(bmeurer): This should be on the AdvancedReducer somehow. | 149 // TODO(bmeurer): This should be on the AdvancedReducer somehow. |
| 148 NodeProperties::MergeControlToEnd(graph(), common(), control); | 150 NodeProperties::MergeControlToEnd(graph(), common(), control); |
| 149 Revisit(graph()->end()); | 151 Revisit(graph()->end()); |
| 150 } | 152 } |
| 151 return Replace(dead()); | 153 return Replace(dead()); |
| 152 } | 154 } |
| 153 | 155 |
| 154 Reduction CommonOperatorReducer::ReduceMerge(Node* node) { | 156 Reduction CommonOperatorReducer::ReduceMerge(Node* node) { |
| 155 DCHECK_EQ(IrOpcode::kMerge, node->opcode()); | 157 DCHECK_EQ(IrOpcode::kMerge, node->opcode()); |
| 156 // | 158 // |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 node->ReplaceInput(0, a); | 405 node->ReplaceInput(0, a); |
| 404 node->ReplaceInput(1, b); | 406 node->ReplaceInput(1, b); |
| 405 node->TrimInputCount(2); | 407 node->TrimInputCount(2); |
| 406 NodeProperties::ChangeOp(node, op); | 408 NodeProperties::ChangeOp(node, op); |
| 407 return Changed(node); | 409 return Changed(node); |
| 408 } | 410 } |
| 409 | 411 |
| 410 } // namespace compiler | 412 } // namespace compiler |
| 411 } // namespace internal | 413 } // namespace internal |
| 412 } // namespace v8 | 414 } // namespace v8 |
| OLD | NEW |