| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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_INSTRUCTION_SCHEDULER_H_ | 5 #ifndef V8_COMPILER_INSTRUCTION_SCHEDULER_H_ |
| 6 #define V8_COMPILER_INSTRUCTION_SCHEDULER_H_ | 6 #define V8_COMPILER_INSTRUCTION_SCHEDULER_H_ |
| 7 | 7 |
| 8 #include "src/compiler/instruction.h" | 8 #include "src/compiler/instruction.h" |
| 9 #include "src/zone-containers.h" | 9 #include "src/zone-containers.h" |
| 10 | 10 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // have been scheduled. Note that this class is inteded to be extended by | 94 // have been scheduled. Note that this class is inteded to be extended by |
| 95 // concrete implementation of the scheduling queue which define the policy | 95 // concrete implementation of the scheduling queue which define the policy |
| 96 // to pop node from the queue. | 96 // to pop node from the queue. |
| 97 class SchedulingQueueBase { | 97 class SchedulingQueueBase { |
| 98 public: | 98 public: |
| 99 explicit SchedulingQueueBase(InstructionScheduler* scheduler) | 99 explicit SchedulingQueueBase(InstructionScheduler* scheduler) |
| 100 : scheduler_(scheduler), | 100 : scheduler_(scheduler), |
| 101 nodes_(scheduler->zone()) { | 101 nodes_(scheduler->zone()) { |
| 102 } | 102 } |
| 103 | 103 |
| 104 void AddNode(ScheduleGraphNode* node) { | 104 void AddNode(ScheduleGraphNode* node); |
| 105 nodes_.push_back(node); | |
| 106 } | |
| 107 | 105 |
| 108 bool IsEmpty() const { | 106 bool IsEmpty() const { |
| 109 return nodes_.empty(); | 107 return nodes_.empty(); |
| 110 } | 108 } |
| 111 | 109 |
| 112 protected: | 110 protected: |
| 113 InstructionScheduler* scheduler_; | 111 InstructionScheduler* scheduler_; |
| 114 ZoneLinkedList<ScheduleGraphNode*> nodes_; | 112 ZoneLinkedList<ScheduleGraphNode*> nodes_; |
| 115 }; | 113 }; |
| 116 | 114 |
| 117 // A scheduling queue which prioritize nodes on the critical path (we look | 115 // A scheduling queue which prioritize nodes on the critical path (we look |
| 118 // for the instruction with the highest latency on the path to reach the end | 116 // for the instruction with the highest latency on the path to reach the end |
| 119 // of the graph). | 117 // of the graph). |
| 120 class CriticalPathFirstQueue : public SchedulingQueueBase { | 118 class CriticalPathFirstQueue : public SchedulingQueueBase { |
| 121 public: | 119 public: |
| 122 explicit CriticalPathFirstQueue(InstructionScheduler* scheduler) | 120 explicit CriticalPathFirstQueue(InstructionScheduler* scheduler) |
| 123 : SchedulingQueueBase(scheduler) { } | 121 : SchedulingQueueBase(scheduler) { } |
| 124 | 122 |
| 125 // Look for the best candidate to schedule, remove it from the queue and | 123 // Look for the best candidate to schedule, remove it from the queue and |
| 126 // return it. | 124 // return it. |
| 127 ScheduleGraphNode* PopBestCandidate(int cycle); | 125 ScheduleGraphNode* PopBestCandidate(int cycle); |
| 128 | |
| 129 private: | |
| 130 // Compare the two nodes and return true if node1 is a better candidate than | |
| 131 // node2 (i.e. node1 should be scheduled before node2). | |
| 132 bool CompareNodes(ScheduleGraphNode *node1, ScheduleGraphNode *node2) const; | |
| 133 }; | 126 }; |
| 134 | 127 |
| 135 // A queue which pop a random node from the queue to perform stress tests on | 128 // A queue which pop a random node from the queue to perform stress tests on |
| 136 // the scheduler. | 129 // the scheduler. |
| 137 class StressSchedulerQueue : public SchedulingQueueBase { | 130 class StressSchedulerQueue : public SchedulingQueueBase { |
| 138 public: | 131 public: |
| 139 explicit StressSchedulerQueue(InstructionScheduler* scheduler) | 132 explicit StressSchedulerQueue(InstructionScheduler* scheduler) |
| 140 : SchedulingQueueBase(scheduler) { } | 133 : SchedulingQueueBase(scheduler) { } |
| 141 | 134 |
| 142 ScheduleGraphNode* PopBestCandidate(int cycle); | 135 ScheduleGraphNode* PopBestCandidate(int cycle); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 // Keep track of definition points for virtual registers. This is used to | 207 // Keep track of definition points for virtual registers. This is used to |
| 215 // record operand dependencies in the scheduling graph. | 208 // record operand dependencies in the scheduling graph. |
| 216 ZoneMap<int32_t, ScheduleGraphNode*> operands_map_; | 209 ZoneMap<int32_t, ScheduleGraphNode*> operands_map_; |
| 217 }; | 210 }; |
| 218 | 211 |
| 219 } // namespace compiler | 212 } // namespace compiler |
| 220 } // namespace internal | 213 } // namespace internal |
| 221 } // namespace v8 | 214 } // namespace v8 |
| 222 | 215 |
| 223 #endif // V8_COMPILER_INSTRUCTION_SCHEDULER_H_ | 216 #endif // V8_COMPILER_INSTRUCTION_SCHEDULER_H_ |
| OLD | NEW |