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

Unified Diff: src/compiler/control-reducer.cc

Issue 1123213002: [turbofan] Connect non-terminating loops via Terminate. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/common-operator.cc ('k') | src/compiler/instruction-selector.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/control-reducer.cc
diff --git a/src/compiler/control-reducer.cc b/src/compiler/control-reducer.cc
index 281458b9b2823d40c88d664854e1f199f47c062f..6f7ffb3da38481fa9a896cf1e190638737b241d9 100644
--- a/src/compiler/control-reducer.cc
+++ b/src/compiler/control-reducer.cc
@@ -150,17 +150,11 @@ class ControlReducerImpl final : public AdvancedReducer {
TRACE("ConnectNTL: #%d:%s\n", loop->id(), loop->op()->mnemonic());
DCHECK_EQ(IrOpcode::kLoop, loop->opcode());
- Node* always = graph()->NewNode(common()->Always());
- Node* branch = graph()->NewNode(common()->Branch(), always, loop);
- Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
- Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
-
- // Insert the branch into the loop and collect all loop effects.
+ // Collect all loop effects.
NodeVector effects(zone_);
for (auto edge : loop->use_edges()) {
DCHECK_EQ(loop, edge.to());
DCHECK(NodeProperties::IsControlEdge(edge));
- if (edge.from() == branch) continue;
switch (edge.from()->opcode()) {
case IrOpcode::kPhi:
break;
@@ -168,8 +162,6 @@ class ControlReducerImpl final : public AdvancedReducer {
effects.push_back(edge.from());
break;
default:
- // Update all control edges (except {branch}) pointing to the {loop}.
- edge.UpdateTo(if_true);
break;
}
}
@@ -184,33 +176,32 @@ class ControlReducerImpl final : public AdvancedReducer {
effects_count, &effects.front());
}
- // Add a return to connect the NTL to the end.
- Node* ret = graph()->NewNode(
- common()->Return(), jsgraph_->UndefinedConstant(), effect, if_false);
+ // Add a terminate to connect the NTL to the end.
+ Node* terminate = graph()->NewNode(common()->Terminate(), effect, loop);
Node* end = graph()->end();
if (end->opcode() == IrOpcode::kDead) {
// End is actually the dead node. Make a new end.
- end = graph()->NewNode(common()->End(), ret);
+ end = graph()->NewNode(common()->End(), terminate);
graph()->SetEnd(end);
return end;
}
// End is not dead.
Node* merge = end->InputAt(0);
if (merge == NULL || merge->opcode() == IrOpcode::kDead) {
- // The end node died; just connect end to {ret}.
- end->ReplaceInput(0, ret);
+ // The end node died; just connect end to {terminate}.
+ end->ReplaceInput(0, terminate);
} else if (merge->opcode() != IrOpcode::kMerge) {
- // Introduce a final merge node for {end->InputAt(0)} and {ret}.
- merge = graph()->NewNode(common()->Merge(2), merge, ret);
+ // Introduce a final merge node for {end->InputAt(0)} and {terminate}.
+ merge = graph()->NewNode(common()->Merge(2), merge, terminate);
end->ReplaceInput(0, merge);
- ret = merge;
+ terminate = merge;
} else {
// Append a new input to the final merge at the end.
- merge->AppendInput(graph()->zone(), ret);
+ merge->AppendInput(graph()->zone(), terminate);
merge->set_op(common()->Merge(merge->InputCount()));
}
- return ret;
+ return terminate;
}
void AddNodesReachableFromRoots(ReachabilityMarker& marked,
« no previous file with comments | « src/compiler/common-operator.cc ('k') | src/compiler/instruction-selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698