| 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" |
| 11 | 11 |
| 12 #include "src/compiler/generic-algorithm.h" | 12 #include "src/compiler/generic-algorithm.h" |
| 13 #include "src/compiler/generic-graph.h" | 13 #include "src/compiler/generic-graph.h" |
| 14 #include "src/compiler/generic-node.h" | 14 #include "src/compiler/generic-node.h" |
| 15 #include "src/compiler/generic-node-inl.h" | 15 #include "src/compiler/generic-node-inl.h" |
| 16 #include "src/compiler/node.h" | 16 #include "src/compiler/node.h" |
| 17 #include "src/compiler/opcodes.h" | 17 #include "src/compiler/opcodes.h" |
| 18 #include "src/zone.h" | 18 #include "src/zone.h" |
| 19 | 19 |
| 20 namespace v8 { | 20 namespace v8 { |
| 21 namespace internal { | 21 namespace internal { |
| 22 namespace compiler { | 22 namespace compiler { |
| 23 | 23 |
| 24 class BasicBlock; | 24 class BasicBlock; |
| 25 class BasicBlockInstrumentor; |
| 25 class Graph; | 26 class Graph; |
| 26 class ConstructScheduleData; | 27 class ConstructScheduleData; |
| 27 class CodeGenerator; // Because of a namespace bug in clang. | 28 class CodeGenerator; // Because of a namespace bug in clang. |
| 28 | 29 |
| 29 class BasicBlockData { | 30 class BasicBlockData { |
| 30 public: | 31 public: |
| 31 // Possible control nodes that can end a block. | 32 // Possible control nodes that can end a block. |
| 32 enum Control { | 33 enum Control { |
| 33 kNone, // Control not initialized yet. | 34 kNone, // Control not initialized yet. |
| 34 kGoto, // Goto a single successor block. | 35 kGoto, // Goto a single successor block. |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 friend class CodeGenerator; | 273 friend class CodeGenerator; |
| 273 | 274 |
| 274 void AddSuccessor(BasicBlock* block, BasicBlock* succ) { | 275 void AddSuccessor(BasicBlock* block, BasicBlock* succ) { |
| 275 succ->AppendInput(zone_, block); | 276 succ->AppendInput(zone_, block); |
| 276 } | 277 } |
| 277 | 278 |
| 278 BasicBlockVector* rpo_order() { return &rpo_order_; } | 279 BasicBlockVector* rpo_order() { return &rpo_order_; } |
| 279 | 280 |
| 280 private: | 281 private: |
| 281 friend class ScheduleVisualizer; | 282 friend class ScheduleVisualizer; |
| 283 friend class BasicBlockInstrumentor; |
| 282 | 284 |
| 283 void SetControlInput(BasicBlock* block, Node* node) { | 285 void SetControlInput(BasicBlock* block, Node* node) { |
| 284 block->control_input_ = node; | 286 block->control_input_ = node; |
| 285 SetBlockForNode(block, node); | 287 SetBlockForNode(block, node); |
| 286 } | 288 } |
| 287 | 289 |
| 288 void SetBlockForNode(BasicBlock* block, Node* node) { | 290 void SetBlockForNode(BasicBlock* block, Node* node) { |
| 289 int length = static_cast<int>(nodeid_to_block_.size()); | 291 int length = static_cast<int>(nodeid_to_block_.size()); |
| 290 if (node->id() >= length) { | 292 if (node->id() >= length) { |
| 291 nodeid_to_block_.resize(node->id() + 1); | 293 nodeid_to_block_.resize(node->id() + 1); |
| 292 } | 294 } |
| 293 nodeid_to_block_[node->id()] = block; | 295 nodeid_to_block_[node->id()] = block; |
| 294 } | 296 } |
| 295 | 297 |
| 296 Zone* zone_; | 298 Zone* zone_; |
| 297 BasicBlockVector all_blocks_; // All basic blocks in the schedule. | 299 BasicBlockVector all_blocks_; // All basic blocks in the schedule. |
| 298 BasicBlockVector nodeid_to_block_; // Map from node to containing block. | 300 BasicBlockVector nodeid_to_block_; // Map from node to containing block. |
| 299 BasicBlockVector rpo_order_; // Reverse-post-order block list. | 301 BasicBlockVector rpo_order_; // Reverse-post-order block list. |
| 300 }; | 302 }; |
| 301 | 303 |
| 302 OStream& operator<<(OStream& os, const Schedule& s); | 304 OStream& operator<<(OStream& os, const Schedule& s); |
| 303 } | 305 } |
| 304 } | 306 } |
| 305 } // namespace v8::internal::compiler | 307 } // namespace v8::internal::compiler |
| 306 | 308 |
| 307 #endif // V8_COMPILER_SCHEDULE_H_ | 309 #endif // V8_COMPILER_SCHEDULE_H_ |
| OLD | NEW |