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/zone-containers.h" | 13 #include "src/zone-containers.h" |
13 | 14 |
14 namespace v8 { | 15 namespace v8 { |
15 namespace internal { | 16 namespace internal { |
16 namespace compiler { | 17 namespace compiler { |
17 | 18 |
18 // Computes a schedule from a graph, placing nodes into basic blocks and | 19 // Computes a schedule from a graph, placing nodes into basic blocks and |
19 // ordering the basic blocks in the special RPO order. | 20 // ordering the basic blocks in the special RPO order. |
20 class Scheduler { | 21 class Scheduler { |
21 public: | 22 public: |
22 // The complete scheduling algorithm. Creates a new schedule and places all | 23 // The complete scheduling algorithm. Creates a new schedule and places all |
23 // nodes from the graph into it. | 24 // nodes from the graph into it. |
24 static Schedule* ComputeSchedule(Graph* graph); | 25 static Schedule* ComputeSchedule(ZonePool* zone_pool, Graph* graph); |
25 | 26 |
26 // Compute the RPO of blocks in an existing schedule. | 27 // Compute the RPO of blocks in an existing schedule. |
27 static BasicBlockVector* ComputeSpecialRPO(Schedule* schedule); | 28 static BasicBlockVector* ComputeSpecialRPO(ZonePool* zone_pool, |
| 29 Schedule* schedule); |
28 | 30 |
29 private: | 31 private: |
30 enum Placement { kUnknown, kSchedulable, kFixed }; | 32 enum Placement { kUnknown, kSchedulable, kFixed }; |
31 | 33 |
32 // Per-node data tracked during scheduling. | 34 // Per-node data tracked during scheduling. |
33 struct SchedulerData { | 35 struct SchedulerData { |
34 BasicBlock* minimum_block_; // Minimum legal RPO placement. | 36 BasicBlock* minimum_block_; // Minimum legal RPO placement. |
35 int unscheduled_count_; // Number of unscheduled uses of this node. | 37 int unscheduled_count_; // Number of unscheduled uses of this node. |
36 bool is_connected_control_; // {true} if control-connected to the end node. | 38 bool is_connected_control_; // {true} if control-connected to the end node. |
37 bool is_floating_control_; // {true} if control, but not control-connected | 39 bool is_floating_control_; // {true} if control, but not control-connected |
38 // to the end node. | 40 // to the end node. |
39 Placement placement_ : 3; // Whether the node is fixed, schedulable, | 41 Placement placement_ : 3; // Whether the node is fixed, schedulable, |
40 // or not yet known. | 42 // or not yet known. |
41 }; | 43 }; |
42 | 44 |
| 45 ZonePool* zone_pool_; |
43 Zone* zone_; | 46 Zone* zone_; |
44 Graph* graph_; | 47 Graph* graph_; |
45 Schedule* schedule_; | 48 Schedule* schedule_; |
46 NodeVectorVector scheduled_nodes_; | 49 NodeVectorVector scheduled_nodes_; |
47 NodeVector schedule_root_nodes_; | 50 NodeVector schedule_root_nodes_; |
48 ZoneVector<SchedulerData> node_data_; | 51 ZoneVector<SchedulerData> node_data_; |
49 bool has_floating_control_; | 52 bool has_floating_control_; |
50 | 53 |
51 Scheduler(Zone* zone, Graph* graph, Schedule* schedule); | 54 Scheduler(ZonePool* zone_pool, Zone* zone, Graph* graph, Schedule* schedule); |
52 | 55 |
53 SchedulerData DefaultSchedulerData(); | 56 SchedulerData DefaultSchedulerData(); |
54 | 57 |
55 SchedulerData* GetData(Node* node) { | 58 SchedulerData* GetData(Node* node) { |
56 DCHECK(node->id() < static_cast<int>(node_data_.size())); | 59 DCHECK(node->id() < static_cast<int>(node_data_.size())); |
57 return &node_data_[node->id()]; | 60 return &node_data_[node->id()]; |
58 } | 61 } |
59 | 62 |
60 Placement GetPlacement(Node* node); | 63 Placement GetPlacement(Node* node); |
61 | 64 |
(...skipping 26 matching lines...) Expand all Loading... |
88 | 91 |
89 bool ConnectFloatingControl(); | 92 bool ConnectFloatingControl(); |
90 void ConnectFloatingControlSubgraph(BasicBlock* block, Node* node); | 93 void ConnectFloatingControlSubgraph(BasicBlock* block, Node* node); |
91 }; | 94 }; |
92 | 95 |
93 } // namespace compiler | 96 } // namespace compiler |
94 } // namespace internal | 97 } // namespace internal |
95 } // namespace v8 | 98 } // namespace v8 |
96 | 99 |
97 #endif // V8_COMPILER_SCHEDULER_H_ | 100 #endif // V8_COMPILER_SCHEDULER_H_ |
OLD | NEW |