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

Side by Side Diff: src/compiler/scheduler.cc

Issue 761673004: Start immediate dominator propagation at entry to floating control. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « src/compiler/scheduler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <deque> 5 #include <deque>
6 #include <queue> 6 #include <queue>
7 7
8 #include "src/compiler/scheduler.h" 8 #include "src/compiler/scheduler.h"
9 9
10 #include "src/bit-vector.h" 10 #include "src/bit-vector.h"
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 1030
1031 void Scheduler::ComputeSpecialRPONumbering() { 1031 void Scheduler::ComputeSpecialRPONumbering() {
1032 Trace("--- COMPUTING SPECIAL RPO ----------------------------------\n"); 1032 Trace("--- COMPUTING SPECIAL RPO ----------------------------------\n");
1033 1033
1034 // Compute the special reverse-post-order for basic blocks. 1034 // Compute the special reverse-post-order for basic blocks.
1035 special_rpo_ = new (zone_) SpecialRPONumberer(zone_, schedule_); 1035 special_rpo_ = new (zone_) SpecialRPONumberer(zone_, schedule_);
1036 special_rpo_->ComputeSpecialRPO(); 1036 special_rpo_->ComputeSpecialRPO();
1037 } 1037 }
1038 1038
1039 1039
1040 void Scheduler::GenerateImmediateDominatorTree() { 1040 // TODO(danno): Consider using Lengauer & Tarjan's if this becomes too slow.
titzer 2014/11/27 10:59:59 I think we can remove this TODO
Michael Starzinger 2014/11/27 11:29:31 Done.
1041 Trace("--- IMMEDIATE BLOCK DOMINATORS -----------------------------\n"); 1041 void Scheduler::PropagateImmediateDominators(BasicBlock* block) {
1042 1042 for (/*nop*/; block != NULL; block = block->rpo_next()) {
1043 // TODO(danno): Consider using Lengauer & Tarjan's if this becomes too slow.
1044
1045 // Build the block dominator tree.
1046 schedule_->start()->set_dominator_depth(0);
1047 BasicBlock* second = schedule_->start()->rpo_next();
1048 for (BasicBlock* block = second; block != NULL; block = block->rpo_next()) {
1049 BasicBlock::Predecessors::iterator pred = block->predecessors_begin(); 1043 BasicBlock::Predecessors::iterator pred = block->predecessors_begin();
1050 BasicBlock::Predecessors::iterator end = block->predecessors_end(); 1044 BasicBlock::Predecessors::iterator end = block->predecessors_end();
1051 DCHECK(pred != end); // All blocks except start have predecessors. 1045 DCHECK(pred != end); // All blocks except start have predecessors.
1052 BasicBlock* dominator = *pred; 1046 BasicBlock* dominator = *pred;
1053 // For multiple predecessors, walk up the dominator tree until a common 1047 // For multiple predecessors, walk up the dominator tree until a common
1054 // dominator is found. Visitation order guarantees that all predecessors 1048 // dominator is found. Visitation order guarantees that all predecessors
1055 // except for backwards edges have been visited. 1049 // except for backwards edges have been visited.
1056 for (++pred; pred != end; ++pred) { 1050 for (++pred; pred != end; ++pred) {
1057 // Don't examine backwards edges. 1051 // Don't examine backwards edges.
1058 if ((*pred)->dominator_depth() < 0) continue; 1052 if ((*pred)->dominator_depth() < 0) continue;
1059 dominator = GetCommonDominator(dominator, *pred); 1053 dominator = GetCommonDominator(dominator, *pred);
1060 } 1054 }
1061 block->set_dominator(dominator); 1055 block->set_dominator(dominator);
1062 block->set_dominator_depth(dominator->dominator_depth() + 1); 1056 block->set_dominator_depth(dominator->dominator_depth() + 1);
1063 // Propagate "deferredness" of the dominator. 1057 // Propagate "deferredness" of the dominator.
1064 if (dominator->deferred()) block->set_deferred(true); 1058 if (dominator->deferred()) block->set_deferred(true);
1065 Trace("Block B%d's idom is B%d, depth = %d\n", block->id().ToInt(), 1059 Trace("Block B%d's idom is B%d, depth = %d\n", block->id().ToInt(),
1066 dominator->id().ToInt(), block->dominator_depth()); 1060 dominator->id().ToInt(), block->dominator_depth());
1067 } 1061 }
1068 } 1062 }
1069 1063
1070 1064
1065 void Scheduler::GenerateImmediateDominatorTree() {
1066 Trace("--- IMMEDIATE BLOCK DOMINATORS -----------------------------\n");
1067
1068 // Seed start block to be the first dominator.
1069 schedule_->start()->set_dominator_depth(0);
1070
1071 // Build the block dominator tree resulting from the above seed.
1072 PropagateImmediateDominators(schedule_->start()->rpo_next());
1073 }
1074
1075
1071 // ----------------------------------------------------------------------------- 1076 // -----------------------------------------------------------------------------
1072 // Phase 3: Prepare use counts for nodes. 1077 // Phase 3: Prepare use counts for nodes.
1073 1078
1074 1079
1075 class PrepareUsesVisitor : public NullNodeVisitor { 1080 class PrepareUsesVisitor : public NullNodeVisitor {
1076 public: 1081 public:
1077 explicit PrepareUsesVisitor(Scheduler* scheduler) 1082 explicit PrepareUsesVisitor(Scheduler* scheduler)
1078 : scheduler_(scheduler), schedule_(scheduler->schedule_) {} 1083 : scheduler_(scheduler), schedule_(scheduler->schedule_) {}
1079 1084
1080 void Pre(Node* node) { 1085 void Pre(Node* node) {
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 OFStream os(stdout); 1432 OFStream os(stdout);
1428 os << "Schedule before control flow fusion:\n" << *schedule_; 1433 os << "Schedule before control flow fusion:\n" << *schedule_;
1429 } 1434 }
1430 1435
1431 // Iterate on phase 1: Build control-flow graph. 1436 // Iterate on phase 1: Build control-flow graph.
1432 control_flow_builder_->Run(block, node); 1437 control_flow_builder_->Run(block, node);
1433 1438
1434 // Iterate on phase 2: Compute special RPO and dominator tree. 1439 // Iterate on phase 2: Compute special RPO and dominator tree.
1435 special_rpo_->UpdateSpecialRPO(block, schedule_->block(node)); 1440 special_rpo_->UpdateSpecialRPO(block, schedule_->block(node));
1436 // TODO(mstarzinger): Currently "iterate on" means "re-run". Fix that. 1441 // TODO(mstarzinger): Currently "iterate on" means "re-run". Fix that.
1437 for (BasicBlock* block : schedule_->all_blocks_) { 1442 for (BasicBlock* b = block->rpo_next(); b != NULL; b = b->rpo_next()) {
1438 block->set_dominator_depth(-1); 1443 b->set_dominator_depth(-1);
1439 block->set_dominator(NULL); 1444 b->set_dominator(NULL);
1440 } 1445 }
1441 GenerateImmediateDominatorTree(); 1446 PropagateImmediateDominators(block->rpo_next());
1442 1447
1443 // Iterate on phase 4: Schedule nodes early. 1448 // Iterate on phase 4: Schedule nodes early.
1444 // TODO(mstarzinger): The following loop gathering the propagation roots is a 1449 // TODO(mstarzinger): The following loop gathering the propagation roots is a
1445 // temporary solution and should be merged into the rest of the scheduler as 1450 // temporary solution and should be merged into the rest of the scheduler as
1446 // soon as the approach settled for all floating loops. 1451 // soon as the approach settled for all floating loops.
1447 NodeVector propagation_roots(control_flow_builder_->control_); 1452 NodeVector propagation_roots(control_flow_builder_->control_);
1448 for (Node* node : control_flow_builder_->control_) { 1453 for (Node* node : control_flow_builder_->control_) {
1449 for (Node* use : node->uses()) { 1454 for (Node* use : node->uses()) {
1450 if (use->opcode() == IrOpcode::kPhi || 1455 if (use->opcode() == IrOpcode::kPhi ||
1451 use->opcode() == IrOpcode::kEffectPhi) { 1456 use->opcode() == IrOpcode::kEffectPhi) {
(...skipping 30 matching lines...) Expand all
1482 for (NodeVectorIter i = nodes->begin(); i != nodes->end(); ++i) { 1487 for (NodeVectorIter i = nodes->begin(); i != nodes->end(); ++i) {
1483 schedule_->SetBlockForNode(to, *i); 1488 schedule_->SetBlockForNode(to, *i);
1484 scheduled_nodes_[to->id().ToSize()].push_back(*i); 1489 scheduled_nodes_[to->id().ToSize()].push_back(*i);
1485 } 1490 }
1486 nodes->clear(); 1491 nodes->clear();
1487 } 1492 }
1488 1493
1489 } // namespace compiler 1494 } // namespace compiler
1490 } // namespace internal 1495 } // namespace internal
1491 } // namespace v8 1496 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/scheduler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698