| 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/schedule.h" | 5 #include "src/compiler/schedule.h" |
| 6 | 6 |
| 7 #include "src/compiler/node.h" | 7 #include "src/compiler/node.h" |
| 8 #include "src/compiler/node-properties.h" | 8 #include "src/compiler/node-properties.h" |
| 9 #include "src/ostreams.h" | 9 #include "src/ostreams.h" |
| 10 | 10 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 138 |
| 139 BasicBlock* Schedule::block(Node* node) const { | 139 BasicBlock* Schedule::block(Node* node) const { |
| 140 if (node->id() < static_cast<NodeId>(nodeid_to_block_.size())) { | 140 if (node->id() < static_cast<NodeId>(nodeid_to_block_.size())) { |
| 141 return nodeid_to_block_[node->id()]; | 141 return nodeid_to_block_[node->id()]; |
| 142 } | 142 } |
| 143 return NULL; | 143 return NULL; |
| 144 } | 144 } |
| 145 | 145 |
| 146 | 146 |
| 147 bool Schedule::IsScheduled(Node* node) { | 147 bool Schedule::IsScheduled(Node* node) { |
| 148 int length = static_cast<int>(nodeid_to_block_.size()); | 148 if (node->id() >= nodeid_to_block_.size()) return false; |
| 149 if (node->id() >= length) return false; | |
| 150 return nodeid_to_block_[node->id()] != NULL; | 149 return nodeid_to_block_[node->id()] != NULL; |
| 151 } | 150 } |
| 152 | 151 |
| 153 | 152 |
| 154 BasicBlock* Schedule::GetBlockById(BasicBlock::Id block_id) { | 153 BasicBlock* Schedule::GetBlockById(BasicBlock::Id block_id) { |
| 155 DCHECK(block_id.ToSize() < all_blocks_.size()); | 154 DCHECK(block_id.ToSize() < all_blocks_.size()); |
| 156 return all_blocks_[block_id.ToSize()]; | 155 return all_blocks_[block_id.ToSize()]; |
| 157 } | 156 } |
| 158 | 157 |
| 159 | 158 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 } | 316 } |
| 318 | 317 |
| 319 | 318 |
| 320 void Schedule::SetControlInput(BasicBlock* block, Node* node) { | 319 void Schedule::SetControlInput(BasicBlock* block, Node* node) { |
| 321 block->set_control_input(node); | 320 block->set_control_input(node); |
| 322 SetBlockForNode(block, node); | 321 SetBlockForNode(block, node); |
| 323 } | 322 } |
| 324 | 323 |
| 325 | 324 |
| 326 void Schedule::SetBlockForNode(BasicBlock* block, Node* node) { | 325 void Schedule::SetBlockForNode(BasicBlock* block, Node* node) { |
| 327 int length = static_cast<int>(nodeid_to_block_.size()); | 326 if (node->id() >= nodeid_to_block_.size()) { |
| 328 if (node->id() >= length) { | |
| 329 nodeid_to_block_.resize(node->id() + 1); | 327 nodeid_to_block_.resize(node->id() + 1); |
| 330 } | 328 } |
| 331 nodeid_to_block_[node->id()] = block; | 329 nodeid_to_block_[node->id()] = block; |
| 332 } | 330 } |
| 333 | 331 |
| 334 | 332 |
| 335 std::ostream& operator<<(std::ostream& os, const Schedule& s) { | 333 std::ostream& operator<<(std::ostream& os, const Schedule& s) { |
| 336 for (BasicBlock* block : *s.rpo_order()) { | 334 for (BasicBlock* block : *s.rpo_order()) { |
| 337 os << "--- BLOCK B" << block->rpo_number(); | 335 os << "--- BLOCK B" << block->rpo_number(); |
| 338 if (block->deferred()) os << " (deferred)"; | 336 if (block->deferred()) os << " (deferred)"; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 } | 372 } |
| 375 os << "\n"; | 373 os << "\n"; |
| 376 } | 374 } |
| 377 } | 375 } |
| 378 return os; | 376 return os; |
| 379 } | 377 } |
| 380 | 378 |
| 381 } // namespace compiler | 379 } // namespace compiler |
| 382 } // namespace internal | 380 } // namespace internal |
| 383 } // namespace v8 | 381 } // namespace v8 |
| OLD | NEW |