Revert "Remove workaround for successors on end block from scheduler."

TBR=titzer@chromium.org

Review URL: https://codereview.chromium.org/705043002

Cr-Commit-Position: refs/heads/master@{#25194}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25194 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b309f3d2
...@@ -527,6 +527,7 @@ class SpecialRPONumberer : public ZoneObject { ...@@ -527,6 +527,7 @@ class SpecialRPONumberer : public ZoneObject {
schedule_(schedule), schedule_(schedule),
order_(NULL), order_(NULL),
loops_(zone), loops_(zone),
beyond_end_(NULL),
backedges_(1, zone), backedges_(1, zone),
stack_(zone), stack_(zone),
previous_block_count_(0) {} previous_block_count_(0) {}
...@@ -534,9 +535,9 @@ class SpecialRPONumberer : public ZoneObject { ...@@ -534,9 +535,9 @@ class SpecialRPONumberer : public ZoneObject {
// Computes the special reverse-post-order for the main control flow graph, // Computes the special reverse-post-order for the main control flow graph,
// that is for the graph spanned between the schedule's start and end blocks. // that is for the graph spanned between the schedule's start and end blocks.
void ComputeSpecialRPO() { void ComputeSpecialRPO() {
DCHECK(schedule_->end()->SuccessorCount() == 0);
DCHECK_EQ(NULL, order_); // Main order does not exist yet. DCHECK_EQ(NULL, order_); // Main order does not exist yet.
ComputeAndInsertSpecialRPO(schedule_->start(), schedule_->end()); // TODO(mstarzinger): Should use Schedule::end() after tests are fixed.
ComputeAndInsertSpecialRPO(schedule_->start(), NULL);
} }
// Computes the special reverse-post-order for a partial control flow graph, // Computes the special reverse-post-order for a partial control flow graph,
...@@ -569,9 +570,7 @@ class SpecialRPONumberer : public ZoneObject { ...@@ -569,9 +570,7 @@ class SpecialRPONumberer : public ZoneObject {
l->block->set_rpo_number(number++); l->block->set_rpo_number(number++);
schedule_->rpo_order()->push_back(l->block); schedule_->rpo_order()->push_back(l->block);
} }
if (schedule_->end()->rpo_number() < 0) { BeyondEndSentinel()->set_rpo_number(number);
schedule_->end()->set_rpo_number(number);
}
} }
// Print and verify the special reverse-post-order. // Print and verify the special reverse-post-order.
...@@ -656,6 +655,17 @@ class SpecialRPONumberer : public ZoneObject { ...@@ -656,6 +655,17 @@ class SpecialRPONumberer : public ZoneObject {
return block->ao_number() >= 0; return block->ao_number() >= 0;
} }
// TODO(mstarzinger): We only need this special sentinel because some tests
// use the schedule's end block in actual control flow (e.g. with end having
// successors). Once this has been cleaned up we can use the end block here.
BasicBlock* BeyondEndSentinel() {
if (beyond_end_ == NULL) {
BasicBlock::Id id = BasicBlock::Id::FromInt(-1);
beyond_end_ = new (schedule_->zone()) BasicBlock(schedule_->zone(), id);
}
return beyond_end_;
}
// Compute special RPO for the control flow graph between {entry} and {end}, // Compute special RPO for the control flow graph between {entry} and {end},
// mutating any existing order so that the result is still valid. // mutating any existing order so that the result is still valid.
void ComputeAndInsertSpecialRPO(BasicBlock* entry, BasicBlock* end) { void ComputeAndInsertSpecialRPO(BasicBlock* entry, BasicBlock* end) {
...@@ -838,7 +848,7 @@ class SpecialRPONumberer : public ZoneObject { ...@@ -838,7 +848,7 @@ class SpecialRPONumberer : public ZoneObject {
++loop_depth; ++loop_depth;
current_loop = &loops_[GetLoopNumber(current)]; current_loop = &loops_[GetLoopNumber(current)];
BlockList* end = current_loop->end; BlockList* end = current_loop->end;
current->set_loop_end(end == NULL ? schedule_->end() : end->block); current->set_loop_end(end == NULL ? BeyondEndSentinel() : end->block);
current_header = current_loop->header; current_header = current_loop->header;
Trace("B%d is a loop header, increment loop depth to %d\n", Trace("B%d is a loop header, increment loop depth to %d\n",
current->id().ToInt(), loop_depth); current->id().ToInt(), loop_depth);
...@@ -1008,6 +1018,7 @@ class SpecialRPONumberer : public ZoneObject { ...@@ -1008,6 +1018,7 @@ class SpecialRPONumberer : public ZoneObject {
Schedule* schedule_; Schedule* schedule_;
BlockList* order_; BlockList* order_;
ZoneVector<LoopInfo> loops_; ZoneVector<LoopInfo> loops_;
BasicBlock* beyond_end_;
ZoneList<Backedge> backedges_; ZoneList<Backedge> backedges_;
ZoneVector<SpecialRPOStackFrame> stack_; ZoneVector<SpecialRPOStackFrame> stack_;
size_t previous_block_count_; size_t previous_block_count_;
......
...@@ -200,13 +200,12 @@ TEST(RPOSelfLoop) { ...@@ -200,13 +200,12 @@ TEST(RPOSelfLoop) {
TEST(RPOEntryLoop) { TEST(RPOEntryLoop) {
HandleAndZoneScope scope; HandleAndZoneScope scope;
Schedule schedule(scope.main_zone()); Schedule schedule(scope.main_zone());
BasicBlock* body = schedule.NewBasicBlock(); schedule.AddSuccessorForTesting(schedule.start(), schedule.end());
schedule.AddSuccessorForTesting(schedule.start(), body); schedule.AddSuccessorForTesting(schedule.end(), schedule.start());
schedule.AddSuccessorForTesting(body, schedule.start());
ZonePool zone_pool(scope.main_isolate()); ZonePool zone_pool(scope.main_isolate());
BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
CheckRPONumbers(order, 2, true); CheckRPONumbers(order, 2, true);
BasicBlock* loop[] = {schedule.start(), body}; BasicBlock* loop[] = {schedule.start(), schedule.end()};
CheckLoop(order, loop, 2); CheckLoop(order, loop, 2);
} }
...@@ -654,7 +653,7 @@ TEST(RPOLoopMultibackedge) { ...@@ -654,7 +653,7 @@ TEST(RPOLoopMultibackedge) {
BasicBlock* A = schedule.start(); BasicBlock* A = schedule.start();
BasicBlock* B = schedule.NewBasicBlock(); BasicBlock* B = schedule.NewBasicBlock();
BasicBlock* C = schedule.NewBasicBlock(); BasicBlock* C = schedule.NewBasicBlock();
BasicBlock* D = schedule.NewBasicBlock(); BasicBlock* D = schedule.end();
BasicBlock* E = schedule.NewBasicBlock(); BasicBlock* E = schedule.NewBasicBlock();
schedule.AddSuccessorForTesting(A, B); schedule.AddSuccessorForTesting(A, B);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment