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 js_backend; | 5 part of js_backend; |
6 | 6 |
7 const VERBOSE_OPTIMIZER_HINTS = false; | 7 const VERBOSE_OPTIMIZER_HINTS = false; |
8 | 8 |
9 class JavaScriptItemCompilationContext extends ItemCompilationContext { | 9 class JavaScriptItemCompilationContext extends ItemCompilationContext { |
10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); | 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); |
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1413 Element element = find(isolateHelperLibrary, name); | 1413 Element element = find(isolateHelperLibrary, name); |
1414 enqueuer.addToWorkList(element); | 1414 enqueuer.addToWorkList(element); |
1415 compiler.globalDependencies.registerDependency(element); | 1415 compiler.globalDependencies.registerDependency(element); |
1416 helpersUsed.add(element.declaration); | 1416 helpersUsed.add(element.declaration); |
1417 } | 1417 } |
1418 } else { | 1418 } else { |
1419 enqueuer.addToWorkList(find(isolateHelperLibrary, START_ROOT_ISOLATE)); | 1419 enqueuer.addToWorkList(find(isolateHelperLibrary, START_ROOT_ISOLATE)); |
1420 } | 1420 } |
1421 } | 1421 } |
1422 | 1422 |
1423 void registerRequiredType(DartType type, Element enclosingElement) { | 1423 void registerRequiredType(DartType type) { |
1424 // If [argument] has type variables or is a type variable, this method | 1424 // If [argument] has type variables or is a type variable, this method |
1425 // registers a RTI dependency between the class where the type variable is | 1425 // registers a RTI dependency between the class where the type variable is |
1426 // defined (that is the enclosing class of the current element being | 1426 // defined (that is the enclosing class of the current element being |
1427 // resolved) and the class of [type]. If the class of [type] requires RTI, | 1427 // resolved) and the class of [type]. If the class of [type] requires RTI, |
1428 // then the class of the type variable does too. | 1428 // then the class of the type variable does too. |
1429 ClassElement contextClass = Types.getClassContext(type); | 1429 ClassElement contextClass = Types.getClassContext(type); |
1430 if (contextClass != null) { | 1430 if (contextClass != null) { |
1431 assert(contextClass == enclosingElement.enclosingClass.declaration); | |
1432 rti.registerRtiDependency(type.element, contextClass); | 1431 rti.registerRtiDependency(type.element, contextClass); |
1433 } | 1432 } |
1434 } | 1433 } |
1435 | 1434 |
1436 bool classNeedsRti(ClassElement cls) { | 1435 bool classNeedsRti(ClassElement cls) { |
1437 return rti.classesNeedingRti.contains(cls.declaration) || | 1436 return rti.classesNeedingRti.contains(cls.declaration) || |
1438 compiler.enabledRuntimeType; | 1437 compiler.enabledRuntimeType; |
1439 } | 1438 } |
1440 | 1439 |
1441 bool isComplexNoSuchMethod(FunctionElement element) => | 1440 bool isComplexNoSuchMethod(FunctionElement element) => |
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2420 for (ClassElement cls in resolution.universe.directlyInstantiatedClasses) { | 2419 for (ClassElement cls in resolution.universe.directlyInstantiatedClasses) { |
2421 // Do not process internal classes. | 2420 // Do not process internal classes. |
2422 if (cls.library.isInternalLibrary || cls.isInjected) continue; | 2421 if (cls.library.isInternalLibrary || cls.isInjected) continue; |
2423 if (referencedFromMirrorSystem(cls)) { | 2422 if (referencedFromMirrorSystem(cls)) { |
2424 Set<Name> memberNames = new Set<Name>(); | 2423 Set<Name> memberNames = new Set<Name>(); |
2425 // 1) the class (should be resolved) | 2424 // 1) the class (should be resolved) |
2426 assert(invariant(cls, cls.isResolved)); | 2425 assert(invariant(cls, cls.isResolved)); |
2427 reflectableMembers.add(cls); | 2426 reflectableMembers.add(cls); |
2428 // 2) its constructors (if resolved) | 2427 // 2) its constructors (if resolved) |
2429 cls.constructors.forEach((Element constructor) { | 2428 cls.constructors.forEach((Element constructor) { |
2430 if (resolution.hasBeenResolved(constructor)) { | 2429 if (resolution.hasBeenProcessed(constructor)) { |
2431 reflectableMembers.add(constructor); | 2430 reflectableMembers.add(constructor); |
2432 } | 2431 } |
2433 }); | 2432 }); |
2434 // 3) all members, including fields via getter/setters (if resolved) | 2433 // 3) all members, including fields via getter/setters (if resolved) |
2435 cls.forEachClassMember((Member member) { | 2434 cls.forEachClassMember((Member member) { |
2436 if (resolution.hasBeenResolved(member.element)) { | 2435 if (resolution.hasBeenProcessed(member.element)) { |
2437 memberNames.add(member.name); | 2436 memberNames.add(member.name); |
2438 reflectableMembers.add(member.element); | 2437 reflectableMembers.add(member.element); |
2439 } | 2438 } |
2440 }); | 2439 }); |
2441 // 4) all overriding members of subclasses/subtypes (should be resolved) | 2440 // 4) all overriding members of subclasses/subtypes (should be resolved) |
2442 if (compiler.world.hasAnyStrictSubtype(cls)) { | 2441 if (compiler.world.hasAnyStrictSubtype(cls)) { |
2443 for (ClassElement subcls in compiler.world.strictSubtypesOf(cls)) { | 2442 for (ClassElement subcls in compiler.world.strictSubtypesOf(cls)) { |
2444 subcls.forEachClassMember((Member member) { | 2443 subcls.forEachClassMember((Member member) { |
2445 if (memberNames.contains(member.name)) { | 2444 if (memberNames.contains(member.name)) { |
2446 // TODO(20993): find out why this assertion fails. | 2445 // TODO(20993): find out why this assertion fails. |
2447 // assert(invariant(member.element, | 2446 // assert(invariant(member.element, |
2448 // resolution.hasBeenResolved(member.element))); | 2447 // resolution.hasBeenProcessed(member.element))); |
2449 if (resolution.hasBeenResolved(member.element)) { | 2448 if (resolution.hasBeenProcessed(member.element)) { |
2450 reflectableMembers.add(member.element); | 2449 reflectableMembers.add(member.element); |
2451 } | 2450 } |
2452 } | 2451 } |
2453 }); | 2452 }); |
2454 } | 2453 } |
2455 } | 2454 } |
2456 // 5) all its closures | 2455 // 5) all its closures |
2457 List<LocalFunctionElement> closures = closureMap[cls]; | 2456 List<LocalFunctionElement> closures = closureMap[cls]; |
2458 if (closures != null) { | 2457 if (closures != null) { |
2459 reflectableMembers.addAll(closures); | 2458 reflectableMembers.addAll(closures); |
2460 foundClosure = true; | 2459 foundClosure = true; |
2461 } | 2460 } |
2462 } else { | 2461 } else { |
2463 // check members themselves | 2462 // check members themselves |
2464 cls.constructors.forEach((ConstructorElement element) { | 2463 cls.constructors.forEach((ConstructorElement element) { |
2465 if (!resolution.hasBeenResolved(element)) return; | 2464 if (!resolution.hasBeenProcessed(element)) return; |
2466 if (referencedFromMirrorSystem(element, false)) { | 2465 if (referencedFromMirrorSystem(element, false)) { |
2467 reflectableMembers.add(element); | 2466 reflectableMembers.add(element); |
2468 } | 2467 } |
2469 }); | 2468 }); |
2470 cls.forEachClassMember((Member member) { | 2469 cls.forEachClassMember((Member member) { |
2471 if (!resolution.hasBeenResolved(member.element)) return; | 2470 if (!resolution.hasBeenProcessed(member.element)) return; |
2472 if (referencedFromMirrorSystem(member.element, false)) { | 2471 if (referencedFromMirrorSystem(member.element, false)) { |
2473 reflectableMembers.add(member.element); | 2472 reflectableMembers.add(member.element); |
2474 } | 2473 } |
2475 }); | 2474 }); |
2476 // Also add in closures. Those might be reflectable is their enclosing | 2475 // Also add in closures. Those might be reflectable is their enclosing |
2477 // member is. | 2476 // member is. |
2478 List<LocalFunctionElement> closures = closureMap[cls]; | 2477 List<LocalFunctionElement> closures = closureMap[cls]; |
2479 if (closures != null) { | 2478 if (closures != null) { |
2480 for (LocalFunctionElement closure in closures) { | 2479 for (LocalFunctionElement closure in closures) { |
2481 if (referencedFromMirrorSystem(closure.memberContext, false)) { | 2480 if (referencedFromMirrorSystem(closure.memberContext, false)) { |
2482 reflectableMembers.add(closure); | 2481 reflectableMembers.add(closure); |
2483 foundClosure = true; | 2482 foundClosure = true; |
2484 } | 2483 } |
2485 } | 2484 } |
2486 } | 2485 } |
2487 } | 2486 } |
2488 } | 2487 } |
2489 // We also need top-level non-class elements like static functions and | 2488 // We also need top-level non-class elements like static functions and |
2490 // global fields. We use the resolution queue to decide which elements are | 2489 // global fields. We use the resolution queue to decide which elements are |
2491 // part of the live world. | 2490 // part of the live world. |
2492 for (LibraryElement lib in compiler.libraryLoader.libraries) { | 2491 for (LibraryElement lib in compiler.libraryLoader.libraries) { |
2493 if (lib.isInternalLibrary) continue; | 2492 if (lib.isInternalLibrary) continue; |
2494 lib.forEachLocalMember((Element member) { | 2493 lib.forEachLocalMember((Element member) { |
2495 if (!member.isClass && | 2494 if (!member.isClass && |
2496 resolution.hasBeenResolved(member) && | 2495 resolution.hasBeenProcessed(member) && |
2497 referencedFromMirrorSystem(member)) { | 2496 referencedFromMirrorSystem(member)) { |
2498 reflectableMembers.add(member); | 2497 reflectableMembers.add(member); |
2499 } | 2498 } |
2500 }); | 2499 }); |
2501 } | 2500 } |
2502 // And closures inside top-level elements that do not have a surrounding | 2501 // And closures inside top-level elements that do not have a surrounding |
2503 // class. These will be in the [:null:] bucket of the [closureMap]. | 2502 // class. These will be in the [:null:] bucket of the [closureMap]. |
2504 if (closureMap.containsKey(null)) { | 2503 if (closureMap.containsKey(null)) { |
2505 for (Element closure in closureMap[null]) { | 2504 for (Element closure in closureMap[null]) { |
2506 if (referencedFromMirrorSystem(closure)) { | 2505 if (referencedFromMirrorSystem(closure)) { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2645 // necessary, but the backend relies on them being resolved. | 2644 // necessary, but the backend relies on them being resolved. |
2646 enqueuer.enqueueReflectiveStaticFields(_findStaticFieldTargets()); | 2645 enqueuer.enqueueReflectiveStaticFields(_findStaticFieldTargets()); |
2647 } | 2646 } |
2648 | 2647 |
2649 if (mustPreserveNames) reporter.log('Preserving names.'); | 2648 if (mustPreserveNames) reporter.log('Preserving names.'); |
2650 | 2649 |
2651 if (mustRetainMetadata) { | 2650 if (mustRetainMetadata) { |
2652 reporter.log('Retaining metadata.'); | 2651 reporter.log('Retaining metadata.'); |
2653 | 2652 |
2654 compiler.libraryLoader.libraries.forEach(retainMetadataOf); | 2653 compiler.libraryLoader.libraries.forEach(retainMetadataOf); |
2655 if (!enqueuer.isResolutionQueue) { | 2654 if (enqueuer.isResolutionQueue) { |
2656 for (Dependency dependency in metadataConstants) { | 2655 for (Dependency dependency in metadataConstants) { |
2657 registerCompileTimeConstant( | 2656 registerCompileTimeConstant( |
2658 dependency.constant, | 2657 dependency.constant, |
| 2658 new EagerRegistry(compiler, |
| 2659 dependency.annotatedElement.analyzableElement.treeElements), |
| 2660 addForEmission: false); |
| 2661 } |
| 2662 } else { |
| 2663 for (Dependency dependency in metadataConstants) { |
| 2664 registerCompileTimeConstant( |
| 2665 dependency.constant, |
2659 new CodegenRegistry(compiler, | 2666 new CodegenRegistry(compiler, |
2660 dependency.annotatedElement.analyzableElement.treeElements), | 2667 dependency.annotatedElement.analyzableElement.treeElements), |
2661 addForEmission: false); | 2668 addForEmission: false); |
2662 } | 2669 } |
2663 metadataConstants.clear(); | 2670 metadataConstants.clear(); |
2664 } | 2671 } |
2665 } | 2672 } |
2666 return true; | 2673 return true; |
2667 } | 2674 } |
2668 | 2675 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2792 : "out"; | 2799 : "out"; |
2793 String outName = outPath.substring(outPath.lastIndexOf('/') + 1); | 2800 String outName = outPath.substring(outPath.lastIndexOf('/') + 1); |
2794 String extension = addExtension ? ".part.js" : ""; | 2801 String extension = addExtension ? ".part.js" : ""; |
2795 return "${outName}_$name$extension"; | 2802 return "${outName}_$name$extension"; |
2796 } | 2803 } |
2797 | 2804 |
2798 void registerAsyncMarker(FunctionElement element, | 2805 void registerAsyncMarker(FunctionElement element, |
2799 Enqueuer enqueuer, | 2806 Enqueuer enqueuer, |
2800 Registry registry) { | 2807 Registry registry) { |
2801 if (element.asyncMarker == AsyncMarker.ASYNC) { | 2808 if (element.asyncMarker == AsyncMarker.ASYNC) { |
2802 enqueue(enqueuer, getAsyncHelper(), registry); | 2809 _registerAsync(enqueuer, registry); |
2803 enqueue(enqueuer, getSyncCompleterConstructor(), registry); | |
2804 enqueue(enqueuer, getStreamIteratorConstructor(), registry); | |
2805 enqueue(enqueuer, getWrapBody(), registry); | |
2806 } else if (element.asyncMarker == AsyncMarker.SYNC_STAR) { | 2810 } else if (element.asyncMarker == AsyncMarker.SYNC_STAR) { |
2807 ClassElement clsSyncStarIterable = getSyncStarIterable(); | 2811 _registerSyncStar(enqueuer, registry); |
2808 clsSyncStarIterable.ensureResolved(resolution); | |
2809 registerInstantiatedType(clsSyncStarIterable.rawType, enqueuer, registry); | |
2810 enqueue(enqueuer, getSyncStarIterableConstructor(), registry); | |
2811 enqueue(enqueuer, getEndOfIteration(), registry); | |
2812 enqueue(enqueuer, getYieldStar(), registry); | |
2813 enqueue(enqueuer, getSyncStarUncaughtError(), registry); | |
2814 } else if (element.asyncMarker == AsyncMarker.ASYNC_STAR) { | 2812 } else if (element.asyncMarker == AsyncMarker.ASYNC_STAR) { |
2815 ClassElement clsASyncStarController = getASyncStarController(); | 2813 _registerAsyncStar(enqueuer, registry); |
2816 clsASyncStarController.ensureResolved(resolution); | |
2817 registerInstantiatedType( | |
2818 clsASyncStarController.rawType, enqueuer, registry); | |
2819 enqueue(enqueuer, getAsyncStarHelper(), registry); | |
2820 enqueue(enqueuer, getStreamOfController(), registry); | |
2821 enqueue(enqueuer, getYieldSingle(), registry); | |
2822 enqueue(enqueuer, getYieldStar(), registry); | |
2823 enqueue(enqueuer, getASyncStarControllerConstructor(), registry); | |
2824 enqueue(enqueuer, getStreamIteratorConstructor(), registry); | |
2825 enqueue(enqueuer, getWrapBody(), registry); | |
2826 } | 2814 } |
2827 } | 2815 } |
2828 | 2816 |
| 2817 void _registerAsync(Enqueuer enqueuer, |
| 2818 Registry registry) { |
| 2819 enqueue(enqueuer, getAsyncHelper(), registry); |
| 2820 enqueue(enqueuer, getSyncCompleterConstructor(), registry); |
| 2821 enqueue(enqueuer, getStreamIteratorConstructor(), registry); |
| 2822 enqueue(enqueuer, getWrapBody(), registry); |
| 2823 } |
| 2824 |
| 2825 void _registerSyncStar(Enqueuer enqueuer, |
| 2826 Registry registry) { |
| 2827 ClassElement clsSyncStarIterable = getSyncStarIterable(); |
| 2828 clsSyncStarIterable.ensureResolved(compiler.resolution); |
| 2829 registerInstantiatedType(clsSyncStarIterable.rawType, enqueuer, registry); |
| 2830 enqueue(enqueuer, getSyncStarIterableConstructor(), registry); |
| 2831 enqueue(enqueuer, getEndOfIteration(), registry); |
| 2832 enqueue(enqueuer, getYieldStar(), registry); |
| 2833 enqueue(enqueuer, getSyncStarUncaughtError(), registry); |
| 2834 } |
| 2835 |
| 2836 void _registerAsyncStar(Enqueuer enqueuer, |
| 2837 Registry registry) { |
| 2838 ClassElement clsASyncStarController = getASyncStarController(); |
| 2839 clsASyncStarController.ensureResolved(compiler.resolution); |
| 2840 registerInstantiatedType( |
| 2841 clsASyncStarController.rawType, enqueuer, registry); |
| 2842 enqueue(enqueuer, getAsyncStarHelper(), registry); |
| 2843 enqueue(enqueuer, getStreamOfController(), registry); |
| 2844 enqueue(enqueuer, getYieldSingle(), registry); |
| 2845 enqueue(enqueuer, getYieldStar(), registry); |
| 2846 enqueue(enqueuer, getASyncStarControllerConstructor(), registry); |
| 2847 enqueue(enqueuer, getStreamIteratorConstructor(), registry); |
| 2848 enqueue(enqueuer, getWrapBody(), registry); |
| 2849 } |
| 2850 |
2829 @override | 2851 @override |
2830 bool enableDeferredLoadingIfSupported(Spannable node, Registry registry) { | 2852 bool enableDeferredLoadingIfSupported(Spannable node, Registry registry) { |
2831 registerCheckDeferredIsLoaded(registry); | 2853 registerCheckDeferredIsLoaded(registry); |
2832 return true; | 2854 return true; |
2833 } | 2855 } |
2834 | 2856 |
2835 @override | 2857 @override |
2836 bool enableCodegenWithErrorsIfSupported(Spannable node) { | 2858 bool enableCodegenWithErrorsIfSupported(Spannable node) { |
2837 if (compiler.useCpsIr) { | 2859 if (compiler.useCpsIr) { |
2838 reporter.reportHintMessage( | 2860 reporter.reportHintMessage( |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2977 return false; | 2999 return false; |
2978 }); | 3000 }); |
2979 } | 3001 } |
2980 } | 3002 } |
2981 | 3003 |
2982 class JavaScriptResolutionCallbacks extends ResolutionCallbacks { | 3004 class JavaScriptResolutionCallbacks extends ResolutionCallbacks { |
2983 final JavaScriptBackend backend; | 3005 final JavaScriptBackend backend; |
2984 | 3006 |
2985 JavaScriptResolutionCallbacks(this.backend); | 3007 JavaScriptResolutionCallbacks(this.backend); |
2986 | 3008 |
| 3009 WorldImpact transformImpact(ResolutionWorldImpact worldImpact) { |
| 3010 TransformedWorldImpact transformed = |
| 3011 new TransformedWorldImpact(worldImpact); |
| 3012 for (Feature feature in worldImpact.features) { |
| 3013 switch (feature) { |
| 3014 case Feature.ABSTRACT_CLASS_INSTANTIATION: |
| 3015 onAbstractClassInstantiation(transformed); |
| 3016 break; |
| 3017 case Feature.ASSERT: |
| 3018 onAssert(false, transformed); |
| 3019 break; |
| 3020 case Feature.ASSERT_WITH_MESSAGE: |
| 3021 onAssert(true, transformed); |
| 3022 break; |
| 3023 case Feature.ASYNC: |
| 3024 backend._registerAsync( |
| 3025 backend.compiler.enqueuer.resolution, transformed); |
| 3026 break; |
| 3027 case Feature.ASYNC_FOR_IN: |
| 3028 onAsyncForIn(null, transformed); |
| 3029 break; |
| 3030 case Feature.ASYNC_STAR: |
| 3031 backend._registerAsyncStar( |
| 3032 backend.compiler.enqueuer.resolution, transformed); |
| 3033 break; |
| 3034 case Feature.CATCH_STATEMENT: |
| 3035 onCatchStatement(transformed); |
| 3036 break; |
| 3037 case Feature.COMPILE_TIME_ERROR: |
| 3038 onCompileTimeError(transformed, null); |
| 3039 break; |
| 3040 case Feature.FALL_THROUGH_ERROR: |
| 3041 onFallThroughError(transformed); |
| 3042 break; |
| 3043 case Feature.INC_DEC_OPERATION: |
| 3044 onIncDecOperation(transformed); |
| 3045 break; |
| 3046 case Feature.LAZY_FIELD: |
| 3047 onLazyField(transformed); |
| 3048 break; |
| 3049 case Feature.NEW_SYMBOL: |
| 3050 backend.registerNewSymbol(transformed); |
| 3051 break; |
| 3052 case Feature.STACK_TRACE_IN_CATCH: |
| 3053 onStackTraceInCatch(transformed); |
| 3054 break; |
| 3055 case Feature.STRING_INTERPOLATION: |
| 3056 onStringInterpolation(transformed); |
| 3057 break; |
| 3058 case Feature.SUPER_NO_SUCH_METHOD: |
| 3059 onSuperNoSuchMethod(transformed); |
| 3060 break; |
| 3061 case Feature.SYMBOL_CONSTRUCTOR: |
| 3062 onSymbolConstructor(transformed); |
| 3063 break; |
| 3064 case Feature.SYNC_FOR_IN: |
| 3065 onSyncForIn(transformed); |
| 3066 break; |
| 3067 case Feature.SYNC_STAR: |
| 3068 backend._registerSyncStar( |
| 3069 backend.compiler.enqueuer.resolution, transformed); |
| 3070 break; |
| 3071 case Feature.THROW_EXPRESSION: |
| 3072 onThrowExpression(transformed); |
| 3073 break; |
| 3074 case Feature.THROW_NO_SUCH_METHOD: |
| 3075 onThrowNoSuchMethod(transformed); |
| 3076 break; |
| 3077 case Feature.THROW_RUNTIME_ERROR: |
| 3078 onThrowRuntimeError(transformed); |
| 3079 break; |
| 3080 case Feature.TYPE_VARIABLE_BOUNDS_CHECK: |
| 3081 onTypeVariableBoundCheck(transformed); |
| 3082 break; |
| 3083 } |
| 3084 } |
| 3085 for (DartType type in worldImpact.isChecks) { |
| 3086 onIsCheck(type, transformed); |
| 3087 } |
| 3088 for (DartType type in worldImpact.asCasts) { |
| 3089 onIsCheck(type, transformed); |
| 3090 onAsCheck(type, transformed); |
| 3091 } |
| 3092 if (backend.compiler.enableTypeAssertions) { |
| 3093 for (DartType type in worldImpact.checkedModeChecks) { |
| 3094 onIsCheck(type, transformed); |
| 3095 } |
| 3096 } |
| 3097 for (DartType requiredType in worldImpact.requiredTypes) { |
| 3098 backend.registerRequiredType(requiredType); |
| 3099 } |
| 3100 for (MapLiteralUse mapLiteralUse in worldImpact.mapLiterals) { |
| 3101 // TODO(johnniwinther): Use the [isEmpty] property when factory |
| 3102 // constructors are registered directly. |
| 3103 onMapLiteral(transformed, mapLiteralUse.type, mapLiteralUse.isConstant); |
| 3104 } |
| 3105 for (ListLiteralUse listLiteralUse in worldImpact.listLiterals) { |
| 3106 // TODO(johnniwinther): Use the [isConstant] and [isEmpty] property when |
| 3107 // factory constructors are registered directly. |
| 3108 transformed.registerInstantiation(listLiteralUse.type); |
| 3109 } |
| 3110 for (DartType typeLiteral in worldImpact.typeLiterals) { |
| 3111 onTypeLiteral(typeLiteral, transformed); |
| 3112 transformed.registerInstantiation(backend.compiler.coreTypes.typeType); |
| 3113 if (typeLiteral.isTypeVariable) { |
| 3114 onTypeVariableExpression(transformed, typeLiteral.element); |
| 3115 } |
| 3116 } |
| 3117 for (String constSymbolName in worldImpact.constSymbolNames) { |
| 3118 backend.registerConstSymbol(constSymbolName, transformed); |
| 3119 } |
| 3120 for (LocalFunctionElement closure in worldImpact.closures) { |
| 3121 if (closure.computeType(backend.resolution).containsTypeVariables) { |
| 3122 backend.registerClosureWithFreeTypeVariables( |
| 3123 closure, backend.compiler.enqueuer.resolution, transformed); |
| 3124 } |
| 3125 } |
| 3126 // TODO(johnniwinther): Remove this when dependency tracking is done on |
| 3127 // the world impact itself. |
| 3128 for (InterfaceType instantiatedType in worldImpact.instantiatedTypes) { |
| 3129 transformed.registerInstantiation(instantiatedType); |
| 3130 } |
| 3131 for (Element element in worldImpact.staticUses) { |
| 3132 transformed.registerStaticInvocation(element); |
| 3133 } |
| 3134 |
| 3135 return transformed; |
| 3136 } |
| 3137 |
2987 void registerBackendStaticInvocation(Element element, Registry registry) { | 3138 void registerBackendStaticInvocation(Element element, Registry registry) { |
2988 registry.registerStaticInvocation(backend.registerBackendUse(element)); | 3139 registry.registerStaticInvocation(backend.registerBackendUse(element)); |
2989 } | 3140 } |
2990 | 3141 |
2991 void registerBackendInstantiation(ClassElement element, Registry registry) { | 3142 void registerBackendInstantiation(ClassElement element, Registry registry) { |
2992 backend.registerBackendUse(element); | 3143 backend.registerBackendUse(element); |
2993 element.ensureResolved(backend.resolution); | 3144 element.ensureResolved(backend.resolution); |
2994 registry.registerInstantiation(element.rawType); | 3145 registry.registerInstantiation(element.rawType); |
2995 } | 3146 } |
2996 | 3147 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3182 Identifiers.noSuchMethod_), | 3333 Identifiers.noSuchMethod_), |
3183 registry); | 3334 registry); |
3184 needsInt(registry, | 3335 needsInt(registry, |
3185 'Needed to encode the invocation kind of super.noSuchMethod.'); | 3336 'Needed to encode the invocation kind of super.noSuchMethod.'); |
3186 needsList(registry, | 3337 needsList(registry, |
3187 'Needed to encode the arguments of super.noSuchMethod.'); | 3338 'Needed to encode the arguments of super.noSuchMethod.'); |
3188 needsString(registry, | 3339 needsString(registry, |
3189 'Needed to encode the name of super.noSuchMethod.'); | 3340 'Needed to encode the name of super.noSuchMethod.'); |
3190 } | 3341 } |
3191 | 3342 |
3192 void onMapLiteral(ResolutionRegistry registry, | 3343 void onMapLiteral(Registry registry, |
3193 DartType type, | 3344 DartType type, |
3194 bool isConstant) { | 3345 bool isConstant) { |
3195 assert(registry.isForResolution); | 3346 assert(registry.isForResolution); |
3196 void enqueue(String name) { | 3347 void enqueue(String name) { |
3197 Element e = backend.find(backend.jsHelperLibrary, name); | 3348 Element e = backend.find(backend.jsHelperLibrary, name); |
3198 registerBackendInstantiation(e, registry); | 3349 registerBackendInstantiation(e, registry); |
3199 } | 3350 } |
3200 | 3351 |
3201 if (isConstant) { | 3352 if (isConstant) { |
3202 enqueue(JavaScriptMapConstant.DART_CLASS); | 3353 enqueue(JavaScriptMapConstant.DART_CLASS); |
3203 enqueue(JavaScriptMapConstant.DART_PROTO_CLASS); | 3354 enqueue(JavaScriptMapConstant.DART_PROTO_CLASS); |
3204 enqueue(JavaScriptMapConstant.DART_STRING_CLASS); | 3355 enqueue(JavaScriptMapConstant.DART_STRING_CLASS); |
3205 enqueue(JavaScriptMapConstant.DART_GENERAL_CLASS); | 3356 enqueue(JavaScriptMapConstant.DART_GENERAL_CLASS); |
3206 } else { | 3357 } else { |
3207 registry.registerInstantiatedType(type); | 3358 registry.registerInstantiation(type); |
3208 } | 3359 } |
3209 } | 3360 } |
3210 | 3361 |
3211 /// Called when resolving the `Symbol` constructor. | 3362 /// Called when resolving the `Symbol` constructor. |
3212 void onSymbolConstructor(Registry registry) { | 3363 void onSymbolConstructor(Registry registry) { |
3213 assert(registry.isForResolution); | 3364 assert(registry.isForResolution); |
3214 // Make sure that _internals.Symbol.validated is registered. | 3365 // Make sure that _internals.Symbol.validated is registered. |
3215 assert(backend.compiler.symbolValidatedConstructor != null); | 3366 assert(backend.compiler.symbolValidatedConstructor != null); |
3216 registerBackendStaticInvocation( | 3367 registerBackendStaticInvocation( |
3217 backend.compiler.symbolValidatedConstructor, registry); | 3368 backend.compiler.symbolValidatedConstructor, registry); |
(...skipping 23 matching lines...) Expand all Loading... |
3241 } | 3392 } |
3242 } | 3393 } |
3243 | 3394 |
3244 /// Records that [constant] is used by the element behind [registry]. | 3395 /// Records that [constant] is used by the element behind [registry]. |
3245 class Dependency { | 3396 class Dependency { |
3246 final ConstantValue constant; | 3397 final ConstantValue constant; |
3247 final Element annotatedElement; | 3398 final Element annotatedElement; |
3248 | 3399 |
3249 const Dependency(this.constant, this.annotatedElement); | 3400 const Dependency(this.constant, this.annotatedElement); |
3250 } | 3401 } |
OLD | NEW |