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

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: Tweaks Created 6 years, 1 month 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
Index: src/compiler/control-reducer.cc
diff --git a/src/compiler/control-reducer.cc b/src/compiler/control-reducer.cc
index b5acbb23e7abb6e19d509f6996b37e7930102823..f01dcd721e8e2f3b459ddd216835c3333d156942 100644
--- a/src/compiler/control-reducer.cc
+++ b/src/compiler/control-reducer.cc
@@ -215,15 +215,14 @@ 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();) {
- size_t id = static_cast<size_t>((*i)->id());
+ for (Edge edge : node->use_edges()) {
+ Node* use = edge.from();
+ size_t id = static_cast<size_t>(use->id());
if (state_[id] != kVisited) {
- TRACE(("DeadLink: #%d:%s(%d) -> #%d:%s\n", (*i)->id(),
- (*i)->op()->mnemonic(), i.index(), node->id(),
+ 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);
}
}
}
@@ -453,18 +452,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;

Powered by Google App Engine
This is Rietveld 408576698