| 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 import 'dart:collection'; | 5 import 'dart:collection'; |
| 6 | 6 |
| 7 import 'package:js_runtime/shared/embedded_names.dart'; | 7 import 'package:js_runtime/shared/embedded_names.dart'; |
| 8 | 8 |
| 9 import '../closure.dart'; | 9 import '../closure.dart'; |
| 10 import '../common.dart'; | 10 import '../common.dart'; |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 } | 295 } |
| 296 assert(result.isValid()); | 296 assert(result.isValid()); |
| 297 return result; | 297 return result; |
| 298 } | 298 } |
| 299 | 299 |
| 300 void addWithPosition(HInstruction instruction, ast.Node node) { | 300 void addWithPosition(HInstruction instruction, ast.Node node) { |
| 301 add(attachPosition(instruction, node)); | 301 add(attachPosition(instruction, node)); |
| 302 } | 302 } |
| 303 | 303 |
| 304 HTypeConversion buildFunctionTypeConversion( | 304 HTypeConversion buildFunctionTypeConversion( |
| 305 HInstruction original, DartType type, int kind) { | 305 HInstruction original, ResolutionDartType type, int kind) { |
| 306 HInstruction reifiedType = buildFunctionType(type); | 306 HInstruction reifiedType = buildFunctionType(type); |
| 307 return new HTypeConversion.viaMethodOnType( | 307 return new HTypeConversion.viaMethodOnType( |
| 308 type, kind, original.instructionType, reifiedType, original); | 308 type, kind, original.instructionType, reifiedType, original); |
| 309 } | 309 } |
| 310 | 310 |
| 311 /** | 311 /** |
| 312 * Returns a complete argument list for a call of [function]. | 312 * Returns a complete argument list for a call of [function]. |
| 313 */ | 313 */ |
| 314 List<HInstruction> completeSendArgumentsList( | 314 List<HInstruction> completeSendArgumentsList( |
| 315 FunctionElement function, | 315 FunctionElement function, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 } | 402 } |
| 403 return compiledArguments; | 403 return compiledArguments; |
| 404 } | 404 } |
| 405 | 405 |
| 406 /** | 406 /** |
| 407 * Try to inline [element] within the correct context of the builder. The | 407 * Try to inline [element] within the correct context of the builder. The |
| 408 * insertion point is the state of the builder. | 408 * insertion point is the state of the builder. |
| 409 */ | 409 */ |
| 410 bool tryInlineMethod(Element element, Selector selector, TypeMask mask, | 410 bool tryInlineMethod(Element element, Selector selector, TypeMask mask, |
| 411 List<HInstruction> providedArguments, ast.Node currentNode, | 411 List<HInstruction> providedArguments, ast.Node currentNode, |
| 412 {InterfaceType instanceType}) { | 412 {ResolutionInterfaceType instanceType}) { |
| 413 registry | 413 registry |
| 414 .addImpact(backend.registerUsedElement(element, forResolution: false)); | 414 .addImpact(backend.registerUsedElement(element, forResolution: false)); |
| 415 | 415 |
| 416 if (backend.isJsInterop(element) && !element.isFactoryConstructor) { | 416 if (backend.isJsInterop(element) && !element.isFactoryConstructor) { |
| 417 // We only inline factory JavaScript interop constructors. | 417 // We only inline factory JavaScript interop constructors. |
| 418 return false; | 418 return false; |
| 419 } | 419 } |
| 420 | 420 |
| 421 // Ensure that [element] is an implementation element. | 421 // Ensure that [element] is an implementation element. |
| 422 element = element.implementation; | 422 element = element.implementation; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 ClassElement get currentNonClosureClass { | 647 ClassElement get currentNonClosureClass { |
| 648 ClassElement cls = sourceElement.enclosingClass; | 648 ClassElement cls = sourceElement.enclosingClass; |
| 649 if (cls != null && cls.isClosure) { | 649 if (cls != null && cls.isClosure) { |
| 650 var closureClass = cls; | 650 var closureClass = cls; |
| 651 return closureClass.methodElement.enclosingClass; | 651 return closureClass.methodElement.enclosingClass; |
| 652 } else { | 652 } else { |
| 653 return cls; | 653 return cls; |
| 654 } | 654 } |
| 655 } | 655 } |
| 656 | 656 |
| 657 /// A stack of [DartType]s that have been seen during inlining of factory | 657 /// A stack of [ResolutionDartType]s that have been seen during inlining of |
| 658 /// constructors. These types are preserved in [HInvokeStatic]s and | 658 /// factory constructors. These types are preserved in [HInvokeStatic]s and |
| 659 /// [HCreate]s inside the inline code and registered during code generation | 659 /// [HCreate]s inside the inline code and registered during code generation |
| 660 /// for these nodes. | 660 /// for these nodes. |
| 661 // TODO(karlklose): consider removing this and keeping the (substituted) types | 661 // TODO(karlklose): consider removing this and keeping the (substituted) types |
| 662 // of the type variables in an environment (like the [LocalsHandler]). | 662 // of the type variables in an environment (like the [LocalsHandler]). |
| 663 final List<DartType> currentInlinedInstantiations = <DartType>[]; | 663 final List<ResolutionDartType> currentInlinedInstantiations = |
| 664 <ResolutionDartType>[]; |
| 664 | 665 |
| 665 final List<AstInliningState> inliningStack = <AstInliningState>[]; | 666 final List<AstInliningState> inliningStack = <AstInliningState>[]; |
| 666 | 667 |
| 667 Local returnLocal; | 668 Local returnLocal; |
| 668 DartType returnType; | 669 ResolutionDartType returnType; |
| 669 | 670 |
| 670 bool inTryStatement = false; | 671 bool inTryStatement = false; |
| 671 | 672 |
| 672 ConstantValue getConstantForNode(ast.Node node) { | 673 ConstantValue getConstantForNode(ast.Node node) { |
| 673 ConstantValue constantValue = | 674 ConstantValue constantValue = |
| 674 backend.constants.getConstantValueForNode(node, elements); | 675 backend.constants.getConstantValueForNode(node, elements); |
| 675 assert(invariant(node, constantValue != null, | 676 assert(invariant(node, constantValue != null, |
| 676 message: 'No constant computed for $node')); | 677 message: 'No constant computed for $node')); |
| 677 return constantValue; | 678 return constantValue; |
| 678 } | 679 } |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 * This method sets up the local state of the builder for inlining [function]. | 850 * This method sets up the local state of the builder for inlining [function]. |
| 850 * The arguments of the function are inserted into the [localsHandler]. | 851 * The arguments of the function are inserted into the [localsHandler]. |
| 851 * | 852 * |
| 852 * When inlining a function, [:return:] statements are not emitted as | 853 * When inlining a function, [:return:] statements are not emitted as |
| 853 * [HReturn] instructions. Instead, the value of a synthetic element is | 854 * [HReturn] instructions. Instead, the value of a synthetic element is |
| 854 * updated in the [localsHandler]. This function creates such an element and | 855 * updated in the [localsHandler]. This function creates such an element and |
| 855 * stores it in the [returnLocal] field. | 856 * stores it in the [returnLocal] field. |
| 856 */ | 857 */ |
| 857 void setupStateForInlining( | 858 void setupStateForInlining( |
| 858 FunctionElement function, List<HInstruction> compiledArguments, | 859 FunctionElement function, List<HInstruction> compiledArguments, |
| 859 {InterfaceType instanceType}) { | 860 {ResolutionInterfaceType instanceType}) { |
| 860 ResolvedAst resolvedAst = function.resolvedAst; | 861 ResolvedAst resolvedAst = function.resolvedAst; |
| 861 assert(resolvedAst != null); | 862 assert(resolvedAst != null); |
| 862 localsHandler = new LocalsHandler(this, function, instanceType, compiler); | 863 localsHandler = new LocalsHandler(this, function, instanceType, compiler); |
| 863 localsHandler.closureData = | 864 localsHandler.closureData = |
| 864 compiler.closureToClassMapper.getClosureToClassMapping(resolvedAst); | 865 compiler.closureToClassMapper.getClosureToClassMapping(resolvedAst); |
| 865 returnLocal = new SyntheticLocal("result", function); | 866 returnLocal = new SyntheticLocal("result", function); |
| 866 localsHandler.updateLocal(returnLocal, graph.addConstantNull(closedWorld)); | 867 localsHandler.updateLocal(returnLocal, graph.addConstantNull(closedWorld)); |
| 867 | 868 |
| 868 inTryStatement = false; // TODO(lry): why? Document. | 869 inTryStatement = false; // TODO(lry): why? Document. |
| 869 | 870 |
| 870 int argumentIndex = 0; | 871 int argumentIndex = 0; |
| 871 if (function.isInstanceMember) { | 872 if (function.isInstanceMember) { |
| 872 localsHandler.updateLocal(localsHandler.closureData.thisLocal, | 873 localsHandler.updateLocal(localsHandler.closureData.thisLocal, |
| 873 compiledArguments[argumentIndex++]); | 874 compiledArguments[argumentIndex++]); |
| 874 } | 875 } |
| 875 | 876 |
| 876 FunctionSignature signature = function.functionSignature; | 877 FunctionSignature signature = function.functionSignature; |
| 877 signature.orderedForEachParameter((ParameterElement parameter) { | 878 signature.orderedForEachParameter((ParameterElement parameter) { |
| 878 HInstruction argument = compiledArguments[argumentIndex++]; | 879 HInstruction argument = compiledArguments[argumentIndex++]; |
| 879 localsHandler.updateLocal(parameter, argument); | 880 localsHandler.updateLocal(parameter, argument); |
| 880 }); | 881 }); |
| 881 | 882 |
| 882 ClassElement enclosing = function.enclosingClass; | 883 ClassElement enclosing = function.enclosingClass; |
| 883 if ((function.isConstructor || function.isGenerativeConstructorBody) && | 884 if ((function.isConstructor || function.isGenerativeConstructorBody) && |
| 884 backend.classNeedsRti(enclosing)) { | 885 backend.classNeedsRti(enclosing)) { |
| 885 enclosing.typeVariables.forEach((TypeVariableType typeVariable) { | 886 enclosing.typeVariables |
| 887 .forEach((ResolutionTypeVariableType typeVariable) { |
| 886 HInstruction argument = compiledArguments[argumentIndex++]; | 888 HInstruction argument = compiledArguments[argumentIndex++]; |
| 887 localsHandler.updateLocal( | 889 localsHandler.updateLocal( |
| 888 localsHandler.getTypeVariableAsLocal(typeVariable), argument); | 890 localsHandler.getTypeVariableAsLocal(typeVariable), argument); |
| 889 }); | 891 }); |
| 890 } | 892 } |
| 891 assert(argumentIndex == compiledArguments.length); | 893 assert(argumentIndex == compiledArguments.length); |
| 892 | 894 |
| 893 returnType = signature.type.returnType; | 895 returnType = signature.type.returnType; |
| 894 stack = <HInstruction>[]; | 896 stack = <HInstruction>[]; |
| 895 | 897 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 916 resolvedAst.element.implementation); | 918 resolvedAst.element.implementation); |
| 917 | 919 |
| 918 if (resolvedAst.element.isGenerativeConstructor) { | 920 if (resolvedAst.element.isGenerativeConstructor) { |
| 919 buildFactory(resolvedAst); | 921 buildFactory(resolvedAst); |
| 920 } else { | 922 } else { |
| 921 ast.FunctionExpression functionNode = resolvedAst.node; | 923 ast.FunctionExpression functionNode = resolvedAst.node; |
| 922 functionNode.body.accept(this); | 924 functionNode.body.accept(this); |
| 923 } | 925 } |
| 924 } | 926 } |
| 925 | 927 |
| 926 addInlinedInstantiation(DartType type) { | 928 addInlinedInstantiation(ResolutionDartType type) { |
| 927 if (type != null) { | 929 if (type != null) { |
| 928 currentInlinedInstantiations.add(type); | 930 currentInlinedInstantiations.add(type); |
| 929 } | 931 } |
| 930 } | 932 } |
| 931 | 933 |
| 932 removeInlinedInstantiation(DartType type) { | 934 removeInlinedInstantiation(ResolutionDartType type) { |
| 933 if (type != null) { | 935 if (type != null) { |
| 934 currentInlinedInstantiations.removeLast(); | 936 currentInlinedInstantiations.removeLast(); |
| 935 } | 937 } |
| 936 } | 938 } |
| 937 | 939 |
| 938 bool providedArgumentsKnownToBeComplete(ast.Node currentNode) { | 940 bool providedArgumentsKnownToBeComplete(ast.Node currentNode) { |
| 939 /* When inlining the iterator methods generated for a [:for-in:] loop, the | 941 /* When inlining the iterator methods generated for a [:for-in:] loop, the |
| 940 * [currentNode] is the [ForIn] tree. The compiler-generated iterator | 942 * [currentNode] is the [ForIn] tree. The compiler-generated iterator |
| 941 * invocations are known to have fully specified argument lists, no default | 943 * invocations are known to have fully specified argument lists, no default |
| 942 * arguments are used. See invocations of [pushInvokeDynamic] in | 944 * arguments are used. See invocations of [pushInvokeDynamic] in |
| (...skipping 18 matching lines...) Expand all Loading... |
| 961 constructorResolvedAsts.add(constructorResolvedAst); | 963 constructorResolvedAsts.add(constructorResolvedAst); |
| 962 ClassElement enclosingClass = callee.enclosingClass; | 964 ClassElement enclosingClass = callee.enclosingClass; |
| 963 if (backend.classNeedsRti(enclosingClass)) { | 965 if (backend.classNeedsRti(enclosingClass)) { |
| 964 // If [enclosingClass] needs RTI, we have to give a value to its | 966 // If [enclosingClass] needs RTI, we have to give a value to its |
| 965 // type parameters. | 967 // type parameters. |
| 966 ClassElement currentClass = caller.enclosingClass; | 968 ClassElement currentClass = caller.enclosingClass; |
| 967 // For a super constructor call, the type is the supertype of | 969 // For a super constructor call, the type is the supertype of |
| 968 // [currentClass]. For a redirecting constructor, the type is | 970 // [currentClass]. For a redirecting constructor, the type is |
| 969 // the current type. [InterfaceType.asInstanceOf] takes care | 971 // the current type. [InterfaceType.asInstanceOf] takes care |
| 970 // of both. | 972 // of both. |
| 971 InterfaceType type = currentClass.thisType.asInstanceOf(enclosingClass); | 973 ResolutionInterfaceType type = |
| 974 currentClass.thisType.asInstanceOf(enclosingClass); |
| 972 type = localsHandler.substInContext(type); | 975 type = localsHandler.substInContext(type); |
| 973 List<DartType> arguments = type.typeArguments; | 976 List<ResolutionDartType> arguments = type.typeArguments; |
| 974 List<DartType> typeVariables = enclosingClass.typeVariables; | 977 List<ResolutionDartType> typeVariables = enclosingClass.typeVariables; |
| 975 if (!type.isRaw) { | 978 if (!type.isRaw) { |
| 976 assert(arguments.length == typeVariables.length); | 979 assert(arguments.length == typeVariables.length); |
| 977 Iterator<DartType> variables = typeVariables.iterator; | 980 Iterator<ResolutionDartType> variables = typeVariables.iterator; |
| 978 type.typeArguments.forEach((DartType argument) { | 981 type.typeArguments.forEach((ResolutionDartType argument) { |
| 979 variables.moveNext(); | 982 variables.moveNext(); |
| 980 TypeVariableType typeVariable = variables.current; | 983 ResolutionTypeVariableType typeVariable = variables.current; |
| 981 localsHandler.updateLocal( | 984 localsHandler.updateLocal( |
| 982 localsHandler.getTypeVariableAsLocal(typeVariable), | 985 localsHandler.getTypeVariableAsLocal(typeVariable), |
| 983 typeBuilder.analyzeTypeArgument(argument, sourceElement)); | 986 typeBuilder.analyzeTypeArgument(argument, sourceElement)); |
| 984 }); | 987 }); |
| 985 } else { | 988 } else { |
| 986 // If the supertype is a raw type, we need to set to null the | 989 // If the supertype is a raw type, we need to set to null the |
| 987 // type variables. | 990 // type variables. |
| 988 for (TypeVariableType variable in typeVariables) { | 991 for (ResolutionTypeVariableType variable in typeVariables) { |
| 989 localsHandler.updateLocal( | 992 localsHandler.updateLocal( |
| 990 localsHandler.getTypeVariableAsLocal(variable), | 993 localsHandler.getTypeVariableAsLocal(variable), |
| 991 graph.addConstantNull(closedWorld)); | 994 graph.addConstantNull(closedWorld)); |
| 992 } | 995 } |
| 993 } | 996 } |
| 994 } | 997 } |
| 995 | 998 |
| 996 // For redirecting constructors, the fields will be initialized later | 999 // For redirecting constructors, the fields will be initialized later |
| 997 // by the effective target. | 1000 // by the effective target. |
| 998 if (!callee.isRedirectingGenerative) { | 1001 if (!callee.isRedirectingGenerative) { |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1274 classElement.forEachInstanceField( | 1277 classElement.forEachInstanceField( |
| 1275 (ClassElement enclosingClass, FieldElement member) { | 1278 (ClassElement enclosingClass, FieldElement member) { |
| 1276 HInstruction value = fieldValues[member]; | 1279 HInstruction value = fieldValues[member]; |
| 1277 if (value == null) { | 1280 if (value == null) { |
| 1278 // Uninitialized native fields are pre-initialized by the native | 1281 // Uninitialized native fields are pre-initialized by the native |
| 1279 // implementation. | 1282 // implementation. |
| 1280 assert(invariant( | 1283 assert(invariant( |
| 1281 member, isNativeUpgradeFactory || compiler.compilationFailed)); | 1284 member, isNativeUpgradeFactory || compiler.compilationFailed)); |
| 1282 } else { | 1285 } else { |
| 1283 fields.add(member); | 1286 fields.add(member); |
| 1284 DartType type = localsHandler.substInContext(member.type); | 1287 ResolutionDartType type = localsHandler.substInContext(member.type); |
| 1285 constructorArguments | 1288 constructorArguments |
| 1286 .add(typeBuilder.potentiallyCheckOrTrustType(value, type)); | 1289 .add(typeBuilder.potentiallyCheckOrTrustType(value, type)); |
| 1287 } | 1290 } |
| 1288 }, includeSuperAndInjectedMembers: true); | 1291 }, includeSuperAndInjectedMembers: true); |
| 1289 | 1292 |
| 1290 InterfaceType type = classElement.thisType; | 1293 ResolutionInterfaceType type = classElement.thisType; |
| 1291 TypeMask ssaType = | 1294 TypeMask ssaType = |
| 1292 new TypeMask.nonNullExact(classElement.declaration, closedWorld); | 1295 new TypeMask.nonNullExact(classElement.declaration, closedWorld); |
| 1293 List<DartType> instantiatedTypes; | 1296 List<ResolutionDartType> instantiatedTypes; |
| 1294 addInlinedInstantiation(type); | 1297 addInlinedInstantiation(type); |
| 1295 if (!currentInlinedInstantiations.isEmpty) { | 1298 if (!currentInlinedInstantiations.isEmpty) { |
| 1296 instantiatedTypes = new List<DartType>.from(currentInlinedInstantiations); | 1299 instantiatedTypes = |
| 1300 new List<ResolutionDartType>.from(currentInlinedInstantiations); |
| 1297 } | 1301 } |
| 1298 | 1302 |
| 1299 HInstruction newObject; | 1303 HInstruction newObject; |
| 1300 if (!isNativeUpgradeFactory) { | 1304 if (!isNativeUpgradeFactory) { |
| 1301 // Create the runtime type information, if needed. | 1305 // Create the runtime type information, if needed. |
| 1302 bool hasRtiInput = false; | 1306 bool hasRtiInput = false; |
| 1303 if (backend.classNeedsRtiField(classElement)) { | 1307 if (backend.classNeedsRtiField(classElement)) { |
| 1304 // Read the values of the type arguments and create a | 1308 // Read the values of the type arguments and create a |
| 1305 // HTypeInfoExpression to set on the newly create object. | 1309 // HTypeInfoExpression to set on the newly create object. |
| 1306 hasRtiInput = true; | 1310 hasRtiInput = true; |
| 1307 List<HInstruction> typeArguments = <HInstruction>[]; | 1311 List<HInstruction> typeArguments = <HInstruction>[]; |
| 1308 classElement.typeVariables.forEach((TypeVariableType typeVariable) { | 1312 classElement.typeVariables |
| 1313 .forEach((ResolutionTypeVariableType typeVariable) { |
| 1309 HInstruction argument = localsHandler | 1314 HInstruction argument = localsHandler |
| 1310 .readLocal(localsHandler.getTypeVariableAsLocal(typeVariable)); | 1315 .readLocal(localsHandler.getTypeVariableAsLocal(typeVariable)); |
| 1311 typeArguments.add(argument); | 1316 typeArguments.add(argument); |
| 1312 }); | 1317 }); |
| 1313 | 1318 |
| 1314 HInstruction typeInfo = new HTypeInfoExpression( | 1319 HInstruction typeInfo = new HTypeInfoExpression( |
| 1315 TypeInfoExpressionKind.INSTANCE, | 1320 TypeInfoExpressionKind.INSTANCE, |
| 1316 classElement.thisType, | 1321 classElement.thisType, |
| 1317 typeArguments, | 1322 typeArguments, |
| 1318 commonMasks.dynamicType); | 1323 commonMasks.dynamicType); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1382 bodyCallInputs.add(localsHandler.readLocal(scopeData.boxElement)); | 1387 bodyCallInputs.add(localsHandler.readLocal(scopeData.boxElement)); |
| 1383 } | 1388 } |
| 1384 | 1389 |
| 1385 // Type variables arguments must come after the box (if there is one). | 1390 // Type variables arguments must come after the box (if there is one). |
| 1386 ConstructorElement constructor = | 1391 ConstructorElement constructor = |
| 1387 constructorResolvedAst.element.implementation; | 1392 constructorResolvedAst.element.implementation; |
| 1388 ClassElement currentClass = constructor.enclosingClass; | 1393 ClassElement currentClass = constructor.enclosingClass; |
| 1389 if (backend.classNeedsRti(currentClass)) { | 1394 if (backend.classNeedsRti(currentClass)) { |
| 1390 // If [currentClass] needs RTI, we add the type variables as | 1395 // If [currentClass] needs RTI, we add the type variables as |
| 1391 // parameters of the generative constructor body. | 1396 // parameters of the generative constructor body. |
| 1392 currentClass.typeVariables.forEach((TypeVariableType argument) { | 1397 currentClass.typeVariables |
| 1398 .forEach((ResolutionTypeVariableType argument) { |
| 1393 // TODO(johnniwinther): Substitute [argument] with | 1399 // TODO(johnniwinther): Substitute [argument] with |
| 1394 // `localsHandler.substInContext(argument)`. | 1400 // `localsHandler.substInContext(argument)`. |
| 1395 bodyCallInputs.add(localsHandler | 1401 bodyCallInputs.add(localsHandler |
| 1396 .readLocal(localsHandler.getTypeVariableAsLocal(argument))); | 1402 .readLocal(localsHandler.getTypeVariableAsLocal(argument))); |
| 1397 }); | 1403 }); |
| 1398 } | 1404 } |
| 1399 | 1405 |
| 1400 if (!isNativeUpgradeFactory && // TODO(13836): Fix inlining. | 1406 if (!isNativeUpgradeFactory && // TODO(13836): Fix inlining. |
| 1401 tryInlineMethod(body, null, null, bodyCallInputs, function)) { | 1407 tryInlineMethod(body, null, null, bodyCallInputs, function)) { |
| 1402 pop(); | 1408 pop(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1431 close(new HGoto()).addSuccessor(block); | 1437 close(new HGoto()).addSuccessor(block); |
| 1432 | 1438 |
| 1433 open(block); | 1439 open(block); |
| 1434 | 1440 |
| 1435 // Add the type parameters of the class as parameters of this method. This | 1441 // Add the type parameters of the class as parameters of this method. This |
| 1436 // must be done before adding the normal parameters, because their types | 1442 // must be done before adding the normal parameters, because their types |
| 1437 // may contain references to type variables. | 1443 // may contain references to type variables. |
| 1438 var enclosing = element.enclosingElement; | 1444 var enclosing = element.enclosingElement; |
| 1439 if ((element.isConstructor || element.isGenerativeConstructorBody) && | 1445 if ((element.isConstructor || element.isGenerativeConstructorBody) && |
| 1440 backend.classNeedsRti(enclosing)) { | 1446 backend.classNeedsRti(enclosing)) { |
| 1441 enclosing.typeVariables.forEach((TypeVariableType typeVariable) { | 1447 enclosing.typeVariables |
| 1448 .forEach((ResolutionTypeVariableType typeVariable) { |
| 1442 HParameterValue param = | 1449 HParameterValue param = |
| 1443 addParameter(typeVariable.element, commonMasks.nonNullType); | 1450 addParameter(typeVariable.element, commonMasks.nonNullType); |
| 1444 localsHandler.directLocals[ | 1451 localsHandler.directLocals[ |
| 1445 localsHandler.getTypeVariableAsLocal(typeVariable)] = param; | 1452 localsHandler.getTypeVariableAsLocal(typeVariable)] = param; |
| 1446 }); | 1453 }); |
| 1447 } | 1454 } |
| 1448 | 1455 |
| 1449 if (element is FunctionElement) { | 1456 if (element is FunctionElement) { |
| 1450 FunctionElement functionElement = element; | 1457 FunctionElement functionElement = element; |
| 1451 FunctionSignature signature = functionElement.functionSignature; | 1458 FunctionSignature signature = functionElement.functionSignature; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1513 if (element == backend.helpers.traceHelper) return; | 1520 if (element == backend.helpers.traceHelper) return; |
| 1514 // TODO(sigmund): create a better uuid for elements. | 1521 // TODO(sigmund): create a better uuid for elements. |
| 1515 HConstant idConstant = | 1522 HConstant idConstant = |
| 1516 graph.addConstantInt(element.hashCode, closedWorld); | 1523 graph.addConstantInt(element.hashCode, closedWorld); |
| 1517 HConstant nameConstant = addConstantString(element.name); | 1524 HConstant nameConstant = addConstantString(element.name); |
| 1518 add(new HInvokeStatic(backend.helpers.traceHelper, | 1525 add(new HInvokeStatic(backend.helpers.traceHelper, |
| 1519 <HInstruction>[idConstant, nameConstant], commonMasks.dynamicType)); | 1526 <HInstruction>[idConstant, nameConstant], commonMasks.dynamicType)); |
| 1520 } | 1527 } |
| 1521 } | 1528 } |
| 1522 | 1529 |
| 1523 void assertIsSubtype( | 1530 void assertIsSubtype(ast.Node node, ResolutionDartType subtype, |
| 1524 ast.Node node, DartType subtype, DartType supertype, String message) { | 1531 ResolutionDartType supertype, String message) { |
| 1525 HInstruction subtypeInstruction = typeBuilder.analyzeTypeArgument( | 1532 HInstruction subtypeInstruction = typeBuilder.analyzeTypeArgument( |
| 1526 localsHandler.substInContext(subtype), sourceElement); | 1533 localsHandler.substInContext(subtype), sourceElement); |
| 1527 HInstruction supertypeInstruction = typeBuilder.analyzeTypeArgument( | 1534 HInstruction supertypeInstruction = typeBuilder.analyzeTypeArgument( |
| 1528 localsHandler.substInContext(supertype), sourceElement); | 1535 localsHandler.substInContext(supertype), sourceElement); |
| 1529 HInstruction messageInstruction = graph.addConstantString( | 1536 HInstruction messageInstruction = graph.addConstantString( |
| 1530 new ast.DartString.literal(message), closedWorld); | 1537 new ast.DartString.literal(message), closedWorld); |
| 1531 MethodElement element = helpers.assertIsSubtype; | 1538 MethodElement element = helpers.assertIsSubtype; |
| 1532 var inputs = <HInstruction>[ | 1539 var inputs = <HInstruction>[ |
| 1533 subtypeInstruction, | 1540 subtypeInstruction, |
| 1534 supertypeInstruction, | 1541 supertypeInstruction, |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2386 new HInterceptor(receiver, commonMasks.nonNullType); | 2393 new HInterceptor(receiver, commonMasks.nonNullType); |
| 2387 add(interceptor); | 2394 add(interceptor); |
| 2388 return interceptor; | 2395 return interceptor; |
| 2389 } | 2396 } |
| 2390 | 2397 |
| 2391 HLiteralList buildLiteralList(List<HInstruction> inputs) { | 2398 HLiteralList buildLiteralList(List<HInstruction> inputs) { |
| 2392 return new HLiteralList(inputs, commonMasks.extendableArrayType); | 2399 return new HLiteralList(inputs, commonMasks.extendableArrayType); |
| 2393 } | 2400 } |
| 2394 | 2401 |
| 2395 @override | 2402 @override |
| 2396 void visitAs(ast.Send node, ast.Node expression, DartType type, _) { | 2403 void visitAs(ast.Send node, ast.Node expression, ResolutionDartType type, _) { |
| 2397 HInstruction expressionInstruction = visitAndPop(expression); | 2404 HInstruction expressionInstruction = visitAndPop(expression); |
| 2398 if (type.isMalformed) { | 2405 if (type.isMalformed) { |
| 2399 if (type is MalformedType) { | 2406 if (type is MalformedType) { |
| 2400 ErroneousElement element = type.element; | 2407 ErroneousElement element = type.element; |
| 2401 generateTypeError(node, element.message); | 2408 generateTypeError(node, element.message); |
| 2402 } else { | 2409 } else { |
| 2403 assert(type is MethodTypeVariableType); | 2410 assert(type is MethodTypeVariableType); |
| 2404 stack.add(expressionInstruction); | 2411 stack.add(expressionInstruction); |
| 2405 } | 2412 } |
| 2406 } else { | 2413 } else { |
| 2407 HInstruction converted = typeBuilder.buildTypeConversion( | 2414 HInstruction converted = typeBuilder.buildTypeConversion( |
| 2408 expressionInstruction, | 2415 expressionInstruction, |
| 2409 localsHandler.substInContext(type), | 2416 localsHandler.substInContext(type), |
| 2410 HTypeConversion.CAST_TYPE_CHECK); | 2417 HTypeConversion.CAST_TYPE_CHECK); |
| 2411 if (converted != expressionInstruction) add(converted); | 2418 if (converted != expressionInstruction) add(converted); |
| 2412 stack.add(converted); | 2419 stack.add(converted); |
| 2413 } | 2420 } |
| 2414 } | 2421 } |
| 2415 | 2422 |
| 2416 @override | 2423 @override |
| 2417 void visitIs(ast.Send node, ast.Node expression, DartType type, _) { | 2424 void visitIs(ast.Send node, ast.Node expression, ResolutionDartType type, _) { |
| 2418 HInstruction expressionInstruction = visitAndPop(expression); | 2425 HInstruction expressionInstruction = visitAndPop(expression); |
| 2419 push(buildIsNode(node, type, expressionInstruction)); | 2426 push(buildIsNode(node, type, expressionInstruction)); |
| 2420 } | 2427 } |
| 2421 | 2428 |
| 2422 @override | 2429 @override |
| 2423 void visitIsNot(ast.Send node, ast.Node expression, DartType type, _) { | 2430 void visitIsNot( |
| 2431 ast.Send node, ast.Node expression, ResolutionDartType type, _) { |
| 2424 HInstruction expressionInstruction = visitAndPop(expression); | 2432 HInstruction expressionInstruction = visitAndPop(expression); |
| 2425 HInstruction instruction = buildIsNode(node, type, expressionInstruction); | 2433 HInstruction instruction = buildIsNode(node, type, expressionInstruction); |
| 2426 add(instruction); | 2434 add(instruction); |
| 2427 push(new HNot(instruction, commonMasks.boolType)); | 2435 push(new HNot(instruction, commonMasks.boolType)); |
| 2428 } | 2436 } |
| 2429 | 2437 |
| 2430 HInstruction buildIsNode( | 2438 HInstruction buildIsNode( |
| 2431 ast.Node node, DartType type, HInstruction expression) { | 2439 ast.Node node, ResolutionDartType type, HInstruction expression) { |
| 2432 type = localsHandler.substInContext(type).unaliased; | 2440 type = localsHandler.substInContext(type).unaliased; |
| 2433 if (type.isMalformed) { | 2441 if (type.isMalformed) { |
| 2434 String message; | 2442 String message; |
| 2435 if (type is MethodTypeVariableType) { | 2443 if (type is MethodTypeVariableType) { |
| 2436 message = "Method type variables are not reified, " | 2444 message = "Method type variables are not reified, " |
| 2437 "so they cannot be tested with an `is` expression."; | 2445 "so they cannot be tested with an `is` expression."; |
| 2438 } else { | 2446 } else { |
| 2439 assert(type is MalformedType); | 2447 assert(type is MalformedType); |
| 2440 ErroneousElement element = type.element; | 2448 ErroneousElement element = type.element; |
| 2441 message = element.message; | 2449 message = element.message; |
| (...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3272 } | 3280 } |
| 3273 | 3281 |
| 3274 bool needsSubstitutionForTypeVariableAccess(ClassElement cls) { | 3282 bool needsSubstitutionForTypeVariableAccess(ClassElement cls) { |
| 3275 if (closedWorld.isUsedAsMixin(cls)) return true; | 3283 if (closedWorld.isUsedAsMixin(cls)) return true; |
| 3276 | 3284 |
| 3277 return closedWorld.anyStrictSubclassOf(cls, (ClassElement subclass) { | 3285 return closedWorld.anyStrictSubclassOf(cls, (ClassElement subclass) { |
| 3278 return !rti.isTrivialSubstitution(subclass, cls); | 3286 return !rti.isTrivialSubstitution(subclass, cls); |
| 3279 }); | 3287 }); |
| 3280 } | 3288 } |
| 3281 | 3289 |
| 3282 HInstruction handleListConstructor( | 3290 HInstruction handleListConstructor(ResolutionInterfaceType type, |
| 3283 InterfaceType type, ast.Node currentNode, HInstruction newObject) { | 3291 ast.Node currentNode, HInstruction newObject) { |
| 3284 if (!backend.classNeedsRti(type.element) || type.treatAsRaw) { | 3292 if (!backend.classNeedsRti(type.element) || type.treatAsRaw) { |
| 3285 return newObject; | 3293 return newObject; |
| 3286 } | 3294 } |
| 3287 List<HInstruction> inputs = <HInstruction>[]; | 3295 List<HInstruction> inputs = <HInstruction>[]; |
| 3288 type = localsHandler.substInContext(type); | 3296 type = localsHandler.substInContext(type); |
| 3289 type.typeArguments.forEach((DartType argument) { | 3297 type.typeArguments.forEach((ResolutionDartType argument) { |
| 3290 inputs.add(typeBuilder.analyzeTypeArgument(argument, sourceElement)); | 3298 inputs.add(typeBuilder.analyzeTypeArgument(argument, sourceElement)); |
| 3291 }); | 3299 }); |
| 3292 // TODO(15489): Register at codegen. | 3300 // TODO(15489): Register at codegen. |
| 3293 registry?.registerInstantiation(type); | 3301 registry?.registerInstantiation(type); |
| 3294 return callSetRuntimeTypeInfoWithTypeArguments(type, inputs, newObject); | 3302 return callSetRuntimeTypeInfoWithTypeArguments(type, inputs, newObject); |
| 3295 } | 3303 } |
| 3296 | 3304 |
| 3297 HInstruction callSetRuntimeTypeInfo( | 3305 HInstruction callSetRuntimeTypeInfo( |
| 3298 HInstruction typeInfo, HInstruction newObject) { | 3306 HInstruction typeInfo, HInstruction newObject) { |
| 3299 // Set the runtime type information on the object. | 3307 // Set the runtime type information on the object. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3389 // final target. | 3397 // final target. |
| 3390 ConstructorElement target = constructorDeclaration; | 3398 ConstructorElement target = constructorDeclaration; |
| 3391 while (target.isRedirectingFactory) { | 3399 while (target.isRedirectingFactory) { |
| 3392 if (constructorDeclaration.redirectionDeferredPrefix != null) { | 3400 if (constructorDeclaration.redirectionDeferredPrefix != null) { |
| 3393 generateIsDeferredLoadedCheckIfNeeded( | 3401 generateIsDeferredLoadedCheckIfNeeded( |
| 3394 target.redirectionDeferredPrefix, node); | 3402 target.redirectionDeferredPrefix, node); |
| 3395 } | 3403 } |
| 3396 target = target.immediateRedirectionTarget; | 3404 target = target.immediateRedirectionTarget; |
| 3397 } | 3405 } |
| 3398 } | 3406 } |
| 3399 InterfaceType type = elements.getType(node); | 3407 ResolutionInterfaceType type = elements.getType(node); |
| 3400 InterfaceType expectedType = | 3408 ResolutionInterfaceType expectedType = |
| 3401 constructorDeclaration.computeEffectiveTargetType(type); | 3409 constructorDeclaration.computeEffectiveTargetType(type); |
| 3402 expectedType = localsHandler.substInContext(expectedType); | 3410 expectedType = localsHandler.substInContext(expectedType); |
| 3403 | 3411 |
| 3404 if (compiler.elementHasCompileTimeError(constructor)) { | 3412 if (compiler.elementHasCompileTimeError(constructor)) { |
| 3405 // TODO(ahe): Do something like [generateWrongArgumentCountError]. | 3413 // TODO(ahe): Do something like [generateWrongArgumentCountError]. |
| 3406 stack.add(graph.addConstantNull(closedWorld)); | 3414 stack.add(graph.addConstantNull(closedWorld)); |
| 3407 return; | 3415 return; |
| 3408 } | 3416 } |
| 3409 | 3417 |
| 3410 if (checkTypeVariableBounds(node, type)) return; | 3418 if (checkTypeVariableBounds(node, type)) return; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3518 if (isRedirected) { | 3526 if (isRedirected) { |
| 3519 HInstruction checked = | 3527 HInstruction checked = |
| 3520 typeBuilder.potentiallyCheckOrTrustType(newInstance, type); | 3528 typeBuilder.potentiallyCheckOrTrustType(newInstance, type); |
| 3521 if (checked != newInstance) { | 3529 if (checked != newInstance) { |
| 3522 pop(); | 3530 pop(); |
| 3523 stack.add(checked); | 3531 stack.add(checked); |
| 3524 } | 3532 } |
| 3525 } | 3533 } |
| 3526 } | 3534 } |
| 3527 | 3535 |
| 3528 void potentiallyAddTypeArguments( | 3536 void potentiallyAddTypeArguments(List<HInstruction> inputs, ClassElement cls, |
| 3529 List<HInstruction> inputs, ClassElement cls, InterfaceType expectedType, | 3537 ResolutionInterfaceType expectedType, |
| 3530 {SourceInformation sourceInformation}) { | 3538 {SourceInformation sourceInformation}) { |
| 3531 if (!backend.classNeedsRti(cls)) return; | 3539 if (!backend.classNeedsRti(cls)) return; |
| 3532 assert(cls.typeVariables.length == expectedType.typeArguments.length); | 3540 assert(cls.typeVariables.length == expectedType.typeArguments.length); |
| 3533 expectedType.typeArguments.forEach((DartType argument) { | 3541 expectedType.typeArguments.forEach((ResolutionDartType argument) { |
| 3534 inputs.add(typeBuilder.analyzeTypeArgument(argument, sourceElement, | 3542 inputs.add(typeBuilder.analyzeTypeArgument(argument, sourceElement, |
| 3535 sourceInformation: sourceInformation)); | 3543 sourceInformation: sourceInformation)); |
| 3536 }); | 3544 }); |
| 3537 } | 3545 } |
| 3538 | 3546 |
| 3539 /// In checked mode checks the [type] of [node] to be well-bounded. The method | 3547 /// In checked mode checks the [type] of [node] to be well-bounded. The method |
| 3540 /// returns [:true:] if an error can be statically determined. | 3548 /// returns [:true:] if an error can be statically determined. |
| 3541 bool checkTypeVariableBounds(ast.NewExpression node, InterfaceType type) { | 3549 bool checkTypeVariableBounds( |
| 3550 ast.NewExpression node, ResolutionInterfaceType type) { |
| 3542 if (!compiler.options.enableTypeAssertions) return false; | 3551 if (!compiler.options.enableTypeAssertions) return false; |
| 3543 | 3552 |
| 3544 Map<DartType, Set<DartType>> seenChecksMap = | 3553 Map<ResolutionDartType, Set<ResolutionDartType>> seenChecksMap = |
| 3545 new Map<DartType, Set<DartType>>(); | 3554 new Map<ResolutionDartType, Set<ResolutionDartType>>(); |
| 3546 bool definitelyFails = false; | 3555 bool definitelyFails = false; |
| 3547 | 3556 |
| 3548 void addTypeVariableBoundCheck(GenericType instance, DartType typeArgument, | 3557 void addTypeVariableBoundCheck( |
| 3549 TypeVariableType typeVariable, DartType bound) { | 3558 GenericType instance, |
| 3559 ResolutionDartType typeArgument, |
| 3560 ResolutionTypeVariableType typeVariable, |
| 3561 ResolutionDartType bound) { |
| 3550 if (definitelyFails) return; | 3562 if (definitelyFails) return; |
| 3551 | 3563 |
| 3552 int subtypeRelation = | 3564 int subtypeRelation = |
| 3553 compiler.types.computeSubtypeRelation(typeArgument, bound); | 3565 compiler.types.computeSubtypeRelation(typeArgument, bound); |
| 3554 if (subtypeRelation == Types.IS_SUBTYPE) return; | 3566 if (subtypeRelation == Types.IS_SUBTYPE) return; |
| 3555 | 3567 |
| 3556 String message = "Can't create an instance of malbounded type '$type': " | 3568 String message = "Can't create an instance of malbounded type '$type': " |
| 3557 "'${typeArgument}' is not a subtype of bound '${bound}' for " | 3569 "'${typeArgument}' is not a subtype of bound '${bound}' for " |
| 3558 "type variable '${typeVariable}' of type " | 3570 "type variable '${typeVariable}' of type " |
| 3559 "${type == instance | 3571 "${type == instance |
| 3560 ? "'${type.element.thisType}'" | 3572 ? "'${type.element.thisType}'" |
| 3561 : "'${instance.element.thisType}' on the supertype " | 3573 : "'${instance.element.thisType}' on the supertype " |
| 3562 "'${instance}' of '${type}'" | 3574 "'${instance}' of '${type}'" |
| 3563 }."; | 3575 }."; |
| 3564 if (subtypeRelation == Types.NOT_SUBTYPE) { | 3576 if (subtypeRelation == Types.NOT_SUBTYPE) { |
| 3565 generateTypeError(node, message); | 3577 generateTypeError(node, message); |
| 3566 definitelyFails = true; | 3578 definitelyFails = true; |
| 3567 return; | 3579 return; |
| 3568 } else if (subtypeRelation == Types.MAYBE_SUBTYPE) { | 3580 } else if (subtypeRelation == Types.MAYBE_SUBTYPE) { |
| 3569 Set<DartType> seenChecks = | 3581 Set<ResolutionDartType> seenChecks = seenChecksMap.putIfAbsent( |
| 3570 seenChecksMap.putIfAbsent(typeArgument, () => new Set<DartType>()); | 3582 typeArgument, () => new Set<ResolutionDartType>()); |
| 3571 if (!seenChecks.contains(bound)) { | 3583 if (!seenChecks.contains(bound)) { |
| 3572 seenChecks.add(bound); | 3584 seenChecks.add(bound); |
| 3573 assertIsSubtype(node, typeArgument, bound, message); | 3585 assertIsSubtype(node, typeArgument, bound, message); |
| 3574 } | 3586 } |
| 3575 } | 3587 } |
| 3576 } | 3588 } |
| 3577 | 3589 |
| 3578 compiler.types.checkTypeVariableBounds(type, addTypeVariableBoundCheck); | 3590 compiler.types.checkTypeVariableBounds(type, addTypeVariableBoundCheck); |
| 3579 if (definitelyFails) { | 3591 if (definitelyFails) { |
| 3580 return true; | 3592 return true; |
| 3581 } | 3593 } |
| 3582 for (InterfaceType supertype in type.element.allSupertypes) { | 3594 for (ResolutionInterfaceType supertype in type.element.allSupertypes) { |
| 3583 DartType instance = type.asInstanceOf(supertype.element); | 3595 ResolutionDartType instance = type.asInstanceOf(supertype.element); |
| 3584 compiler.types | 3596 compiler.types |
| 3585 .checkTypeVariableBounds(instance, addTypeVariableBoundCheck); | 3597 .checkTypeVariableBounds(instance, addTypeVariableBoundCheck); |
| 3586 if (definitelyFails) { | 3598 if (definitelyFails) { |
| 3587 return true; | 3599 return true; |
| 3588 } | 3600 } |
| 3589 } | 3601 } |
| 3590 return false; | 3602 return false; |
| 3591 } | 3603 } |
| 3592 | 3604 |
| 3593 visitStaticSend(ast.Send node) { | 3605 visitStaticSend(ast.Send node) { |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3790 // The node itself is not a constant but we register the selector (the | 3802 // The node itself is not a constant but we register the selector (the |
| 3791 // identifier that refers to the class/typedef) as a constant. | 3803 // identifier that refers to the class/typedef) as a constant. |
| 3792 stack.add(addConstant(node.selector)); | 3804 stack.add(addConstant(node.selector)); |
| 3793 } else { | 3805 } else { |
| 3794 stack.add(addConstant(node)); | 3806 stack.add(addConstant(node)); |
| 3795 } | 3807 } |
| 3796 } | 3808 } |
| 3797 | 3809 |
| 3798 /// Generate the literal for [typeVariable] in the current context. | 3810 /// Generate the literal for [typeVariable] in the current context. |
| 3799 void generateTypeVariableLiteral( | 3811 void generateTypeVariableLiteral( |
| 3800 ast.Send node, TypeVariableType typeVariable) { | 3812 ast.Send node, ResolutionTypeVariableType typeVariable) { |
| 3801 // GENERIC_METHODS: This provides thin support for method type variables | 3813 // GENERIC_METHODS: This provides thin support for method type variables |
| 3802 // by treating them as malformed when evaluated as a literal. For full | 3814 // by treating them as malformed when evaluated as a literal. For full |
| 3803 // support of generic methods this must be revised. | 3815 // support of generic methods this must be revised. |
| 3804 if (typeVariable is MethodTypeVariableType) { | 3816 if (typeVariable is MethodTypeVariableType) { |
| 3805 generateTypeError(node, "Method type variables are not reified"); | 3817 generateTypeError(node, "Method type variables are not reified"); |
| 3806 } else { | 3818 } else { |
| 3807 DartType type = localsHandler.substInContext(typeVariable); | 3819 ResolutionDartType type = localsHandler.substInContext(typeVariable); |
| 3808 HInstruction value = typeBuilder.analyzeTypeArgument(type, sourceElement, | 3820 HInstruction value = typeBuilder.analyzeTypeArgument(type, sourceElement, |
| 3809 sourceInformation: sourceInformationBuilder.buildGet(node)); | 3821 sourceInformation: sourceInformationBuilder.buildGet(node)); |
| 3810 pushInvokeStatic(node, helpers.runtimeTypeToString, [value], | 3822 pushInvokeStatic(node, helpers.runtimeTypeToString, [value], |
| 3811 typeMask: commonMasks.stringType); | 3823 typeMask: commonMasks.stringType); |
| 3812 pushInvokeStatic(node, helpers.createRuntimeType, [pop()]); | 3824 pushInvokeStatic(node, helpers.createRuntimeType, [pop()]); |
| 3813 } | 3825 } |
| 3814 } | 3826 } |
| 3815 | 3827 |
| 3816 /// Generate a call to a type literal. | 3828 /// Generate a call to a type literal. |
| 3817 void generateTypeLiteralCall(ast.Send node) { | 3829 void generateTypeLiteralCall(ast.Send node) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3956 } | 3968 } |
| 3957 } else { | 3969 } else { |
| 3958 handleNewSend(node); | 3970 handleNewSend(node); |
| 3959 } | 3971 } |
| 3960 } | 3972 } |
| 3961 | 3973 |
| 3962 @override | 3974 @override |
| 3963 void errorNonConstantConstructorInvoke( | 3975 void errorNonConstantConstructorInvoke( |
| 3964 ast.NewExpression node, | 3976 ast.NewExpression node, |
| 3965 Element element, | 3977 Element element, |
| 3966 DartType type, | 3978 ResolutionDartType type, |
| 3967 ast.NodeList arguments, | 3979 ast.NodeList arguments, |
| 3968 CallStructure callStructure, | 3980 CallStructure callStructure, |
| 3969 _) { | 3981 _) { |
| 3970 bulkHandleNew(node); | 3982 bulkHandleNew(node); |
| 3971 } | 3983 } |
| 3972 | 3984 |
| 3973 void pushInvokeDynamic(ast.Node node, Selector selector, TypeMask mask, | 3985 void pushInvokeDynamic(ast.Node node, Selector selector, TypeMask mask, |
| 3974 List<HInstruction> arguments, | 3986 List<HInstruction> arguments, |
| 3975 {SourceInformation sourceInformation}) { | 3987 {SourceInformation sourceInformation}) { |
| 3976 // We prefer to not inline certain operations on indexables, | 3988 // We prefer to not inline certain operations on indexables, |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4089 // Strip off trailing arguments that were not specified. | 4101 // Strip off trailing arguments that were not specified. |
| 4090 // we could assert that the trailing arguments are all null. | 4102 // we could assert that the trailing arguments are all null. |
| 4091 // TODO(jacobr): rewrite named arguments to an object literal matching | 4103 // TODO(jacobr): rewrite named arguments to an object literal matching |
| 4092 // the factory constructor case. | 4104 // the factory constructor case. |
| 4093 arguments = arguments.where((arg) => arg != null).toList(); | 4105 arguments = arguments.where((arg) => arg != null).toList(); |
| 4094 var inputs = <HInstruction>[target]..addAll(arguments); | 4106 var inputs = <HInstruction>[target]..addAll(arguments); |
| 4095 | 4107 |
| 4096 var nativeBehavior = new native.NativeBehavior() | 4108 var nativeBehavior = new native.NativeBehavior() |
| 4097 ..sideEffects.setAllSideEffects(); | 4109 ..sideEffects.setAllSideEffects(); |
| 4098 | 4110 |
| 4099 DartType type = element.isConstructor | 4111 ResolutionDartType type = element.isConstructor |
| 4100 ? element.enclosingClass.thisType | 4112 ? element.enclosingClass.thisType |
| 4101 : element.type.returnType; | 4113 : element.type.returnType; |
| 4102 // Native behavior effects here are similar to native/behavior.dart. | 4114 // Native behavior effects here are similar to native/behavior.dart. |
| 4103 // The return type is dynamic if we don't trust js-interop type | 4115 // The return type is dynamic if we don't trust js-interop type |
| 4104 // declarations. | 4116 // declarations. |
| 4105 nativeBehavior.typesReturned.add( | 4117 nativeBehavior.typesReturned.add( |
| 4106 compiler.options.trustJSInteropTypeAnnotations | 4118 compiler.options.trustJSInteropTypeAnnotations |
| 4107 ? type | 4119 ? type |
| 4108 : const DynamicType()); | 4120 : const ResolutionDynamicType()); |
| 4109 | 4121 |
| 4110 // The allocation effects include the declared type if it is native (which | 4122 // The allocation effects include the declared type if it is native (which |
| 4111 // includes js interop types). | 4123 // includes js interop types). |
| 4112 if (type.element != null && backend.isNative(type.element)) { | 4124 if (type.element != null && backend.isNative(type.element)) { |
| 4113 nativeBehavior.typesInstantiated.add(type); | 4125 nativeBehavior.typesInstantiated.add(type); |
| 4114 } | 4126 } |
| 4115 | 4127 |
| 4116 // It also includes any other JS interop type if we don't trust the | 4128 // It also includes any other JS interop type if we don't trust the |
| 4117 // annotation or if is declared too broad. | 4129 // annotation or if is declared too broad. |
| 4118 if (!compiler.options.trustJSInteropTypeAnnotations || | 4130 if (!compiler.options.trustJSInteropTypeAnnotations || |
| (...skipping 15 matching lines...) Expand all Loading... |
| 4134 js.Template codeTemplate = js.js.parseForeignJS(code); | 4146 js.Template codeTemplate = js.js.parseForeignJS(code); |
| 4135 nativeBehavior.codeTemplate = codeTemplate; | 4147 nativeBehavior.codeTemplate = codeTemplate; |
| 4136 | 4148 |
| 4137 return new HForeignCode(codeTemplate, commonMasks.dynamicType, inputs, | 4149 return new HForeignCode(codeTemplate, commonMasks.dynamicType, inputs, |
| 4138 nativeBehavior: nativeBehavior)..sourceInformation = sourceInformation; | 4150 nativeBehavior: nativeBehavior)..sourceInformation = sourceInformation; |
| 4139 } | 4151 } |
| 4140 | 4152 |
| 4141 void pushInvokeStatic( | 4153 void pushInvokeStatic( |
| 4142 ast.Node location, MethodElement element, List<HInstruction> arguments, | 4154 ast.Node location, MethodElement element, List<HInstruction> arguments, |
| 4143 {TypeMask typeMask, | 4155 {TypeMask typeMask, |
| 4144 InterfaceType instanceType, | 4156 ResolutionInterfaceType instanceType, |
| 4145 SourceInformation sourceInformation}) { | 4157 SourceInformation sourceInformation}) { |
| 4146 assert(element.isDeclaration); | 4158 assert(element.isDeclaration); |
| 4147 // TODO(johnniwinther): Use [sourceInformation] instead of [location]. | 4159 // TODO(johnniwinther): Use [sourceInformation] instead of [location]. |
| 4148 if (tryInlineMethod(element, null, null, arguments, location, | 4160 if (tryInlineMethod(element, null, null, arguments, location, |
| 4149 instanceType: instanceType)) { | 4161 instanceType: instanceType)) { |
| 4150 return; | 4162 return; |
| 4151 } | 4163 } |
| 4152 | 4164 |
| 4153 if (typeMask == null) { | 4165 if (typeMask == null) { |
| 4154 typeMask = TypeMaskFactory.inferredReturnTypeForElement( | 4166 typeMask = TypeMaskFactory.inferredReturnTypeForElement( |
| 4155 element, globalInferenceResults); | 4167 element, globalInferenceResults); |
| 4156 } | 4168 } |
| 4157 bool targetCanThrow = !closedWorld.getCannotThrow(element); | 4169 bool targetCanThrow = !closedWorld.getCannotThrow(element); |
| 4158 // TODO(5346): Try to avoid the need for calling [declaration] before | 4170 // TODO(5346): Try to avoid the need for calling [declaration] before |
| 4159 var instruction; | 4171 var instruction; |
| 4160 if (backend.isJsInterop(element)) { | 4172 if (backend.isJsInterop(element)) { |
| 4161 instruction = | 4173 instruction = |
| 4162 invokeJsInteropFunction(element, arguments, sourceInformation); | 4174 invokeJsInteropFunction(element, arguments, sourceInformation); |
| 4163 } else { | 4175 } else { |
| 4164 // creating an [HInvokeStatic]. | 4176 // creating an [HInvokeStatic]. |
| 4165 instruction = new HInvokeStatic(element, arguments, typeMask, | 4177 instruction = new HInvokeStatic(element, arguments, typeMask, |
| 4166 targetCanThrow: targetCanThrow) | 4178 targetCanThrow: targetCanThrow) |
| 4167 ..sourceInformation = sourceInformation; | 4179 ..sourceInformation = sourceInformation; |
| 4168 if (currentInlinedInstantiations.isNotEmpty) { | 4180 if (currentInlinedInstantiations.isNotEmpty) { |
| 4169 instruction.instantiatedTypes = | 4181 instruction.instantiatedTypes = |
| 4170 new List<DartType>.from(currentInlinedInstantiations); | 4182 new List<ResolutionDartType>.from(currentInlinedInstantiations); |
| 4171 } | 4183 } |
| 4172 instruction.sideEffects = closedWorld.getSideEffectsOfElement(element); | 4184 instruction.sideEffects = closedWorld.getSideEffectsOfElement(element); |
| 4173 } | 4185 } |
| 4174 if (location == null) { | 4186 if (location == null) { |
| 4175 push(instruction); | 4187 push(instruction); |
| 4176 } else { | 4188 } else { |
| 4177 pushWithPosition(instruction, location); | 4189 pushWithPosition(instruction, location); |
| 4178 } | 4190 } |
| 4179 } | 4191 } |
| 4180 | 4192 |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5120 } else { | 5132 } else { |
| 5121 for (ParameterElement parameter in targetOptionals) { | 5133 for (ParameterElement parameter in targetOptionals) { |
| 5122 loadPosition(position++, parameter); | 5134 loadPosition(position++, parameter); |
| 5123 } | 5135 } |
| 5124 } | 5136 } |
| 5125 } | 5137 } |
| 5126 | 5138 |
| 5127 ClassElement targetClass = targetConstructor.enclosingClass; | 5139 ClassElement targetClass = targetConstructor.enclosingClass; |
| 5128 if (backend.classNeedsRti(targetClass)) { | 5140 if (backend.classNeedsRti(targetClass)) { |
| 5129 ClassElement cls = redirectingConstructor.enclosingClass; | 5141 ClassElement cls = redirectingConstructor.enclosingClass; |
| 5130 InterfaceType targetType = | 5142 ResolutionInterfaceType targetType = |
| 5131 redirectingConstructor.computeEffectiveTargetType(cls.thisType); | 5143 redirectingConstructor.computeEffectiveTargetType(cls.thisType); |
| 5132 targetType = localsHandler.substInContext(targetType); | 5144 targetType = localsHandler.substInContext(targetType); |
| 5133 targetType.typeArguments.forEach((DartType argument) { | 5145 targetType.typeArguments.forEach((ResolutionDartType argument) { |
| 5134 inputs.add(typeBuilder.analyzeTypeArgument(argument, sourceElement)); | 5146 inputs.add(typeBuilder.analyzeTypeArgument(argument, sourceElement)); |
| 5135 }); | 5147 }); |
| 5136 } | 5148 } |
| 5137 pushInvokeStatic(node, targetConstructor.declaration, inputs); | 5149 pushInvokeStatic(node, targetConstructor.declaration, inputs); |
| 5138 HInstruction value = pop(); | 5150 HInstruction value = pop(); |
| 5139 emitReturn(value, node); | 5151 emitReturn(value, node); |
| 5140 } | 5152 } |
| 5141 | 5153 |
| 5142 /// Returns true if the [type] is a valid return type for an asynchronous | 5154 /// Returns true if the [type] is a valid return type for an asynchronous |
| 5143 /// function. | 5155 /// function. |
| 5144 /// | 5156 /// |
| 5145 /// Asynchronous functions return a `Future`, and a valid return is thus | 5157 /// Asynchronous functions return a `Future`, and a valid return is thus |
| 5146 /// either dynamic, Object, or Future. | 5158 /// either dynamic, Object, or Future. |
| 5147 /// | 5159 /// |
| 5148 /// We do not accept the internal Future implementation class. | 5160 /// We do not accept the internal Future implementation class. |
| 5149 bool isValidAsyncReturnType(DartType type) { | 5161 bool isValidAsyncReturnType(ResolutionDartType type) { |
| 5150 assert(isBuildingAsyncFunction); | 5162 assert(isBuildingAsyncFunction); |
| 5151 // TODO(sigurdm): In an internal library a function could be declared: | 5163 // TODO(sigurdm): In an internal library a function could be declared: |
| 5152 // | 5164 // |
| 5153 // _FutureImpl foo async => 1; | 5165 // _FutureImpl foo async => 1; |
| 5154 // | 5166 // |
| 5155 // This should be valid (because the actual value returned from an async | 5167 // This should be valid (because the actual value returned from an async |
| 5156 // function is a `_FutureImpl`), but currently false is returned in this | 5168 // function is a `_FutureImpl`), but currently false is returned in this |
| 5157 // case. | 5169 // case. |
| 5158 return type.isDynamic || | 5170 return type.isDynamic || |
| 5159 type.isObject || | 5171 type.isObject || |
| 5160 (type is InterfaceType && type.element == commonElements.futureClass); | 5172 (type is ResolutionInterfaceType && |
| 5173 type.element == commonElements.futureClass); |
| 5161 } | 5174 } |
| 5162 | 5175 |
| 5163 visitReturn(ast.Return node) { | 5176 visitReturn(ast.Return node) { |
| 5164 if (identical(node.beginToken.stringValue, 'native')) { | 5177 if (identical(node.beginToken.stringValue, 'native')) { |
| 5165 native.handleSsaNative(this, node.expression); | 5178 native.handleSsaNative(this, node.expression); |
| 5166 return; | 5179 return; |
| 5167 } | 5180 } |
| 5168 HInstruction value; | 5181 HInstruction value; |
| 5169 if (node.expression == null) { | 5182 if (node.expression == null) { |
| 5170 value = graph.addConstantNull(closedWorld); | 5183 value = graph.addConstantNull(closedWorld); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5230 } else { | 5243 } else { |
| 5231 ast.SendSet node = definition; | 5244 ast.SendSet node = definition; |
| 5232 generateNonInstanceSetter( | 5245 generateNonInstanceSetter( |
| 5233 node, local, visitAndPop(node.arguments.first)); | 5246 node, local, visitAndPop(node.arguments.first)); |
| 5234 pop(); // Discard value. | 5247 pop(); // Discard value. |
| 5235 } | 5248 } |
| 5236 } | 5249 } |
| 5237 } | 5250 } |
| 5238 | 5251 |
| 5239 HInstruction setRtiIfNeeded(HInstruction object, ast.Node node) { | 5252 HInstruction setRtiIfNeeded(HInstruction object, ast.Node node) { |
| 5240 InterfaceType type = localsHandler.substInContext(elements.getType(node)); | 5253 ResolutionInterfaceType type = |
| 5254 localsHandler.substInContext(elements.getType(node)); |
| 5241 if (!backend.classNeedsRti(type.element) || type.treatAsRaw) { | 5255 if (!backend.classNeedsRti(type.element) || type.treatAsRaw) { |
| 5242 return object; | 5256 return object; |
| 5243 } | 5257 } |
| 5244 List<HInstruction> arguments = <HInstruction>[]; | 5258 List<HInstruction> arguments = <HInstruction>[]; |
| 5245 for (DartType argument in type.typeArguments) { | 5259 for (ResolutionDartType argument in type.typeArguments) { |
| 5246 arguments.add(typeBuilder.analyzeTypeArgument(argument, sourceElement)); | 5260 arguments.add(typeBuilder.analyzeTypeArgument(argument, sourceElement)); |
| 5247 } | 5261 } |
| 5248 // TODO(15489): Register at codegen. | 5262 // TODO(15489): Register at codegen. |
| 5249 registry?.registerInstantiation(type); | 5263 registry?.registerInstantiation(type); |
| 5250 return callSetRuntimeTypeInfoWithTypeArguments(type, arguments, object); | 5264 return callSetRuntimeTypeInfoWithTypeArguments(type, arguments, object); |
| 5251 } | 5265 } |
| 5252 | 5266 |
| 5253 visitLiteralList(ast.LiteralList node) { | 5267 visitLiteralList(ast.LiteralList node) { |
| 5254 HInstruction instruction; | 5268 HInstruction instruction; |
| 5255 | 5269 |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5667 HLiteralList keyValuePairs = buildLiteralList(listInputs); | 5681 HLiteralList keyValuePairs = buildLiteralList(listInputs); |
| 5668 add(keyValuePairs); | 5682 add(keyValuePairs); |
| 5669 inputs.add(keyValuePairs); | 5683 inputs.add(keyValuePairs); |
| 5670 } | 5684 } |
| 5671 | 5685 |
| 5672 assert(constructor.isFactoryConstructor); | 5686 assert(constructor.isFactoryConstructor); |
| 5673 | 5687 |
| 5674 ConstructorElement functionElement = constructor; | 5688 ConstructorElement functionElement = constructor; |
| 5675 constructor = functionElement.effectiveTarget; | 5689 constructor = functionElement.effectiveTarget; |
| 5676 | 5690 |
| 5677 InterfaceType type = elements.getType(node); | 5691 ResolutionInterfaceType type = elements.getType(node); |
| 5678 InterfaceType expectedType = | 5692 ResolutionInterfaceType expectedType = |
| 5679 functionElement.computeEffectiveTargetType(type); | 5693 functionElement.computeEffectiveTargetType(type); |
| 5680 expectedType = localsHandler.substInContext(expectedType); | 5694 expectedType = localsHandler.substInContext(expectedType); |
| 5681 | 5695 |
| 5682 ClassElement cls = constructor.enclosingClass; | 5696 ClassElement cls = constructor.enclosingClass; |
| 5683 | 5697 |
| 5684 if (backend.classNeedsRti(cls)) { | 5698 if (backend.classNeedsRti(cls)) { |
| 5685 List<HInstruction> typeInputs = <HInstruction>[]; | 5699 List<HInstruction> typeInputs = <HInstruction>[]; |
| 5686 expectedType.typeArguments.forEach((DartType argument) { | 5700 expectedType.typeArguments.forEach((ResolutionDartType argument) { |
| 5687 typeInputs | 5701 typeInputs |
| 5688 .add(typeBuilder.analyzeTypeArgument(argument, sourceElement)); | 5702 .add(typeBuilder.analyzeTypeArgument(argument, sourceElement)); |
| 5689 }); | 5703 }); |
| 5690 | 5704 |
| 5691 // We lift this common call pattern into a helper function to save space | 5705 // We lift this common call pattern into a helper function to save space |
| 5692 // in the output. | 5706 // in the output. |
| 5693 if (typeInputs.every((HInstruction input) => input.isNull())) { | 5707 if (typeInputs.every((HInstruction input) => input.isNull())) { |
| 5694 if (listInputs.isEmpty) { | 5708 if (listInputs.isEmpty) { |
| 5695 constructor = helpers.mapLiteralUntypedEmptyMaker; | 5709 constructor = helpers.mapLiteralUntypedEmptyMaker; |
| 5696 } else { | 5710 } else { |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6237 HInstruction oldRethrowableException = rethrowableException; | 6251 HInstruction oldRethrowableException = rethrowableException; |
| 6238 rethrowableException = exception; | 6252 rethrowableException = exception; |
| 6239 | 6253 |
| 6240 pushInvokeStatic(node, helpers.exceptionUnwrapper, [exception]); | 6254 pushInvokeStatic(node, helpers.exceptionUnwrapper, [exception]); |
| 6241 HInvokeStatic unwrappedException = pop(); | 6255 HInvokeStatic unwrappedException = pop(); |
| 6242 tryInstruction.exception = exception; | 6256 tryInstruction.exception = exception; |
| 6243 Link<ast.Node> link = node.catchBlocks.nodes; | 6257 Link<ast.Node> link = node.catchBlocks.nodes; |
| 6244 | 6258 |
| 6245 void pushCondition(ast.CatchBlock catchBlock) { | 6259 void pushCondition(ast.CatchBlock catchBlock) { |
| 6246 if (catchBlock.onKeyword != null) { | 6260 if (catchBlock.onKeyword != null) { |
| 6247 DartType type = elements.getType(catchBlock.type); | 6261 ResolutionDartType type = elements.getType(catchBlock.type); |
| 6248 if (type == null) { | 6262 if (type == null) { |
| 6249 reporter.internalError(catchBlock.type, 'On with no type.'); | 6263 reporter.internalError(catchBlock.type, 'On with no type.'); |
| 6250 } | 6264 } |
| 6251 HInstruction condition = | 6265 HInstruction condition = |
| 6252 buildIsNode(catchBlock.type, type, unwrappedException); | 6266 buildIsNode(catchBlock.type, type, unwrappedException); |
| 6253 push(condition); | 6267 push(condition); |
| 6254 } else { | 6268 } else { |
| 6255 ast.VariableDefinitions declaration = catchBlock.formals.nodes.head; | 6269 ast.VariableDefinitions declaration = catchBlock.formals.nodes.head; |
| 6256 HInstruction condition = null; | 6270 HInstruction condition = null; |
| 6257 if (declaration.type == null) { | 6271 if (declaration.type == null) { |
| 6258 condition = graph.addConstantBool(true, closedWorld); | 6272 condition = graph.addConstantBool(true, closedWorld); |
| 6259 stack.add(condition); | 6273 stack.add(condition); |
| 6260 } else { | 6274 } else { |
| 6261 // TODO(aprelev@gmail.com): Once old catch syntax is removed | 6275 // TODO(aprelev@gmail.com): Once old catch syntax is removed |
| 6262 // "if" condition above and this "else" branch should be deleted as | 6276 // "if" condition above and this "else" branch should be deleted as |
| 6263 // type of declared variable won't matter for the catch | 6277 // type of declared variable won't matter for the catch |
| 6264 // condition. | 6278 // condition. |
| 6265 DartType type = elements.getType(declaration.type); | 6279 ResolutionDartType type = elements.getType(declaration.type); |
| 6266 if (type == null) { | 6280 if (type == null) { |
| 6267 reporter.internalError(catchBlock, 'Catch with unresolved type.'); | 6281 reporter.internalError(catchBlock, 'Catch with unresolved type.'); |
| 6268 } | 6282 } |
| 6269 condition = buildIsNode(declaration.type, type, unwrappedException); | 6283 condition = buildIsNode(declaration.type, type, unwrappedException); |
| 6270 push(condition); | 6284 push(condition); |
| 6271 } | 6285 } |
| 6272 } | 6286 } |
| 6273 } | 6287 } |
| 6274 | 6288 |
| 6275 void visitThen() { | 6289 void visitThen() { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6408 visitTypeVariable(ast.TypeVariable node) { | 6422 visitTypeVariable(ast.TypeVariable node) { |
| 6409 reporter.internalError(node, 'SsaFromAstMixin.visitTypeVariable.'); | 6423 reporter.internalError(node, 'SsaFromAstMixin.visitTypeVariable.'); |
| 6410 } | 6424 } |
| 6411 | 6425 |
| 6412 /** | 6426 /** |
| 6413 * This method is invoked before inlining the body of [function] into this | 6427 * This method is invoked before inlining the body of [function] into this |
| 6414 * [SsaBuilder]. | 6428 * [SsaBuilder]. |
| 6415 */ | 6429 */ |
| 6416 void enterInlinedMethod(MethodElement function, | 6430 void enterInlinedMethod(MethodElement function, |
| 6417 ResolvedAst functionResolvedAst, List<HInstruction> compiledArguments, | 6431 ResolvedAst functionResolvedAst, List<HInstruction> compiledArguments, |
| 6418 {InterfaceType instanceType}) { | 6432 {ResolutionInterfaceType instanceType}) { |
| 6419 AstInliningState state = new AstInliningState( | 6433 AstInliningState state = new AstInliningState( |
| 6420 function, | 6434 function, |
| 6421 returnLocal, | 6435 returnLocal, |
| 6422 returnType, | 6436 returnType, |
| 6423 resolvedAst, | 6437 resolvedAst, |
| 6424 stack, | 6438 stack, |
| 6425 localsHandler, | 6439 localsHandler, |
| 6426 inTryStatement, | 6440 inTryStatement, |
| 6427 isCalledOnce(function), | 6441 isCalledOnce(function), |
| 6428 elementInferenceResults); | 6442 elementInferenceResults); |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6735 */ | 6749 */ |
| 6736 final FunctionElement function; | 6750 final FunctionElement function; |
| 6737 | 6751 |
| 6738 InliningState(this.function) { | 6752 InliningState(this.function) { |
| 6739 assert(function.isImplementation); | 6753 assert(function.isImplementation); |
| 6740 } | 6754 } |
| 6741 } | 6755 } |
| 6742 | 6756 |
| 6743 class AstInliningState extends InliningState { | 6757 class AstInliningState extends InliningState { |
| 6744 final Local oldReturnLocal; | 6758 final Local oldReturnLocal; |
| 6745 final DartType oldReturnType; | 6759 final ResolutionDartType oldReturnType; |
| 6746 final ResolvedAst oldResolvedAst; | 6760 final ResolvedAst oldResolvedAst; |
| 6747 final List<HInstruction> oldStack; | 6761 final List<HInstruction> oldStack; |
| 6748 final LocalsHandler oldLocalsHandler; | 6762 final LocalsHandler oldLocalsHandler; |
| 6749 final bool inTryStatement; | 6763 final bool inTryStatement; |
| 6750 final bool allFunctionsCalledOnce; | 6764 final bool allFunctionsCalledOnce; |
| 6751 final GlobalTypeInferenceElementResult oldElementInferenceResults; | 6765 final GlobalTypeInferenceElementResult oldElementInferenceResults; |
| 6752 | 6766 |
| 6753 AstInliningState( | 6767 AstInliningState( |
| 6754 FunctionElement function, | 6768 FunctionElement function, |
| 6755 this.oldReturnLocal, | 6769 this.oldReturnLocal, |
| 6756 this.oldReturnType, | 6770 this.oldReturnType, |
| 6757 this.oldResolvedAst, | 6771 this.oldResolvedAst, |
| 6758 this.oldStack, | 6772 this.oldStack, |
| 6759 this.oldLocalsHandler, | 6773 this.oldLocalsHandler, |
| 6760 this.inTryStatement, | 6774 this.inTryStatement, |
| 6761 this.allFunctionsCalledOnce, | 6775 this.allFunctionsCalledOnce, |
| 6762 this.oldElementInferenceResults) | 6776 this.oldElementInferenceResults) |
| 6763 : super(function); | 6777 : super(function); |
| 6764 } | 6778 } |
| OLD | NEW |