| 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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 | 583 |
| 584 HInstruction visitInvokeDynamicSetter(HInvokeDynamicSetter node) { | 584 HInstruction visitInvokeDynamicSetter(HInvokeDynamicSetter node) { |
| 585 HInstruction receiver = node.inputs[0]; | 585 HInstruction receiver = node.inputs[0]; |
| 586 if (!receiver.propagatedType.isUseful()) return node; | 586 if (!receiver.propagatedType.isUseful()) return node; |
| 587 Type type = receiver.propagatedType.computeType(compiler); | 587 Type type = receiver.propagatedType.computeType(compiler); |
| 588 if (type === null) return node; | 588 if (type === null) return node; |
| 589 Element field = compiler.world.locateSingleField(type, node.name); | 589 Element field = compiler.world.locateSingleField(type, node.name); |
| 590 if (field === null) return node; | 590 if (field === null) return node; |
| 591 return new HFieldSet(field, node.inputs[0], node.inputs[1]); | 591 return new HFieldSet(field, node.inputs[0], node.inputs[1]); |
| 592 } | 592 } |
| 593 |
| 594 HInstruction visitStringConcat(HStringConcat node) { |
| 595 DartString folded = const LiteralDartString(""); |
| 596 for (int i = 0; i < node.inputs.length; i++) { |
| 597 HInstruction part = node.inputs[i]; |
| 598 if (!part.isConstant()) return node; |
| 599 HConstant constant = part; |
| 600 if (!constant.constant.isPrimitive()) return node; |
| 601 PrimitiveConstant primitive = constant.constant; |
| 602 folded = new DartString.concat(folded, primitive.toDartString()); |
| 603 } |
| 604 return graph.addConstantString(folded, node); |
| 605 } |
| 593 } | 606 } |
| 594 | 607 |
| 595 class SsaCheckInserter extends HBaseVisitor implements OptimizationPhase { | 608 class SsaCheckInserter extends HBaseVisitor implements OptimizationPhase { |
| 596 final String name = "SsaCheckInserter"; | 609 final String name = "SsaCheckInserter"; |
| 597 Element lengthInterceptor; | 610 Element lengthInterceptor; |
| 598 | 611 |
| 599 SsaCheckInserter(JavaScriptBackend backend) { | 612 SsaCheckInserter(JavaScriptBackend backend) { |
| 600 SourceString lengthString = const SourceString('length'); | 613 SourceString lengthString = const SourceString('length'); |
| 601 lengthInterceptor = | 614 lengthInterceptor = |
| 602 backend.builder.interceptors.getStaticGetInterceptor(lengthString); | 615 backend.builder.interceptors.getStaticGetInterceptor(lengthString); |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 // the if block terminates. So any use of the instruction | 1137 // the if block terminates. So any use of the instruction |
| 1125 // after the join block should be changed to the new | 1138 // after the join block should be changed to the new |
| 1126 // instruction. | 1139 // instruction. |
| 1127 changeUsesDominatedBy(ifUser.joinBlock, input, convertedType); | 1140 changeUsesDominatedBy(ifUser.joinBlock, input, convertedType); |
| 1128 } | 1141 } |
| 1129 // 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 |
| 1130 // that knows it is not of a specific Type. | 1143 // that knows it is not of a specific Type. |
| 1131 } | 1144 } |
| 1132 } | 1145 } |
| 1133 } | 1146 } |
| OLD | NEW |