| 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) { | 1423 void registerRequiredType(DartType type, Element enclosingElement) { |
| 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); |
| 1431 rti.registerRtiDependency(type.element, contextClass); | 1432 rti.registerRtiDependency(type.element, contextClass); |
| 1432 } | 1433 } |
| 1433 } | 1434 } |
| 1434 | 1435 |
| 1435 bool classNeedsRti(ClassElement cls) { | 1436 bool classNeedsRti(ClassElement cls) { |
| 1436 return rti.classesNeedingRti.contains(cls.declaration) || | 1437 return rti.classesNeedingRti.contains(cls.declaration) || |
| 1437 compiler.enabledRuntimeType; | 1438 compiler.enabledRuntimeType; |
| 1438 } | 1439 } |
| 1439 | 1440 |
| 1440 bool isComplexNoSuchMethod(FunctionElement element) => | 1441 bool isComplexNoSuchMethod(FunctionElement element) => |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2419 for (ClassElement cls in resolution.universe.directlyInstantiatedClasses) { | 2420 for (ClassElement cls in resolution.universe.directlyInstantiatedClasses) { |
| 2420 // Do not process internal classes. | 2421 // Do not process internal classes. |
| 2421 if (cls.library.isInternalLibrary || cls.isInjected) continue; | 2422 if (cls.library.isInternalLibrary || cls.isInjected) continue; |
| 2422 if (referencedFromMirrorSystem(cls)) { | 2423 if (referencedFromMirrorSystem(cls)) { |
| 2423 Set<Name> memberNames = new Set<Name>(); | 2424 Set<Name> memberNames = new Set<Name>(); |
| 2424 // 1) the class (should be resolved) | 2425 // 1) the class (should be resolved) |
| 2425 assert(invariant(cls, cls.isResolved)); | 2426 assert(invariant(cls, cls.isResolved)); |
| 2426 reflectableMembers.add(cls); | 2427 reflectableMembers.add(cls); |
| 2427 // 2) its constructors (if resolved) | 2428 // 2) its constructors (if resolved) |
| 2428 cls.constructors.forEach((Element constructor) { | 2429 cls.constructors.forEach((Element constructor) { |
| 2429 if (resolution.hasBeenProcessed(constructor)) { | 2430 if (resolution.hasBeenResolved(constructor)) { |
| 2430 reflectableMembers.add(constructor); | 2431 reflectableMembers.add(constructor); |
| 2431 } | 2432 } |
| 2432 }); | 2433 }); |
| 2433 // 3) all members, including fields via getter/setters (if resolved) | 2434 // 3) all members, including fields via getter/setters (if resolved) |
| 2434 cls.forEachClassMember((Member member) { | 2435 cls.forEachClassMember((Member member) { |
| 2435 if (resolution.hasBeenProcessed(member.element)) { | 2436 if (resolution.hasBeenResolved(member.element)) { |
| 2436 memberNames.add(member.name); | 2437 memberNames.add(member.name); |
| 2437 reflectableMembers.add(member.element); | 2438 reflectableMembers.add(member.element); |
| 2438 } | 2439 } |
| 2439 }); | 2440 }); |
| 2440 // 4) all overriding members of subclasses/subtypes (should be resolved) | 2441 // 4) all overriding members of subclasses/subtypes (should be resolved) |
| 2441 if (compiler.world.hasAnyStrictSubtype(cls)) { | 2442 if (compiler.world.hasAnyStrictSubtype(cls)) { |
| 2442 for (ClassElement subcls in compiler.world.strictSubtypesOf(cls)) { | 2443 for (ClassElement subcls in compiler.world.strictSubtypesOf(cls)) { |
| 2443 subcls.forEachClassMember((Member member) { | 2444 subcls.forEachClassMember((Member member) { |
| 2444 if (memberNames.contains(member.name)) { | 2445 if (memberNames.contains(member.name)) { |
| 2445 // TODO(20993): find out why this assertion fails. | 2446 // TODO(20993): find out why this assertion fails. |
| 2446 // assert(invariant(member.element, | 2447 // assert(invariant(member.element, |
| 2447 // resolution.hasBeenProcessed(member.element))); | 2448 // resolution.hasBeenResolved(member.element))); |
| 2448 if (resolution.hasBeenProcessed(member.element)) { | 2449 if (resolution.hasBeenResolved(member.element)) { |
| 2449 reflectableMembers.add(member.element); | 2450 reflectableMembers.add(member.element); |
| 2450 } | 2451 } |
| 2451 } | 2452 } |
| 2452 }); | 2453 }); |
| 2453 } | 2454 } |
| 2454 } | 2455 } |
| 2455 // 5) all its closures | 2456 // 5) all its closures |
| 2456 List<LocalFunctionElement> closures = closureMap[cls]; | 2457 List<LocalFunctionElement> closures = closureMap[cls]; |
| 2457 if (closures != null) { | 2458 if (closures != null) { |
| 2458 reflectableMembers.addAll(closures); | 2459 reflectableMembers.addAll(closures); |
| 2459 foundClosure = true; | 2460 foundClosure = true; |
| 2460 } | 2461 } |
| 2461 } else { | 2462 } else { |
| 2462 // check members themselves | 2463 // check members themselves |
| 2463 cls.constructors.forEach((ConstructorElement element) { | 2464 cls.constructors.forEach((ConstructorElement element) { |
| 2464 if (!resolution.hasBeenProcessed(element)) return; | 2465 if (!resolution.hasBeenResolved(element)) return; |
| 2465 if (referencedFromMirrorSystem(element, false)) { | 2466 if (referencedFromMirrorSystem(element, false)) { |
| 2466 reflectableMembers.add(element); | 2467 reflectableMembers.add(element); |
| 2467 } | 2468 } |
| 2468 }); | 2469 }); |
| 2469 cls.forEachClassMember((Member member) { | 2470 cls.forEachClassMember((Member member) { |
| 2470 if (!resolution.hasBeenProcessed(member.element)) return; | 2471 if (!resolution.hasBeenResolved(member.element)) return; |
| 2471 if (referencedFromMirrorSystem(member.element, false)) { | 2472 if (referencedFromMirrorSystem(member.element, false)) { |
| 2472 reflectableMembers.add(member.element); | 2473 reflectableMembers.add(member.element); |
| 2473 } | 2474 } |
| 2474 }); | 2475 }); |
| 2475 // Also add in closures. Those might be reflectable is their enclosing | 2476 // Also add in closures. Those might be reflectable is their enclosing |
| 2476 // member is. | 2477 // member is. |
| 2477 List<LocalFunctionElement> closures = closureMap[cls]; | 2478 List<LocalFunctionElement> closures = closureMap[cls]; |
| 2478 if (closures != null) { | 2479 if (closures != null) { |
| 2479 for (LocalFunctionElement closure in closures) { | 2480 for (LocalFunctionElement closure in closures) { |
| 2480 if (referencedFromMirrorSystem(closure.memberContext, false)) { | 2481 if (referencedFromMirrorSystem(closure.memberContext, false)) { |
| 2481 reflectableMembers.add(closure); | 2482 reflectableMembers.add(closure); |
| 2482 foundClosure = true; | 2483 foundClosure = true; |
| 2483 } | 2484 } |
| 2484 } | 2485 } |
| 2485 } | 2486 } |
| 2486 } | 2487 } |
| 2487 } | 2488 } |
| 2488 // We also need top-level non-class elements like static functions and | 2489 // We also need top-level non-class elements like static functions and |
| 2489 // global fields. We use the resolution queue to decide which elements are | 2490 // global fields. We use the resolution queue to decide which elements are |
| 2490 // part of the live world. | 2491 // part of the live world. |
| 2491 for (LibraryElement lib in compiler.libraryLoader.libraries) { | 2492 for (LibraryElement lib in compiler.libraryLoader.libraries) { |
| 2492 if (lib.isInternalLibrary) continue; | 2493 if (lib.isInternalLibrary) continue; |
| 2493 lib.forEachLocalMember((Element member) { | 2494 lib.forEachLocalMember((Element member) { |
| 2494 if (!member.isClass && | 2495 if (!member.isClass && |
| 2495 resolution.hasBeenProcessed(member) && | 2496 resolution.hasBeenResolved(member) && |
| 2496 referencedFromMirrorSystem(member)) { | 2497 referencedFromMirrorSystem(member)) { |
| 2497 reflectableMembers.add(member); | 2498 reflectableMembers.add(member); |
| 2498 } | 2499 } |
| 2499 }); | 2500 }); |
| 2500 } | 2501 } |
| 2501 // And closures inside top-level elements that do not have a surrounding | 2502 // And closures inside top-level elements that do not have a surrounding |
| 2502 // class. These will be in the [:null:] bucket of the [closureMap]. | 2503 // class. These will be in the [:null:] bucket of the [closureMap]. |
| 2503 if (closureMap.containsKey(null)) { | 2504 if (closureMap.containsKey(null)) { |
| 2504 for (Element closure in closureMap[null]) { | 2505 for (Element closure in closureMap[null]) { |
| 2505 if (referencedFromMirrorSystem(closure)) { | 2506 if (referencedFromMirrorSystem(closure)) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2644 // necessary, but the backend relies on them being resolved. | 2645 // necessary, but the backend relies on them being resolved. |
| 2645 enqueuer.enqueueReflectiveStaticFields(_findStaticFieldTargets()); | 2646 enqueuer.enqueueReflectiveStaticFields(_findStaticFieldTargets()); |
| 2646 } | 2647 } |
| 2647 | 2648 |
| 2648 if (mustPreserveNames) reporter.log('Preserving names.'); | 2649 if (mustPreserveNames) reporter.log('Preserving names.'); |
| 2649 | 2650 |
| 2650 if (mustRetainMetadata) { | 2651 if (mustRetainMetadata) { |
| 2651 reporter.log('Retaining metadata.'); | 2652 reporter.log('Retaining metadata.'); |
| 2652 | 2653 |
| 2653 compiler.libraryLoader.libraries.forEach(retainMetadataOf); | 2654 compiler.libraryLoader.libraries.forEach(retainMetadataOf); |
| 2654 if (enqueuer.isResolutionQueue) { | 2655 if (!enqueuer.isResolutionQueue) { |
| 2655 for (Dependency dependency in metadataConstants) { | 2656 for (Dependency dependency in metadataConstants) { |
| 2656 registerCompileTimeConstant( | 2657 registerCompileTimeConstant( |
| 2657 dependency.constant, | 2658 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, | |
| 2666 new CodegenRegistry(compiler, | 2659 new CodegenRegistry(compiler, |
| 2667 dependency.annotatedElement.analyzableElement.treeElements), | 2660 dependency.annotatedElement.analyzableElement.treeElements), |
| 2668 addForEmission: false); | 2661 addForEmission: false); |
| 2669 } | 2662 } |
| 2670 metadataConstants.clear(); | 2663 metadataConstants.clear(); |
| 2671 } | 2664 } |
| 2672 } | 2665 } |
| 2673 return true; | 2666 return true; |
| 2674 } | 2667 } |
| 2675 | 2668 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2799 : "out"; | 2792 : "out"; |
| 2800 String outName = outPath.substring(outPath.lastIndexOf('/') + 1); | 2793 String outName = outPath.substring(outPath.lastIndexOf('/') + 1); |
| 2801 String extension = addExtension ? ".part.js" : ""; | 2794 String extension = addExtension ? ".part.js" : ""; |
| 2802 return "${outName}_$name$extension"; | 2795 return "${outName}_$name$extension"; |
| 2803 } | 2796 } |
| 2804 | 2797 |
| 2805 void registerAsyncMarker(FunctionElement element, | 2798 void registerAsyncMarker(FunctionElement element, |
| 2806 Enqueuer enqueuer, | 2799 Enqueuer enqueuer, |
| 2807 Registry registry) { | 2800 Registry registry) { |
| 2808 if (element.asyncMarker == AsyncMarker.ASYNC) { | 2801 if (element.asyncMarker == AsyncMarker.ASYNC) { |
| 2809 _registerAsync(enqueuer, registry); | 2802 enqueue(enqueuer, getAsyncHelper(), registry); |
| 2803 enqueue(enqueuer, getSyncCompleterConstructor(), registry); |
| 2804 enqueue(enqueuer, getStreamIteratorConstructor(), registry); |
| 2805 enqueue(enqueuer, getWrapBody(), registry); |
| 2810 } else if (element.asyncMarker == AsyncMarker.SYNC_STAR) { | 2806 } else if (element.asyncMarker == AsyncMarker.SYNC_STAR) { |
| 2811 _registerSyncStar(enqueuer, registry); | 2807 ClassElement clsSyncStarIterable = getSyncStarIterable(); |
| 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); |
| 2812 } else if (element.asyncMarker == AsyncMarker.ASYNC_STAR) { | 2814 } else if (element.asyncMarker == AsyncMarker.ASYNC_STAR) { |
| 2813 _registerAsyncStar(enqueuer, registry); | 2815 ClassElement clsASyncStarController = getASyncStarController(); |
| 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); |
| 2814 } | 2826 } |
| 2815 } | 2827 } |
| 2816 | 2828 |
| 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 | |
| 2851 @override | 2829 @override |
| 2852 bool enableDeferredLoadingIfSupported(Spannable node, Registry registry) { | 2830 bool enableDeferredLoadingIfSupported(Spannable node, Registry registry) { |
| 2853 registerCheckDeferredIsLoaded(registry); | 2831 registerCheckDeferredIsLoaded(registry); |
| 2854 return true; | 2832 return true; |
| 2855 } | 2833 } |
| 2856 | 2834 |
| 2857 @override | 2835 @override |
| 2858 bool enableCodegenWithErrorsIfSupported(Spannable node) { | 2836 bool enableCodegenWithErrorsIfSupported(Spannable node) { |
| 2859 if (compiler.useCpsIr) { | 2837 if (compiler.useCpsIr) { |
| 2860 reporter.reportHintMessage( | 2838 reporter.reportHintMessage( |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2999 return false; | 2977 return false; |
| 3000 }); | 2978 }); |
| 3001 } | 2979 } |
| 3002 } | 2980 } |
| 3003 | 2981 |
| 3004 class JavaScriptResolutionCallbacks extends ResolutionCallbacks { | 2982 class JavaScriptResolutionCallbacks extends ResolutionCallbacks { |
| 3005 final JavaScriptBackend backend; | 2983 final JavaScriptBackend backend; |
| 3006 | 2984 |
| 3007 JavaScriptResolutionCallbacks(this.backend); | 2985 JavaScriptResolutionCallbacks(this.backend); |
| 3008 | 2986 |
| 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 | |
| 3132 return transformed; | |
| 3133 } | |
| 3134 | |
| 3135 void registerBackendStaticInvocation(Element element, Registry registry) { | 2987 void registerBackendStaticInvocation(Element element, Registry registry) { |
| 3136 registry.registerStaticInvocation(backend.registerBackendUse(element)); | 2988 registry.registerStaticInvocation(backend.registerBackendUse(element)); |
| 3137 } | 2989 } |
| 3138 | 2990 |
| 3139 void registerBackendInstantiation(ClassElement element, Registry registry) { | 2991 void registerBackendInstantiation(ClassElement element, Registry registry) { |
| 3140 backend.registerBackendUse(element); | 2992 backend.registerBackendUse(element); |
| 3141 element.ensureResolved(backend.resolution); | 2993 element.ensureResolved(backend.resolution); |
| 3142 registry.registerInstantiation(element.rawType); | 2994 registry.registerInstantiation(element.rawType); |
| 3143 } | 2995 } |
| 3144 | 2996 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3330 Identifiers.noSuchMethod_), | 3182 Identifiers.noSuchMethod_), |
| 3331 registry); | 3183 registry); |
| 3332 needsInt(registry, | 3184 needsInt(registry, |
| 3333 'Needed to encode the invocation kind of super.noSuchMethod.'); | 3185 'Needed to encode the invocation kind of super.noSuchMethod.'); |
| 3334 needsList(registry, | 3186 needsList(registry, |
| 3335 'Needed to encode the arguments of super.noSuchMethod.'); | 3187 'Needed to encode the arguments of super.noSuchMethod.'); |
| 3336 needsString(registry, | 3188 needsString(registry, |
| 3337 'Needed to encode the name of super.noSuchMethod.'); | 3189 'Needed to encode the name of super.noSuchMethod.'); |
| 3338 } | 3190 } |
| 3339 | 3191 |
| 3340 void onMapLiteral(Registry registry, | 3192 void onMapLiteral(ResolutionRegistry registry, |
| 3341 DartType type, | 3193 DartType type, |
| 3342 bool isConstant) { | 3194 bool isConstant) { |
| 3343 assert(registry.isForResolution); | 3195 assert(registry.isForResolution); |
| 3344 void enqueue(String name) { | 3196 void enqueue(String name) { |
| 3345 Element e = backend.find(backend.jsHelperLibrary, name); | 3197 Element e = backend.find(backend.jsHelperLibrary, name); |
| 3346 registerBackendInstantiation(e, registry); | 3198 registerBackendInstantiation(e, registry); |
| 3347 } | 3199 } |
| 3348 | 3200 |
| 3349 if (isConstant) { | 3201 if (isConstant) { |
| 3350 enqueue(JavaScriptMapConstant.DART_CLASS); | 3202 enqueue(JavaScriptMapConstant.DART_CLASS); |
| 3351 enqueue(JavaScriptMapConstant.DART_PROTO_CLASS); | 3203 enqueue(JavaScriptMapConstant.DART_PROTO_CLASS); |
| 3352 enqueue(JavaScriptMapConstant.DART_STRING_CLASS); | 3204 enqueue(JavaScriptMapConstant.DART_STRING_CLASS); |
| 3353 enqueue(JavaScriptMapConstant.DART_GENERAL_CLASS); | 3205 enqueue(JavaScriptMapConstant.DART_GENERAL_CLASS); |
| 3354 } else { | 3206 } else { |
| 3355 registry.registerInstantiation(type); | 3207 registry.registerInstantiatedType(type); |
| 3356 } | 3208 } |
| 3357 } | 3209 } |
| 3358 | 3210 |
| 3359 /// Called when resolving the `Symbol` constructor. | 3211 /// Called when resolving the `Symbol` constructor. |
| 3360 void onSymbolConstructor(Registry registry) { | 3212 void onSymbolConstructor(Registry registry) { |
| 3361 assert(registry.isForResolution); | 3213 assert(registry.isForResolution); |
| 3362 // Make sure that _internals.Symbol.validated is registered. | 3214 // Make sure that _internals.Symbol.validated is registered. |
| 3363 assert(backend.compiler.symbolValidatedConstructor != null); | 3215 assert(backend.compiler.symbolValidatedConstructor != null); |
| 3364 registerBackendStaticInvocation( | 3216 registerBackendStaticInvocation( |
| 3365 backend.compiler.symbolValidatedConstructor, registry); | 3217 backend.compiler.symbolValidatedConstructor, registry); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3389 } | 3241 } |
| 3390 } | 3242 } |
| 3391 | 3243 |
| 3392 /// Records that [constant] is used by the element behind [registry]. | 3244 /// Records that [constant] is used by the element behind [registry]. |
| 3393 class Dependency { | 3245 class Dependency { |
| 3394 final ConstantValue constant; | 3246 final ConstantValue constant; |
| 3395 final Element annotatedElement; | 3247 final Element annotatedElement; |
| 3396 | 3248 |
| 3397 const Dependency(this.constant, this.annotatedElement); | 3249 const Dependency(this.constant, this.annotatedElement); |
| 3398 } | 3250 } |
| OLD | NEW |