| 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 #ifndef V8_COMPILER_SCHEDULER_H_ | 5 #ifndef V8_COMPILER_SCHEDULER_H_ |
| 6 #define V8_COMPILER_SCHEDULER_H_ | 6 #define V8_COMPILER_SCHEDULER_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/compiler/opcodes.h" | 10 #include "src/compiler/opcodes.h" |
| 11 #include "src/compiler/schedule.h" | 11 #include "src/compiler/schedule.h" |
| 12 #include "src/compiler/zone-pool.h" | 12 #include "src/compiler/zone-pool.h" |
| 13 #include "src/zone-containers.h" | 13 #include "src/zone-containers.h" |
| 14 | 14 |
| 15 namespace v8 { | 15 namespace v8 { |
| 16 namespace internal { | 16 namespace internal { |
| 17 namespace compiler { | 17 namespace compiler { |
| 18 | 18 |
| 19 class CFGBuilder; | 19 class CFGBuilder; |
| 20 class ControlEquivalence; |
| 20 class SpecialRPONumberer; | 21 class SpecialRPONumberer; |
| 21 | 22 |
| 22 // Computes a schedule from a graph, placing nodes into basic blocks and | 23 // Computes a schedule from a graph, placing nodes into basic blocks and |
| 23 // ordering the basic blocks in the special RPO order. | 24 // ordering the basic blocks in the special RPO order. |
| 24 class Scheduler { | 25 class Scheduler { |
| 25 public: | 26 public: |
| 26 // The complete scheduling algorithm. Creates a new schedule and places all | 27 // The complete scheduling algorithm. Creates a new schedule and places all |
| 27 // nodes from the graph into it. | 28 // nodes from the graph into it. |
| 28 static Schedule* ComputeSchedule(Zone* zone, Graph* graph); | 29 static Schedule* ComputeSchedule(Zone* zone, Graph* graph); |
| 29 | 30 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 42 // | 43 // |
| 43 // 1) GetPlacement(): kUnknown -> kCoupled|kSchedulable|kFixed | 44 // 1) GetPlacement(): kUnknown -> kCoupled|kSchedulable|kFixed |
| 44 // 2) UpdatePlacement(): kCoupled|kSchedulable -> kFixed|kScheduled | 45 // 2) UpdatePlacement(): kCoupled|kSchedulable -> kFixed|kScheduled |
| 45 enum Placement { kUnknown, kSchedulable, kFixed, kCoupled, kScheduled }; | 46 enum Placement { kUnknown, kSchedulable, kFixed, kCoupled, kScheduled }; |
| 46 | 47 |
| 47 // Per-node data tracked during scheduling. | 48 // Per-node data tracked during scheduling. |
| 48 struct SchedulerData { | 49 struct SchedulerData { |
| 49 BasicBlock* minimum_block_; // Minimum legal RPO placement. | 50 BasicBlock* minimum_block_; // Minimum legal RPO placement. |
| 50 int unscheduled_count_; // Number of unscheduled uses of this node. | 51 int unscheduled_count_; // Number of unscheduled uses of this node. |
| 51 bool is_connected_control_; // {true} if control-connected to the end node. | 52 bool is_connected_control_; // {true} if control-connected to the end node. |
| 52 bool is_floating_control_; // {true} if control, but not control-connected | |
| 53 // to the end node. | |
| 54 Placement placement_; // Whether the node is fixed, schedulable, | 53 Placement placement_; // Whether the node is fixed, schedulable, |
| 55 // coupled to another node, or not yet known. | 54 // coupled to another node, or not yet known. |
| 56 }; | 55 }; |
| 57 | 56 |
| 58 Zone* zone_; | 57 Zone* zone_; |
| 59 Graph* graph_; | 58 Graph* graph_; |
| 60 Schedule* schedule_; | 59 Schedule* schedule_; |
| 61 NodeVectorVector scheduled_nodes_; // Per-block list of nodes in reverse. | 60 NodeVectorVector scheduled_nodes_; // Per-block list of nodes in reverse. |
| 62 NodeVector schedule_root_nodes_; // Fixed root nodes seed the worklist. | 61 NodeVector schedule_root_nodes_; // Fixed root nodes seed the worklist. |
| 63 ZoneQueue<Node*> schedule_queue_; // Worklist of schedulable nodes. | 62 ZoneQueue<Node*> schedule_queue_; // Worklist of schedulable nodes. |
| 64 ZoneVector<SchedulerData> node_data_; // Per-node data for all nodes. | 63 ZoneVector<SchedulerData> node_data_; // Per-node data for all nodes. |
| 65 CFGBuilder* control_flow_builder_; // Builds basic blocks for controls. | 64 CFGBuilder* control_flow_builder_; // Builds basic blocks for controls. |
| 66 SpecialRPONumberer* special_rpo_; // Special RPO numbering of blocks. | 65 SpecialRPONumberer* special_rpo_; // Special RPO numbering of blocks. |
| 66 ControlEquivalence* equivalence_; // Control dependence equivalence. |
| 67 | 67 |
| 68 Scheduler(Zone* zone, Graph* graph, Schedule* schedule); | 68 Scheduler(Zone* zone, Graph* graph, Schedule* schedule); |
| 69 | 69 |
| 70 inline SchedulerData DefaultSchedulerData(); | 70 inline SchedulerData DefaultSchedulerData(); |
| 71 inline SchedulerData* GetData(Node* node); | 71 inline SchedulerData* GetData(Node* node); |
| 72 | 72 |
| 73 Placement GetPlacement(Node* node); | 73 Placement GetPlacement(Node* node); |
| 74 void UpdatePlacement(Node* node, Placement placement); | 74 void UpdatePlacement(Node* node, Placement placement); |
| 75 | 75 |
| 76 inline bool IsCoupledControlEdge(Node* node, int index); | 76 inline bool IsCoupledControlEdge(Node* node, int index); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 106 | 106 |
| 107 void FuseFloatingControl(BasicBlock* block, Node* node); | 107 void FuseFloatingControl(BasicBlock* block, Node* node); |
| 108 void MovePlannedNodes(BasicBlock* from, BasicBlock* to); | 108 void MovePlannedNodes(BasicBlock* from, BasicBlock* to); |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 } // namespace compiler | 111 } // namespace compiler |
| 112 } // namespace internal | 112 } // namespace internal |
| 113 } // namespace v8 | 113 } // namespace v8 |
| 114 | 114 |
| 115 #endif // V8_COMPILER_SCHEDULER_H_ | 115 #endif // V8_COMPILER_SCHEDULER_H_ |
| OLD | NEW |