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 28 matching lines...) Expand all Loading... |
39 if (block.last is HGoto && block.successors.length != 1) { | 39 if (block.last is HGoto && block.successors.length != 1) { |
40 markInvalid("Goto node with not exactly one successor"); | 40 markInvalid("Goto node with not exactly one successor"); |
41 } | 41 } |
42 if (block.last is HJump && block.successors.length != 1) { | 42 if (block.last is HJump && block.successors.length != 1) { |
43 markInvalid("Break or continue node without one successor"); | 43 markInvalid("Break or continue node without one successor"); |
44 } | 44 } |
45 if (block.last is HReturn && | 45 if (block.last is HReturn && |
46 (block.successors.length != 1 || !block.successors[0].isExitBlock())) { | 46 (block.successors.length != 1 || !block.successors[0].isExitBlock())) { |
47 markInvalid("Return node with > 1 succesor or not going to exit-block"); | 47 markInvalid("Return node with > 1 succesor or not going to exit-block"); |
48 } | 48 } |
49 if (block.last is HExit && !block.successors.isEmpty()) { | 49 if (block.last is HExit && !block.successors.isEmpty) { |
50 markInvalid("Exit block with successor"); | 50 markInvalid("Exit block with successor"); |
51 } | 51 } |
52 if (block.last is HThrow && !block.successors.isEmpty()) { | 52 if (block.last is HThrow && !block.successors.isEmpty) { |
53 markInvalid("Throw block with successor"); | 53 markInvalid("Throw block with successor"); |
54 } | 54 } |
55 | 55 |
56 if (block.successors.isEmpty() && | 56 if (block.successors.isEmpty && |
57 block.last is !HThrow && | 57 block.last is !HThrow && |
58 !block.isExitBlock()) { | 58 !block.isExitBlock()) { |
59 markInvalid("Non-exit or throw block without successor"); | 59 markInvalid("Non-exit or throw block without successor"); |
60 } | 60 } |
61 | 61 |
62 // Check that successors ids are always higher than the current one. | 62 // Check that successors ids are always higher than the current one. |
63 // TODO(floitsch): this is, of course, not true for back-branches. | 63 // TODO(floitsch): this is, of course, not true for back-branches. |
64 if (block.id == null) markInvalid("block without id"); | 64 if (block.id == null) markInvalid("block without id"); |
65 for (HBasicBlock successor in block.successors) { | 65 for (HBasicBlock successor in block.successors) { |
66 if (!isValid) break; | 66 if (!isValid) break; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 markInvalid("Instruction in wrong block"); | 170 markInvalid("Instruction in wrong block"); |
171 } | 171 } |
172 if (!hasCorrectInputs()) { | 172 if (!hasCorrectInputs()) { |
173 markInvalid("Incorrect inputs"); | 173 markInvalid("Incorrect inputs"); |
174 } | 174 } |
175 if (!hasCorrectUses()) { | 175 if (!hasCorrectUses()) { |
176 markInvalid("Incorrect uses"); | 176 markInvalid("Incorrect uses"); |
177 } | 177 } |
178 } | 178 } |
179 } | 179 } |
OLD | NEW |