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

Side by Side Diff: src/compiler/branch-elimination.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/arm64/instruction-selector-arm64.cc ('k') | src/compiler/code-generator.h » ('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 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
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
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
OLDNEW
« no previous file with comments | « src/compiler/arm64/instruction-selector-arm64.cc ('k') | src/compiler/code-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698