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_SCHEDULE_H_ | 5 #ifndef V8_COMPILER_SCHEDULE_H_ |
6 #define V8_COMPILER_SCHEDULE_H_ | 6 #define V8_COMPILER_SCHEDULE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "src/v8.h" | 10 #include "src/v8.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 typedef ZoneVector<BasicBlock*> BasicBlockVector; | 148 typedef ZoneVector<BasicBlock*> BasicBlockVector; |
149 typedef BasicBlockVector::iterator BasicBlockVectorIter; | 149 typedef BasicBlockVector::iterator BasicBlockVectorIter; |
150 typedef BasicBlockVector::reverse_iterator BasicBlockVectorRIter; | 150 typedef BasicBlockVector::reverse_iterator BasicBlockVectorRIter; |
151 | 151 |
152 // A schedule represents the result of assigning nodes to basic blocks | 152 // A schedule represents the result of assigning nodes to basic blocks |
153 // and ordering them within basic blocks. Prior to computing a schedule, | 153 // and ordering them within basic blocks. Prior to computing a schedule, |
154 // a graph has no notion of control flow ordering other than that induced | 154 // a graph has no notion of control flow ordering other than that induced |
155 // by the graph's dependencies. A schedule is required to generate code. | 155 // by the graph's dependencies. A schedule is required to generate code. |
156 class Schedule : public GenericGraph<BasicBlock> { | 156 class Schedule : public GenericGraph<BasicBlock> { |
157 public: | 157 public: |
158 explicit Schedule(Zone* zone) | 158 explicit Schedule(Zone* zone, size_t node_count_hint = 0) |
159 : GenericGraph<BasicBlock>(zone), | 159 : GenericGraph<BasicBlock>(zone), |
160 zone_(zone), | 160 zone_(zone), |
161 all_blocks_(zone), | 161 all_blocks_(zone), |
162 nodeid_to_block_(zone), | 162 nodeid_to_block_(zone), |
163 rpo_order_(zone) { | 163 rpo_order_(zone) { |
164 SetStart(NewBasicBlock()); // entry. | 164 SetStart(NewBasicBlock()); // entry. |
165 SetEnd(NewBasicBlock()); // exit. | 165 SetEnd(NewBasicBlock()); // exit. |
| 166 nodeid_to_block_.reserve(node_count_hint); |
166 } | 167 } |
167 | 168 |
168 // Return the block which contains {node}, if any. | 169 // Return the block which contains {node}, if any. |
169 BasicBlock* block(Node* node) const { | 170 BasicBlock* block(Node* node) const { |
170 if (node->id() < static_cast<NodeId>(nodeid_to_block_.size())) { | 171 if (node->id() < static_cast<NodeId>(nodeid_to_block_.size())) { |
171 return nodeid_to_block_[node->id()]; | 172 return nodeid_to_block_[node->id()]; |
172 } | 173 } |
173 return NULL; | 174 return NULL; |
174 } | 175 } |
175 | 176 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 BasicBlockVector nodeid_to_block_; // Map from node to containing block. | 298 BasicBlockVector nodeid_to_block_; // Map from node to containing block. |
298 BasicBlockVector rpo_order_; // Reverse-post-order block list. | 299 BasicBlockVector rpo_order_; // Reverse-post-order block list. |
299 }; | 300 }; |
300 | 301 |
301 OStream& operator<<(OStream& os, const Schedule& s); | 302 OStream& operator<<(OStream& os, const Schedule& s); |
302 } | 303 } |
303 } | 304 } |
304 } // namespace v8::internal::compiler | 305 } // namespace v8::internal::compiler |
305 | 306 |
306 #endif // V8_COMPILER_SCHEDULE_H_ | 307 #endif // V8_COMPILER_SCHEDULE_H_ |
OLD | NEW |