| 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 library js_backend.backend; | 5 library js_backend.backend; |
| 6 | 6 |
| 7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
| 8 | 8 |
| 9 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; | 9 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 import '../common/tasks.dart' show CompilerTask; | 23 import '../common/tasks.dart' show CompilerTask; |
| 24 import '../compiler.dart' show Compiler; | 24 import '../compiler.dart' show Compiler; |
| 25 import '../constants/constant_system.dart'; | 25 import '../constants/constant_system.dart'; |
| 26 import '../constants/expressions.dart'; | 26 import '../constants/expressions.dart'; |
| 27 import '../constants/values.dart'; | 27 import '../constants/values.dart'; |
| 28 import '../core_types.dart' show CoreClasses, CoreTypes; | 28 import '../core_types.dart' show CoreClasses, CoreTypes; |
| 29 import '../dart_types.dart'; | 29 import '../dart_types.dart'; |
| 30 import '../deferred_load.dart' show DeferredLoadTask; | 30 import '../deferred_load.dart' show DeferredLoadTask; |
| 31 import '../dump_info.dart' show DumpInfoTask; | 31 import '../dump_info.dart' show DumpInfoTask; |
| 32 import '../elements/elements.dart'; | 32 import '../elements/elements.dart'; |
| 33 import '../elements/entities.dart'; |
| 33 import '../enqueue.dart' | 34 import '../enqueue.dart' |
| 34 show Enqueuer, ResolutionEnqueuer, TreeShakingEnqueuerStrategy; | 35 show Enqueuer, ResolutionEnqueuer, TreeShakingEnqueuerStrategy; |
| 35 import '../io/position_information.dart' show PositionSourceInformationStrategy; | 36 import '../io/position_information.dart' show PositionSourceInformationStrategy; |
| 36 import '../io/source_information.dart' show SourceInformationStrategy; | 37 import '../io/source_information.dart' show SourceInformationStrategy; |
| 37 import '../io/start_end_information.dart' | 38 import '../io/start_end_information.dart' |
| 38 show StartEndSourceInformationStrategy; | 39 show StartEndSourceInformationStrategy; |
| 39 import '../js/js.dart' as jsAst; | 40 import '../js/js.dart' as jsAst; |
| 40 import '../js/js.dart' show js; | 41 import '../js/js.dart' show js; |
| 41 import '../js/js_source_mapping.dart' show JavaScriptSourceInformationStrategy; | 42 import '../js/js_source_mapping.dart' show JavaScriptSourceInformationStrategy; |
| 42 import '../js/rewrite_async.dart'; | 43 import '../js/rewrite_async.dart'; |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 | 516 |
| 516 /// True if the html library has been loaded. | 517 /// True if the html library has been loaded. |
| 517 bool htmlLibraryIsLoaded = false; | 518 bool htmlLibraryIsLoaded = false; |
| 518 | 519 |
| 519 /// True when we enqueue the loadLibrary code. | 520 /// True when we enqueue the loadLibrary code. |
| 520 bool isLoadLibraryFunctionResolved = false; | 521 bool isLoadLibraryFunctionResolved = false; |
| 521 | 522 |
| 522 /// `true` if access to [BackendHelpers.invokeOnMethod] is supported. | 523 /// `true` if access to [BackendHelpers.invokeOnMethod] is supported. |
| 523 bool hasInvokeOnSupport = false; | 524 bool hasInvokeOnSupport = false; |
| 524 | 525 |
| 526 /// `true` if tear-offs are supported for incremental compilation. |
| 527 bool hasIncrementalTearOffSupport = false; |
| 528 |
| 525 /// List of constants from metadata. If metadata must be preserved, | 529 /// List of constants from metadata. If metadata must be preserved, |
| 526 /// these constants must be registered. | 530 /// these constants must be registered. |
| 527 final List<Dependency> metadataConstants = <Dependency>[]; | 531 final List<Dependency> metadataConstants = <Dependency>[]; |
| 528 | 532 |
| 529 /// Set of elements for which metadata has been registered as dependencies. | 533 /// Set of elements for which metadata has been registered as dependencies. |
| 530 final Set<Element> _registeredMetadata = new Set<Element>(); | 534 final Set<Element> _registeredMetadata = new Set<Element>(); |
| 531 | 535 |
| 532 /// List of elements that the user has requested for reflection. | 536 /// List of elements that the user has requested for reflection. |
| 533 final Set<Element> targetsUsed = new Set<Element>(); | 537 final Set<Element> targetsUsed = new Set<Element>(); |
| 534 | 538 |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 impactTransformer.registerBackendImpact( | 1335 impactTransformer.registerBackendImpact( |
| 1332 impactBuilder, impacts.traceHelper); | 1336 impactBuilder, impacts.traceHelper); |
| 1333 } | 1337 } |
| 1334 impactTransformer.registerBackendImpact( | 1338 impactTransformer.registerBackendImpact( |
| 1335 impactBuilder, impacts.assertUnreachable); | 1339 impactBuilder, impacts.assertUnreachable); |
| 1336 _registerCheckedModeHelpers(impactBuilder); | 1340 _registerCheckedModeHelpers(impactBuilder); |
| 1337 return impactBuilder; | 1341 return impactBuilder; |
| 1338 } | 1342 } |
| 1339 | 1343 |
| 1340 onResolutionComplete() { | 1344 onResolutionComplete() { |
| 1345 compiler.enqueuer.resolution.processedEntities.forEach(processAnnotations); |
| 1341 super.onResolutionComplete(); | 1346 super.onResolutionComplete(); |
| 1342 computeMembersNeededForReflection(); | 1347 computeMembersNeededForReflection(); |
| 1343 rti.computeClassesNeedingRti(); | 1348 rti.computeClassesNeedingRti(); |
| 1344 _registeredMetadata.clear(); | 1349 _registeredMetadata.clear(); |
| 1345 } | 1350 } |
| 1346 | 1351 |
| 1347 onTypeInferenceComplete() { | 1352 onTypeInferenceComplete() { |
| 1348 super.onTypeInferenceComplete(); | 1353 super.onTypeInferenceComplete(); |
| 1349 noSuchMethodRegistry.onTypeInferenceComplete(); | 1354 noSuchMethodRegistry.onTypeInferenceComplete(); |
| 1350 } | 1355 } |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1798 bool mayGenerateInstanceofCheck(DartType type) { | 1803 bool mayGenerateInstanceofCheck(DartType type) { |
| 1799 // We can use an instanceof check for raw types that have no subclass that | 1804 // We can use an instanceof check for raw types that have no subclass that |
| 1800 // is mixed-in or in an implements clause. | 1805 // is mixed-in or in an implements clause. |
| 1801 | 1806 |
| 1802 if (!type.isRaw) return false; | 1807 if (!type.isRaw) return false; |
| 1803 ClassElement classElement = type.element; | 1808 ClassElement classElement = type.element; |
| 1804 if (isInterceptorClass(classElement)) return false; | 1809 if (isInterceptorClass(classElement)) return false; |
| 1805 return compiler.closedWorld.hasOnlySubclasses(classElement); | 1810 return compiler.closedWorld.hasOnlySubclasses(classElement); |
| 1806 } | 1811 } |
| 1807 | 1812 |
| 1808 WorldImpact registerStaticUse(Element element, {bool forResolution}) { | 1813 WorldImpact registerUsedElement(Element element, {bool forResolution}) { |
| 1809 WorldImpactBuilderImpl worldImpact = new WorldImpactBuilderImpl(); | 1814 WorldImpactBuilderImpl worldImpact = new WorldImpactBuilderImpl(); |
| 1810 if (element == helpers.disableTreeShakingMarker) { | 1815 if (element == helpers.disableTreeShakingMarker) { |
| 1811 isTreeShakingDisabled = true; | 1816 isTreeShakingDisabled = true; |
| 1812 } else if (element == helpers.preserveNamesMarker) { | 1817 } else if (element == helpers.preserveNamesMarker) { |
| 1813 mustPreserveNames = true; | 1818 mustPreserveNames = true; |
| 1814 } else if (element == helpers.preserveMetadataMarker) { | 1819 } else if (element == helpers.preserveMetadataMarker) { |
| 1815 mustRetainMetadata = true; | 1820 mustRetainMetadata = true; |
| 1816 } else if (element == helpers.preserveUrisMarker) { | 1821 } else if (element == helpers.preserveUrisMarker) { |
| 1817 if (compiler.options.preserveUris) mustPreserveUris = true; | 1822 if (compiler.options.preserveUris) mustPreserveUris = true; |
| 1818 } else if (element == helpers.preserveLibraryNamesMarker) { | 1823 } else if (element == helpers.preserveLibraryNamesMarker) { |
| 1819 mustRetainLibraryNames = true; | 1824 mustRetainLibraryNames = true; |
| 1820 } else if (element == helpers.getIsolateAffinityTagMarker) { | 1825 } else if (element == helpers.getIsolateAffinityTagMarker) { |
| 1821 needToInitializeIsolateAffinityTag = true; | 1826 needToInitializeIsolateAffinityTag = true; |
| 1822 } else if (element.isDeferredLoaderGetter) { | 1827 } else if (element.isDeferredLoaderGetter) { |
| 1823 // TODO(sigurdm): Create a function registerLoadLibraryAccess. | 1828 // TODO(sigurdm): Create a function registerLoadLibraryAccess. |
| 1824 if (!isLoadLibraryFunctionResolved) { | 1829 if (!isLoadLibraryFunctionResolved) { |
| 1825 isLoadLibraryFunctionResolved = true; | 1830 isLoadLibraryFunctionResolved = true; |
| 1826 if (forResolution) { | 1831 if (forResolution) { |
| 1827 impactTransformer.registerBackendImpact( | 1832 impactTransformer.registerBackendImpact( |
| 1828 worldImpact, impacts.loadLibrary); | 1833 worldImpact, impacts.loadLibrary); |
| 1829 } | 1834 } |
| 1830 } | 1835 } |
| 1831 } else if (element == helpers.requiresPreambleMarker) { | 1836 } else if (element == helpers.requiresPreambleMarker) { |
| 1832 requiresPreamble = true; | 1837 requiresPreamble = true; |
| 1838 } else if (element == helpers.invokeOnMethod && forResolution) { |
| 1839 hasInvokeOnSupport = true; |
| 1833 } | 1840 } |
| 1834 customElementsAnalysis.registerStaticUse(element, | 1841 customElementsAnalysis.registerStaticUse(element, |
| 1835 forResolution: forResolution); | 1842 forResolution: forResolution); |
| 1836 return worldImpact; | 1843 return worldImpact; |
| 1837 } | 1844 } |
| 1838 | 1845 |
| 1839 /// Called when [:const Symbol(name):] is seen. | 1846 /// Called when [:const Symbol(name):] is seen. |
| 1840 void registerConstSymbol(String name) { | 1847 void registerConstSymbol(String name) { |
| 1841 symbolsUsed.add(name); | 1848 symbolsUsed.add(name); |
| 1842 if (name.endsWith('=')) { | 1849 if (name.endsWith('=')) { |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2247 if (target.isField) { | 2254 if (target.isField) { |
| 2248 staticFields.add(target); | 2255 staticFields.add(target); |
| 2249 } else if (target.isLibrary || target.isClass) { | 2256 } else if (target.isLibrary || target.isClass) { |
| 2250 addFieldsInContainer(target); | 2257 addFieldsInContainer(target); |
| 2251 } | 2258 } |
| 2252 } | 2259 } |
| 2253 return staticFields; | 2260 return staticFields; |
| 2254 } | 2261 } |
| 2255 | 2262 |
| 2256 /// Called when [enqueuer] is empty, but before it is closed. | 2263 /// Called when [enqueuer] is empty, but before it is closed. |
| 2257 bool onQueueEmpty(Enqueuer enqueuer, Iterable<ClassElement> recentClasses) { | 2264 bool onQueueEmpty(Enqueuer enqueuer, Iterable<ClassEntity> recentClasses) { |
| 2258 // Add elements used synthetically, that is, through features rather than | 2265 // Add elements used synthetically, that is, through features rather than |
| 2259 // syntax, for instance custom elements. | 2266 // syntax, for instance custom elements. |
| 2260 // | 2267 // |
| 2261 // Return early if any elements are added to avoid counting the elements as | 2268 // Return early if any elements are added to avoid counting the elements as |
| 2262 // due to mirrors. | 2269 // due to mirrors. |
| 2263 enqueuer.applyImpact(customElementsAnalysis.flush( | 2270 enqueuer.applyImpact(customElementsAnalysis.flush( |
| 2264 forResolution: enqueuer.isResolutionQueue)); | 2271 forResolution: enqueuer.isResolutionQueue)); |
| 2265 enqueuer.applyImpact( | 2272 enqueuer.applyImpact( |
| 2266 lookupMapAnalysis.flush(forResolution: enqueuer.isResolutionQueue)); | 2273 lookupMapAnalysis.flush(forResolution: enqueuer.isResolutionQueue)); |
| 2267 enqueuer.applyImpact( | 2274 enqueuer.applyImpact( |
| 2268 typeVariableHandler.flush(forResolution: enqueuer.isResolutionQueue)); | 2275 typeVariableHandler.flush(forResolution: enqueuer.isResolutionQueue)); |
| 2269 | 2276 |
| 2270 if (!enqueuer.queueIsEmpty) return false; | 2277 if (!enqueuer.queueIsEmpty) return false; |
| 2271 | 2278 |
| 2272 noSuchMethodRegistry.onQueueEmpty(); | 2279 noSuchMethodRegistry.onQueueEmpty(); |
| 2273 if (!enabledNoSuchMethod && | 2280 if (!enabledNoSuchMethod && |
| 2274 (noSuchMethodRegistry.hasThrowingNoSuchMethod || | 2281 (noSuchMethodRegistry.hasThrowingNoSuchMethod || |
| 2275 noSuchMethodRegistry.hasComplexNoSuchMethod)) { | 2282 noSuchMethodRegistry.hasComplexNoSuchMethod)) { |
| 2276 enqueuer.applyImpact(enableNoSuchMethod()); | 2283 enqueuer.applyImpact(enableNoSuchMethod()); |
| 2277 enabledNoSuchMethod = true; | 2284 enabledNoSuchMethod = true; |
| 2278 } | 2285 } |
| 2279 | 2286 |
| 2280 if (compiler.options.useKernel && compiler.mainApp != null) { | 2287 if (compiler.options.useKernel && compiler.mainApp != null) { |
| 2281 kernelTask.buildKernelIr(); | 2288 kernelTask.buildKernelIr(); |
| 2282 } | 2289 } |
| 2283 | 2290 |
| 2284 if (compiler.options.hasIncrementalSupport) { | 2291 if (compiler.options.hasIncrementalSupport && |
| 2292 !hasIncrementalTearOffSupport) { |
| 2285 // Always enable tear-off closures during incremental compilation. | 2293 // Always enable tear-off closures during incremental compilation. |
| 2286 Element element = helpers.closureFromTearOff; | 2294 Element element = helpers.closureFromTearOff; |
| 2287 if (element != null && !enqueuer.isProcessed(element)) { | 2295 if (element != null) { |
| 2288 enqueuer.applyImpact( | 2296 enqueuer.applyImpact( |
| 2289 impactTransformer.createImpactFor(impacts.closureClass)); | 2297 impactTransformer.createImpactFor(impacts.closureClass)); |
| 2290 } | 2298 } |
| 2299 hasIncrementalTearOffSupport = true; |
| 2291 } | 2300 } |
| 2292 | 2301 |
| 2293 if (!enqueuer.isResolutionQueue && preMirrorsMethodCount == 0) { | 2302 if (!enqueuer.isResolutionQueue && preMirrorsMethodCount == 0) { |
| 2294 preMirrorsMethodCount = generatedCode.length; | 2303 preMirrorsMethodCount = generatedCode.length; |
| 2295 } | 2304 } |
| 2296 | 2305 |
| 2297 if (isTreeShakingDisabled) { | 2306 if (isTreeShakingDisabled) { |
| 2298 enqueuer.applyImpact(mirrorsAnalysis.computeImpactForReflectiveElements( | 2307 enqueuer.applyImpact(mirrorsAnalysis.computeImpactForReflectiveElements( |
| 2299 recentClasses, | 2308 recentClasses, |
| 2300 enqueuer.processedClasses, | 2309 enqueuer.processedClasses, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2326 constants.getConstantValueForMetadata(metadata); | 2335 constants.getConstantValueForMetadata(metadata); |
| 2327 Dependency dependency = | 2336 Dependency dependency = |
| 2328 new Dependency(constant, metadata.annotatedElement); | 2337 new Dependency(constant, metadata.annotatedElement); |
| 2329 metadataConstants.add(dependency); | 2338 metadataConstants.add(dependency); |
| 2330 computeImpactForCompileTimeConstant( | 2339 computeImpactForCompileTimeConstant( |
| 2331 dependency.constant, impactBuilder, enqueuer.isResolutionQueue); | 2340 dependency.constant, impactBuilder, enqueuer.isResolutionQueue); |
| 2332 } | 2341 } |
| 2333 | 2342 |
| 2334 // TODO(johnniwinther): We should have access to all recently processed | 2343 // TODO(johnniwinther): We should have access to all recently processed |
| 2335 // elements and process these instead. | 2344 // elements and process these instead. |
| 2336 processMetadata(compiler.enqueuer.resolution.processedElements, | 2345 processMetadata(compiler.enqueuer.resolution.processedEntities, |
| 2337 registerMetadataConstant); | 2346 registerMetadataConstant); |
| 2338 } else { | 2347 } else { |
| 2339 for (Dependency dependency in metadataConstants) { | 2348 for (Dependency dependency in metadataConstants) { |
| 2340 computeImpactForCompileTimeConstant( | 2349 computeImpactForCompileTimeConstant( |
| 2341 dependency.constant, impactBuilder, enqueuer.isResolutionQueue); | 2350 dependency.constant, impactBuilder, enqueuer.isResolutionQueue); |
| 2342 } | 2351 } |
| 2343 metadataConstants.clear(); | 2352 metadataConstants.clear(); |
| 2344 } | 2353 } |
| 2345 enqueuer.applyImpact(impactBuilder.flush()); | 2354 enqueuer.applyImpact(impactBuilder.flush()); |
| 2346 } | 2355 } |
| 2347 return true; | 2356 return true; |
| 2348 } | 2357 } |
| 2349 | 2358 |
| 2350 /// Call [registerMetadataConstant] on all metadata from [elements]. | 2359 /// Call [registerMetadataConstant] on all metadata from [entities]. |
| 2351 void processMetadata(Iterable<Element> elements, | 2360 void processMetadata( |
| 2352 void onMetadata(MetadataAnnotation metadata)) { | 2361 Iterable<Entity> entities, void onMetadata(MetadataAnnotation metadata)) { |
| 2353 void processLibraryMetadata(LibraryElement library) { | 2362 void processLibraryMetadata(LibraryElement library) { |
| 2354 if (_registeredMetadata.add(library)) { | 2363 if (_registeredMetadata.add(library)) { |
| 2355 library.metadata.forEach(onMetadata); | 2364 library.metadata.forEach(onMetadata); |
| 2356 library.entryCompilationUnit.metadata.forEach(onMetadata); | 2365 library.entryCompilationUnit.metadata.forEach(onMetadata); |
| 2357 for (ImportElement import in library.imports) { | 2366 for (ImportElement import in library.imports) { |
| 2358 import.metadata.forEach(onMetadata); | 2367 import.metadata.forEach(onMetadata); |
| 2359 } | 2368 } |
| 2360 } | 2369 } |
| 2361 } | 2370 } |
| 2362 | 2371 |
| 2363 void processElementMetadata(Element element) { | 2372 void processElementMetadata(Element element) { |
| 2364 if (_registeredMetadata.add(element)) { | 2373 if (_registeredMetadata.add(element)) { |
| 2365 element.metadata.forEach(onMetadata); | 2374 element.metadata.forEach(onMetadata); |
| 2366 if (element.isFunction) { | 2375 if (element.isFunction) { |
| 2367 FunctionElement function = element; | 2376 FunctionElement function = element; |
| 2368 for (ParameterElement parameter in function.parameters) { | 2377 for (ParameterElement parameter in function.parameters) { |
| 2369 parameter.metadata.forEach(onMetadata); | 2378 parameter.metadata.forEach(onMetadata); |
| 2370 } | 2379 } |
| 2371 } | 2380 } |
| 2372 if (element.enclosingClass != null) { | 2381 if (element.enclosingClass != null) { |
| 2373 processElementMetadata(element.enclosingClass); | 2382 processElementMetadata(element.enclosingClass); |
| 2374 } else { | 2383 } else { |
| 2375 processLibraryMetadata(element.library); | 2384 processLibraryMetadata(element.library); |
| 2376 } | 2385 } |
| 2377 } | 2386 } |
| 2378 } | 2387 } |
| 2379 | 2388 |
| 2380 elements.forEach(processElementMetadata); | 2389 entities.forEach(processElementMetadata); |
| 2381 } | 2390 } |
| 2382 | 2391 |
| 2383 void onQueueClosed() { | 2392 void onQueueClosed() { |
| 2384 lookupMapAnalysis.onQueueClosed(); | 2393 lookupMapAnalysis.onQueueClosed(); |
| 2385 jsInteropAnalysis.onQueueClosed(); | 2394 jsInteropAnalysis.onQueueClosed(); |
| 2386 } | 2395 } |
| 2387 | 2396 |
| 2388 void onCodegenStart() { | 2397 void onCodegenStart() { |
| 2389 lookupMapAnalysis.onCodegenStart(); | 2398 lookupMapAnalysis.onCodegenStart(); |
| 2390 } | 2399 } |
| 2391 | 2400 |
| 2392 @override | 2401 /// Process backend specific annotations. |
| 2393 void onElementResolved(Element element) { | 2402 void processAnnotations(Element element) { |
| 2394 if (element.isMalformed) { | 2403 if (element.isMalformed) { |
| 2395 // Elements that are marker as malformed during parsing or resolution | 2404 // Elements that are marked as malformed during parsing or resolution |
| 2396 // might be registered here. These should just be ignored. | 2405 // might be registered here. These should just be ignored. |
| 2397 return; | 2406 return; |
| 2398 } | 2407 } |
| 2399 | 2408 |
| 2400 Element implementation = element.implementation; | 2409 Element implementation = element.implementation; |
| 2401 if (element.isFunction || element.isConstructor) { | 2410 if (element.isFunction || element.isConstructor) { |
| 2402 if (annotations.noInline(implementation)) { | 2411 if (annotations.noInline(implementation)) { |
| 2403 inlineCache.markAsNonInlinable(implementation); | 2412 inlineCache.markAsNonInlinable(implementation); |
| 2404 } | 2413 } |
| 2405 } | 2414 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2459 element, "@ForceInline() must not be used with @NoInline."); | 2468 element, "@ForceInline() must not be used with @NoInline."); |
| 2460 } | 2469 } |
| 2461 if (hasNoThrows && !hasNoInline) { | 2470 if (hasNoThrows && !hasNoInline) { |
| 2462 reporter.internalError( | 2471 reporter.internalError( |
| 2463 element, "@NoThrows() should always be combined with @NoInline."); | 2472 element, "@NoThrows() should always be combined with @NoInline."); |
| 2464 } | 2473 } |
| 2465 if (hasNoSideEffects && !hasNoInline) { | 2474 if (hasNoSideEffects && !hasNoInline) { |
| 2466 reporter.internalError(element, | 2475 reporter.internalError(element, |
| 2467 "@NoSideEffects() should always be combined with @NoInline."); | 2476 "@NoSideEffects() should always be combined with @NoInline."); |
| 2468 } | 2477 } |
| 2469 if (element == helpers.invokeOnMethod) { | |
| 2470 hasInvokeOnSupport = true; | |
| 2471 } | |
| 2472 } | 2478 } |
| 2473 | 2479 |
| 2474 /* | |
| 2475 CodeBuffer codeOf(Element element) { | |
| 2476 return generatedCode.containsKey(element) | |
| 2477 ? jsAst.prettyPrint(generatedCode[element], compiler) | |
| 2478 : null; | |
| 2479 } | |
| 2480 */ | |
| 2481 FunctionElement helperForBadMain() => helpers.badMain; | 2480 FunctionElement helperForBadMain() => helpers.badMain; |
| 2482 | 2481 |
| 2483 FunctionElement helperForMissingMain() => helpers.missingMain; | 2482 FunctionElement helperForMissingMain() => helpers.missingMain; |
| 2484 | 2483 |
| 2485 FunctionElement helperForMainArity() => helpers.mainHasTooManyParameters; | 2484 FunctionElement helperForMainArity() => helpers.mainHasTooManyParameters; |
| 2486 | 2485 |
| 2487 void forgetElement(Element element) { | 2486 void forgetElement(Element element) { |
| 2488 constants.forgetElement(element); | 2487 constants.forgetElement(element); |
| 2489 constantCompilerTask.dartConstantCompiler.forgetElement(element); | 2488 constantCompilerTask.dartConstantCompiler.forgetElement(element); |
| 2490 aliasedSuperMembers.remove(element); | 2489 aliasedSuperMembers.remove(element); |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3171 final bool supportDeferredLoad; | 3170 final bool supportDeferredLoad; |
| 3172 final bool supportDumpInfo; | 3171 final bool supportDumpInfo; |
| 3173 final bool supportSerialization; | 3172 final bool supportSerialization; |
| 3174 | 3173 |
| 3175 JavaScriptImpactStrategy(this.resolution, this.dumpInfoTask, | 3174 JavaScriptImpactStrategy(this.resolution, this.dumpInfoTask, |
| 3176 {this.supportDeferredLoad, | 3175 {this.supportDeferredLoad, |
| 3177 this.supportDumpInfo, | 3176 this.supportDumpInfo, |
| 3178 this.supportSerialization}); | 3177 this.supportSerialization}); |
| 3179 | 3178 |
| 3180 @override | 3179 @override |
| 3181 void visitImpact(Element element, WorldImpact impact, | 3180 void visitImpact(var impactSource, WorldImpact impact, |
| 3182 WorldImpactVisitor visitor, ImpactUseCase impactUse) { | 3181 WorldImpactVisitor visitor, ImpactUseCase impactUse) { |
| 3183 // TODO(johnniwinther): Compute the application strategy once for each use. | 3182 // TODO(johnniwinther): Compute the application strategy once for each use. |
| 3184 if (impactUse == ResolutionEnqueuer.IMPACT_USE) { | 3183 if (impactUse == ResolutionEnqueuer.IMPACT_USE) { |
| 3185 if (supportDeferredLoad || supportSerialization) { | 3184 if (supportDeferredLoad || supportSerialization) { |
| 3186 impact.apply(visitor); | 3185 impact.apply(visitor); |
| 3187 } else { | 3186 } else { |
| 3188 impact.apply(visitor); | 3187 impact.apply(visitor); |
| 3189 if (element != null) { | 3188 if (impactSource is Element) { |
| 3190 resolution.uncacheWorldImpact(element); | 3189 resolution.uncacheWorldImpact(impactSource); |
| 3191 } | 3190 } |
| 3192 } | 3191 } |
| 3193 } else if (impactUse == DeferredLoadTask.IMPACT_USE) { | 3192 } else if (impactUse == DeferredLoadTask.IMPACT_USE) { |
| 3194 impact.apply(visitor); | 3193 impact.apply(visitor); |
| 3195 // Impacts are uncached globally in [onImpactUsed]. | 3194 // Impacts are uncached globally in [onImpactUsed]. |
| 3196 } else if (impactUse == DumpInfoTask.IMPACT_USE) { | 3195 } else if (impactUse == DumpInfoTask.IMPACT_USE) { |
| 3197 impact.apply(visitor); | 3196 impact.apply(visitor); |
| 3198 dumpInfoTask.unregisterImpact(element); | 3197 dumpInfoTask.unregisterImpact(impactSource); |
| 3199 } else { | 3198 } else { |
| 3200 impact.apply(visitor); | 3199 impact.apply(visitor); |
| 3201 } | 3200 } |
| 3202 } | 3201 } |
| 3203 | 3202 |
| 3204 @override | 3203 @override |
| 3205 void onImpactUsed(ImpactUseCase impactUse) { | 3204 void onImpactUsed(ImpactUseCase impactUse) { |
| 3206 if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) { | 3205 if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) { |
| 3207 // TODO(johnniwinther): Allow emptying when serialization has been | 3206 // TODO(johnniwinther): Allow emptying when serialization has been |
| 3208 // performed. | 3207 // performed. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3230 ClassElement get mapImplementation => helpers.mapLiteralClass; | 3229 ClassElement get mapImplementation => helpers.mapLiteralClass; |
| 3231 ClassElement get constMapImplementation => helpers.constMapLiteralClass; | 3230 ClassElement get constMapImplementation => helpers.constMapLiteralClass; |
| 3232 ClassElement get typeImplementation => helpers.typeLiteralClass; | 3231 ClassElement get typeImplementation => helpers.typeLiteralClass; |
| 3233 ClassElement get boolImplementation => helpers.jsBoolClass; | 3232 ClassElement get boolImplementation => helpers.jsBoolClass; |
| 3234 ClassElement get nullImplementation => helpers.jsNullClass; | 3233 ClassElement get nullImplementation => helpers.jsNullClass; |
| 3235 ClassElement get syncStarIterableImplementation => helpers.syncStarIterable; | 3234 ClassElement get syncStarIterableImplementation => helpers.syncStarIterable; |
| 3236 ClassElement get asyncFutureImplementation => helpers.futureImplementation; | 3235 ClassElement get asyncFutureImplementation => helpers.futureImplementation; |
| 3237 ClassElement get asyncStarStreamImplementation => helpers.controllerStream; | 3236 ClassElement get asyncStarStreamImplementation => helpers.controllerStream; |
| 3238 ClassElement get functionImplementation => helpers.coreClasses.functionClass; | 3237 ClassElement get functionImplementation => helpers.coreClasses.functionClass; |
| 3239 } | 3238 } |
| OLD | NEW |