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 interface OptimizationPhase { | 5 interface OptimizationPhase { |
| 6 String get name(); | 6 String get name(); |
| 7 void visitGraph(HGraph graph); | 7 void visitGraph(HGraph graph); |
| 8 } | 8 } |
| 9 | 9 |
| 10 class SsaOptimizerTask extends CompilerTask { | 10 class SsaOptimizerTask extends CompilerTask { |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 675 node.block.addBefore(node, length); | 675 node.block.addBefore(node, length); |
| 676 | 676 |
| 677 HBoundsCheck check = new HBoundsCheck(index, length); | 677 HBoundsCheck check = new HBoundsCheck(index, length); |
| 678 node.block.addBefore(node, check); | 678 node.block.addBefore(node, check); |
| 679 return check; | 679 return check; |
| 680 } | 680 } |
| 681 | 681 |
| 682 HIntegerCheck insertIntegerCheck(HInstruction node, HInstruction value) { | 682 HIntegerCheck insertIntegerCheck(HInstruction node, HInstruction value) { |
| 683 HIntegerCheck check = new HIntegerCheck(value); | 683 HIntegerCheck check = new HIntegerCheck(value); |
| 684 node.block.addBefore(node, check); | 684 node.block.addBefore(node, check); |
| 685 Set<HInstruction> dominatedUsers = value.dominatedUsers(check); | 685 Set<HInstruction> dominatedUsers = value.dominatedUsers(node); |
| 686 for (HInstruction user in dominatedUsers) { | 686 for (HInstruction user in dominatedUsers) { |
| 687 user.changeUse(value, check); | 687 user.changeUse(value, check); |
| 688 } | 688 } |
| 689 return check; | 689 return check; |
| 690 } | 690 } |
| 691 | 691 |
| 692 void visitIndex(HIndex node) { | 692 void visitIndex(HIndex node) { |
| 693 if (!node.receiver.isIndexablePrimitive(types)) return; | 693 if (!node.receiver.isIndexablePrimitive(types)) return; |
| 694 HInstruction index = node.index; | 694 HInstruction index = node.index; |
| 695 if (index is HBoundsCheck) return; | 695 if (index is HBoundsCheck) return; |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1128 void visitGraph(HGraph graph) { | 1128 void visitGraph(HGraph graph) { |
| 1129 visitDominatorTree(graph); | 1129 visitDominatorTree(graph); |
| 1130 } | 1130 } |
| 1131 | 1131 |
| 1132 | 1132 |
| 1133 // Update users of [input] that are dominated by [:dominator.first:] | 1133 // Update users of [input] that are dominated by [:dominator.first:] |
| 1134 // to use [newInput] instead. | 1134 // to use [newInput] instead. |
| 1135 void changeUsesDominatedBy(HBasicBlock dominator, | 1135 void changeUsesDominatedBy(HBasicBlock dominator, |
| 1136 HInstruction input, | 1136 HInstruction input, |
| 1137 HType convertedType) { | 1137 HType convertedType) { |
| 1138 HTypeConversion newInput; | |
| 1139 Set<HInstruction> dominatedUsers = input.dominatedUsers(dominator.first); | 1138 Set<HInstruction> dominatedUsers = input.dominatedUsers(dominator.first); |
| 1139 if (dominatedUsers.isEmpty()) return; | |
| 1140 | |
| 1141 HTypeConversion newInput = new HTypeConversion(convertedType, input); | |
| 1142 dominator.addBefore(dominator.first, newInput); | |
| 1140 for (HInstruction user in dominatedUsers) { | 1143 for (HInstruction user in dominatedUsers) { |
|
kasperl
2012/08/20 12:58:35
Use dominatedUsers.forEach?
ngeoffray
2012/08/20 13:01:32
Sure. Personal preference?
| |
| 1141 if (newInput === null) { | |
| 1142 newInput = new HTypeConversion(convertedType, input); | |
| 1143 dominator.addBefore(dominator.first, newInput); | |
| 1144 } | |
| 1145 user.changeUse(input, newInput); | 1144 user.changeUse(input, newInput); |
| 1146 } | 1145 } |
| 1147 } | 1146 } |
| 1148 | 1147 |
| 1149 void visitIs(HIs instruction) { | 1148 void visitIs(HIs instruction) { |
| 1150 HInstruction input = instruction.expression; | 1149 HInstruction input = instruction.expression; |
| 1151 HType convertedType = | 1150 HType convertedType = |
| 1152 new HType.fromBoundedType(instruction.typeExpression, compiler); | 1151 new HType.fromBoundedType(instruction.typeExpression, compiler); |
| 1153 | 1152 |
| 1154 List<HInstruction> ifUsers = <HInstruction>[]; | 1153 List<HInstruction> ifUsers = <HInstruction>[]; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1330 // this type for the field is still a strong signal | 1329 // this type for the field is still a strong signal |
| 1331 // indicating the expected type of the field. | 1330 // indicating the expected type of the field. |
| 1332 types[field] = type; | 1331 types[field] = type; |
| 1333 } else { | 1332 } else { |
| 1334 // If there are no invoked setters we know the type of | 1333 // If there are no invoked setters we know the type of |
| 1335 // this field for sure. | 1334 // this field for sure. |
| 1336 field.guaranteedType = type; | 1335 field.guaranteedType = type; |
| 1337 } | 1336 } |
| 1338 } | 1337 } |
| 1339 } | 1338 } |
| OLD | NEW |