| 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 class SsaFunctionCompiler implements FunctionCompiler { | 7 class SsaFunctionCompiler implements FunctionCompiler { |
| 8 final SsaCodeGeneratorTask generator; | 8 final SsaCodeGeneratorTask generator; |
| 9 final SsaBuilderTask builder; | 9 final SsaBuilderTask builder; |
| 10 final SsaOptimizerTask optimizer; | 10 final SsaOptimizerTask optimizer; |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 this.rti = backend.rti, | 1100 this.rti = backend.rti, |
| 1101 this.elements = work.resolutionTree { | 1101 this.elements = work.resolutionTree { |
| 1102 graph.element = work.element; | 1102 graph.element = work.element; |
| 1103 localsHandler = new LocalsHandler(this, work.element, null); | 1103 localsHandler = new LocalsHandler(this, work.element, null); |
| 1104 sourceElementStack.add(work.element); | 1104 sourceElementStack.add(work.element); |
| 1105 sourceInformationBuilder = | 1105 sourceInformationBuilder = |
| 1106 sourceInformationFactory.createBuilderForContext( | 1106 sourceInformationFactory.createBuilderForContext( |
| 1107 work.element.implementation); | 1107 work.element.implementation); |
| 1108 } | 1108 } |
| 1109 | 1109 |
| 1110 RuntimeTypesEncoder get rtiEncoder => backend.rtiEncoder; |
| 1110 | 1111 |
| 1111 DiagnosticReporter get reporter => compiler.reporter; | 1112 DiagnosticReporter get reporter => compiler.reporter; |
| 1112 | 1113 |
| 1113 // TODO(johnniwinther): Avoid the need for this. | 1114 // TODO(johnniwinther): Avoid the need for this. |
| 1114 Resolution get resolution => compiler.resolution; | 1115 Resolution get resolution => compiler.resolution; |
| 1115 | 1116 |
| 1116 @override | 1117 @override |
| 1117 SemanticSendVisitor get sendVisitor => this; | 1118 SemanticSendVisitor get sendVisitor => this; |
| 1118 | 1119 |
| 1119 @override | 1120 @override |
| (...skipping 2642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3762 assert(type.element.isClass); | 3763 assert(type.element.isClass); |
| 3763 InterfaceType interface = type; | 3764 InterfaceType interface = type; |
| 3764 List<HInstruction> inputs = <HInstruction>[]; | 3765 List<HInstruction> inputs = <HInstruction>[]; |
| 3765 List<js.Expression> templates = <js.Expression>[]; | 3766 List<js.Expression> templates = <js.Expression>[]; |
| 3766 for (DartType argument in interface.typeArguments) { | 3767 for (DartType argument in interface.typeArguments) { |
| 3767 // As we construct the template in stages, we have to make sure that for | 3768 // As we construct the template in stages, we have to make sure that for |
| 3768 // each part the generated sub-template's holes match the index of the | 3769 // each part the generated sub-template's holes match the index of the |
| 3769 // inputs that are later used to instantiate it. We do this by starting | 3770 // inputs that are later used to instantiate it. We do this by starting |
| 3770 // the indexing with the number of inputs from previous sub-templates. | 3771 // the indexing with the number of inputs from previous sub-templates. |
| 3771 templates.add( | 3772 templates.add( |
| 3772 rti.getTypeRepresentationWithPlaceholders(argument, (variable) { | 3773 rtiEncoder.getTypeRepresentationWithPlaceholders( |
| 3774 argument, (variable) { |
| 3773 HInstruction runtimeType = addTypeVariableReference(variable); | 3775 HInstruction runtimeType = addTypeVariableReference(variable); |
| 3774 inputs.add(runtimeType); | 3776 inputs.add(runtimeType); |
| 3775 }, firstPlaceholderIndex: inputs.length)); | 3777 }, firstPlaceholderIndex: inputs.length)); |
| 3776 } | 3778 } |
| 3777 // TODO(sra): This is a fresh template each time. We can't let the | 3779 // TODO(sra): This is a fresh template each time. We can't let the |
| 3778 // template manager build them. | 3780 // template manager build them. |
| 3779 js.Template code = new js.Template(null, | 3781 js.Template code = new js.Template(null, |
| 3780 new js.ArrayInitializer(templates)); | 3782 new js.ArrayInitializer(templates)); |
| 3781 HInstruction representation = | 3783 HInstruction representation = |
| 3782 new HForeignCode(code, backend.readableArrayType, inputs, | 3784 new HForeignCode(code, backend.readableArrayType, inputs, |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4792 * extract the type argument by the index of the variable in the list of type | 4794 * extract the type argument by the index of the variable in the list of type |
| 4793 * variables for that class. | 4795 * variables for that class. |
| 4794 */ | 4796 */ |
| 4795 HInstruction readTypeVariable( | 4797 HInstruction readTypeVariable( |
| 4796 ClassElement cls, | 4798 ClassElement cls, |
| 4797 TypeVariableElement variable, | 4799 TypeVariableElement variable, |
| 4798 {SourceInformation sourceInformation}) { | 4800 {SourceInformation sourceInformation}) { |
| 4799 assert(sourceElement.isInstanceMember); | 4801 assert(sourceElement.isInstanceMember); |
| 4800 | 4802 |
| 4801 HInstruction target = localsHandler.readThis(); | 4803 HInstruction target = localsHandler.readThis(); |
| 4802 HConstant index = graph.addConstantInt( | 4804 HConstant index = graph.addConstantInt(variable.index, compiler); |
| 4803 RuntimeTypes.getTypeVariableIndex(variable), | |
| 4804 compiler); | |
| 4805 | 4805 |
| 4806 if (needsSubstitutionForTypeVariableAccess(cls)) { | 4806 if (needsSubstitutionForTypeVariableAccess(cls)) { |
| 4807 // TODO(ahe): Creating a string here is unfortunate. It is slow (due to | 4807 // TODO(ahe): Creating a string here is unfortunate. It is slow (due to |
| 4808 // string concatenation in the implementation), and may prevent | 4808 // string concatenation in the implementation), and may prevent |
| 4809 // segmentation of '$'. | 4809 // segmentation of '$'. |
| 4810 js.Name substitutionName = backend.namer.runtimeTypeName(cls); | 4810 js.Name substitutionName = backend.namer.runtimeTypeName(cls); |
| 4811 HInstruction substitutionNameInstr = graph.addConstantStringFromName( | 4811 HInstruction substitutionNameInstr = graph.addConstantStringFromName( |
| 4812 substitutionName, compiler); | 4812 substitutionName, compiler); |
| 4813 pushInvokeStatic(null, | 4813 pushInvokeStatic(null, |
| 4814 backend.getGetRuntimeTypeArgument(), | 4814 backend.getGetRuntimeTypeArgument(), |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4909 } | 4909 } |
| 4910 | 4910 |
| 4911 if (argument.isTypeVariable) { | 4911 if (argument.isTypeVariable) { |
| 4912 return addTypeVariableReference( | 4912 return addTypeVariableReference( |
| 4913 argument, sourceInformation: sourceInformation); | 4913 argument, sourceInformation: sourceInformation); |
| 4914 } | 4914 } |
| 4915 | 4915 |
| 4916 List<HInstruction> inputs = <HInstruction>[]; | 4916 List<HInstruction> inputs = <HInstruction>[]; |
| 4917 | 4917 |
| 4918 js.Expression template = | 4918 js.Expression template = |
| 4919 rti.getTypeRepresentationWithPlaceholders(argument, (variable) { | 4919 rtiEncoder.getTypeRepresentationWithPlaceholders(argument, (variable) { |
| 4920 inputs.add(addTypeVariableReference(variable)); | 4920 inputs.add(addTypeVariableReference(variable)); |
| 4921 }); | 4921 }); |
| 4922 | 4922 |
| 4923 js.Template code = new js.Template(null, template); | 4923 js.Template code = new js.Template(null, template); |
| 4924 HInstruction result = new HForeignCode(code, backend.stringType, inputs, | 4924 HInstruction result = new HForeignCode(code, backend.stringType, inputs, |
| 4925 nativeBehavior: native.NativeBehavior.PURE); | 4925 nativeBehavior: native.NativeBehavior.PURE); |
| 4926 add(result); | 4926 add(result); |
| 4927 return result; | 4927 return result; |
| 4928 } | 4928 } |
| 4929 | 4929 |
| (...skipping 4066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8996 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 8996 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
| 8997 unaliased.accept(this, builder); | 8997 unaliased.accept(this, builder); |
| 8998 } | 8998 } |
| 8999 | 8999 |
| 9000 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 9000 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
| 9001 JavaScriptBackend backend = builder.compiler.backend; | 9001 JavaScriptBackend backend = builder.compiler.backend; |
| 9002 ClassElement cls = backend.findHelper('DynamicRuntimeType'); | 9002 ClassElement cls = backend.findHelper('DynamicRuntimeType'); |
| 9003 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); | 9003 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); |
| 9004 } | 9004 } |
| 9005 } | 9005 } |
| OLD | NEW |