| 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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 if (!constant.constant.isPrimitive()) return node; | 674 if (!constant.constant.isPrimitive()) return node; |
| 675 PrimitiveConstant primitive = constant.constant; | 675 PrimitiveConstant primitive = constant.constant; |
| 676 folded = new DartString.concat(folded, primitive.toDartString()); | 676 folded = new DartString.concat(folded, primitive.toDartString()); |
| 677 } | 677 } |
| 678 return graph.addConstant(constantSystem.createString(folded, node.node)); | 678 return graph.addConstant(constantSystem.createString(folded, node.node)); |
| 679 } | 679 } |
| 680 | 680 |
| 681 HInstruction visitInterceptor(HInterceptor node) { | 681 HInstruction visitInterceptor(HInterceptor node) { |
| 682 if (node.isConstant()) return node; | 682 if (node.isConstant()) return node; |
| 683 HType type = types[node.inputs[0]]; | 683 HType type = types[node.inputs[0]]; |
| 684 Element constantInterceptor; | 684 ClassElement constantInterceptor; |
| 685 if (type.isInteger()) { | 685 if (type.isInteger()) { |
| 686 constantInterceptor = backend.intInterceptor; | 686 constantInterceptor = backend.jsIntClass; |
| 687 } else if (type.isDouble()) { | 687 } else if (type.isDouble()) { |
| 688 constantInterceptor = backend.doubleInterceptor; | 688 constantInterceptor = backend.jsDoubleClass; |
| 689 } else if (type.isBoolean()) { | 689 } else if (type.isBoolean()) { |
| 690 constantInterceptor = backend.boolInterceptor; | 690 constantInterceptor = backend.jsBoolClass; |
| 691 } else if (type.isString()) { | 691 } else if (type.isString()) { |
| 692 constantInterceptor = backend.stringInterceptor; | 692 constantInterceptor = backend.jsStringClass; |
| 693 } else if (type.isArray()) { | 693 } else if (type.isArray()) { |
| 694 constantInterceptor = backend.arrayInterceptor; | 694 constantInterceptor = backend.jsArrayClass; |
| 695 } else if (type.isNull()) { | 695 } else if (type.isNull()) { |
| 696 constantInterceptor = backend.nullInterceptor; | 696 constantInterceptor = backend.jsIntClass; |
| 697 } else if (type.isNumber()) { | 697 } else if (type.isNumber()) { |
| 698 Set<ClassElement> intercepted = node.interceptedClasses; | 698 Set<ClassElement> intercepted = node.interceptedClasses; |
| 699 // If the method being intercepted is not defined in [int] or | 699 // If the method being intercepted is not defined in [int] or |
| 700 // [double] we can safely use the number interceptor. | 700 // [double] we can safely use the number interceptor. |
| 701 if (!intercepted.contains(compiler.intClass) | 701 if (!intercepted.contains(compiler.intClass) |
| 702 && !intercepted.contains(compiler.doubleClass)) { | 702 && !intercepted.contains(compiler.doubleClass)) { |
| 703 constantInterceptor = backend.numberInterceptor; | 703 constantInterceptor = backend.jsNumberClass; |
| 704 } | 704 } |
| 705 } | 705 } |
| 706 | 706 |
| 707 if (constantInterceptor == null) return node; | 707 if (constantInterceptor == null) return node; |
| 708 | 708 |
| 709 ConstantHandler handler = compiler.constantHandler; | 709 ConstantHandler handler = compiler.constantHandler; |
| 710 return graph.addConstant(handler.compileVariable(constantInterceptor)); | 710 Constant constant = new ConstructedConstant( |
| 711 constantInterceptor.computeType(compiler), <Constant>[]); |
| 712 handler.registerCompileTimeConstant(constant); |
| 713 return graph.addConstant(constant); |
| 711 } | 714 } |
| 712 } | 715 } |
| 713 | 716 |
| 714 class SsaCheckInserter extends HBaseVisitor implements OptimizationPhase { | 717 class SsaCheckInserter extends HBaseVisitor implements OptimizationPhase { |
| 715 final HTypeMap types; | 718 final HTypeMap types; |
| 716 final ConstantSystem constantSystem; | 719 final ConstantSystem constantSystem; |
| 717 final Set<HInstruction> boundsChecked; | 720 final Set<HInstruction> boundsChecked; |
| 718 final WorkItem work; | 721 final WorkItem work; |
| 719 final String name = "SsaCheckInserter"; | 722 final String name = "SsaCheckInserter"; |
| 720 HGraph graph; | 723 HGraph graph; |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1406 } | 1409 } |
| 1407 | 1410 |
| 1408 // For other fields having setters in the generative constructor body, set | 1411 // For other fields having setters in the generative constructor body, set |
| 1409 // the type to UNKNOWN to avoid relying on the type set in the initializer | 1412 // the type to UNKNOWN to avoid relying on the type set in the initializer |
| 1410 // list. | 1413 // list. |
| 1411 allSetters.forEach((Element element) { | 1414 allSetters.forEach((Element element) { |
| 1412 backend.registerFieldConstructor(element, HType.UNKNOWN); | 1415 backend.registerFieldConstructor(element, HType.UNKNOWN); |
| 1413 }); | 1416 }); |
| 1414 } | 1417 } |
| 1415 } | 1418 } |
| OLD | NEW |