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 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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 HInstruction visitStringConcat(HStringConcat node) { | 594 HInstruction visitStringConcat(HStringConcat node) { |
595 DartString folded = const LiteralDartString(""); | 595 DartString folded = const LiteralDartString(""); |
596 for (int i = 0; i < node.inputs.length; i++) { | 596 for (int i = 0; i < node.inputs.length; i++) { |
597 HInstruction part = node.inputs[i]; | 597 HInstruction part = node.inputs[i]; |
598 if (!part.isConstant()) return node; | 598 if (!part.isConstant()) return node; |
599 HConstant constant = part; | 599 HConstant constant = part; |
600 if (!constant.constant.isPrimitive()) return node; | 600 if (!constant.constant.isPrimitive()) return node; |
601 PrimitiveConstant primitive = constant.constant; | 601 PrimitiveConstant primitive = constant.constant; |
602 folded = new DartString.concat(folded, primitive.toDartString()); | 602 folded = new DartString.concat(folded, primitive.toDartString()); |
603 } | 603 } |
604 return graph.addConstantString(folded, node); | 604 return graph.addConstantString(folded, node.node); |
605 } | 605 } |
606 } | 606 } |
607 | 607 |
608 class SsaCheckInserter extends HBaseVisitor implements OptimizationPhase { | 608 class SsaCheckInserter extends HBaseVisitor implements OptimizationPhase { |
609 final String name = "SsaCheckInserter"; | 609 final String name = "SsaCheckInserter"; |
610 Element lengthInterceptor; | 610 Element lengthInterceptor; |
611 | 611 |
612 SsaCheckInserter(JavaScriptBackend backend) { | 612 SsaCheckInserter(JavaScriptBackend backend) { |
613 SourceString lengthString = const SourceString('length'); | 613 SourceString lengthString = const SourceString('length'); |
614 lengthInterceptor = | 614 lengthInterceptor = |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 // the if block terminates. So any use of the instruction | 1137 // the if block terminates. So any use of the instruction |
1138 // after the join block should be changed to the new | 1138 // after the join block should be changed to the new |
1139 // instruction. | 1139 // instruction. |
1140 changeUsesDominatedBy(ifUser.joinBlock, input, convertedType); | 1140 changeUsesDominatedBy(ifUser.joinBlock, input, convertedType); |
1141 } | 1141 } |
1142 // TODO(ngeoffray): Also change uses for the then block on a HType | 1142 // TODO(ngeoffray): Also change uses for the then block on a HType |
1143 // that knows it is not of a specific Type. | 1143 // that knows it is not of a specific Type. |
1144 } | 1144 } |
1145 } | 1145 } |
1146 } | 1146 } |
OLD | NEW |