Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/verifier.h" | 5 #include "src/compiler/verifier.h" | 
| 6 | 6 | 
| 7 #include <deque> | 7 #include <deque> | 
| 8 #include <queue> | 8 #include <queue> | 
| 9 | 9 | 
| 10 #include "src/compiler/generic-algorithm.h" | 10 #include "src/compiler/generic-algorithm.h" | 
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 } | 264 } | 
| 265 block = block->dominator_; | 265 block = block->dominator_; | 
| 266 if (block == NULL) break; | 266 if (block == NULL) break; | 
| 267 use_pos = static_cast<int>(block->nodes_.size()) - 1; | 267 use_pos = static_cast<int>(block->nodes_.size()) - 1; | 
| 268 if (node == block->control_input_) return true; | 268 if (node == block->control_input_) return true; | 
| 269 } | 269 } | 
| 270 return false; | 270 return false; | 
| 271 } | 271 } | 
| 272 | 272 | 
| 273 | 273 | 
| 274 static bool Dominates(Schedule* schedule, Node* dominator, Node* dominee) { | |
| 
 
titzer
2014/09/25 12:19:24
You should walk up the dominator tree and very the
 
titzer
2014/09/26 10:44:38
BTW can you split this check out into a separate C
 
sigurds
2014/09/26 11:35:24
Done.
 
 | |
| 275 return schedule->block(dominator)->rpo_number_ <= | |
| 276 schedule->block(dominee)->rpo_number_; | |
| 277 } | |
| 278 | |
| 279 | |
| 274 static void CheckInputsDominate(Schedule* schedule, BasicBlock* block, | 280 static void CheckInputsDominate(Schedule* schedule, BasicBlock* block, | 
| 275 Node* node, int use_pos) { | 281 Node* node, int use_pos) { | 
| 276 for (int j = OperatorProperties::GetValueInputCount(node->op()) - 1; j >= 0; | 282 for (int j = OperatorProperties::GetValueInputCount(node->op()) - 1; j >= 0; | 
| 277 j--) { | 283 j--) { | 
| 278 BasicBlock* use_block = block; | 284 BasicBlock* use_block = block; | 
| 279 if (node->opcode() == IrOpcode::kPhi) { | 285 if (node->opcode() == IrOpcode::kPhi) { | 
| 280 use_block = use_block->PredecessorAt(j); | 286 use_block = use_block->PredecessorAt(j); | 
| 281 use_pos = static_cast<int>(use_block->nodes_.size()) - 1; | 287 use_pos = static_cast<int>(use_block->nodes_.size()) - 1; | 
| 282 } | 288 } | 
| 283 Node* input = node->InputAt(j); | 289 Node* input = node->InputAt(j); | 
| 284 if (!HasDominatingDef(schedule, node->InputAt(j), block, use_block, | 290 if (!HasDominatingDef(schedule, node->InputAt(j), block, use_block, | 
| 285 use_pos)) { | 291 use_pos)) { | 
| 286 V8_Fatal(__FILE__, __LINE__, | 292 V8_Fatal(__FILE__, __LINE__, | 
| 287 "Node #%d:%s in B%d is not dominated by input@%d #%d:%s", | 293 "Node #%d:%s in B%d is not dominated by input@%d #%d:%s", | 
| 288 node->id(), node->op()->mnemonic(), block->id(), j, input->id(), | 294 node->id(), node->op()->mnemonic(), block->id(), j, input->id(), | 
| 289 input->op()->mnemonic()); | 295 input->op()->mnemonic()); | 
| 290 } | 296 } | 
| 291 } | 297 } | 
| 298 if (OperatorProperties::GetControlInputCount(node->op()) == 1) { | |
| 299 Node* ctl = NodeProperties::GetControlInput(node); | |
| 300 if (!Dominates(schedule, ctl, node)) { | |
| 301 V8_Fatal(__FILE__, __LINE__, | |
| 302 "Node #%d:%s in B%d is not dominated by control input #%d:%s", | |
| 303 node->id(), node->op()->mnemonic(), block->id(), ctl->id(), | |
| 304 ctl->op()->mnemonic()); | |
| 305 } | |
| 306 } | |
| 292 } | 307 } | 
| 293 | 308 | 
| 294 | 309 | 
| 295 void ScheduleVerifier::Run(Schedule* schedule) { | 310 void ScheduleVerifier::Run(Schedule* schedule) { | 
| 296 const int count = schedule->BasicBlockCount(); | 311 const int count = schedule->BasicBlockCount(); | 
| 297 Zone tmp_zone(schedule->zone()->isolate()); | 312 Zone tmp_zone(schedule->zone()->isolate()); | 
| 298 Zone* zone = &tmp_zone; | 313 Zone* zone = &tmp_zone; | 
| 299 BasicBlock* start = schedule->start(); | 314 BasicBlock* start = schedule->start(); | 
| 300 BasicBlockVector* rpo_order = schedule->rpo_order(); | 315 BasicBlockVector* rpo_order = schedule->rpo_order(); | 
| 301 | 316 | 
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 // Check inputs for all nodes in the block. | 461 // Check inputs for all nodes in the block. | 
| 447 for (size_t i = 0; i < block->nodes_.size(); i++) { | 462 for (size_t i = 0; i < block->nodes_.size(); i++) { | 
| 448 Node* node = block->nodes_[i]; | 463 Node* node = block->nodes_[i]; | 
| 449 CheckInputsDominate(schedule, block, node, static_cast<int>(i) - 1); | 464 CheckInputsDominate(schedule, block, node, static_cast<int>(i) - 1); | 
| 450 } | 465 } | 
| 451 } | 466 } | 
| 452 } | 467 } | 
| 453 } | 468 } | 
| 454 } | 469 } | 
| 455 } // namespace v8::internal::compiler | 470 } // namespace v8::internal::compiler | 
| OLD | NEW |