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

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

Issue 753073009: [turbofan] Avoid repeatedly revisiting inputs in GraphReducer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
« no previous file with comments | « src/compiler/graph-reducer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/graph-reducer.cc
diff --git a/src/compiler/graph-reducer.cc b/src/compiler/graph-reducer.cc
index ff04f6ba5f01d643c473a2efb077ef94e9e510bf..26163bf41613ddbaaf6d07eb7437af315b14ef9e 100644
--- a/src/compiler/graph-reducer.cc
+++ b/src/compiler/graph-reducer.cc
@@ -99,11 +99,22 @@ Reduction GraphReducer::Reduce(Node* const node) {
void GraphReducer::ReduceTop() {
- Node* const node = Top();
+ NodeState& entry = stack_.top();
+ Node* node = entry.node;
+ DCHECK(state_[node->id()] == State::kOnStack);
+
if (node->IsDead()) return Pop(); // Node was killed while on stack.
// Recurse on an input if necessary.
- for (auto const input : node->inputs()) {
+ int start = entry.input_index < node->InputCount() ? entry.input_index : 0;
+ for (int i = start; i < node->InputCount(); i++) {
+ Node* input = node->InputAt(i);
+ entry.input_index = i + 1;
+ if (input != node && Recurse(input)) return;
+ }
+ for (int i = 0; i < start; i++) {
+ Node* input = node->InputAt(i);
+ entry.input_index = i + 1;
if (input != node && Recurse(input)) return;
}
@@ -153,7 +164,7 @@ void GraphReducer::ReduceTop() {
void GraphReducer::Pop() {
- Node* const node = Top();
+ Node* const node = stack_.top().node;
state_[node->id()] = State::kVisited;
stack_.pop();
}
@@ -165,18 +176,7 @@ void GraphReducer::Push(Node* const node) {
DCHECK(id < state_.size());
DCHECK(state_[id] != State::kOnStack);
state_[id] = State::kOnStack;
- stack_.push(node);
-}
-
-
-Node* GraphReducer::Top() const {
- DCHECK(!stack_.empty());
- Node* const node = stack_.top();
- size_t const id = static_cast<size_t>(node->id());
- DCHECK(id < state_.size());
- DCHECK(state_[id] == State::kOnStack);
- USE(id);
- return node;
+ stack_.push({node, 0});
}
« no previous file with comments | « src/compiler/graph-reducer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698