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 SsaCodeGeneratorTask generator; | 8 SsaCodeGeneratorTask generator; |
9 SsaBuilderTask builder; | 9 SsaBuilderTask builder; |
10 SsaOptimizerTask optimizer; | 10 SsaOptimizerTask optimizer; |
(...skipping 1941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 List<FunctionElement> constructors, | 1952 List<FunctionElement> constructors, |
1953 Map<Element, HInstruction> fieldValues) { | 1953 Map<Element, HInstruction> fieldValues) { |
1954 assert(invariant(constructor, constructor.isImplementation)); | 1954 assert(invariant(constructor, constructor.isImplementation)); |
1955 if (constructor.isSynthesized) { | 1955 if (constructor.isSynthesized) { |
1956 List<HInstruction> arguments = <HInstruction>[]; | 1956 List<HInstruction> arguments = <HInstruction>[]; |
1957 HInstruction compileArgument(ParameterElement parameter) { | 1957 HInstruction compileArgument(ParameterElement parameter) { |
1958 return localsHandler.readLocal(parameter); | 1958 return localsHandler.readLocal(parameter); |
1959 } | 1959 } |
1960 | 1960 |
1961 Element target = constructor.definingConstructor.implementation; | 1961 Element target = constructor.definingConstructor.implementation; |
1962 bool match = CallStructure.addForwardingElementArgumentsToList( | 1962 bool match = !target.isErroneous && |
1963 constructor, | 1963 CallStructure.addForwardingElementArgumentsToList( |
1964 arguments, | 1964 constructor, |
1965 target, | 1965 arguments, |
1966 compileArgument, | 1966 target, |
1967 handleConstantForOptionalParameter); | 1967 compileArgument, |
| 1968 handleConstantForOptionalParameter); |
1968 if (!match) { | 1969 if (!match) { |
1969 if (compiler.elementHasCompileTimeError(constructor)) { | 1970 if (compiler.elementHasCompileTimeError(constructor)) { |
1970 return; | 1971 return; |
1971 } | 1972 } |
1972 // If this fails, the selector we constructed for the call to a | 1973 // If this fails, the selector we constructed for the call to a |
1973 // forwarding constructor in a mixin application did not match the | 1974 // forwarding constructor in a mixin application did not match the |
1974 // constructor (which, for example, may happen when the libraries are | 1975 // constructor (which, for example, may happen when the libraries are |
1975 // not compatible for private names, see issue 20394). | 1976 // not compatible for private names, see issue 20394). |
1976 compiler.internalError(constructor, | 1977 compiler.internalError(constructor, |
1977 'forwarding constructor call does not match'); | 1978 'forwarding constructor call does not match'); |
(...skipping 2901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4879 if (checkTypeVariableBounds(node, type)) return; | 4880 if (checkTypeVariableBounds(node, type)) return; |
4880 | 4881 |
4881 var inputs = <HInstruction>[]; | 4882 var inputs = <HInstruction>[]; |
4882 if (constructor.isGenerativeConstructor && | 4883 if (constructor.isGenerativeConstructor && |
4883 Elements.isNativeOrExtendsNative(constructor.enclosingClass)) { | 4884 Elements.isNativeOrExtendsNative(constructor.enclosingClass)) { |
4884 // Native class generative constructors take a pre-constructed object. | 4885 // Native class generative constructors take a pre-constructed object. |
4885 inputs.add(graph.addConstantNull(compiler)); | 4886 inputs.add(graph.addConstantNull(compiler)); |
4886 } | 4887 } |
4887 // TODO(5347): Try to avoid the need for calling [implementation] before | 4888 // TODO(5347): Try to avoid the need for calling [implementation] before |
4888 // calling [makeStaticArgumentList]. | 4889 // calling [makeStaticArgumentList]. |
4889 if (!callStructure.signatureApplies(constructor.implementation)) { | 4890 constructorImplementation = constructor.implementation; |
| 4891 if (constructorImplementation.isErroneous || |
| 4892 !callStructure.signatureApplies( |
| 4893 constructorImplementation.functionSignature)) { |
4890 generateWrongArgumentCountError(send, constructor, send.arguments); | 4894 generateWrongArgumentCountError(send, constructor, send.arguments); |
4891 return; | 4895 return; |
4892 } | 4896 } |
4893 inputs.addAll(makeStaticArgumentList(callStructure, | 4897 inputs.addAll(makeStaticArgumentList(callStructure, |
4894 send.arguments, | 4898 send.arguments, |
4895 constructor.implementation)); | 4899 constructorImplementation)); |
4896 | 4900 |
4897 TypeMask elementType = computeType(constructor); | 4901 TypeMask elementType = computeType(constructor); |
4898 if (isFixedListConstructorCall) { | 4902 if (isFixedListConstructorCall) { |
4899 if (!inputs[0].isNumber(compiler)) { | 4903 if (!inputs[0].isNumber(compiler)) { |
4900 HTypeConversion conversion = new HTypeConversion( | 4904 HTypeConversion conversion = new HTypeConversion( |
4901 null, HTypeConversion.ARGUMENT_TYPE_CHECK, backend.numType, | 4905 null, HTypeConversion.ARGUMENT_TYPE_CHECK, backend.numType, |
4902 inputs[0], null); | 4906 inputs[0], null); |
4903 add(conversion); | 4907 add(conversion); |
4904 inputs[0] = conversion; | 4908 inputs[0] = conversion; |
4905 } | 4909 } |
(...skipping 3776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8682 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 8686 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
8683 unaliased.accept(this, builder); | 8687 unaliased.accept(this, builder); |
8684 } | 8688 } |
8685 | 8689 |
8686 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 8690 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
8687 JavaScriptBackend backend = builder.compiler.backend; | 8691 JavaScriptBackend backend = builder.compiler.backend; |
8688 ClassElement cls = backend.findHelper('DynamicRuntimeType'); | 8692 ClassElement cls = backend.findHelper('DynamicRuntimeType'); |
8689 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); | 8693 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); |
8690 } | 8694 } |
8691 } | 8695 } |
OLD | NEW |