| 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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 // If this method is an intercepted method, add the extra | 346 // If this method is an intercepted method, add the extra |
| 347 // parameter to it, that is the actual receiver for intercepted | 347 // parameter to it, that is the actual receiver for intercepted |
| 348 // classes, or the same as [:this:] for non-intercepted classes. | 348 // classes, or the same as [:this:] for non-intercepted classes. |
| 349 ClassElement cls = element.enclosingClass; | 349 ClassElement cls = element.enclosingClass; |
| 350 | 350 |
| 351 // When the class extends a native class, the instance is pre-constructed | 351 // When the class extends a native class, the instance is pre-constructed |
| 352 // and passed to the generative constructor factory function as a parameter. | 352 // and passed to the generative constructor factory function as a parameter. |
| 353 // Instead of allocating and initializing the object, the constructor | 353 // Instead of allocating and initializing the object, the constructor |
| 354 // 'upgrades' the native subclass object by initializing the Dart fields. | 354 // 'upgrades' the native subclass object by initializing the Dart fields. |
| 355 bool isNativeUpgradeFactory = element.isGenerativeConstructor | 355 bool isNativeUpgradeFactory = element.isGenerativeConstructor |
| 356 && Elements.isNativeOrExtendsNative(cls); | 356 && backend.isNativeOrExtendsNative(cls); |
| 357 if (backend.isInterceptedMethod(element)) { | 357 if (backend.isInterceptedMethod(element)) { |
| 358 bool isInterceptorClass = backend.isInterceptorClass(cls.declaration); | 358 bool isInterceptorClass = backend.isInterceptorClass(cls.declaration); |
| 359 String name = isInterceptorClass ? 'receiver' : '_'; | 359 String name = isInterceptorClass ? 'receiver' : '_'; |
| 360 SyntheticLocal parameter = new SyntheticLocal(name, executableContext); | 360 SyntheticLocal parameter = new SyntheticLocal(name, executableContext); |
| 361 HParameterValue value = | 361 HParameterValue value = |
| 362 new HParameterValue(parameter, builder.getTypeOfThis()); | 362 new HParameterValue(parameter, builder.getTypeOfThis()); |
| 363 builder.graph.explicitReceiverParameter = value; | 363 builder.graph.explicitReceiverParameter = value; |
| 364 builder.graph.entry.addAfter(directLocals[closureData.thisLocal], value); | 364 builder.graph.entry.addAfter(directLocals[closureData.thisLocal], value); |
| 365 if (builder.lastAddedParameter == null) { | 365 if (builder.lastAddedParameter == null) { |
| 366 // If this is the first parameter inserted, make sure it stays first. | 366 // If this is the first parameter inserted, make sure it stays first. |
| (...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1332 Selector selector, | 1332 Selector selector, |
| 1333 TypeMask mask, | 1333 TypeMask mask, |
| 1334 List<HInstruction> providedArguments, | 1334 List<HInstruction> providedArguments, |
| 1335 ast.Node currentNode, | 1335 ast.Node currentNode, |
| 1336 {InterfaceType instanceType}) { | 1336 {InterfaceType instanceType}) { |
| 1337 // TODO(johnniwinther): Register this on the [registry]. Currently the | 1337 // TODO(johnniwinther): Register this on the [registry]. Currently the |
| 1338 // [CodegenRegistry] calls the enqueuer, but [element] should _not_ be | 1338 // [CodegenRegistry] calls the enqueuer, but [element] should _not_ be |
| 1339 // enqueued. | 1339 // enqueued. |
| 1340 backend.registerStaticUse(element, compiler.enqueuer.codegen); | 1340 backend.registerStaticUse(element, compiler.enqueuer.codegen); |
| 1341 | 1341 |
| 1342 if (element.isJsInterop && !element.isFactoryConstructor) { | 1342 if (backend.isJsInterop(element) && !element.isFactoryConstructor) { |
| 1343 // We only inline factory JavaScript interop constructors. | 1343 // We only inline factory JavaScript interop constructors. |
| 1344 return false; | 1344 return false; |
| 1345 } | 1345 } |
| 1346 | 1346 |
| 1347 // Ensure that [element] is an implementation element. | 1347 // Ensure that [element] is an implementation element. |
| 1348 element = element.implementation; | 1348 element = element.implementation; |
| 1349 | 1349 |
| 1350 if (compiler.elementHasCompileTimeError(element)) return false; | 1350 if (compiler.elementHasCompileTimeError(element)) return false; |
| 1351 | 1351 |
| 1352 FunctionElement function = element; | 1352 FunctionElement function = element; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1367 Elements.isStaticOrTopLevel(element) || | 1367 Elements.isStaticOrTopLevel(element) || |
| 1368 element.isGenerativeConstructorBody, | 1368 element.isGenerativeConstructorBody, |
| 1369 message: "Missing selector for inlining of $element.")); | 1369 message: "Missing selector for inlining of $element.")); |
| 1370 if (selector != null) { | 1370 if (selector != null) { |
| 1371 if (!selector.applies(function, compiler.world)) return false; | 1371 if (!selector.applies(function, compiler.world)) return false; |
| 1372 if (mask != null && !mask.canHit(function, selector, compiler.world)) { | 1372 if (mask != null && !mask.canHit(function, selector, compiler.world)) { |
| 1373 return false; | 1373 return false; |
| 1374 } | 1374 } |
| 1375 } | 1375 } |
| 1376 | 1376 |
| 1377 if (element.isJsInterop) return false; | 1377 if (backend.isJsInterop(element)) return false; |
| 1378 | 1378 |
| 1379 // Don't inline operator== methods if the parameter can be null. | 1379 // Don't inline operator== methods if the parameter can be null. |
| 1380 if (element.name == '==') { | 1380 if (element.name == '==') { |
| 1381 if (element.enclosingClass != compiler.objectClass | 1381 if (element.enclosingClass != compiler.objectClass |
| 1382 && providedArguments[1].canBeNull()) { | 1382 && providedArguments[1].canBeNull()) { |
| 1383 return false; | 1383 return false; |
| 1384 } | 1384 } |
| 1385 } | 1385 } |
| 1386 | 1386 |
| 1387 // Generative constructors of native classes should not be called directly | 1387 // Generative constructors of native classes should not be called directly |
| 1388 // and have an extra argument that causes problems with inlining. | 1388 // and have an extra argument that causes problems with inlining. |
| 1389 if (element.isGenerativeConstructor | 1389 if (element.isGenerativeConstructor |
| 1390 && Elements.isNativeOrExtendsNative(element.enclosingClass)) { | 1390 && backend.isNativeOrExtendsNative(element.enclosingClass)) { |
| 1391 return false; | 1391 return false; |
| 1392 } | 1392 } |
| 1393 | 1393 |
| 1394 // A generative constructor body is not seen by global analysis, | 1394 // A generative constructor body is not seen by global analysis, |
| 1395 // so we should not query for its type. | 1395 // so we should not query for its type. |
| 1396 if (!element.isGenerativeConstructorBody) { | 1396 if (!element.isGenerativeConstructorBody) { |
| 1397 // Don't inline if the return type was inferred to be non-null empty. | 1397 // Don't inline if the return type was inferred to be non-null empty. |
| 1398 // This means that the function always throws an exception. | 1398 // This means that the function always throws an exception. |
| 1399 TypeMask returnType = | 1399 TypeMask returnType = |
| 1400 compiler.typesTask.getGuaranteedReturnTypeOfElement(element); | 1400 compiler.typesTask.getGuaranteedReturnTypeOfElement(element); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1644 * Invariant: [functionElement] must be an implementation element. | 1644 * Invariant: [functionElement] must be an implementation element. |
| 1645 */ | 1645 */ |
| 1646 HGraph buildMethod(FunctionElement functionElement) { | 1646 HGraph buildMethod(FunctionElement functionElement) { |
| 1647 assert(invariant(functionElement, functionElement.isImplementation)); | 1647 assert(invariant(functionElement, functionElement.isImplementation)); |
| 1648 graph.calledInLoop = compiler.world.isCalledInLoop(functionElement); | 1648 graph.calledInLoop = compiler.world.isCalledInLoop(functionElement); |
| 1649 ast.FunctionExpression function = functionElement.node; | 1649 ast.FunctionExpression function = functionElement.node; |
| 1650 assert(function != null); | 1650 assert(function != null); |
| 1651 assert(elements.getFunctionDefinition(function) != null); | 1651 assert(elements.getFunctionDefinition(function) != null); |
| 1652 openFunction(functionElement, function); | 1652 openFunction(functionElement, function); |
| 1653 String name = functionElement.name; | 1653 String name = functionElement.name; |
| 1654 if (functionElement.isJsInterop) { | 1654 if (backend.isJsInterop(functionElement)) { |
| 1655 push(invokeJsInteropFunction(functionElement, parameters.values.toList(), | 1655 push(invokeJsInteropFunction(functionElement, parameters.values.toList(), |
| 1656 sourceInformationBuilder.buildGeneric(function))); | 1656 sourceInformationBuilder.buildGeneric(function))); |
| 1657 var value = pop(); | 1657 var value = pop(); |
| 1658 closeAndGotoExit(new HReturn(value, | 1658 closeAndGotoExit(new HReturn(value, |
| 1659 sourceInformationBuilder.buildReturn(functionElement.node))); | 1659 sourceInformationBuilder.buildReturn(functionElement.node))); |
| 1660 return closeFunction(); | 1660 return closeFunction(); |
| 1661 } | 1661 } |
| 1662 assert(invariant(functionElement, !function.modifiers.isExternal)); | 1662 assert(invariant(functionElement, !function.modifiers.isExternal)); |
| 1663 | 1663 |
| 1664 // If [functionElement] is `operator==` we explicitely add a null check at | 1664 // If [functionElement] is `operator==` we explicitely add a null check at |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2129 classElement.forEachInstanceField( | 2129 classElement.forEachInstanceField( |
| 2130 (ClassElement enclosingClass, VariableElement member) { | 2130 (ClassElement enclosingClass, VariableElement member) { |
| 2131 if (compiler.elementHasCompileTimeError(member)) return; | 2131 if (compiler.elementHasCompileTimeError(member)) return; |
| 2132 reporter.withCurrentElement(member, () { | 2132 reporter.withCurrentElement(member, () { |
| 2133 TreeElements definitions = member.treeElements; | 2133 TreeElements definitions = member.treeElements; |
| 2134 ast.Node node = member.node; | 2134 ast.Node node = member.node; |
| 2135 ast.Expression initializer = member.initializer; | 2135 ast.Expression initializer = member.initializer; |
| 2136 if (initializer == null) { | 2136 if (initializer == null) { |
| 2137 // Unassigned fields of native classes are not initialized to | 2137 // Unassigned fields of native classes are not initialized to |
| 2138 // prevent overwriting pre-initialized native properties. | 2138 // prevent overwriting pre-initialized native properties. |
| 2139 if (!Elements.isNativeOrExtendsNative(classElement)) { | 2139 if (!backend.isNativeOrExtendsNative(classElement)) { |
| 2140 fieldValues[member] = graph.addConstantNull(compiler); | 2140 fieldValues[member] = graph.addConstantNull(compiler); |
| 2141 } | 2141 } |
| 2142 } else { | 2142 } else { |
| 2143 ast.Node right = initializer; | 2143 ast.Node right = initializer; |
| 2144 TreeElements savedElements = elements; | 2144 TreeElements savedElements = elements; |
| 2145 elements = definitions; | 2145 elements = definitions; |
| 2146 // In case the field initializer uses closures, run the | 2146 // In case the field initializer uses closures, run the |
| 2147 // closure to class mapper. | 2147 // closure to class mapper. |
| 2148 compiler.closureToClassMapper.computeClosureToClassMapping( | 2148 compiler.closureToClassMapper.computeClosureToClassMapping( |
| 2149 member, node, elements); | 2149 member, node, elements); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2162 * current constructor and super constructors or constructors redirected | 2162 * current constructor and super constructors or constructors redirected |
| 2163 * to, starting from the current constructor. | 2163 * to, starting from the current constructor. |
| 2164 * - Call the constructor bodies, starting from the constructor(s) in the | 2164 * - Call the constructor bodies, starting from the constructor(s) in the |
| 2165 * super class(es). | 2165 * super class(es). |
| 2166 */ | 2166 */ |
| 2167 HGraph buildFactory(ConstructorElement functionElement) { | 2167 HGraph buildFactory(ConstructorElement functionElement) { |
| 2168 functionElement = functionElement.implementation; | 2168 functionElement = functionElement.implementation; |
| 2169 ClassElement classElement = | 2169 ClassElement classElement = |
| 2170 functionElement.enclosingClass.implementation; | 2170 functionElement.enclosingClass.implementation; |
| 2171 bool isNativeUpgradeFactory = | 2171 bool isNativeUpgradeFactory = |
| 2172 Elements.isNativeOrExtendsNative(classElement) | 2172 backend.isNativeOrExtendsNative(classElement) |
| 2173 && !classElement.isJsInterop; | 2173 && !backend.isJsInterop(classElement); |
| 2174 ast.FunctionExpression function = functionElement.node; | 2174 ast.FunctionExpression function = functionElement.node; |
| 2175 // Note that constructors (like any other static function) do not need | 2175 // Note that constructors (like any other static function) do not need |
| 2176 // to deal with optional arguments. It is the callers job to provide all | 2176 // to deal with optional arguments. It is the callers job to provide all |
| 2177 // arguments as if they were positional. | 2177 // arguments as if they were positional. |
| 2178 | 2178 |
| 2179 if (inliningStack.isEmpty) { | 2179 if (inliningStack.isEmpty) { |
| 2180 // The initializer list could contain closures. | 2180 // The initializer list could contain closures. |
| 2181 openFunction(functionElement, function); | 2181 openFunction(functionElement, function); |
| 2182 } | 2182 } |
| 2183 | 2183 |
| (...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3974 | 3974 |
| 3975 HInstruction compileArgument(ast.Node argument) { | 3975 HInstruction compileArgument(ast.Node argument) { |
| 3976 visit(argument); | 3976 visit(argument); |
| 3977 return pop(); | 3977 return pop(); |
| 3978 } | 3978 } |
| 3979 | 3979 |
| 3980 return callStructure.makeArgumentsList( | 3980 return callStructure.makeArgumentsList( |
| 3981 arguments, | 3981 arguments, |
| 3982 element, | 3982 element, |
| 3983 compileArgument, | 3983 compileArgument, |
| 3984 element.isJsInterop ? | 3984 backend.isJsInterop(element) ? |
| 3985 handleConstantForOptionalParameterJsInterop : | 3985 handleConstantForOptionalParameterJsInterop : |
| 3986 handleConstantForOptionalParameter); | 3986 handleConstantForOptionalParameter); |
| 3987 } | 3987 } |
| 3988 | 3988 |
| 3989 void addGenericSendArgumentsToList(Link<ast.Node> link, List<HInstruction> lis
t) { | 3989 void addGenericSendArgumentsToList(Link<ast.Node> link, List<HInstruction> lis
t) { |
| 3990 for (; !link.isEmpty; link = link.tail) { | 3990 for (; !link.isEmpty; link = link.tail) { |
| 3991 visit(link.head); | 3991 visit(link.head); |
| 3992 list.add(pop()); | 3992 list.add(pop()); |
| 3993 } | 3993 } |
| 3994 } | 3994 } |
| (...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5060 TypeMaskFactory.inferredForNode(sourceElement, send, compiler); | 5060 TypeMaskFactory.inferredForNode(sourceElement, send, compiler); |
| 5061 return inferred.containsAll(compiler.world) | 5061 return inferred.containsAll(compiler.world) |
| 5062 ? backend.extendableArrayType | 5062 ? backend.extendableArrayType |
| 5063 : inferred; | 5063 : inferred; |
| 5064 } else if (Elements.isConstructorOfTypedArraySubclass( | 5064 } else if (Elements.isConstructorOfTypedArraySubclass( |
| 5065 originalElement, compiler)) { | 5065 originalElement, compiler)) { |
| 5066 isFixedList = true; | 5066 isFixedList = true; |
| 5067 TypeMask inferred = | 5067 TypeMask inferred = |
| 5068 TypeMaskFactory.inferredForNode(sourceElement, send, compiler); | 5068 TypeMaskFactory.inferredForNode(sourceElement, send, compiler); |
| 5069 ClassElement cls = element.enclosingClass; | 5069 ClassElement cls = element.enclosingClass; |
| 5070 assert(cls.thisType.element.isNative); | 5070 assert(backend.isNative(cls.thisType.element)); |
| 5071 return inferred.containsAll(compiler.world) | 5071 return inferred.containsAll(compiler.world) |
| 5072 ? new TypeMask.nonNullExact(cls.thisType.element, compiler.world) | 5072 ? new TypeMask.nonNullExact(cls.thisType.element, compiler.world) |
| 5073 : inferred; | 5073 : inferred; |
| 5074 } else if (element.isGenerativeConstructor) { | 5074 } else if (element.isGenerativeConstructor) { |
| 5075 ClassElement cls = element.enclosingClass; | 5075 ClassElement cls = element.enclosingClass; |
| 5076 return new TypeMask.nonNullExact(cls.thisType.element, compiler.world); | 5076 return new TypeMask.nonNullExact(cls.thisType.element, compiler.world); |
| 5077 } else { | 5077 } else { |
| 5078 return TypeMaskFactory.inferredReturnTypeForElement( | 5078 return TypeMaskFactory.inferredReturnTypeForElement( |
| 5079 originalElement, compiler); | 5079 originalElement, compiler); |
| 5080 } | 5080 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5121 | 5121 |
| 5122 if (compiler.elementHasCompileTimeError(constructor)) { | 5122 if (compiler.elementHasCompileTimeError(constructor)) { |
| 5123 // TODO(ahe): Do something like [generateWrongArgumentCountError]. | 5123 // TODO(ahe): Do something like [generateWrongArgumentCountError]. |
| 5124 stack.add(graph.addConstantNull(compiler)); | 5124 stack.add(graph.addConstantNull(compiler)); |
| 5125 return; | 5125 return; |
| 5126 } | 5126 } |
| 5127 if (checkTypeVariableBounds(node, type)) return; | 5127 if (checkTypeVariableBounds(node, type)) return; |
| 5128 | 5128 |
| 5129 var inputs = <HInstruction>[]; | 5129 var inputs = <HInstruction>[]; |
| 5130 if (constructor.isGenerativeConstructor && | 5130 if (constructor.isGenerativeConstructor && |
| 5131 Elements.isNativeOrExtendsNative(constructor.enclosingClass) && | 5131 backend.isNativeOrExtendsNative(constructor.enclosingClass) && |
| 5132 !constructor.isJsInterop) { | 5132 !backend.isJsInterop(constructor)) { |
| 5133 // Native class generative constructors take a pre-constructed object. | 5133 // Native class generative constructors take a pre-constructed object. |
| 5134 inputs.add(graph.addConstantNull(compiler)); | 5134 inputs.add(graph.addConstantNull(compiler)); |
| 5135 } | 5135 } |
| 5136 // TODO(5347): Try to avoid the need for calling [implementation] before | 5136 // TODO(5347): Try to avoid the need for calling [implementation] before |
| 5137 // calling [makeStaticArgumentList]. | 5137 // calling [makeStaticArgumentList]. |
| 5138 constructorImplementation = constructor.implementation; | 5138 constructorImplementation = constructor.implementation; |
| 5139 if (constructorImplementation.isErroneous || | 5139 if (constructorImplementation.isErroneous || |
| 5140 !callStructure.signatureApplies( | 5140 !callStructure.signatureApplies( |
| 5141 constructorImplementation.functionSignature)) { | 5141 constructorImplementation.functionSignature)) { |
| 5142 generateWrongArgumentCountError(send, constructor, send.arguments); | 5142 generateWrongArgumentCountError(send, constructor, send.arguments); |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5842 } else { | 5842 } else { |
| 5843 push( | 5843 push( |
| 5844 new HInvokeDynamicMethod(selector, mask, inputs, type, isIntercepted) | 5844 new HInvokeDynamicMethod(selector, mask, inputs, type, isIntercepted) |
| 5845 ..sourceInformation = sourceInformation); | 5845 ..sourceInformation = sourceInformation); |
| 5846 } | 5846 } |
| 5847 } | 5847 } |
| 5848 | 5848 |
| 5849 HForeignCode invokeJsInteropFunction(Element element, | 5849 HForeignCode invokeJsInteropFunction(Element element, |
| 5850 List<HInstruction> arguments, | 5850 List<HInstruction> arguments, |
| 5851 SourceInformation sourceInformation) { | 5851 SourceInformation sourceInformation) { |
| 5852 assert(element.isJsInterop); | 5852 assert(backend.isJsInterop(element)); |
| 5853 nativeEmitter.nativeMethods.add(element); | 5853 nativeEmitter.nativeMethods.add(element); |
| 5854 String templateString; | 5854 String templateString; |
| 5855 | 5855 |
| 5856 if (element.isFactoryConstructor) { | 5856 if (element.isFactoryConstructor) { |
| 5857 // Treat factory constructors as syntactic sugar for creating object | 5857 // Treat factory constructors as syntactic sugar for creating object |
| 5858 // literals. | 5858 // literals. |
| 5859 ConstructorElement constructor = element; | 5859 ConstructorElement constructor = element; |
| 5860 FunctionSignature params = constructor.functionSignature; | 5860 FunctionSignature params = constructor.functionSignature; |
| 5861 int i = 0; | 5861 int i = 0; |
| 5862 int positions = 0; | 5862 int positions = 0; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 5887 var nativeBehavior = new native.NativeBehavior() | 5887 var nativeBehavior = new native.NativeBehavior() |
| 5888 ..codeTemplate = codeTemplate; | 5888 ..codeTemplate = codeTemplate; |
| 5889 return new HForeignCode( | 5889 return new HForeignCode( |
| 5890 codeTemplate, | 5890 codeTemplate, |
| 5891 backend.dynamicType, filteredArguments, | 5891 backend.dynamicType, filteredArguments, |
| 5892 nativeBehavior: nativeBehavior) | 5892 nativeBehavior: nativeBehavior) |
| 5893 ..sourceInformation = sourceInformation; | 5893 ..sourceInformation = sourceInformation; |
| 5894 } | 5894 } |
| 5895 var target = new HForeignCode(js.js.parseForeignJS( | 5895 var target = new HForeignCode(js.js.parseForeignJS( |
| 5896 "${backend.namer.fixedBackendPath(element)}." | 5896 "${backend.namer.fixedBackendPath(element)}." |
| 5897 "${element.fixedBackendName}"), | 5897 "${backend.getFixedBackendName(element)}"), |
| 5898 backend.dynamicType, | 5898 backend.dynamicType, |
| 5899 <HInstruction>[]); | 5899 <HInstruction>[]); |
| 5900 add(target); | 5900 add(target); |
| 5901 // Strip off trailing arguments that were not specified. | 5901 // Strip off trailing arguments that were not specified. |
| 5902 // we could assert that the trailing arguments are all null. | 5902 // we could assert that the trailing arguments are all null. |
| 5903 // TODO(jacobr): rewrite named arguments to an object literal matching | 5903 // TODO(jacobr): rewrite named arguments to an object literal matching |
| 5904 // the factory constructor case. | 5904 // the factory constructor case. |
| 5905 arguments = arguments.where((arg) => arg != null).toList(); | 5905 arguments = arguments.where((arg) => arg != null).toList(); |
| 5906 var inputs = <HInstruction>[target]..addAll(arguments); | 5906 var inputs = <HInstruction>[target]..addAll(arguments); |
| 5907 | 5907 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5948 return; | 5948 return; |
| 5949 } | 5949 } |
| 5950 | 5950 |
| 5951 if (typeMask == null) { | 5951 if (typeMask == null) { |
| 5952 typeMask = | 5952 typeMask = |
| 5953 TypeMaskFactory.inferredReturnTypeForElement(element, compiler); | 5953 TypeMaskFactory.inferredReturnTypeForElement(element, compiler); |
| 5954 } | 5954 } |
| 5955 bool targetCanThrow = !compiler.world.getCannotThrow(element); | 5955 bool targetCanThrow = !compiler.world.getCannotThrow(element); |
| 5956 // TODO(5346): Try to avoid the need for calling [declaration] before | 5956 // TODO(5346): Try to avoid the need for calling [declaration] before |
| 5957 var instruction; | 5957 var instruction; |
| 5958 if (element.isJsInterop) { | 5958 if (backend.isJsInterop(element)) { |
| 5959 instruction = invokeJsInteropFunction(element, arguments, | 5959 instruction = invokeJsInteropFunction(element, arguments, |
| 5960 sourceInformation); | 5960 sourceInformation); |
| 5961 } else { | 5961 } else { |
| 5962 // creating an [HInvokeStatic]. | 5962 // creating an [HInvokeStatic]. |
| 5963 instruction = new HInvokeStatic( | 5963 instruction = new HInvokeStatic( |
| 5964 element.declaration, arguments, typeMask, | 5964 element.declaration, arguments, typeMask, |
| 5965 targetCanThrow: targetCanThrow) | 5965 targetCanThrow: targetCanThrow) |
| 5966 ..sourceInformation = sourceInformation; | 5966 ..sourceInformation = sourceInformation; |
| 5967 if (!currentInlinedInstantiations.isEmpty) { | 5967 if (!currentInlinedInstantiations.isEmpty) { |
| 5968 instruction.instantiatedTypes = new List<DartType>.from( | 5968 instruction.instantiatedTypes = new List<DartType>.from( |
| (...skipping 3176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9145 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 9145 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
| 9146 unaliased.accept(this, builder); | 9146 unaliased.accept(this, builder); |
| 9147 } | 9147 } |
| 9148 | 9148 |
| 9149 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 9149 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
| 9150 JavaScriptBackend backend = builder.compiler.backend; | 9150 JavaScriptBackend backend = builder.compiler.backend; |
| 9151 ClassElement cls = backend.findHelper('DynamicRuntimeType'); | 9151 ClassElement cls = backend.findHelper('DynamicRuntimeType'); |
| 9152 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); | 9152 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); |
| 9153 } | 9153 } |
| 9154 } | 9154 } |
| OLD | NEW |