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

Unified Diff: src/compiler/scheduler.cc

Issue 702683002: Avoid redundant work in scheduler loop header/depth calculation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/scheduler.cc
diff --git a/src/compiler/scheduler.cc b/src/compiler/scheduler.cc
index 76ddfd30a94f39f92db8c89f3f68b2336d893ec1..3e871924b6cc33a99a5f16cb73d40c1e842c0cb2 100644
--- a/src/compiler/scheduler.cc
+++ b/src/compiler/scheduler.cc
@@ -584,7 +584,7 @@ class SpecialRPONumberer : public ZoneObject {
// TODO(mstarzinger): Only for Scheduler::GenerateImmediateDominatorTree.
friend class Scheduler;
- // Numbering for BasicBlockData.rpo_number_ for this block traversal:
+ // Numbering for BasicBlock::rpo_number for this block traversal:
static const int kBlockOnStack = -2;
static const int kBlockVisited1 = -3;
static const int kBlockVisited2 = -4;
@@ -674,6 +674,7 @@ class SpecialRPONumberer : public ZoneObject {
// Find correct insertion point within existing order.
BlockList* insert_head = order_->FindForBlock(entry);
BlockList* insert_tail = insert_head == NULL ? NULL : insert_head->next;
+ BlockList* order = insert_tail;
// Perform an iterative RPO traversal using an explicit stack,
// recording backedges that form cycles. O(|B|).
@@ -708,19 +709,12 @@ class SpecialRPONumberer : public ZoneObject {
}
} else {
// Finished with all successors; pop the stack and add the block.
- insert_tail = insert_tail->Add(zone_, frame->block);
+ order = order->Add(zone_, frame->block);
frame->block->set_rpo_number(kBlockVisited1);
stack_depth--;
}
}
- // Insert the result into any existing order.
- if (insert_head == NULL) {
- order_ = insert_tail;
- } else {
- insert_head->next = insert_tail->next;
- }
-
// If no loops were encountered, then the order we computed was correct.
if (num_loops != 0) {
// Otherwise, compute the loop information from the backedges in order
@@ -730,7 +724,7 @@ class SpecialRPONumberer : public ZoneObject {
// Initialize the "loop stack". Note the entry could be a loop header.
LoopInfo* loop =
HasLoopNumber(entry) ? &loops_[GetLoopNumber(entry)] : NULL;
- order_ = NULL;
+ order = NULL;
// Perform an iterative post-order traversal, visiting loop bodies before
// edges that lead out of loops. Visits each block once, but linking loop
@@ -751,8 +745,8 @@ class SpecialRPONumberer : public ZoneObject {
// Finish the loop body the first time the header is left on the
// stack.
DCHECK(loop != NULL && loop->header == block);
- loop->start = order_->Add(zone_, block);
- order_ = loop->end;
+ loop->start = order->Add(zone_, block);
+ order = loop->end;
block->set_rpo_number(kBlockVisited2);
// Pop the loop stack and continue visiting outgoing edges within
// the context of the outer loop, if any.
@@ -789,7 +783,7 @@ class SpecialRPONumberer : public ZoneObject {
// Push the inner loop onto the loop stack.
DCHECK(GetLoopNumber(succ) < num_loops);
LoopInfo* next = &loops_[GetLoopNumber(succ)];
- next->end = order_;
+ next->end = order;
next->prev = loop;
loop = next;
}
@@ -801,15 +795,15 @@ class SpecialRPONumberer : public ZoneObject {
LoopInfo* info = &loops_[GetLoopNumber(block)];
for (BlockList* l = info->start; true; l = l->next) {
if (l->next == info->end) {
- l->next = order_;
- info->end = order_;
+ l->next = order;
+ info->end = order;
break;
}
}
- order_ = info->start;
+ order = info->start;
} else {
// Pop a single node off the stack and add it to the order.
- order_ = order_->Add(zone_, block);
+ order = order->Add(zone_, block);
block->set_rpo_number(kBlockVisited2);
}
stack_depth--;
@@ -817,13 +811,23 @@ class SpecialRPONumberer : public ZoneObject {
}
}
+ // Insert result into existing order.
+ if (insert_head == NULL) {
+ order_ = order;
+ } else {
+ insert_head->next = order->next;
+ }
+
// Compute the correct loop headers and set the correct loop ends.
LoopInfo* current_loop = NULL;
- BasicBlock* current_header = NULL;
- int loop_depth = 0;
- for (BlockList* l = order_; l != NULL; l = l->next) {
+ BasicBlock* current_header = entry->loop_header();
+ int32_t loop_depth = entry->loop_depth();
+ for (BlockList* l = order; l != insert_tail; l = l->next) {
BasicBlock* current = l->block;
+ // Reset BasicBlock::rpo_number again.
+ current->set_rpo_number(-1);
Jarin 2014/11/05 01:03:56 Could we use the constant defined above? (kBlockUn
Michael Starzinger 2014/11/05 10:18:40 Done.
+
// Finish the previous loop(s) if we just exited them.
while (current_header != NULL && current == current_header->loop_end()) {
DCHECK(current_header->IsLoopHeader());
@@ -1430,13 +1434,12 @@ void Scheduler::FuseFloatingControl(BasicBlock* block, Node* node) {
cfg_builder.Run(block, node);
// Iterate on phase 2: Compute special RPO and dominator tree.
+ special_rpo_->UpdateSpecialRPO(block, schedule_->block(node));
// TODO(mstarzinger): Currently "iterate on" means "re-run". Fix that.
for (BasicBlock* block : schedule_->all_blocks_) {
- block->set_rpo_number(-1);
block->set_dominator_depth(-1);
block->set_dominator(NULL);
}
- special_rpo_->UpdateSpecialRPO(block, schedule_->block(node));
GenerateImmediateDominatorTree();
// Move previously planned nodes.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698