Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: src/compiler/common-operator-reducer.cc

Issue 2161543002: [turbofan] Add support for eager/soft deoptimization reasons. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Do the ports properly Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/common-operator.cc ('k') | src/compiler/effect-control-linearizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « src/compiler/common-operator.cc ('k') | src/compiler/effect-control-linearizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698