| 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 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 class BasicBlock; | 24 class BasicBlock; |
| 25 class Graph; | 25 class Graph; |
| 26 class ConstructScheduleData; | 26 class ConstructScheduleData; |
| 27 class CodeGenerator; // Because of a namespace bug in clang. | 27 class CodeGenerator; // Because of a namespace bug in clang. |
| 28 | 28 |
| 29 class BasicBlockData { | 29 class BasicBlockData { |
| 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 kReturn, // Return a value from this method. | 36 kReturn, // Return a value from this method. |
| 37 kThrow, // Throw an exception. | 37 kThrow // Throw an exception. |
| 38 kCall, // Call to a possibly deoptimizing or throwing function. | |
| 39 kDeoptimize // Deoptimize. | |
| 40 }; | 38 }; |
| 41 | 39 |
| 42 int32_t rpo_number_; // special RPO number of the block. | 40 int32_t rpo_number_; // special RPO number of the block. |
| 43 BasicBlock* dominator_; // Immediate dominator of the block. | 41 BasicBlock* dominator_; // Immediate dominator of the block. |
| 44 BasicBlock* loop_header_; // Pointer to dominating loop header basic block, | 42 BasicBlock* loop_header_; // Pointer to dominating loop header basic block, |
| 45 // NULL if none. For loop headers, this points to | 43 // NULL if none. For loop headers, this points to |
| 46 // enclosing loop header. | 44 // enclosing loop header. |
| 47 int32_t loop_depth_; // loop nesting, 0 is top-level | 45 int32_t loop_depth_; // loop nesting, 0 is top-level |
| 48 int32_t loop_end_; // end of the loop, if this block is a loop header. | 46 int32_t loop_end_; // end of the loop, if this block is a loop header. |
| 49 int32_t code_start_; // start index of arch-specific code. | 47 int32_t code_start_; // start index of arch-specific code. |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 SetBlockForNode(block, node); | 225 SetBlockForNode(block, node); |
| 228 } | 226 } |
| 229 | 227 |
| 230 // BasicBlock building: add a goto to the end of {block}. | 228 // BasicBlock building: add a goto to the end of {block}. |
| 231 void AddGoto(BasicBlock* block, BasicBlock* succ) { | 229 void AddGoto(BasicBlock* block, BasicBlock* succ) { |
| 232 DCHECK(block->control_ == BasicBlock::kNone); | 230 DCHECK(block->control_ == BasicBlock::kNone); |
| 233 block->control_ = BasicBlock::kGoto; | 231 block->control_ = BasicBlock::kGoto; |
| 234 AddSuccessor(block, succ); | 232 AddSuccessor(block, succ); |
| 235 } | 233 } |
| 236 | 234 |
| 237 // BasicBlock building: add a (branching) call at the end of {block}. | |
| 238 void AddCall(BasicBlock* block, Node* call, BasicBlock* cont_block, | |
| 239 BasicBlock* deopt_block) { | |
| 240 DCHECK(block->control_ == BasicBlock::kNone); | |
| 241 DCHECK(call->opcode() == IrOpcode::kCall); | |
| 242 block->control_ = BasicBlock::kCall; | |
| 243 // Insert the deopt block first so that the RPO order builder picks | |
| 244 // it first (and thus it ends up late in the RPO order). | |
| 245 AddSuccessor(block, deopt_block); | |
| 246 AddSuccessor(block, cont_block); | |
| 247 SetControlInput(block, call); | |
| 248 SetBlockForNode(block, call); | |
| 249 } | |
| 250 | |
| 251 // BasicBlock building: add a branch at the end of {block}. | 235 // BasicBlock building: add a branch at the end of {block}. |
| 252 void AddBranch(BasicBlock* block, Node* branch, BasicBlock* tblock, | 236 void AddBranch(BasicBlock* block, Node* branch, BasicBlock* tblock, |
| 253 BasicBlock* fblock) { | 237 BasicBlock* fblock) { |
| 254 DCHECK(block->control_ == BasicBlock::kNone); | 238 DCHECK(block->control_ == BasicBlock::kNone); |
| 255 DCHECK(branch->opcode() == IrOpcode::kBranch); | 239 DCHECK(branch->opcode() == IrOpcode::kBranch); |
| 256 block->control_ = BasicBlock::kBranch; | 240 block->control_ = BasicBlock::kBranch; |
| 257 AddSuccessor(block, tblock); | 241 AddSuccessor(block, tblock); |
| 258 AddSuccessor(block, fblock); | 242 AddSuccessor(block, fblock); |
| 259 SetControlInput(block, branch); | 243 SetControlInput(block, branch); |
| 260 if (branch->opcode() == IrOpcode::kBranch) { | 244 if (branch->opcode() == IrOpcode::kBranch) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 276 } | 260 } |
| 277 | 261 |
| 278 // BasicBlock building: add a throw at the end of {block}. | 262 // BasicBlock building: add a throw at the end of {block}. |
| 279 void AddThrow(BasicBlock* block, Node* input) { | 263 void AddThrow(BasicBlock* block, Node* input) { |
| 280 DCHECK(block->control_ == BasicBlock::kNone); | 264 DCHECK(block->control_ == BasicBlock::kNone); |
| 281 block->control_ = BasicBlock::kThrow; | 265 block->control_ = BasicBlock::kThrow; |
| 282 SetControlInput(block, input); | 266 SetControlInput(block, input); |
| 283 if (block != end()) AddSuccessor(block, end()); | 267 if (block != end()) AddSuccessor(block, end()); |
| 284 } | 268 } |
| 285 | 269 |
| 286 // BasicBlock building: add a deopt at the end of {block}. | |
| 287 void AddDeoptimize(BasicBlock* block, Node* state) { | |
| 288 DCHECK(block->control_ == BasicBlock::kNone); | |
| 289 block->control_ = BasicBlock::kDeoptimize; | |
| 290 SetControlInput(block, state); | |
| 291 block->deferred_ = true; // By default, consider deopts the slow path. | |
| 292 if (block != end()) AddSuccessor(block, end()); | |
| 293 } | |
| 294 | |
| 295 friend class Scheduler; | 270 friend class Scheduler; |
| 296 friend class CodeGenerator; | 271 friend class CodeGenerator; |
| 297 | 272 |
| 298 void AddSuccessor(BasicBlock* block, BasicBlock* succ) { | 273 void AddSuccessor(BasicBlock* block, BasicBlock* succ) { |
| 299 succ->AppendInput(zone_, block); | 274 succ->AppendInput(zone_, block); |
| 300 } | 275 } |
| 301 | 276 |
| 302 BasicBlockVector* rpo_order() { return &rpo_order_; } | 277 BasicBlockVector* rpo_order() { return &rpo_order_; } |
| 303 | 278 |
| 304 private: | 279 private: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 322 BasicBlockVector nodeid_to_block_; // Map from node to containing block. | 297 BasicBlockVector nodeid_to_block_; // Map from node to containing block. |
| 323 BasicBlockVector rpo_order_; // Reverse-post-order block list. | 298 BasicBlockVector rpo_order_; // Reverse-post-order block list. |
| 324 }; | 299 }; |
| 325 | 300 |
| 326 OStream& operator<<(OStream& os, const Schedule& s); | 301 OStream& operator<<(OStream& os, const Schedule& s); |
| 327 } | 302 } |
| 328 } | 303 } |
| 329 } // namespace v8::internal::compiler | 304 } // namespace v8::internal::compiler |
| 330 | 305 |
| 331 #endif // V8_COMPILER_SCHEDULE_H_ | 306 #endif // V8_COMPILER_SCHEDULE_H_ |
| OLD | NEW |