| 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 dart2js.compiler_base; | 5 library dart2js.compiler_base; |
| 6 | 6 |
| 7 import 'dart:async' show EventSink, Future; | 7 import 'dart:async' show EventSink, Future; |
| 8 | 8 |
| 9 import '../compiler_new.dart' as api; | 9 import '../compiler_new.dart' as api; |
| 10 import 'cache_strategy.dart' show CacheStrategy; | 10 import 'cache_strategy.dart' show CacheStrategy; |
| 11 import 'closure.dart' as closureMapping show ClosureTask; | 11 import 'closure.dart' as closureMapping show ClosureTask; |
| 12 import 'common/backend_api.dart' show Backend; | 12 import 'common/backend_api.dart' show Backend; |
| 13 import 'common/codegen.dart' show CodegenWorkItem; | 13 import 'common/codegen.dart' show CodegenWorkItem; |
| 14 import 'common/names.dart' show Selectors; | 14 import 'common/names.dart' show Selectors; |
| 15 import 'common/names.dart' show Identifiers, Uris; | 15 import 'common/names.dart' show Identifiers, Uris; |
| 16 import 'common/registry.dart' show EagerRegistry, Registry; | 16 import 'common/registry.dart' show EagerRegistry, Registry; |
| 17 import 'common/resolution.dart' | 17 import 'common/resolution.dart' |
| 18 show ParsingContext, Resolution, ResolutionWorkItem, ResolutionImpact; | 18 show ParsingContext, Resolution, ResolutionWorkItem, ResolutionImpact; |
| 19 import 'common/tasks.dart' show CompilerTask, GenericTask; | 19 import 'common/tasks.dart' show CompilerTask, GenericTask, Measurer; |
| 20 import 'common/work.dart' show ItemCompilationContext, WorkItem; | 20 import 'common/work.dart' show ItemCompilationContext, WorkItem; |
| 21 import 'common.dart'; | 21 import 'common.dart'; |
| 22 import 'compile_time_constants.dart'; | 22 import 'compile_time_constants.dart'; |
| 23 import 'constants/values.dart'; | 23 import 'constants/values.dart'; |
| 24 import 'core_types.dart' show CoreClasses, CoreTypes; | 24 import 'core_types.dart' show CoreClasses, CoreTypes; |
| 25 import 'dart_backend/dart_backend.dart' as dart_backend; | 25 import 'dart_backend/dart_backend.dart' as dart_backend; |
| 26 import 'dart_types.dart' show DartType, DynamicType, InterfaceType, Types; | 26 import 'dart_types.dart' show DartType, DynamicType, InterfaceType, Types; |
| 27 import 'deferred_load.dart' show DeferredLoadTask; | 27 import 'deferred_load.dart' show DeferredLoadTask; |
| 28 import 'diagnostics/code_location.dart'; | 28 import 'diagnostics/code_location.dart'; |
| 29 import 'diagnostics/diagnostic_listener.dart' show DiagnosticReporter; | 29 import 'diagnostics/diagnostic_listener.dart' show DiagnosticReporter; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 import 'typechecker.dart' show TypeCheckerTask; | 73 import 'typechecker.dart' show TypeCheckerTask; |
| 74 import 'types/types.dart' as ti; | 74 import 'types/types.dart' as ti; |
| 75 import 'universe/selector.dart' show Selector; | 75 import 'universe/selector.dart' show Selector; |
| 76 import 'universe/universe.dart' show Universe; | 76 import 'universe/universe.dart' show Universe; |
| 77 import 'universe/use.dart' show StaticUse; | 77 import 'universe/use.dart' show StaticUse; |
| 78 import 'universe/world_impact.dart' show ImpactStrategy, WorldImpact; | 78 import 'universe/world_impact.dart' show ImpactStrategy, WorldImpact; |
| 79 import 'util/util.dart' show Link, Setlet; | 79 import 'util/util.dart' show Link, Setlet; |
| 80 import 'world.dart' show World; | 80 import 'world.dart' show World; |
| 81 | 81 |
| 82 abstract class Compiler implements LibraryLoaderListener { | 82 abstract class Compiler implements LibraryLoaderListener { |
| 83 final Stopwatch totalCompileTime = new Stopwatch(); | 83 /// Helper instance for measurements in [CompilerTask]. |
| 84 /// |
| 85 /// Note: MUST be first field to ensure [Measurer.wallclock] is started |
| 86 /// before other computations. |
| 87 final Measurer measurer = new Measurer(); |
| 88 |
| 84 final IdGenerator idGenerator = new IdGenerator(); | 89 final IdGenerator idGenerator = new IdGenerator(); |
| 85 World world; | 90 World world; |
| 86 Types types; | 91 Types types; |
| 87 _CompilerCoreTypes _coreTypes; | 92 _CompilerCoreTypes _coreTypes; |
| 88 _CompilerDiagnosticReporter _reporter; | 93 _CompilerDiagnosticReporter _reporter; |
| 89 _CompilerResolution _resolution; | 94 _CompilerResolution _resolution; |
| 90 ParsingContext _parsingContext; | 95 ParsingContext _parsingContext; |
| 91 | 96 |
| 92 final CacheStrategy cacheStrategy; | 97 final CacheStrategy cacheStrategy; |
| 93 | 98 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 133 |
| 129 /// Output provider from user of Compiler API. | 134 /// Output provider from user of Compiler API. |
| 130 api.CompilerOutput userOutputProvider; | 135 api.CompilerOutput userOutputProvider; |
| 131 | 136 |
| 132 List<Uri> librariesToAnalyzeWhenRun; | 137 List<Uri> librariesToAnalyzeWhenRun; |
| 133 | 138 |
| 134 ResolvedUriTranslator get resolvedUriTranslator; | 139 ResolvedUriTranslator get resolvedUriTranslator; |
| 135 | 140 |
| 136 Tracer tracer; | 141 Tracer tracer; |
| 137 | 142 |
| 138 CompilerTask measuredTask; | |
| 139 LibraryElement coreLibrary; | 143 LibraryElement coreLibrary; |
| 140 LibraryElement asyncLibrary; | 144 LibraryElement asyncLibrary; |
| 141 | 145 |
| 142 LibraryElement mainApp; | 146 LibraryElement mainApp; |
| 143 FunctionElement mainFunction; | 147 FunctionElement mainFunction; |
| 144 | 148 |
| 145 /// Initialized when dart:mirrors is loaded. | 149 /// Initialized when dart:mirrors is loaded. |
| 146 LibraryElement mirrorsLibrary; | 150 LibraryElement mirrorsLibrary; |
| 147 | 151 |
| 148 /// Initialized when dart:typed_data is loaded. | 152 /// Initialized when dart:typed_data is loaded. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 LibraryLoaderTask libraryLoader; | 231 LibraryLoaderTask libraryLoader; |
| 228 SerializationTask serialization; | 232 SerializationTask serialization; |
| 229 ResolverTask resolver; | 233 ResolverTask resolver; |
| 230 closureMapping.ClosureTask closureToClassMapper; | 234 closureMapping.ClosureTask closureToClassMapper; |
| 231 TypeCheckerTask checker; | 235 TypeCheckerTask checker; |
| 232 ti.TypesTask typesTask; | 236 ti.TypesTask typesTask; |
| 233 Backend backend; | 237 Backend backend; |
| 234 | 238 |
| 235 GenericTask reuseLibraryTask; | 239 GenericTask reuseLibraryTask; |
| 236 | 240 |
| 241 GenericTask selfTask; |
| 242 |
| 237 /// The constant environment for the frontend interpretation of compile-time | 243 /// The constant environment for the frontend interpretation of compile-time |
| 238 /// constants. | 244 /// constants. |
| 239 ConstantEnvironment constants; | 245 ConstantEnvironment constants; |
| 240 | 246 |
| 241 EnqueueTask enqueuer; | 247 EnqueueTask enqueuer; |
| 242 DeferredLoadTask deferredLoadTask; | 248 DeferredLoadTask deferredLoadTask; |
| 243 MirrorUsageAnalyzerTask mirrorUsageAnalyzerTask; | 249 MirrorUsageAnalyzerTask mirrorUsageAnalyzerTask; |
| 244 DumpInfoTask dumpInfoTask; | 250 DumpInfoTask dumpInfoTask; |
| 245 | 251 |
| 246 /// A customizable filter that is applied to enqueued work items. | 252 /// A customizable filter that is applied to enqueued work items. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 resolver = createResolverTask(), | 348 resolver = createResolverTask(), |
| 343 closureToClassMapper = new closureMapping.ClosureTask(this), | 349 closureToClassMapper = new closureMapping.ClosureTask(this), |
| 344 checker = new TypeCheckerTask(this), | 350 checker = new TypeCheckerTask(this), |
| 345 typesTask = new ti.TypesTask(this), | 351 typesTask = new ti.TypesTask(this), |
| 346 constants = backend.constantCompilerTask, | 352 constants = backend.constantCompilerTask, |
| 347 deferredLoadTask = new DeferredLoadTask(this), | 353 deferredLoadTask = new DeferredLoadTask(this), |
| 348 mirrorUsageAnalyzerTask = new MirrorUsageAnalyzerTask(this), | 354 mirrorUsageAnalyzerTask = new MirrorUsageAnalyzerTask(this), |
| 349 enqueuer = new EnqueueTask(this), | 355 enqueuer = new EnqueueTask(this), |
| 350 dumpInfoTask = new DumpInfoTask(this), | 356 dumpInfoTask = new DumpInfoTask(this), |
| 351 reuseLibraryTask = new GenericTask('Reuse library', this), | 357 reuseLibraryTask = new GenericTask('Reuse library', this), |
| 358 selfTask = new GenericTask('self', this), |
| 352 ]; | 359 ]; |
| 353 | 360 |
| 354 _parsingContext = | 361 _parsingContext = |
| 355 new ParsingContext(reporter, options, parser, patchParser, backend); | 362 new ParsingContext(reporter, options, parser, patchParser, backend); |
| 356 | 363 |
| 357 tasks.addAll(backend.tasks); | 364 tasks.addAll(backend.tasks); |
| 358 } | 365 } |
| 359 | 366 |
| 360 /// Creates the scanner task. | 367 /// Creates the scanner task. |
| 361 /// | 368 /// |
| (...skipping 19 matching lines...) Expand all Loading... |
| 381 options.disableTypeInference || compilationFailed; | 388 options.disableTypeInference || compilationFailed; |
| 382 | 389 |
| 383 void unimplemented(Spannable spannable, String methodName) { | 390 void unimplemented(Spannable spannable, String methodName) { |
| 384 reporter.internalError(spannable, "$methodName not implemented."); | 391 reporter.internalError(spannable, "$methodName not implemented."); |
| 385 } | 392 } |
| 386 | 393 |
| 387 // Compiles the dart script at [uri]. | 394 // Compiles the dart script at [uri]. |
| 388 // | 395 // |
| 389 // The resulting future will complete with true if the compilation | 396 // The resulting future will complete with true if the compilation |
| 390 // succeeded. | 397 // succeeded. |
| 391 Future<bool> run(Uri uri) { | 398 Future<bool> run(Uri uri) => selfTask.measureSubtask("Compiler.run", () { |
| 392 totalCompileTime.start(); | 399 measurer.startWallClock(); |
| 393 | 400 |
| 394 return new Future.sync(() => runInternal(uri)) | 401 return new Future.sync(() => runInternal(uri)) |
| 395 .catchError((error) => _reporter.onError(uri, error)) | 402 .catchError((error) => _reporter.onError(uri, error)) |
| 396 .whenComplete(() { | 403 .whenComplete(() { |
| 397 tracer.close(); | 404 tracer.close(); |
| 398 totalCompileTime.stop(); | 405 measurer.stopWallClock(); |
| 399 }).then((_) { | 406 }).then((_) { |
| 400 return !compilationFailed; | 407 return !compilationFailed; |
| 401 }); | 408 }); |
| 402 } | 409 }); |
| 403 | 410 |
| 404 /// This method is called immediately after the [LibraryElement] [library] has | 411 /// This method is called immediately after the [LibraryElement] [library] has |
| 405 /// been created. | 412 /// been created. |
| 406 /// | 413 /// |
| 407 /// Use this callback method to store references to specific libraries. | 414 /// Use this callback method to store references to specific libraries. |
| 408 /// Note that [library] has not been scanned yet, nor has its imports/exports | 415 /// Note that [library] has not been scanned yet, nor has its imports/exports |
| 409 /// been resolved. | 416 /// been resolved. |
| 410 void onLibraryCreated(LibraryElement library) { | 417 void onLibraryCreated(LibraryElement library) { |
| 411 Uri uri = library.canonicalUri; | 418 Uri uri = library.canonicalUri; |
| 412 if (uri == Uris.dart_core) { | 419 if (uri == Uris.dart_core) { |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 .then((LibraryElement library) { | 786 .then((LibraryElement library) { |
| 780 if (library == null) return null; | 787 if (library == null) return null; |
| 781 fullyEnqueueLibrary(library, enqueuer.resolution); | 788 fullyEnqueueLibrary(library, enqueuer.resolution); |
| 782 emptyQueue(enqueuer.resolution); | 789 emptyQueue(enqueuer.resolution); |
| 783 enqueuer.resolution.logSummary(reporter.log); | 790 enqueuer.resolution.logSummary(reporter.log); |
| 784 return library; | 791 return library; |
| 785 }); | 792 }); |
| 786 } | 793 } |
| 787 | 794 |
| 788 /// Performs the compilation when all libraries have been loaded. | 795 /// Performs the compilation when all libraries have been loaded. |
| 789 void compileLoadedLibraries() { | 796 void compileLoadedLibraries() |
| 797 => selfTask.measureSubtask("Compiler.compileLoadedLibraries", () { |
| 798 |
| 790 computeMain(); | 799 computeMain(); |
| 791 | 800 |
| 792 mirrorUsageAnalyzerTask.analyzeUsage(mainApp); | 801 mirrorUsageAnalyzerTask.analyzeUsage(mainApp); |
| 793 | 802 |
| 794 // In order to see if a library is deferred, we must compute the | 803 // In order to see if a library is deferred, we must compute the |
| 795 // compile-time constants that are metadata. This means adding | 804 // compile-time constants that are metadata. This means adding |
| 796 // something to the resolution queue. So we cannot wait with | 805 // something to the resolution queue. So we cannot wait with |
| 797 // this until after the resolution queue is processed. | 806 // this until after the resolution queue is processed. |
| 798 deferredLoadTask.beforeResolution(this); | 807 deferredLoadTask.beforeResolution(this); |
| 799 impactStrategy = backend.createImpactStrategy( | 808 impactStrategy = backend.createImpactStrategy( |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 int programSize = backend.assembleProgram(); | 891 int programSize = backend.assembleProgram(); |
| 883 | 892 |
| 884 if (options.dumpInfo) { | 893 if (options.dumpInfo) { |
| 885 dumpInfoTask.reportSize(programSize); | 894 dumpInfoTask.reportSize(programSize); |
| 886 dumpInfoTask.dumpInfo(); | 895 dumpInfoTask.dumpInfo(); |
| 887 } | 896 } |
| 888 | 897 |
| 889 backend.sourceInformationStrategy.onComplete(); | 898 backend.sourceInformationStrategy.onComplete(); |
| 890 | 899 |
| 891 checkQueues(); | 900 checkQueues(); |
| 892 } | 901 }); |
| 893 | 902 |
| 894 void fullyEnqueueLibrary(LibraryElement library, Enqueuer world) { | 903 void fullyEnqueueLibrary(LibraryElement library, Enqueuer world) { |
| 895 void enqueueAll(Element element) { | 904 void enqueueAll(Element element) { |
| 896 fullyEnqueueTopLevelElement(element, world); | 905 fullyEnqueueTopLevelElement(element, world); |
| 897 } | 906 } |
| 898 library.implementation.forEachLocalMember(enqueueAll); | 907 library.implementation.forEachLocalMember(enqueueAll); |
| 899 } | 908 } |
| 900 | 909 |
| 901 void fullyEnqueueTopLevelElement(Element element, Enqueuer world) { | 910 void fullyEnqueueTopLevelElement(Element element, Enqueuer world) { |
| 902 if (element.isClass) { | 911 if (element.isClass) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 918 for (MetadataAnnotation metadata in library.metadata) { | 927 for (MetadataAnnotation metadata in library.metadata) { |
| 919 metadata.ensureResolved(resolution); | 928 metadata.ensureResolved(resolution); |
| 920 } | 929 } |
| 921 } | 930 } |
| 922 } | 931 } |
| 923 } | 932 } |
| 924 | 933 |
| 925 /** | 934 /** |
| 926 * Empty the [world] queue. | 935 * Empty the [world] queue. |
| 927 */ | 936 */ |
| 928 void emptyQueue(Enqueuer world) { | 937 void emptyQueue(Enqueuer world) |
| 938 => selfTask.measureSubtask("Compiler.emptyQueue", () { |
| 929 world.forEach((WorkItem work) { | 939 world.forEach((WorkItem work) { |
| 930 reporter.withCurrentElement(work.element, () { | 940 reporter.withCurrentElement( |
| 931 world.applyImpact(work.element, work.run(this, world)); | 941 work.element, () => selfTask.measureSubtask("world.applyImpact", () { |
| 932 }); | 942 world.applyImpact( |
| 943 work.element, |
| 944 selfTask.measureSubtask("work.run", () => work.run(this, world))); |
| 945 })); |
| 933 }); | 946 }); |
| 934 } | 947 }); |
| 935 | 948 |
| 936 void processQueue(Enqueuer world, Element main) { | 949 void processQueue(Enqueuer world, Element main) |
| 950 => selfTask.measureSubtask("Compiler.processQueue", () { |
| 937 world.nativeEnqueuer.processNativeClasses(libraryLoader.libraries); | 951 world.nativeEnqueuer.processNativeClasses(libraryLoader.libraries); |
| 938 if (main != null && !main.isMalformed) { | 952 if (main != null && !main.isMalformed) { |
| 939 FunctionElement mainMethod = main; | 953 FunctionElement mainMethod = main; |
| 940 mainMethod.computeType(resolution); | 954 mainMethod.computeType(resolution); |
| 941 if (mainMethod.functionSignature.parameterCount != 0) { | 955 if (mainMethod.functionSignature.parameterCount != 0) { |
| 942 // The first argument could be a list of strings. | 956 // The first argument could be a list of strings. |
| 943 backend.listImplementation.ensureResolved(resolution); | 957 backend.listImplementation.ensureResolved(resolution); |
| 944 backend.registerInstantiatedType( | 958 backend.registerInstantiatedType( |
| 945 backend.listImplementation.rawType, world, globalDependencies); | 959 backend.listImplementation.rawType, world, globalDependencies); |
| 946 backend.stringImplementation.ensureResolved(resolution); | 960 backend.stringImplementation.ensureResolved(resolution); |
| 947 backend.registerInstantiatedType( | 961 backend.registerInstantiatedType( |
| 948 backend.stringImplementation.rawType, world, globalDependencies); | 962 backend.stringImplementation.rawType, world, globalDependencies); |
| 949 | 963 |
| 950 backend.registerMainHasArguments(world); | 964 backend.registerMainHasArguments(world); |
| 951 } | 965 } |
| 952 world.addToWorkList(main); | 966 world.addToWorkList(main); |
| 953 } | 967 } |
| 954 if (options.verbose) { | 968 if (options.verbose) { |
| 955 progress.reset(); | 969 progress.reset(); |
| 956 } | 970 } |
| 957 emptyQueue(world); | 971 emptyQueue(world); |
| 958 world.queueIsClosed = true; | 972 world.queueIsClosed = true; |
| 959 // Notify the impact strategy impacts are no longer needed for this | 973 // Notify the impact strategy impacts are no longer needed for this |
| 960 // enqueuer. | 974 // enqueuer. |
| 961 impactStrategy.onImpactUsed(world.impactUse); | 975 impactStrategy.onImpactUsed(world.impactUse); |
| 962 backend.onQueueClosed(); | 976 backend.onQueueClosed(); |
| 963 assert(compilationFailed || world.checkNoEnqueuedInvokedInstanceMethods()); | 977 assert(compilationFailed || world.checkNoEnqueuedInvokedInstanceMethods()); |
| 964 } | 978 }); |
| 965 | 979 |
| 966 /** | 980 /** |
| 967 * Perform various checks of the queues. This includes checking that | 981 * Perform various checks of the queues. This includes checking that |
| 968 * the queues are empty (nothing was added after we stopped | 982 * the queues are empty (nothing was added after we stopped |
| 969 * processing the queues). Also compute the number of methods that | 983 * processing the queues). Also compute the number of methods that |
| 970 * were resolved, but not compiled (aka excess resolution). | 984 * were resolved, but not compiled (aka excess resolution). |
| 971 */ | 985 */ |
| 972 checkQueues() { | 986 checkQueues() { |
| 973 for (Enqueuer world in [enqueuer.resolution, enqueuer.codegen]) { | 987 for (Enqueuer world in [enqueuer.resolution, enqueuer.codegen]) { |
| 974 world.forEach((WorkItem work) { | 988 world.forEach((WorkItem work) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 995 resolved.remove(e); | 1009 resolved.remove(e); |
| 996 } | 1010 } |
| 997 } | 1011 } |
| 998 reporter.log('Excess resolution work: ${resolved.length}.'); | 1012 reporter.log('Excess resolution work: ${resolved.length}.'); |
| 999 for (Element e in resolved) { | 1013 for (Element e in resolved) { |
| 1000 reporter.reportWarningMessage(e, MessageKind.GENERIC, | 1014 reporter.reportWarningMessage(e, MessageKind.GENERIC, |
| 1001 {'text': 'Warning: $e resolved but not compiled.'}); | 1015 {'text': 'Warning: $e resolved but not compiled.'}); |
| 1002 } | 1016 } |
| 1003 } | 1017 } |
| 1004 | 1018 |
| 1005 WorldImpact analyzeElement(Element element) { | 1019 WorldImpact analyzeElement(Element element) |
| 1020 => selfTask.measureSubtask("Compiler.analyzeElement", () { |
| 1006 assert(invariant( | 1021 assert(invariant( |
| 1007 element, | 1022 element, |
| 1008 element.impliesType || | 1023 element.impliesType || |
| 1009 element.isField || | 1024 element.isField || |
| 1010 element.isFunction || | 1025 element.isFunction || |
| 1011 element.isConstructor || | 1026 element.isConstructor || |
| 1012 element.isGetter || | 1027 element.isGetter || |
| 1013 element.isSetter, | 1028 element.isSetter, |
| 1014 message: 'Unexpected element kind: ${element.kind}')); | 1029 message: 'Unexpected element kind: ${element.kind}')); |
| 1015 assert(invariant(element, element is AnalyzableElement, | 1030 assert(invariant(element, element is AnalyzableElement, |
| 1016 message: 'Element $element is not analyzable.')); | 1031 message: 'Element $element is not analyzable.')); |
| 1017 assert(invariant(element, element.isDeclaration)); | 1032 assert(invariant(element, element.isDeclaration)); |
| 1018 return resolution.computeWorldImpact(element); | 1033 return resolution.computeWorldImpact(element); |
| 1019 } | 1034 }); |
| 1020 | 1035 |
| 1021 WorldImpact analyze(ResolutionWorkItem work, ResolutionEnqueuer world) { | 1036 WorldImpact analyze(ResolutionWorkItem work, |
| 1037 ResolutionEnqueuer world) |
| 1038 => selfTask.measureSubtask("Compiler.analyze", () { |
| 1022 assert(invariant(work.element, identical(world, enqueuer.resolution))); | 1039 assert(invariant(work.element, identical(world, enqueuer.resolution))); |
| 1023 assert(invariant(work.element, !work.isAnalyzed, | 1040 assert(invariant(work.element, !work.isAnalyzed, |
| 1024 message: 'Element ${work.element} has already been analyzed')); | 1041 message: 'Element ${work.element} has already been analyzed')); |
| 1025 if (shouldPrintProgress) { | 1042 if (shouldPrintProgress) { |
| 1026 // TODO(ahe): Add structured diagnostics to the compiler API and | 1043 // TODO(ahe): Add structured diagnostics to the compiler API and |
| 1027 // use it to separate this from the --verbose option. | 1044 // use it to separate this from the --verbose option. |
| 1028 if (phase == PHASE_RESOLVING) { | 1045 if (phase == PHASE_RESOLVING) { |
| 1029 reporter.log('Resolved ${enqueuer.resolution.processedElements.length} ' | 1046 reporter.log('Resolved ${enqueuer.resolution.processedElements.length} ' |
| 1030 'elements.'); | 1047 'elements.'); |
| 1031 progress.reset(); | 1048 progress.reset(); |
| 1032 } | 1049 } |
| 1033 } | 1050 } |
| 1034 AstElement element = work.element; | 1051 AstElement element = work.element; |
| 1035 if (world.hasBeenProcessed(element)) { | 1052 if (world.hasBeenProcessed(element)) { |
| 1036 return const WorldImpact(); | 1053 return const WorldImpact(); |
| 1037 } | 1054 } |
| 1038 WorldImpact worldImpact = analyzeElement(element); | 1055 WorldImpact worldImpact = analyzeElement(element); |
| 1039 backend.onElementResolved(element); | 1056 backend.onElementResolved(element); |
| 1040 world.registerProcessedElement(element); | 1057 world.registerProcessedElement(element); |
| 1041 return worldImpact; | 1058 return worldImpact; |
| 1042 } | 1059 }); |
| 1043 | 1060 |
| 1044 WorldImpact codegen(CodegenWorkItem work, CodegenEnqueuer world) { | 1061 WorldImpact codegen(CodegenWorkItem work, CodegenEnqueuer world) { |
| 1045 assert(invariant(work.element, identical(world, enqueuer.codegen))); | 1062 assert(invariant(work.element, identical(world, enqueuer.codegen))); |
| 1046 if (shouldPrintProgress) { | 1063 if (shouldPrintProgress) { |
| 1047 // TODO(ahe): Add structured diagnostics to the compiler API and | 1064 // TODO(ahe): Add structured diagnostics to the compiler API and |
| 1048 // use it to separate this from the --verbose option. | 1065 // use it to separate this from the --verbose option. |
| 1049 reporter | 1066 reporter |
| 1050 .log('Compiled ${enqueuer.codegen.generatedCode.length} methods.'); | 1067 .log('Compiled ${enqueuer.codegen.generatedCode.length} methods.'); |
| 1051 progress.reset(); | 1068 progress.reset(); |
| 1052 } | 1069 } |
| (...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2015 _ElementScanner(this.scanner); | 2032 _ElementScanner(this.scanner); |
| 2016 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); | 2033 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); |
| 2017 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); | 2034 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); |
| 2018 } | 2035 } |
| 2019 | 2036 |
| 2020 class _EmptyEnvironment implements Environment { | 2037 class _EmptyEnvironment implements Environment { |
| 2021 const _EmptyEnvironment(); | 2038 const _EmptyEnvironment(); |
| 2022 | 2039 |
| 2023 String valueOf(String key) => null; | 2040 String valueOf(String key) => null; |
| 2024 } | 2041 } |
| OLD | NEW |