Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 abstract class OptimizationPhase { | 7 abstract class OptimizationPhase { |
| 8 String get name; | 8 String get name; |
| 9 void visitGraph(HGraph graph); | 9 void visitGraph(HGraph graph); |
| 10 } | 10 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 HInstruction replacement = instruction.accept(this); | 135 HInstruction replacement = instruction.accept(this); |
| 136 if (!identical(replacement, instruction)) { | 136 if (!identical(replacement, instruction)) { |
| 137 if (!replacement.isInBasicBlock()) { | 137 if (!replacement.isInBasicBlock()) { |
| 138 // The constant folding can return an instruction that is already | 138 // The constant folding can return an instruction that is already |
| 139 // part of the graph (like an input), so we only add the replacement | 139 // part of the graph (like an input), so we only add the replacement |
| 140 // if necessary. | 140 // if necessary. |
| 141 block.addAfter(instruction, replacement); | 141 block.addAfter(instruction, replacement); |
| 142 } | 142 } |
| 143 block.rewrite(instruction, replacement); | 143 block.rewrite(instruction, replacement); |
| 144 block.remove(instruction); | 144 block.remove(instruction); |
| 145 // If the replacement instruction does not know its type or | 145 |
| 146 // source element yet, use the type and source element of the | 146 // If we can replace [instruction] with [replacement], then |
| 147 // [replacement]'s type can be narrowed. | |
| 148 types[replacement] = | |
| 149 types[replacement].intersection(types[instruction], compiler); | |
| 150 // If the replacement instruction does not know its | |
|
kasperl
2012/11/02 11:09:41
Add newline before the comment here.
ngeoffray
2012/11/02 11:15:31
Done.
| |
| 151 // source element, use the source element of the | |
| 147 // instruction. | 152 // instruction. |
| 148 if (!types[replacement].isUseful()) { | |
| 149 types[replacement] = types[instruction]; | |
| 150 } | |
| 151 if (replacement.sourceElement == null) { | 153 if (replacement.sourceElement == null) { |
| 152 replacement.sourceElement = instruction.sourceElement; | 154 replacement.sourceElement = instruction.sourceElement; |
| 153 } | 155 } |
| 154 if (replacement.sourcePosition == null) { | 156 if (replacement.sourcePosition == null) { |
| 155 replacement.sourcePosition = instruction.sourcePosition; | 157 replacement.sourcePosition = instruction.sourcePosition; |
| 156 } | 158 } |
| 157 } | 159 } |
| 158 instruction = next; | 160 instruction = next; |
| 159 } | 161 } |
| 160 } | 162 } |
| (...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1345 } | 1347 } |
| 1346 | 1348 |
| 1347 // For other fields having setters in the generative constructor body, set | 1349 // For other fields having setters in the generative constructor body, set |
| 1348 // the type to UNKNOWN to avoid relying on the type set in the initializer | 1350 // the type to UNKNOWN to avoid relying on the type set in the initializer |
| 1349 // list. | 1351 // list. |
| 1350 allSetters.forEach((Element element) { | 1352 allSetters.forEach((Element element) { |
| 1351 backend.registerFieldConstructor(element, HType.UNKNOWN); | 1353 backend.registerFieldConstructor(element, HType.UNKNOWN); |
| 1352 }); | 1354 }); |
| 1353 } | 1355 } |
| 1354 } | 1356 } |
| OLD | NEW |