Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 class HValidator extends HInstructionVisitor { | 5 class HValidator extends HInstructionVisitor { |
| 6 bool isValid = true; | 6 bool isValid = true; |
| 7 HGraph graph; | 7 HGraph graph; |
| 8 | 8 |
| 9 void visitGraph(HGraph visitee) { | 9 void visitGraph(HGraph visitee) { |
| 10 graph = visitee; | 10 graph = visitee; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 } | 76 } |
| 77 if (dominated.id === null || dominated.id <= lastId) { | 77 if (dominated.id === null || dominated.id <= lastId) { |
| 78 markInvalid("dominated.id === null or dominated has <= id"); | 78 markInvalid("dominated.id === null or dominated has <= id"); |
| 79 } | 79 } |
| 80 lastId = dominated.id; | 80 lastId = dominated.id; |
| 81 } | 81 } |
| 82 | 82 |
| 83 if (!isValid) return; | 83 if (!isValid) return; |
| 84 block.forEachPhi(visitInstruction); | 84 block.forEachPhi(visitInstruction); |
| 85 | 85 |
| 86 // Make sure the parameters of a phi are dominating the | 86 // Make sure the blocks of the parameters of a phi are dominating the |
|
Lasse Reichstein Nielsen
2012/05/31 07:11:58
Pedantry: "Make sure" -> "Check that". If you "mak
ngeoffray
2012/05/31 08:16:16
Done.
| |
| 87 // corresponding predecessor block. | 87 // corresponding predecessor block. Note that block dominates |
|
Lasse Reichstein Nielsen
2012/05/31 07:11:58
"block dominates" -> "blocks dominate" (or "a bloc
ngeoffray
2012/05/31 08:16:16
Done.
| |
| 88 // themselves. | |
| 88 block.forEachPhi((HPhi phi) { | 89 block.forEachPhi((HPhi phi) { |
| 89 for (int i = 0; i < phi.inputs.length; i++) { | 90 for (int i = 0; i < phi.inputs.length; i++) { |
| 90 HInstruction input = phi.inputs[i]; | 91 HInstruction input = phi.inputs[i]; |
| 91 if (!input.block.dominates(block.predecessors[i])) { | 92 if (!input.block.dominates(block.predecessors[i])) { |
| 92 markInvalid("Definition does not dominate use"); | 93 markInvalid("Definition does not dominate use"); |
| 93 } | 94 } |
| 94 } | 95 } |
| 95 }); | 96 }); |
| 96 | 97 |
| 97 // Make sure the inputs of an instruction dominate the | 98 // Make sure the blocks of the inputs of an instruction dominate the |
| 98 // instruction. | 99 // instruction's block. |
| 99 block.forEachInstruction((HInstruction instruction) { | 100 block.forEachInstruction((HInstruction instruction) { |
| 100 for (HInstruction input in instruction.inputs) { | 101 for (HInstruction input in instruction.inputs) { |
| 101 if (!input.block.dominates(block)) { | 102 if (!input.block.dominates(block)) { |
| 102 markInvalid("Definition does not dominate use"); | 103 markInvalid("Definition does not dominate use"); |
| 103 } | 104 } |
| 104 } | 105 } |
| 105 }); | 106 }); |
| 106 | 107 |
| 107 super.visitBasicBlock(block); | 108 super.visitBasicBlock(block); |
| 108 } | 109 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 markInvalid("Instruction in wrong block"); | 167 markInvalid("Instruction in wrong block"); |
| 167 } | 168 } |
| 168 if (!hasCorrectInputs()) { | 169 if (!hasCorrectInputs()) { |
| 169 markInvalid("Incorrect inputs"); | 170 markInvalid("Incorrect inputs"); |
| 170 } | 171 } |
| 171 if (!hasCorrectUses()) { | 172 if (!hasCorrectUses()) { |
| 172 markInvalid("Incorrect uses"); | 173 markInvalid("Incorrect uses"); |
| 173 } | 174 } |
| 174 } | 175 } |
| 175 } | 176 } |
| OLD | NEW |