OLD | NEW |
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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 } | 288 } |
289 DCHECK_NOT_NULL(component_head_); | 289 DCHECK_NOT_NULL(component_head_); |
290 | 290 |
291 for (NodeVector::iterator i = control_.begin(); i != control_.end(); ++i) { | 291 for (NodeVector::iterator i = control_.begin(); i != control_.end(); ++i) { |
292 scheduler_->GetData(*i)->is_floating_control_ = false; | 292 scheduler_->GetData(*i)->is_floating_control_ = false; |
293 ConnectBlocks(*i); // Connect block to its predecessor/successors. | 293 ConnectBlocks(*i); // Connect block to its predecessor/successors. |
294 } | 294 } |
295 } | 295 } |
296 | 296 |
297 private: | 297 private: |
| 298 // TODO(mstarzinger): Only for Scheduler::FuseFloatingControl. |
| 299 friend class Scheduler; |
| 300 |
298 void FixNode(BasicBlock* block, Node* node) { | 301 void FixNode(BasicBlock* block, Node* node) { |
299 schedule_->AddNode(block, node); | 302 schedule_->AddNode(block, node); |
300 scheduler_->UpdatePlacement(node, Scheduler::kFixed); | 303 scheduler_->UpdatePlacement(node, Scheduler::kFixed); |
301 } | 304 } |
302 | 305 |
303 void Queue(Node* node) { | 306 void Queue(Node* node) { |
304 // Mark the connected control nodes as they are queued. | 307 // Mark the connected control nodes as they are queued. |
305 Scheduler::SchedulerData* data = scheduler_->GetData(node); | 308 Scheduler::SchedulerData* data = scheduler_->GetData(node); |
306 if (!data->is_connected_control_) { | 309 if (!data->is_connected_control_) { |
307 data->is_connected_control_ = true; | 310 data->is_connected_control_ = true; |
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 } | 1154 } |
1152 | 1155 |
1153 private: | 1156 private: |
1154 // Visits one node from the queue and propagates its current schedule early | 1157 // Visits one node from the queue and propagates its current schedule early |
1155 // position to all uses. This in turn might push more nodes onto the queue. | 1158 // position to all uses. This in turn might push more nodes onto the queue. |
1156 void VisitNode(Node* node) { | 1159 void VisitNode(Node* node) { |
1157 Scheduler::SchedulerData* data = scheduler_->GetData(node); | 1160 Scheduler::SchedulerData* data = scheduler_->GetData(node); |
1158 | 1161 |
1159 // Fixed nodes already know their schedule early position. | 1162 // Fixed nodes already know their schedule early position. |
1160 if (scheduler_->GetPlacement(node) == Scheduler::kFixed) { | 1163 if (scheduler_->GetPlacement(node) == Scheduler::kFixed) { |
1161 DCHECK_EQ(schedule_->start(), data->minimum_block_); | |
1162 data->minimum_block_ = schedule_->block(node); | 1164 data->minimum_block_ = schedule_->block(node); |
1163 Trace("Fixing #%d:%s minimum_block = B%d, dominator_depth = %d\n", | 1165 Trace("Fixing #%d:%s minimum_block = B%d, dominator_depth = %d\n", |
1164 node->id(), node->op()->mnemonic(), | 1166 node->id(), node->op()->mnemonic(), |
1165 data->minimum_block_->id().ToInt(), | 1167 data->minimum_block_->id().ToInt(), |
1166 data->minimum_block_->dominator_depth()); | 1168 data->minimum_block_->dominator_depth()); |
1167 } | 1169 } |
1168 | 1170 |
1169 // No need to propagate unconstrained schedule early positions. | 1171 // No need to propagate unconstrained schedule early positions. |
1170 if (data->minimum_block_ == schedule_->start()) return; | 1172 if (data->minimum_block_ == schedule_->start()) return; |
1171 | 1173 |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 | 1445 |
1444 // Iterate on phase 2: Compute special RPO and dominator tree. | 1446 // Iterate on phase 2: Compute special RPO and dominator tree. |
1445 special_rpo_->UpdateSpecialRPO(block, schedule_->block(node)); | 1447 special_rpo_->UpdateSpecialRPO(block, schedule_->block(node)); |
1446 // TODO(mstarzinger): Currently "iterate on" means "re-run". Fix that. | 1448 // TODO(mstarzinger): Currently "iterate on" means "re-run". Fix that. |
1447 for (BasicBlock* block : schedule_->all_blocks_) { | 1449 for (BasicBlock* block : schedule_->all_blocks_) { |
1448 block->set_dominator_depth(-1); | 1450 block->set_dominator_depth(-1); |
1449 block->set_dominator(NULL); | 1451 block->set_dominator(NULL); |
1450 } | 1452 } |
1451 GenerateImmediateDominatorTree(); | 1453 GenerateImmediateDominatorTree(); |
1452 | 1454 |
| 1455 // Iterate on phase 4: Schedule nodes early. |
| 1456 // TODO(mstarzinger): The following loop gathering the propagation roots is a |
| 1457 // temporary solution and should be merged into the rest of the scheduler as |
| 1458 // soon as the approach settled for all floating loops. |
| 1459 NodeVector propagation_roots(cfg_builder.control_); |
| 1460 for (Node* node : cfg_builder.control_) { |
| 1461 for (Node* use : node->uses()) { |
| 1462 if (use->opcode() == IrOpcode::kPhi || |
| 1463 use->opcode() == IrOpcode::kEffectPhi) { |
| 1464 propagation_roots.push_back(use); |
| 1465 } |
| 1466 } |
| 1467 } |
| 1468 if (FLAG_trace_turbo_scheduler) { |
| 1469 Trace("propagation roots: "); |
| 1470 for (Node* node : propagation_roots) { |
| 1471 Trace("#%d:%s ", node->id(), node->op()->mnemonic()); |
| 1472 } |
| 1473 Trace("\n"); |
| 1474 } |
| 1475 ScheduleEarlyNodeVisitor schedule_early_visitor(zone_, this); |
| 1476 schedule_early_visitor.Run(&propagation_roots); |
| 1477 |
1453 // Move previously planned nodes. | 1478 // Move previously planned nodes. |
1454 // TODO(mstarzinger): Improve that by supporting bulk moves. | 1479 // TODO(mstarzinger): Improve that by supporting bulk moves. |
1455 scheduled_nodes_.resize(schedule_->BasicBlockCount(), NodeVector(zone_)); | 1480 scheduled_nodes_.resize(schedule_->BasicBlockCount(), NodeVector(zone_)); |
1456 MovePlannedNodes(block, schedule_->block(node)); | 1481 MovePlannedNodes(block, schedule_->block(node)); |
1457 | 1482 |
1458 if (FLAG_trace_turbo_scheduler) { | 1483 if (FLAG_trace_turbo_scheduler) { |
1459 OFStream os(stdout); | 1484 OFStream os(stdout); |
1460 os << "Schedule after control flow fusion:\n" << *schedule_; | 1485 os << "Schedule after control flow fusion:\n" << *schedule_; |
1461 } | 1486 } |
1462 } | 1487 } |
1463 | 1488 |
1464 | 1489 |
1465 void Scheduler::MovePlannedNodes(BasicBlock* from, BasicBlock* to) { | 1490 void Scheduler::MovePlannedNodes(BasicBlock* from, BasicBlock* to) { |
1466 Trace("Move planned nodes from B%d to B%d\n", from->id().ToInt(), | 1491 Trace("Move planned nodes from B%d to B%d\n", from->id().ToInt(), |
1467 to->id().ToInt()); | 1492 to->id().ToInt()); |
1468 NodeVector* nodes = &(scheduled_nodes_[from->id().ToSize()]); | 1493 NodeVector* nodes = &(scheduled_nodes_[from->id().ToSize()]); |
1469 for (NodeVectorIter i = nodes->begin(); i != nodes->end(); ++i) { | 1494 for (NodeVectorIter i = nodes->begin(); i != nodes->end(); ++i) { |
1470 schedule_->SetBlockForNode(to, *i); | 1495 schedule_->SetBlockForNode(to, *i); |
1471 scheduled_nodes_[to->id().ToSize()].push_back(*i); | 1496 scheduled_nodes_[to->id().ToSize()].push_back(*i); |
1472 } | 1497 } |
1473 nodes->clear(); | 1498 nodes->clear(); |
1474 } | 1499 } |
1475 | 1500 |
1476 } // namespace compiler | 1501 } // namespace compiler |
1477 } // namespace internal | 1502 } // namespace internal |
1478 } // namespace v8 | 1503 } // namespace v8 |
OLD | NEW |