| 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->NodeCount()) - 1; | 267 use_pos = static_cast<int>(block->NodeCount()) - 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* dominatee) { | |
| 275 BasicBlock* dom = schedule->block(dominator); | |
| 276 BasicBlock* sub = schedule->block(dominatee); | |
| 277 while (sub != NULL) { | |
| 278 if (sub == dom) { | |
| 279 return true; | |
| 280 } | |
| 281 sub = sub->dominator(); | |
| 282 } | |
| 283 return false; | |
| 284 } | |
| 285 | |
| 286 | |
| 287 static void CheckInputsDominate(Schedule* schedule, BasicBlock* block, | 274 static void CheckInputsDominate(Schedule* schedule, BasicBlock* block, |
| 288 Node* node, int use_pos) { | 275 Node* node, int use_pos) { |
| 289 for (int j = OperatorProperties::GetValueInputCount(node->op()) - 1; j >= 0; | 276 for (int j = OperatorProperties::GetValueInputCount(node->op()) - 1; j >= 0; |
| 290 j--) { | 277 j--) { |
| 291 BasicBlock* use_block = block; | 278 BasicBlock* use_block = block; |
| 292 if (node->opcode() == IrOpcode::kPhi) { | 279 if (node->opcode() == IrOpcode::kPhi) { |
| 293 use_block = use_block->PredecessorAt(j); | 280 use_block = use_block->PredecessorAt(j); |
| 294 use_pos = static_cast<int>(use_block->NodeCount()) - 1; | 281 use_pos = static_cast<int>(use_block->NodeCount()) - 1; |
| 295 } | 282 } |
| 296 Node* input = node->InputAt(j); | 283 Node* input = node->InputAt(j); |
| 297 if (!HasDominatingDef(schedule, node->InputAt(j), block, use_block, | 284 if (!HasDominatingDef(schedule, node->InputAt(j), block, use_block, |
| 298 use_pos)) { | 285 use_pos)) { |
| 299 V8_Fatal(__FILE__, __LINE__, | 286 V8_Fatal(__FILE__, __LINE__, |
| 300 "Node #%d:%s in B%d is not dominated by input@%d #%d:%s", | 287 "Node #%d:%s in B%d is not dominated by input@%d #%d:%s", |
| 301 node->id(), node->op()->mnemonic(), block->id().ToInt(), j, | 288 node->id(), node->op()->mnemonic(), block->id().ToInt(), j, |
| 302 input->id(), input->op()->mnemonic()); | 289 input->id(), input->op()->mnemonic()); |
| 303 } | 290 } |
| 304 } | 291 } |
| 305 // Ensure that nodes are dominated by their control inputs; | |
| 306 // kEnd is an exception, as unreachable blocks resulting from kMerge | |
| 307 // are not in the RPO. | |
| 308 if (OperatorProperties::GetControlInputCount(node->op()) == 1 && | |
| 309 node->opcode() != IrOpcode::kEnd) { | |
| 310 Node* ctl = NodeProperties::GetControlInput(node); | |
| 311 if (!Dominates(schedule, ctl, node)) { | |
| 312 V8_Fatal(__FILE__, __LINE__, | |
| 313 "Node #%d:%s in B%d is not dominated by control input #%d:%s", | |
| 314 node->id(), node->op()->mnemonic(), block->id(), ctl->id(), | |
| 315 ctl->op()->mnemonic()); | |
| 316 } | |
| 317 } | |
| 318 } | 292 } |
| 319 | 293 |
| 320 | 294 |
| 321 void ScheduleVerifier::Run(Schedule* schedule) { | 295 void ScheduleVerifier::Run(Schedule* schedule) { |
| 322 const size_t count = schedule->BasicBlockCount(); | 296 const size_t count = schedule->BasicBlockCount(); |
| 323 Zone tmp_zone(schedule->zone()->isolate()); | 297 Zone tmp_zone(schedule->zone()->isolate()); |
| 324 Zone* zone = &tmp_zone; | 298 Zone* zone = &tmp_zone; |
| 325 BasicBlock* start = schedule->start(); | 299 BasicBlock* start = schedule->start(); |
| 326 BasicBlockVector* rpo_order = schedule->rpo_order(); | 300 BasicBlockVector* rpo_order = schedule->rpo_order(); |
| 327 | 301 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 // Check inputs for all nodes in the block. | 448 // Check inputs for all nodes in the block. |
| 475 for (size_t i = 0; i < block->NodeCount(); i++) { | 449 for (size_t i = 0; i < block->NodeCount(); i++) { |
| 476 Node* node = block->NodeAt(i); | 450 Node* node = block->NodeAt(i); |
| 477 CheckInputsDominate(schedule, block, node, static_cast<int>(i) - 1); | 451 CheckInputsDominate(schedule, block, node, static_cast<int>(i) - 1); |
| 478 } | 452 } |
| 479 } | 453 } |
| 480 } | 454 } |
| 481 } | 455 } |
| 482 } | 456 } |
| 483 } // namespace v8::internal::compiler | 457 } // namespace v8::internal::compiler |
| OLD | NEW |