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

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

Issue 765983002: Clean up node iteration (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix windows build Created 6 years 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/change-lowering.cc ('k') | src/compiler/generic-algorithm.h » ('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 50683855140f2e91b9be428f726c170adcfd13ed..236ce4b77ef725306f308c3b96771e5041db07a3 100644
--- a/src/compiler/control-reducer.cc
+++ b/src/compiler/control-reducer.cc
@@ -237,14 +237,13 @@ class ControlReducerImpl {
// Remove dead->live edges.
for (size_t j = 0; j < nodes.size(); j++) {
Node* node = nodes[j];
- for (UseIter i = node->uses().begin(); i != node->uses().end();) {
- if (!marked.IsReachableFromEnd(*i)) {
- TRACE(("DeadLink: #%d:%s(%d) -> #%d:%s\n", (*i)->id(),
- (*i)->op()->mnemonic(), i.index(), node->id(),
+ for (Edge edge : node->use_edges()) {
+ Node* use = edge.from();
+ if (!marked.IsReachableFromEnd(use)) {
+ TRACE(("DeadLink: #%d:%s(%d) -> #%d:%s\n", use->id(),
+ use->op()->mnemonic(), edge.index(), node->id(),
node->op()->mnemonic()));
- i.UpdateToAndIncrement(NULL);
- } else {
- ++i;
+ edge.UpdateTo(NULL);
}
}
}
@@ -473,18 +472,16 @@ class ControlReducerImpl {
// Replace IfTrue and IfFalse projections from this branch.
Node* control = NodeProperties::GetControlInput(node);
- for (UseIter i = node->uses().begin(); i != node->uses().end();) {
- Node* to = *i;
- if (to->opcode() == IrOpcode::kIfTrue) {
- TRACE((" IfTrue: #%d:%s\n", to->id(), to->op()->mnemonic()));
- i.UpdateToAndIncrement(NULL);
- ReplaceNode(to, (result == kTrue) ? control : dead());
- } else if (to->opcode() == IrOpcode::kIfFalse) {
- TRACE((" IfFalse: #%d:%s\n", to->id(), to->op()->mnemonic()));
- i.UpdateToAndIncrement(NULL);
- ReplaceNode(to, (result == kTrue) ? dead() : control);
- } else {
- ++i;
+ for (Edge edge : node->use_edges()) {
+ Node* use = edge.from();
+ if (use->opcode() == IrOpcode::kIfTrue) {
+ TRACE((" IfTrue: #%d:%s\n", use->id(), use->op()->mnemonic()));
+ edge.UpdateTo(NULL);
+ ReplaceNode(use, (result == kTrue) ? control : dead());
+ } else if (use->opcode() == IrOpcode::kIfFalse) {
+ TRACE((" IfFalse: #%d:%s\n", use->id(), use->op()->mnemonic()));
+ edge.UpdateTo(NULL);
+ ReplaceNode(use, (result == kTrue) ? dead() : control);
}
}
return control;
« no previous file with comments | « src/compiler/change-lowering.cc ('k') | src/compiler/generic-algorithm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698