| 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 #include "src/compiler/node.h" | 5 #include "src/compiler/node.h" |
| 6 #include "src/compiler/node-properties.h" | 6 #include "src/compiler/node-properties.h" |
| 7 #include "src/compiler/node-properties-inl.h" | 7 #include "src/compiler/node-properties-inl.h" |
| 8 #include "src/compiler/schedule.h" | 8 #include "src/compiler/schedule.h" |
| 9 #include "src/ostreams.h" | 9 #include "src/ostreams.h" |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 bool BasicBlock::LoopContains(BasicBlock* block) const { | 29 bool BasicBlock::LoopContains(BasicBlock* block) const { |
| 30 // RPO numbers must be initialized. | 30 // RPO numbers must be initialized. |
| 31 DCHECK(rpo_number_ >= 0); | 31 DCHECK(rpo_number_ >= 0); |
| 32 DCHECK(block->rpo_number_ >= 0); | 32 DCHECK(block->rpo_number_ >= 0); |
| 33 if (loop_end_ < 0) return false; // This is not a loop. | 33 if (loop_end_ < 0) return false; // This is not a loop. |
| 34 return block->rpo_number_ >= rpo_number_ && block->rpo_number_ < loop_end_; | 34 return block->rpo_number_ >= rpo_number_ && block->rpo_number_ < loop_end_; |
| 35 } | 35 } |
| 36 | 36 |
| 37 | 37 |
| 38 BasicBlock* BasicBlock::ContainingLoop() { | |
| 39 if (IsLoopHeader()) return this; | |
| 40 return loop_header(); | |
| 41 } | |
| 42 | |
| 43 | |
| 44 void BasicBlock::AddSuccessor(BasicBlock* successor) { | 38 void BasicBlock::AddSuccessor(BasicBlock* successor) { |
| 45 successors_.push_back(successor); | 39 successors_.push_back(successor); |
| 46 } | 40 } |
| 47 | 41 |
| 48 | 42 |
| 49 void BasicBlock::AddPredecessor(BasicBlock* predecessor) { | 43 void BasicBlock::AddPredecessor(BasicBlock* predecessor) { |
| 50 predecessors_.push_back(predecessor); | 44 predecessors_.push_back(predecessor); |
| 51 } | 45 } |
| 52 | 46 |
| 53 | 47 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 81 | 75 |
| 82 | 76 |
| 83 void BasicBlock::set_loop_end(int32_t loop_end) { loop_end_ = loop_end; } | 77 void BasicBlock::set_loop_end(int32_t loop_end) { loop_end_ = loop_end; } |
| 84 | 78 |
| 85 | 79 |
| 86 void BasicBlock::set_loop_header(BasicBlock* loop_header) { | 80 void BasicBlock::set_loop_header(BasicBlock* loop_header) { |
| 87 loop_header_ = loop_header; | 81 loop_header_ = loop_header; |
| 88 } | 82 } |
| 89 | 83 |
| 90 | 84 |
| 91 size_t BasicBlock::PredecessorIndexOf(BasicBlock* predecessor) { | |
| 92 size_t j = 0; | |
| 93 for (BasicBlock::Predecessors::iterator i = predecessors_.begin(); | |
| 94 i != predecessors_.end(); ++i, ++j) { | |
| 95 if (*i == predecessor) break; | |
| 96 } | |
| 97 return j; | |
| 98 } | |
| 99 | |
| 100 | |
| 101 std::ostream& operator<<(std::ostream& os, const BasicBlock::Control& c) { | 85 std::ostream& operator<<(std::ostream& os, const BasicBlock::Control& c) { |
| 102 switch (c) { | 86 switch (c) { |
| 103 case BasicBlock::kNone: | 87 case BasicBlock::kNone: |
| 104 return os << "none"; | 88 return os << "none"; |
| 105 case BasicBlock::kGoto: | 89 case BasicBlock::kGoto: |
| 106 return os << "goto"; | 90 return os << "goto"; |
| 107 case BasicBlock::kBranch: | 91 case BasicBlock::kBranch: |
| 108 return os << "branch"; | 92 return os << "branch"; |
| 109 case BasicBlock::kReturn: | 93 case BasicBlock::kReturn: |
| 110 return os << "return"; | 94 return os << "return"; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 } | 287 } |
| 304 os << "\n"; | 288 os << "\n"; |
| 305 } | 289 } |
| 306 } | 290 } |
| 307 return os; | 291 return os; |
| 308 } | 292 } |
| 309 | 293 |
| 310 } // namespace compiler | 294 } // namespace compiler |
| 311 } // namespace internal | 295 } // namespace internal |
| 312 } // namespace v8 | 296 } // namespace v8 |
| OLD | NEW |