Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1223)

Side by Side Diff: pkg/compiler/lib/src/js_backend/backend.dart

Issue 2378063002: Remove Enqueuer argument from Backend.registerStaticUse (Closed)
Patch Set: Updated cf. comments. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 addInterceptors(helpers.jsJavaScriptFunctionClass, enqueuer, registry); 1303 addInterceptors(helpers.jsJavaScriptFunctionClass, enqueuer, registry);
1304 } else if (isNativeOrExtendsNative(cls)) { 1304 } else if (isNativeOrExtendsNative(cls)) {
1305 addInterceptorsForNativeClassMembers(cls, enqueuer); 1305 addInterceptorsForNativeClassMembers(cls, enqueuer);
1306 } else if (cls == helpers.jsIndexingBehaviorInterface) { 1306 } else if (cls == helpers.jsIndexingBehaviorInterface) {
1307 // These two helpers are used by the emitter and the codegen. 1307 // These two helpers are used by the emitter and the codegen.
1308 // Because we cannot enqueue elements at the time of emission, 1308 // Because we cannot enqueue elements at the time of emission,
1309 // we make sure they are always generated. 1309 // we make sure they are always generated.
1310 enqueue(enqueuer, helpers.isJsIndexable, registry); 1310 enqueue(enqueuer, helpers.isJsIndexable, registry);
1311 } 1311 }
1312 1312
1313 customElementsAnalysis.registerInstantiatedClass(cls, enqueuer); 1313 customElementsAnalysis.registerInstantiatedClass(cls,
1314 forResolution: enqueuer.isResolutionQueue);
1314 if (!enqueuer.isResolutionQueue) { 1315 if (!enqueuer.isResolutionQueue) {
1315 lookupMapAnalysis.registerInstantiatedClass(cls); 1316 lookupMapAnalysis.registerInstantiatedClass(cls);
1316 } 1317 }
1317 } 1318 }
1318 1319
1319 void registerInstantiatedType( 1320 void registerInstantiatedType(
1320 InterfaceType type, Enqueuer enqueuer, Registry registry, 1321 InterfaceType type, Enqueuer enqueuer, Registry registry,
1321 {bool mirrorUsage: false}) { 1322 {bool mirrorUsage: false}) {
1322 lookupMapAnalysis.registerInstantiatedType(type); 1323 lookupMapAnalysis.registerInstantiatedType(type);
1323 super.registerInstantiatedType(type, enqueuer, registry, 1324 super.registerInstantiatedType(type, enqueuer, registry,
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 bool mayGenerateInstanceofCheck(DartType type) { 1898 bool mayGenerateInstanceofCheck(DartType type) {
1898 // We can use an instanceof check for raw types that have no subclass that 1899 // We can use an instanceof check for raw types that have no subclass that
1899 // is mixed-in or in an implements clause. 1900 // is mixed-in or in an implements clause.
1900 1901
1901 if (!type.isRaw) return false; 1902 if (!type.isRaw) return false;
1902 ClassElement classElement = type.element; 1903 ClassElement classElement = type.element;
1903 if (isInterceptorClass(classElement)) return false; 1904 if (isInterceptorClass(classElement)) return false;
1904 return compiler.closedWorld.hasOnlySubclasses(classElement); 1905 return compiler.closedWorld.hasOnlySubclasses(classElement);
1905 } 1906 }
1906 1907
1907 void registerStaticUse(Element element, Enqueuer enqueuer) { 1908 void registerStaticUse(Element element, {bool forResolution}) {
1908 if (element == helpers.disableTreeShakingMarker) { 1909 if (element == helpers.disableTreeShakingMarker) {
1909 isTreeShakingDisabled = true; 1910 isTreeShakingDisabled = true;
1910 } else if (element == helpers.preserveNamesMarker) { 1911 } else if (element == helpers.preserveNamesMarker) {
1911 mustPreserveNames = true; 1912 mustPreserveNames = true;
1912 } else if (element == helpers.preserveMetadataMarker) { 1913 } else if (element == helpers.preserveMetadataMarker) {
1913 mustRetainMetadata = true; 1914 mustRetainMetadata = true;
1914 } else if (element == helpers.preserveUrisMarker) { 1915 } else if (element == helpers.preserveUrisMarker) {
1915 if (compiler.options.preserveUris) mustPreserveUris = true; 1916 if (compiler.options.preserveUris) mustPreserveUris = true;
1916 } else if (element == helpers.preserveLibraryNamesMarker) { 1917 } else if (element == helpers.preserveLibraryNamesMarker) {
1917 mustRetainLibraryNames = true; 1918 mustRetainLibraryNames = true;
1918 } else if (element == helpers.getIsolateAffinityTagMarker) { 1919 } else if (element == helpers.getIsolateAffinityTagMarker) {
1919 needToInitializeIsolateAffinityTag = true; 1920 needToInitializeIsolateAffinityTag = true;
1920 } else if (element.isDeferredLoaderGetter) { 1921 } else if (element.isDeferredLoaderGetter) {
1921 // TODO(sigurdm): Create a function registerLoadLibraryAccess. 1922 // TODO(sigurdm): Create a function registerLoadLibraryAccess.
1922 if (!isLoadLibraryFunctionResolved) { 1923 if (!isLoadLibraryFunctionResolved) {
1923 isLoadLibraryFunctionResolved = true; 1924 isLoadLibraryFunctionResolved = true;
1924 enqueueInResolution( 1925 enqueueInResolution(
1925 helpers.loadLibraryWrapper, compiler.globalDependencies); 1926 helpers.loadLibraryWrapper, compiler.globalDependencies);
1926 } 1927 }
1927 } else if (element == helpers.requiresPreambleMarker) { 1928 } else if (element == helpers.requiresPreambleMarker) {
1928 requiresPreamble = true; 1929 requiresPreamble = true;
1929 } 1930 }
1930 customElementsAnalysis.registerStaticUse(element, enqueuer); 1931 customElementsAnalysis.registerStaticUse(element,
1932 forResolution: forResolution);
1931 } 1933 }
1932 1934
1933 /// Called when [:const Symbol(name):] is seen. 1935 /// Called when [:const Symbol(name):] is seen.
1934 void registerConstSymbol(String name) { 1936 void registerConstSymbol(String name) {
1935 symbolsUsed.add(name); 1937 symbolsUsed.add(name);
1936 if (name.endsWith('=')) { 1938 if (name.endsWith('=')) {
1937 symbolsUsed.add(name.substring(0, name.length - 1)); 1939 symbolsUsed.add(name.substring(0, name.length - 1));
1938 } 1940 }
1939 } 1941 }
1940 1942
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
2344 return staticFields; 2346 return staticFields;
2345 } 2347 }
2346 2348
2347 /// Called when [enqueuer] is empty, but before it is closed. 2349 /// Called when [enqueuer] is empty, but before it is closed.
2348 bool onQueueEmpty(Enqueuer enqueuer, Iterable<ClassElement> recentClasses) { 2350 bool onQueueEmpty(Enqueuer enqueuer, Iterable<ClassElement> recentClasses) {
2349 // Add elements used synthetically, that is, through features rather than 2351 // Add elements used synthetically, that is, through features rather than
2350 // syntax, for instance custom elements. 2352 // syntax, for instance custom elements.
2351 // 2353 //
2352 // Return early if any elements are added to avoid counting the elements as 2354 // Return early if any elements are added to avoid counting the elements as
2353 // due to mirrors. 2355 // due to mirrors.
2354 customElementsAnalysis.onQueueEmpty(enqueuer); 2356 enqueuer.applyImpact(customElementsAnalysis.flush(
2355 lookupMapAnalysis.onQueueEmpty(enqueuer); 2357 forResolution: enqueuer.isResolutionQueue));
2356 typeVariableHandler.onQueueEmpty(enqueuer); 2358 enqueuer.applyImpact(
2359 lookupMapAnalysis.flush(forResolution: enqueuer.isResolutionQueue));
2360 enqueuer.applyImpact(
2361 typeVariableHandler.flush(forResolution: enqueuer.isResolutionQueue));
2357 2362
2358 if (!enqueuer.queueIsEmpty) return false; 2363 if (!enqueuer.queueIsEmpty) return false;
2359 2364
2360 noSuchMethodRegistry.onQueueEmpty(); 2365 noSuchMethodRegistry.onQueueEmpty();
2361 if (!enabledNoSuchMethod && 2366 if (!enabledNoSuchMethod &&
2362 (noSuchMethodRegistry.hasThrowingNoSuchMethod || 2367 (noSuchMethodRegistry.hasThrowingNoSuchMethod ||
2363 noSuchMethodRegistry.hasComplexNoSuchMethod)) { 2368 noSuchMethodRegistry.hasComplexNoSuchMethod)) {
2364 enableNoSuchMethod(enqueuer); 2369 enableNoSuchMethod(enqueuer);
2365 enabledNoSuchMethod = true; 2370 enabledNoSuchMethod = true;
2366 } 2371 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2417 // elements and process these instead. 2422 // elements and process these instead.
2418 processMetadata(compiler.enqueuer.resolution.processedElements, 2423 processMetadata(compiler.enqueuer.resolution.processedElements,
2419 registerMetadataConstant); 2424 registerMetadataConstant);
2420 } else { 2425 } else {
2421 for (Dependency dependency in metadataConstants) { 2426 for (Dependency dependency in metadataConstants) {
2422 computeImpactForCompileTimeConstant( 2427 computeImpactForCompileTimeConstant(
2423 dependency.constant, impactBuilder, enqueuer.isResolutionQueue); 2428 dependency.constant, impactBuilder, enqueuer.isResolutionQueue);
2424 } 2429 }
2425 metadataConstants.clear(); 2430 metadataConstants.clear();
2426 } 2431 }
2427 enqueuer.applyImpact(null, impactBuilder.flush()); 2432 enqueuer.applyImpact(impactBuilder.flush());
2428 } 2433 }
2429 return true; 2434 return true;
2430 } 2435 }
2431 2436
2432 /// Call [registerMetadataConstant] on all metadata from [elements]. 2437 /// Call [registerMetadataConstant] on all metadata from [elements].
2433 void processMetadata(Iterable<Element> elements, 2438 void processMetadata(Iterable<Element> elements,
2434 void onMetadata(MetadataAnnotation metadata)) { 2439 void onMetadata(MetadataAnnotation metadata)) {
2435 void processLibraryMetadata(LibraryElement library) { 2440 void processLibraryMetadata(LibraryElement library) {
2436 if (_registeredMetadata.add(library)) { 2441 if (_registeredMetadata.add(library)) {
2437 library.metadata.forEach(onMetadata); 2442 library.metadata.forEach(onMetadata);
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
3260 ClassElement get mapImplementation => helpers.mapLiteralClass; 3265 ClassElement get mapImplementation => helpers.mapLiteralClass;
3261 ClassElement get constMapImplementation => helpers.constMapLiteralClass; 3266 ClassElement get constMapImplementation => helpers.constMapLiteralClass;
3262 ClassElement get typeImplementation => helpers.typeLiteralClass; 3267 ClassElement get typeImplementation => helpers.typeLiteralClass;
3263 ClassElement get boolImplementation => helpers.jsBoolClass; 3268 ClassElement get boolImplementation => helpers.jsBoolClass;
3264 ClassElement get nullImplementation => helpers.jsNullClass; 3269 ClassElement get nullImplementation => helpers.jsNullClass;
3265 ClassElement get syncStarIterableImplementation => helpers.syncStarIterable; 3270 ClassElement get syncStarIterableImplementation => helpers.syncStarIterable;
3266 ClassElement get asyncFutureImplementation => helpers.futureImplementation; 3271 ClassElement get asyncFutureImplementation => helpers.futureImplementation;
3267 ClassElement get asyncStarStreamImplementation => helpers.controllerStream; 3272 ClassElement get asyncStarStreamImplementation => helpers.controllerStream;
3268 ClassElement get functionImplementation => helpers.coreClasses.functionClass; 3273 ClassElement get functionImplementation => helpers.coreClasses.functionClass;
3269 } 3274 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/enqueue.dart ('k') | pkg/compiler/lib/src/js_backend/custom_elements_analysis.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698