| 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 "src/compiler/scheduler.h" | 5 #include "src/compiler/scheduler.h" |
| 6 | 6 |
| 7 #include <iomanip> | 7 #include <iomanip> |
| 8 | 8 |
| 9 #include "src/bit-vector.h" | 9 #include "src/bit-vector.h" |
| 10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
| 11 #include "src/compiler/control-equivalence.h" | 11 #include "src/compiler/control-equivalence.h" |
| 12 #include "src/compiler/graph.h" | 12 #include "src/compiler/graph.h" |
| 13 #include "src/compiler/node.h" | 13 #include "src/compiler/node.h" |
| 14 #include "src/compiler/node-marker.h" | 14 #include "src/compiler/node-marker.h" |
| 15 #include "src/compiler/node-properties.h" | 15 #include "src/compiler/node-properties.h" |
| 16 #include "src/compiler/visualizer.h" |
| 16 #include "src/zone-containers.h" | 17 #include "src/zone-containers.h" |
| 17 | 18 |
| 18 namespace v8 { | 19 namespace v8 { |
| 19 namespace internal { | 20 namespace internal { |
| 20 namespace compiler { | 21 namespace compiler { |
| 21 | 22 |
| 22 static inline void Trace(const char* msg, ...) { | 23 static inline void Trace(const char* msg, ...) { |
| 23 if (FLAG_trace_turbo_scheduler) { | 24 if (FLAG_trace_turbo_scheduler) { |
| 24 va_list arguments; | 25 va_list arguments; |
| 25 va_start(arguments, msg); | 26 va_start(arguments, msg); |
| (...skipping 1604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1630 } | 1631 } |
| 1631 | 1632 |
| 1632 | 1633 |
| 1633 // ----------------------------------------------------------------------------- | 1634 // ----------------------------------------------------------------------------- |
| 1634 | 1635 |
| 1635 | 1636 |
| 1636 void Scheduler::FuseFloatingControl(BasicBlock* block, Node* node) { | 1637 void Scheduler::FuseFloatingControl(BasicBlock* block, Node* node) { |
| 1637 Trace("--- FUSE FLOATING CONTROL ----------------------------------\n"); | 1638 Trace("--- FUSE FLOATING CONTROL ----------------------------------\n"); |
| 1638 if (FLAG_trace_turbo_scheduler) { | 1639 if (FLAG_trace_turbo_scheduler) { |
| 1639 OFStream os(stdout); | 1640 OFStream os(stdout); |
| 1640 os << "Schedule before control flow fusion:\n" << *schedule_; | 1641 os << "Schedule before control flow fusion:\n" |
| 1642 << ScheduleAsJSON(*schedule_); |
| 1641 } | 1643 } |
| 1642 | 1644 |
| 1643 // Iterate on phase 1: Build control-flow graph. | 1645 // Iterate on phase 1: Build control-flow graph. |
| 1644 control_flow_builder_->Run(block, node); | 1646 control_flow_builder_->Run(block, node); |
| 1645 | 1647 |
| 1646 // Iterate on phase 2: Compute special RPO and dominator tree. | 1648 // Iterate on phase 2: Compute special RPO and dominator tree. |
| 1647 special_rpo_->UpdateSpecialRPO(block, schedule_->block(node)); | 1649 special_rpo_->UpdateSpecialRPO(block, schedule_->block(node)); |
| 1648 // TODO(mstarzinger): Currently "iterate on" means "re-run". Fix that. | 1650 // TODO(mstarzinger): Currently "iterate on" means "re-run". Fix that. |
| 1649 for (BasicBlock* b = block->rpo_next(); b != NULL; b = b->rpo_next()) { | 1651 for (BasicBlock* b = block->rpo_next(); b != NULL; b = b->rpo_next()) { |
| 1650 b->set_dominator_depth(-1); | 1652 b->set_dominator_depth(-1); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1672 ScheduleEarlyNodeVisitor schedule_early_visitor(zone_, this); | 1674 ScheduleEarlyNodeVisitor schedule_early_visitor(zone_, this); |
| 1673 schedule_early_visitor.Run(&propagation_roots); | 1675 schedule_early_visitor.Run(&propagation_roots); |
| 1674 | 1676 |
| 1675 // Move previously planned nodes. | 1677 // Move previously planned nodes. |
| 1676 // TODO(mstarzinger): Improve that by supporting bulk moves. | 1678 // TODO(mstarzinger): Improve that by supporting bulk moves. |
| 1677 scheduled_nodes_.resize(schedule_->BasicBlockCount(), NodeVector(zone_)); | 1679 scheduled_nodes_.resize(schedule_->BasicBlockCount(), NodeVector(zone_)); |
| 1678 MovePlannedNodes(block, schedule_->block(node)); | 1680 MovePlannedNodes(block, schedule_->block(node)); |
| 1679 | 1681 |
| 1680 if (FLAG_trace_turbo_scheduler) { | 1682 if (FLAG_trace_turbo_scheduler) { |
| 1681 OFStream os(stdout); | 1683 OFStream os(stdout); |
| 1682 os << "Schedule after control flow fusion:\n" << *schedule_; | 1684 os << "Schedule after control flow fusion:\n" << ScheduleAsJSON(*schedule_); |
| 1683 } | 1685 } |
| 1684 } | 1686 } |
| 1685 | 1687 |
| 1686 | 1688 |
| 1687 void Scheduler::MovePlannedNodes(BasicBlock* from, BasicBlock* to) { | 1689 void Scheduler::MovePlannedNodes(BasicBlock* from, BasicBlock* to) { |
| 1688 Trace("Move planned nodes from id:%d to id:%d\n", from->id().ToInt(), | 1690 Trace("Move planned nodes from id:%d to id:%d\n", from->id().ToInt(), |
| 1689 to->id().ToInt()); | 1691 to->id().ToInt()); |
| 1690 NodeVector* nodes = &(scheduled_nodes_[from->id().ToSize()]); | 1692 NodeVector* nodes = &(scheduled_nodes_[from->id().ToSize()]); |
| 1691 for (Node* const node : *nodes) { | 1693 for (Node* const node : *nodes) { |
| 1692 schedule_->SetBlockForNode(to, node); | 1694 schedule_->SetBlockForNode(to, node); |
| 1693 scheduled_nodes_[to->id().ToSize()].push_back(node); | 1695 scheduled_nodes_[to->id().ToSize()].push_back(node); |
| 1694 } | 1696 } |
| 1695 nodes->clear(); | 1697 nodes->clear(); |
| 1696 } | 1698 } |
| 1697 | 1699 |
| 1698 } // namespace compiler | 1700 } // namespace compiler |
| 1699 } // namespace internal | 1701 } // namespace internal |
| 1700 } // namespace v8 | 1702 } // namespace v8 |
| OLD | NEW |