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 <iosfwd> | 8 #include <iosfwd> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 Predecessors::iterator predecessors_begin() { return predecessors_.begin(); } | 88 Predecessors::iterator predecessors_begin() { return predecessors_.begin(); } |
89 Predecessors::iterator predecessors_end() { return predecessors_.end(); } | 89 Predecessors::iterator predecessors_end() { return predecessors_.end(); } |
90 Predecessors::const_iterator predecessors_begin() const { | 90 Predecessors::const_iterator predecessors_begin() const { |
91 return predecessors_.begin(); | 91 return predecessors_.begin(); |
92 } | 92 } |
93 Predecessors::const_iterator predecessors_end() const { | 93 Predecessors::const_iterator predecessors_end() const { |
94 return predecessors_.end(); | 94 return predecessors_.end(); |
95 } | 95 } |
96 size_t PredecessorCount() const { return predecessors_.size(); } | 96 size_t PredecessorCount() const { return predecessors_.size(); } |
97 BasicBlock* PredecessorAt(size_t index) { return predecessors_[index]; } | 97 BasicBlock* PredecessorAt(size_t index) { return predecessors_[index]; } |
| 98 void ClearPredecessors() { predecessors_.clear(); } |
98 void AddPredecessor(BasicBlock* predecessor); | 99 void AddPredecessor(BasicBlock* predecessor); |
99 | 100 |
100 typedef ZoneVector<BasicBlock*> Successors; | 101 typedef ZoneVector<BasicBlock*> Successors; |
101 Successors::iterator successors_begin() { return successors_.begin(); } | 102 Successors::iterator successors_begin() { return successors_.begin(); } |
102 Successors::iterator successors_end() { return successors_.end(); } | 103 Successors::iterator successors_end() { return successors_.end(); } |
103 Successors::const_iterator successors_begin() const { | 104 Successors::const_iterator successors_begin() const { |
104 return successors_.begin(); | 105 return successors_.begin(); |
105 } | 106 } |
106 Successors::const_iterator successors_end() const { | 107 Successors::const_iterator successors_end() const { |
107 return successors_.end(); | 108 return successors_.end(); |
108 } | 109 } |
109 size_t SuccessorCount() const { return successors_.size(); } | 110 size_t SuccessorCount() const { return successors_.size(); } |
110 BasicBlock* SuccessorAt(size_t index) { return successors_[index]; } | 111 BasicBlock* SuccessorAt(size_t index) { return successors_[index]; } |
| 112 void ClearSuccessors() { successors_.clear(); } |
111 void AddSuccessor(BasicBlock* successor); | 113 void AddSuccessor(BasicBlock* successor); |
112 | 114 |
113 // Nodes in the basic block. | 115 // Nodes in the basic block. |
114 Node* NodeAt(size_t index) { return nodes_[index]; } | 116 Node* NodeAt(size_t index) { return nodes_[index]; } |
115 size_t NodeCount() const { return nodes_.size(); } | 117 size_t NodeCount() const { return nodes_.size(); } |
116 | 118 |
117 typedef NodeVector::iterator iterator; | 119 typedef NodeVector::iterator iterator; |
118 iterator begin() { return nodes_.begin(); } | 120 iterator begin() { return nodes_.begin(); } |
119 iterator end() { return nodes_.end(); } | 121 iterator end() { return nodes_.end(); } |
120 | 122 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // BasicBlock building: add a branch at the end of {block}. | 235 // BasicBlock building: add a branch at the end of {block}. |
234 void AddBranch(BasicBlock* block, Node* branch, BasicBlock* tblock, | 236 void AddBranch(BasicBlock* block, Node* branch, BasicBlock* tblock, |
235 BasicBlock* fblock); | 237 BasicBlock* fblock); |
236 | 238 |
237 // BasicBlock building: add a return at the end of {block}. | 239 // BasicBlock building: add a return at the end of {block}. |
238 void AddReturn(BasicBlock* block, Node* input); | 240 void AddReturn(BasicBlock* block, Node* input); |
239 | 241 |
240 // BasicBlock building: add a throw at the end of {block}. | 242 // BasicBlock building: add a throw at the end of {block}. |
241 void AddThrow(BasicBlock* block, Node* input); | 243 void AddThrow(BasicBlock* block, Node* input); |
242 | 244 |
243 void AddSuccessor(BasicBlock* block, BasicBlock* succ); | 245 // BasicBlock mutation: insert a branch into the end of {block}. |
| 246 void InsertBranch(BasicBlock* block, BasicBlock* end, Node* branch, |
| 247 BasicBlock* tblock, BasicBlock* fblock); |
| 248 |
| 249 // Exposed publicly for testing only. |
| 250 void AddSuccessorForTesting(BasicBlock* block, BasicBlock* succ) { |
| 251 return AddSuccessor(block, succ); |
| 252 } |
244 | 253 |
245 BasicBlockVector* rpo_order() { return &rpo_order_; } | 254 BasicBlockVector* rpo_order() { return &rpo_order_; } |
246 const BasicBlockVector* rpo_order() const { return &rpo_order_; } | 255 const BasicBlockVector* rpo_order() const { return &rpo_order_; } |
247 | 256 |
248 BasicBlock* start() { return start_; } | 257 BasicBlock* start() { return start_; } |
249 BasicBlock* end() { return end_; } | 258 BasicBlock* end() { return end_; } |
250 | 259 |
251 Zone* zone() const { return zone_; } | 260 Zone* zone() const { return zone_; } |
252 | 261 |
253 private: | 262 private: |
254 friend class Scheduler; | 263 friend class Scheduler; |
255 friend class CodeGenerator; | 264 friend class CodeGenerator; |
256 friend class ScheduleVisualizer; | 265 friend class ScheduleVisualizer; |
257 friend class BasicBlockInstrumentor; | 266 friend class BasicBlockInstrumentor; |
258 | 267 |
| 268 void AddSuccessor(BasicBlock* block, BasicBlock* succ); |
| 269 void MoveSuccessors(BasicBlock* from, BasicBlock* to); |
| 270 |
259 void SetControlInput(BasicBlock* block, Node* node); | 271 void SetControlInput(BasicBlock* block, Node* node); |
260 void SetBlockForNode(BasicBlock* block, Node* node); | 272 void SetBlockForNode(BasicBlock* block, Node* node); |
261 | 273 |
262 Zone* zone_; | 274 Zone* zone_; |
263 BasicBlockVector all_blocks_; // All basic blocks in the schedule. | 275 BasicBlockVector all_blocks_; // All basic blocks in the schedule. |
264 BasicBlockVector nodeid_to_block_; // Map from node to containing block. | 276 BasicBlockVector nodeid_to_block_; // Map from node to containing block. |
265 BasicBlockVector rpo_order_; // Reverse-post-order block list. | 277 BasicBlockVector rpo_order_; // Reverse-post-order block list. |
266 BasicBlock* start_; | 278 BasicBlock* start_; |
267 BasicBlock* end_; | 279 BasicBlock* end_; |
268 }; | 280 }; |
269 | 281 |
270 std::ostream& operator<<(std::ostream& os, const Schedule& s); | 282 std::ostream& operator<<(std::ostream& os, const Schedule& s); |
271 | 283 |
272 } // namespace compiler | 284 } // namespace compiler |
273 } // namespace internal | 285 } // namespace internal |
274 } // namespace v8 | 286 } // namespace v8 |
275 | 287 |
276 #endif // V8_COMPILER_SCHEDULE_H_ | 288 #endif // V8_COMPILER_SCHEDULE_H_ |
OLD | NEW |