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 | 9 |
10 #include "src/zone-containers.h" | 10 #include "src/zone-containers.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 // A basic block contains an ordered list of nodes and ends with a control | 26 // A basic block contains an ordered list of nodes and ends with a control |
27 // node. Note that if a basic block has phis, then all phis must appear as the | 27 // node. Note that if a basic block has phis, then all phis must appear as the |
28 // first nodes in the block. | 28 // first nodes in the block. |
29 class BasicBlock FINAL : public ZoneObject { | 29 class BasicBlock FINAL : public ZoneObject { |
30 public: | 30 public: |
31 // Possible control nodes that can end a block. | 31 // Possible control nodes that can end a block. |
32 enum Control { | 32 enum Control { |
33 kNone, // Control not initialized yet. | 33 kNone, // Control not initialized yet. |
34 kGoto, // Goto a single successor block. | 34 kGoto, // Goto a single successor block. |
35 kBranch, // Branch if true to first successor, otherwise second. | 35 kBranch, // Branch if true to first successor, otherwise second. |
| 36 kSwitch, // Table dispatch to one of the successor blocks. |
36 kReturn, // Return a value from this method. | 37 kReturn, // Return a value from this method. |
37 kThrow // Throw an exception. | 38 kThrow // Throw an exception. |
38 }; | 39 }; |
39 | 40 |
40 class Id { | 41 class Id { |
41 public: | 42 public: |
42 int ToInt() const { return static_cast<int>(index_); } | 43 int ToInt() const { return static_cast<int>(index_); } |
43 size_t ToSize() const { return index_; } | 44 size_t ToSize() const { return index_; } |
44 static Id FromSize(size_t index) { return Id(index); } | 45 static Id FromSize(size_t index) { return Id(index); } |
45 static Id FromInt(int index) { return Id(static_cast<size_t>(index)); } | 46 static Id FromInt(int index) { return Id(static_cast<size_t>(index)); } |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 // BasicBlock building: add a node to the end of the block. | 227 // BasicBlock building: add a node to the end of the block. |
227 void AddNode(BasicBlock* block, Node* node); | 228 void AddNode(BasicBlock* block, Node* node); |
228 | 229 |
229 // BasicBlock building: add a goto to the end of {block}. | 230 // BasicBlock building: add a goto to the end of {block}. |
230 void AddGoto(BasicBlock* block, BasicBlock* succ); | 231 void AddGoto(BasicBlock* block, BasicBlock* succ); |
231 | 232 |
232 // BasicBlock building: add a branch at the end of {block}. | 233 // BasicBlock building: add a branch at the end of {block}. |
233 void AddBranch(BasicBlock* block, Node* branch, BasicBlock* tblock, | 234 void AddBranch(BasicBlock* block, Node* branch, BasicBlock* tblock, |
234 BasicBlock* fblock); | 235 BasicBlock* fblock); |
235 | 236 |
| 237 // BasicBlock building: add a switch at the end of {block}. |
| 238 void AddSwitch(BasicBlock* block, Node* sw, BasicBlock** succ_blocks, |
| 239 size_t succ_count); |
| 240 |
236 // BasicBlock building: add a return at the end of {block}. | 241 // BasicBlock building: add a return at the end of {block}. |
237 void AddReturn(BasicBlock* block, Node* input); | 242 void AddReturn(BasicBlock* block, Node* input); |
238 | 243 |
239 // BasicBlock building: add a throw at the end of {block}. | 244 // BasicBlock building: add a throw at the end of {block}. |
240 void AddThrow(BasicBlock* block, Node* input); | 245 void AddThrow(BasicBlock* block, Node* input); |
241 | 246 |
242 // BasicBlock mutation: insert a branch into the end of {block}. | 247 // BasicBlock mutation: insert a branch into the end of {block}. |
243 void InsertBranch(BasicBlock* block, BasicBlock* end, Node* branch, | 248 void InsertBranch(BasicBlock* block, BasicBlock* end, Node* branch, |
244 BasicBlock* tblock, BasicBlock* fblock); | 249 BasicBlock* tblock, BasicBlock* fblock); |
245 | 250 |
| 251 // BasicBlock mutation: insert a switch into the end of {block}. |
| 252 void InsertSwitch(BasicBlock* block, BasicBlock* end, Node* sw, |
| 253 BasicBlock** succ_blocks, size_t succ_count); |
| 254 |
246 // Exposed publicly for testing only. | 255 // Exposed publicly for testing only. |
247 void AddSuccessorForTesting(BasicBlock* block, BasicBlock* succ) { | 256 void AddSuccessorForTesting(BasicBlock* block, BasicBlock* succ) { |
248 return AddSuccessor(block, succ); | 257 return AddSuccessor(block, succ); |
249 } | 258 } |
250 | 259 |
251 BasicBlockVector* rpo_order() { return &rpo_order_; } | 260 BasicBlockVector* rpo_order() { return &rpo_order_; } |
252 const BasicBlockVector* rpo_order() const { return &rpo_order_; } | 261 const BasicBlockVector* rpo_order() const { return &rpo_order_; } |
253 | 262 |
254 BasicBlock* start() { return start_; } | 263 BasicBlock* start() { return start_; } |
255 BasicBlock* end() { return end_; } | 264 BasicBlock* end() { return end_; } |
(...skipping 20 matching lines...) Expand all Loading... |
276 DISALLOW_COPY_AND_ASSIGN(Schedule); | 285 DISALLOW_COPY_AND_ASSIGN(Schedule); |
277 }; | 286 }; |
278 | 287 |
279 std::ostream& operator<<(std::ostream&, const Schedule&); | 288 std::ostream& operator<<(std::ostream&, const Schedule&); |
280 | 289 |
281 } // namespace compiler | 290 } // namespace compiler |
282 } // namespace internal | 291 } // namespace internal |
283 } // namespace v8 | 292 } // namespace v8 |
284 | 293 |
285 #endif // V8_COMPILER_SCHEDULE_H_ | 294 #endif // V8_COMPILER_SCHEDULE_H_ |
OLD | NEW |