| 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 | 7 import 'dart:async' show |
| 8 EventSink, | 8 EventSink, |
| 9 Future; | 9 Future; |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 import 'common/registry.dart' show | 25 import 'common/registry.dart' show |
| 26 EagerRegistry, | 26 EagerRegistry, |
| 27 Registry; | 27 Registry; |
| 28 import 'common/resolution.dart' show | 28 import 'common/resolution.dart' show |
| 29 Parsing, | 29 Parsing, |
| 30 Resolution, | 30 Resolution, |
| 31 ResolutionWorkItem, | 31 ResolutionWorkItem, |
| 32 ResolutionImpact; | 32 ResolutionImpact; |
| 33 import 'common/tasks.dart' show | 33 import 'common/tasks.dart' show |
| 34 CompilerTask, | 34 CompilerTask, |
| 35 GenericTask; | 35 GenericTask, |
| 36 Measurer; |
| 36 import 'common/work.dart' show | 37 import 'common/work.dart' show |
| 37 WorkItem; | 38 WorkItem; |
| 38 import 'compile_time_constants.dart'; | 39 import 'compile_time_constants.dart'; |
| 39 import 'constants/values.dart'; | 40 import 'constants/values.dart'; |
| 40 import 'core_types.dart' show | 41 import 'core_types.dart' show |
| 41 CoreClasses, | 42 CoreClasses, |
| 42 CoreTypes; | 43 CoreTypes; |
| 43 import 'dart_backend/dart_backend.dart' as dart_backend; | 44 import 'dart_backend/dart_backend.dart' as dart_backend; |
| 44 import 'dart_types.dart' show | 45 import 'dart_types.dart' show |
| 45 DartType, | 46 DartType, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 StaticUse; | 139 StaticUse; |
| 139 import 'universe/world_impact.dart' show | 140 import 'universe/world_impact.dart' show |
| 140 WorldImpact; | 141 WorldImpact; |
| 141 import 'util/util.dart' show | 142 import 'util/util.dart' show |
| 142 Link, | 143 Link, |
| 143 Setlet; | 144 Setlet; |
| 144 import 'world.dart' show | 145 import 'world.dart' show |
| 145 World; | 146 World; |
| 146 | 147 |
| 147 abstract class Compiler { | 148 abstract class Compiler { |
| 149 /// Helper instance for measurements in [CompilerTask]. |
| 150 /// |
| 151 /// Note: MUST be first field to ensure [Measurer.wallclock] is started |
| 152 /// before other computations. |
| 153 final Measurer measurer = new Measurer(); |
| 148 | 154 |
| 149 final Stopwatch totalCompileTime = new Stopwatch(); | |
| 150 int nextFreeClassId = 0; | 155 int nextFreeClassId = 0; |
| 151 World world; | 156 World world; |
| 152 Types types; | 157 Types types; |
| 153 _CompilerCoreTypes _coreTypes; | 158 _CompilerCoreTypes _coreTypes; |
| 154 _CompilerDiagnosticReporter _reporter; | 159 _CompilerDiagnosticReporter _reporter; |
| 155 _CompilerResolution _resolution; | 160 _CompilerResolution _resolution; |
| 156 _CompilerParsing _parsing; | 161 _CompilerParsing _parsing; |
| 157 | 162 |
| 158 final CacheStrategy cacheStrategy; | 163 final CacheStrategy cacheStrategy; |
| 159 | 164 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 | 273 |
| 269 List<Uri> librariesToAnalyzeWhenRun; | 274 List<Uri> librariesToAnalyzeWhenRun; |
| 270 | 275 |
| 271 /// The set of platform libraries reported as unsupported. | 276 /// The set of platform libraries reported as unsupported. |
| 272 /// | 277 /// |
| 273 /// For instance when importing 'dart:io' without '--categories=Server'. | 278 /// For instance when importing 'dart:io' without '--categories=Server'. |
| 274 Set<Uri> disallowedLibraryUris = new Setlet<Uri>(); | 279 Set<Uri> disallowedLibraryUris = new Setlet<Uri>(); |
| 275 | 280 |
| 276 Tracer tracer; | 281 Tracer tracer; |
| 277 | 282 |
| 278 CompilerTask measuredTask; | |
| 279 LibraryElement coreLibrary; | 283 LibraryElement coreLibrary; |
| 280 LibraryElement asyncLibrary; | 284 LibraryElement asyncLibrary; |
| 281 | 285 |
| 282 LibraryElement mainApp; | 286 LibraryElement mainApp; |
| 283 FunctionElement mainFunction; | 287 FunctionElement mainFunction; |
| 284 | 288 |
| 285 /// Initialized when dart:mirrors is loaded. | 289 /// Initialized when dart:mirrors is loaded. |
| 286 LibraryElement mirrorsLibrary; | 290 LibraryElement mirrorsLibrary; |
| 287 | 291 |
| 288 /// Initialized when dart:typed_data is loaded. | 292 /// Initialized when dart:typed_data is loaded. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 LibraryLoaderTask libraryLoader; | 365 LibraryLoaderTask libraryLoader; |
| 362 SerializationTask serialization; | 366 SerializationTask serialization; |
| 363 ResolverTask resolver; | 367 ResolverTask resolver; |
| 364 closureMapping.ClosureTask closureToClassMapper; | 368 closureMapping.ClosureTask closureToClassMapper; |
| 365 TypeCheckerTask checker; | 369 TypeCheckerTask checker; |
| 366 ti.TypesTask typesTask; | 370 ti.TypesTask typesTask; |
| 367 Backend backend; | 371 Backend backend; |
| 368 | 372 |
| 369 GenericTask reuseLibraryTask; | 373 GenericTask reuseLibraryTask; |
| 370 | 374 |
| 375 GenericTask selfTask; |
| 376 |
| 371 /// The constant environment for the frontend interpretation of compile-time | 377 /// The constant environment for the frontend interpretation of compile-time |
| 372 /// constants. | 378 /// constants. |
| 373 ConstantEnvironment constants; | 379 ConstantEnvironment constants; |
| 374 | 380 |
| 375 EnqueueTask enqueuer; | 381 EnqueueTask enqueuer; |
| 376 DeferredLoadTask deferredLoadTask; | 382 DeferredLoadTask deferredLoadTask; |
| 377 MirrorUsageAnalyzerTask mirrorUsageAnalyzerTask; | 383 MirrorUsageAnalyzerTask mirrorUsageAnalyzerTask; |
| 378 DumpInfoTask dumpInfoTask; | 384 DumpInfoTask dumpInfoTask; |
| 379 String buildId; | 385 String buildId; |
| 380 | 386 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 this.enableExperimentalMirrors: false, | 451 this.enableExperimentalMirrors: false, |
| 446 this.enableAssertMessage: false, | 452 this.enableAssertMessage: false, |
| 447 this.allowNativeExtensions: false, | 453 this.allowNativeExtensions: false, |
| 448 this.generateCodeWithCompileTimeErrors: false, | 454 this.generateCodeWithCompileTimeErrors: false, |
| 449 this.testMode: false, | 455 this.testMode: false, |
| 450 DiagnosticOptions diagnosticOptions, | 456 DiagnosticOptions diagnosticOptions, |
| 451 api.CompilerOutput outputProvider, | 457 api.CompilerOutput outputProvider, |
| 452 List<String> strips: const [], | 458 List<String> strips: const [], |
| 453 Backend makeBackend(Compiler compiler)}) | 459 Backend makeBackend(Compiler compiler)}) |
| 454 : this.disableTypeInferenceFlag = | 460 : this.disableTypeInferenceFlag = |
| 455 disableTypeInferenceFlag || !emitJavaScript, | 461 disableTypeInferenceFlag || !emitJavaScript, |
| 456 this.analyzeOnly = | 462 this.analyzeOnly = |
| 457 analyzeOnly || analyzeSignaturesOnly || analyzeAllFlag, | 463 analyzeOnly || analyzeSignaturesOnly || analyzeAllFlag, |
| 458 this.analyzeSignaturesOnly = analyzeSignaturesOnly, | 464 this.analyzeSignaturesOnly = analyzeSignaturesOnly, |
| 459 this.analyzeAllFlag = analyzeAllFlag, | 465 this.analyzeAllFlag = analyzeAllFlag, |
| 460 this.hasIncrementalSupport = hasIncrementalSupport, | 466 this.hasIncrementalSupport = hasIncrementalSupport, |
| 461 cacheStrategy = new CacheStrategy(hasIncrementalSupport), | 467 cacheStrategy = new CacheStrategy(hasIncrementalSupport), |
| 462 this.userOutputProvider = outputProvider == null | 468 this.userOutputProvider = outputProvider == null |
| 463 ? const NullCompilerOutput() : outputProvider { | 469 ? const NullCompilerOutput() : outputProvider { |
| 464 if (hasIncrementalSupport) { | 470 if (hasIncrementalSupport) { |
| 465 // TODO(ahe): This is too much. Any method from platform and package | 471 // TODO(ahe): This is too much. Any method from platform and package |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 resolver = new ResolverTask(this, backend.constantCompilerTask), | 516 resolver = new ResolverTask(this, backend.constantCompilerTask), |
| 511 closureToClassMapper = new closureMapping.ClosureTask(this), | 517 closureToClassMapper = new closureMapping.ClosureTask(this), |
| 512 checker = new TypeCheckerTask(this), | 518 checker = new TypeCheckerTask(this), |
| 513 typesTask = new ti.TypesTask(this), | 519 typesTask = new ti.TypesTask(this), |
| 514 constants = backend.constantCompilerTask, | 520 constants = backend.constantCompilerTask, |
| 515 deferredLoadTask = new DeferredLoadTask(this), | 521 deferredLoadTask = new DeferredLoadTask(this), |
| 516 mirrorUsageAnalyzerTask = new MirrorUsageAnalyzerTask(this), | 522 mirrorUsageAnalyzerTask = new MirrorUsageAnalyzerTask(this), |
| 517 enqueuer = backend.makeEnqueuer(), | 523 enqueuer = backend.makeEnqueuer(), |
| 518 dumpInfoTask = new DumpInfoTask(this), | 524 dumpInfoTask = new DumpInfoTask(this), |
| 519 reuseLibraryTask = new GenericTask('Reuse library', this), | 525 reuseLibraryTask = new GenericTask('Reuse library', this), |
| 526 selfTask = new GenericTask('self', this), |
| 520 ]; | 527 ]; |
| 521 | 528 |
| 522 tasks.addAll(backend.tasks); | 529 tasks.addAll(backend.tasks); |
| 523 } | 530 } |
| 524 | 531 |
| 525 Universe get resolverWorld => enqueuer.resolution.universe; | 532 Universe get resolverWorld => enqueuer.resolution.universe; |
| 526 Universe get codegenWorld => enqueuer.codegen.universe; | 533 Universe get codegenWorld => enqueuer.codegen.universe; |
| 527 | 534 |
| 528 bool get hasBuildId => buildId != UNDETERMINED_BUILD_ID; | 535 bool get hasBuildId => buildId != UNDETERMINED_BUILD_ID; |
| 529 | 536 |
| 530 bool get analyzeAll => analyzeAllFlag || compileAll; | 537 bool get analyzeAll => analyzeAllFlag || compileAll; |
| 531 | 538 |
| 532 bool get compileAll => false; | 539 bool get compileAll => false; |
| 533 | 540 |
| 534 bool get disableTypeInference { | 541 bool get disableTypeInference { |
| 535 return disableTypeInferenceFlag || compilationFailed; | 542 return disableTypeInferenceFlag || compilationFailed; |
| 536 } | 543 } |
| 537 | 544 |
| 538 int getNextFreeClassId() => nextFreeClassId++; | 545 int getNextFreeClassId() => nextFreeClassId++; |
| 539 | 546 |
| 540 void unimplemented(Spannable spannable, String methodName) { | 547 void unimplemented(Spannable spannable, String methodName) { |
| 541 reporter.internalError(spannable, "$methodName not implemented."); | 548 reporter.internalError(spannable, "$methodName not implemented."); |
| 542 } | 549 } |
| 543 | 550 |
| 544 // Compiles the dart script at [uri]. | 551 // Compiles the dart script at [uri]. |
| 545 // | 552 // |
| 546 // The resulting future will complete with true if the compilation | 553 // The resulting future will complete with true if the compilation |
| 547 // succeded. | 554 // succeded. |
| 548 Future<bool> run(Uri uri) { | 555 Future<bool> run(Uri uri) => selfTask.measureSubtask("Compiler.run", () { |
| 549 totalCompileTime.start(); | 556 measurer.startWallClock(); |
| 550 | 557 |
| 551 return new Future.sync(() => runInternal(uri)) | 558 return new Future.sync(() => runInternal(uri)) |
| 552 .catchError((error) => _reporter.onError(uri, error)) | 559 .catchError((error) => _reporter.onError(uri, error)) |
| 553 .whenComplete(() { | 560 .whenComplete(() { |
| 554 tracer.close(); | 561 tracer.close(); |
| 555 totalCompileTime.stop(); | 562 measurer.stopWallClock(); |
| 556 }).then((_) { | 563 }).then((_) { |
| 557 return !compilationFailed; | 564 return !compilationFailed; |
| 558 }); | 565 }); |
| 559 } | 566 }); |
| 560 | 567 |
| 561 /// This method is called immediately after the [LibraryElement] [library] has | 568 /// This method is called immediately after the [LibraryElement] [library] has |
| 562 /// been created. | 569 /// been created. |
| 563 /// | 570 /// |
| 564 /// Use this callback method to store references to specific libraries. | 571 /// Use this callback method to store references to specific libraries. |
| 565 /// Note that [library] has not been scanned yet, nor has its imports/exports | 572 /// Note that [library] has not been scanned yet, nor has its imports/exports |
| 566 /// been resolved. | 573 /// been resolved. |
| 567 void onLibraryCreated(LibraryElement library) { | 574 void onLibraryCreated(LibraryElement library) { |
| 568 Uri uri = library.canonicalUri; | 575 Uri uri = library.canonicalUri; |
| 569 if (uri == Uris.dart_core) { | 576 if (uri == Uris.dart_core) { |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 return null; | 960 return null; |
| 954 } | 961 } |
| 955 fullyEnqueueLibrary(library, enqueuer.resolution); | 962 fullyEnqueueLibrary(library, enqueuer.resolution); |
| 956 emptyQueue(enqueuer.resolution); | 963 emptyQueue(enqueuer.resolution); |
| 957 enqueuer.resolution.logSummary(reporter.log); | 964 enqueuer.resolution.logSummary(reporter.log); |
| 958 return library; | 965 return library; |
| 959 }); | 966 }); |
| 960 } | 967 } |
| 961 | 968 |
| 962 /// Performs the compilation when all libraries have been loaded. | 969 /// Performs the compilation when all libraries have been loaded. |
| 963 void compileLoadedLibraries() { | 970 void compileLoadedLibraries() |
| 971 => selfTask.measureSubtask("Compiler.compileLoadedLibraries", () { |
| 972 |
| 964 computeMain(); | 973 computeMain(); |
| 965 | 974 |
| 966 mirrorUsageAnalyzerTask.analyzeUsage(mainApp); | 975 mirrorUsageAnalyzerTask.analyzeUsage(mainApp); |
| 967 | 976 |
| 968 // In order to see if a library is deferred, we must compute the | 977 // In order to see if a library is deferred, we must compute the |
| 969 // compile-time constants that are metadata. This means adding | 978 // compile-time constants that are metadata. This means adding |
| 970 // something to the resolution queue. So we cannot wait with | 979 // something to the resolution queue. So we cannot wait with |
| 971 // this until after the resolution queue is processed. | 980 // this until after the resolution queue is processed. |
| 972 deferredLoadTask.beforeResolution(this); | 981 deferredLoadTask.beforeResolution(this); |
| 973 | 982 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 enqueuer.codegen.logSummary(reporter.log); | 1059 enqueuer.codegen.logSummary(reporter.log); |
| 1051 | 1060 |
| 1052 int programSize = backend.assembleProgram(); | 1061 int programSize = backend.assembleProgram(); |
| 1053 | 1062 |
| 1054 if (dumpInfo) { | 1063 if (dumpInfo) { |
| 1055 dumpInfoTask.reportSize(programSize); | 1064 dumpInfoTask.reportSize(programSize); |
| 1056 dumpInfoTask.dumpInfo(); | 1065 dumpInfoTask.dumpInfo(); |
| 1057 } | 1066 } |
| 1058 | 1067 |
| 1059 checkQueues(); | 1068 checkQueues(); |
| 1060 } | 1069 }); |
| 1061 | 1070 |
| 1062 void fullyEnqueueLibrary(LibraryElement library, Enqueuer world) { | 1071 void fullyEnqueueLibrary(LibraryElement library, Enqueuer world) { |
| 1063 void enqueueAll(Element element) { | 1072 void enqueueAll(Element element) { |
| 1064 fullyEnqueueTopLevelElement(element, world); | 1073 fullyEnqueueTopLevelElement(element, world); |
| 1065 } | 1074 } |
| 1066 library.implementation.forEachLocalMember(enqueueAll); | 1075 library.implementation.forEachLocalMember(enqueueAll); |
| 1067 } | 1076 } |
| 1068 | 1077 |
| 1069 void fullyEnqueueTopLevelElement(Element element, Enqueuer world) { | 1078 void fullyEnqueueTopLevelElement(Element element, Enqueuer world) { |
| 1070 if (element.isClass) { | 1079 if (element.isClass) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1087 for (MetadataAnnotation metadata in library.metadata) { | 1096 for (MetadataAnnotation metadata in library.metadata) { |
| 1088 metadata.ensureResolved(resolution); | 1097 metadata.ensureResolved(resolution); |
| 1089 } | 1098 } |
| 1090 } | 1099 } |
| 1091 } | 1100 } |
| 1092 } | 1101 } |
| 1093 | 1102 |
| 1094 /** | 1103 /** |
| 1095 * Empty the [world] queue. | 1104 * Empty the [world] queue. |
| 1096 */ | 1105 */ |
| 1097 void emptyQueue(Enqueuer world) { | 1106 void emptyQueue(Enqueuer world) |
| 1107 => selfTask.measureSubtask("Compiler.emptyQueue", () { |
| 1098 world.forEach((WorkItem work) { | 1108 world.forEach((WorkItem work) { |
| 1099 reporter.withCurrentElement(work.element, () { | 1109 reporter.withCurrentElement( |
| 1100 world.applyImpact(work.element, work.run(this, world)); | 1110 work.element, () => selfTask.measureSubtask("world.applyImpact", () { |
| 1101 }); | 1111 world.applyImpact( |
| 1112 work.element, |
| 1113 selfTask.measureSubtask("work.run", () => work.run(this, world))); |
| 1114 })); |
| 1102 }); | 1115 }); |
| 1103 } | 1116 }); |
| 1104 | 1117 |
| 1105 void processQueue(Enqueuer world, Element main) { | 1118 void processQueue(Enqueuer world, Element main) |
| 1119 => selfTask.measureSubtask("Compiler.processQueue", () { |
| 1106 world.nativeEnqueuer.processNativeClasses(libraryLoader.libraries); | 1120 world.nativeEnqueuer.processNativeClasses(libraryLoader.libraries); |
| 1107 if (main != null && !main.isMalformed) { | 1121 if (main != null && !main.isMalformed) { |
| 1108 FunctionElement mainMethod = main; | 1122 FunctionElement mainMethod = main; |
| 1109 mainMethod.computeType(resolution); | 1123 mainMethod.computeType(resolution); |
| 1110 if (mainMethod.functionSignature.parameterCount != 0) { | 1124 if (mainMethod.functionSignature.parameterCount != 0) { |
| 1111 // The first argument could be a list of strings. | 1125 // The first argument could be a list of strings. |
| 1112 backend.listImplementation.ensureResolved(resolution); | 1126 backend.listImplementation.ensureResolved(resolution); |
| 1113 backend.registerInstantiatedType( | 1127 backend.registerInstantiatedType( |
| 1114 backend.listImplementation.rawType, world, globalDependencies); | 1128 backend.listImplementation.rawType, world, globalDependencies); |
| 1115 backend.stringImplementation.ensureResolved(resolution); | 1129 backend.stringImplementation.ensureResolved(resolution); |
| 1116 backend.registerInstantiatedType( | 1130 backend.registerInstantiatedType( |
| 1117 backend.stringImplementation.rawType, world, globalDependencies); | 1131 backend.stringImplementation.rawType, world, globalDependencies); |
| 1118 | 1132 |
| 1119 backend.registerMainHasArguments(world); | 1133 backend.registerMainHasArguments(world); |
| 1120 } | 1134 } |
| 1121 world.addToWorkList(main); | 1135 world.addToWorkList(main); |
| 1122 } | 1136 } |
| 1123 if (verbose) { | 1137 if (verbose) { |
| 1124 progress.reset(); | 1138 progress.reset(); |
| 1125 } | 1139 } |
| 1126 emptyQueue(world); | 1140 emptyQueue(world); |
| 1127 world.queueIsClosed = true; | 1141 world.queueIsClosed = true; |
| 1128 backend.onQueueClosed(); | 1142 backend.onQueueClosed(); |
| 1129 assert(compilationFailed || world.checkNoEnqueuedInvokedInstanceMethods()); | 1143 assert(compilationFailed || world.checkNoEnqueuedInvokedInstanceMethods()); |
| 1130 } | 1144 }); |
| 1131 | 1145 |
| 1132 /** | 1146 /** |
| 1133 * Perform various checks of the queues. This includes checking that | 1147 * Perform various checks of the queues. This includes checking that |
| 1134 * the queues are empty (nothing was added after we stopped | 1148 * the queues are empty (nothing was added after we stopped |
| 1135 * processing the queues). Also compute the number of methods that | 1149 * processing the queues). Also compute the number of methods that |
| 1136 * were resolved, but not compiled (aka excess resolution). | 1150 * were resolved, but not compiled (aka excess resolution). |
| 1137 */ | 1151 */ |
| 1138 checkQueues() { | 1152 checkQueues() { |
| 1139 for (Enqueuer world in [enqueuer.resolution, enqueuer.codegen]) { | 1153 for (Enqueuer world in [enqueuer.resolution, enqueuer.codegen]) { |
| 1140 world.forEach((WorkItem work) { | 1154 world.forEach((WorkItem work) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1162 } | 1176 } |
| 1163 } | 1177 } |
| 1164 reporter.log('Excess resolution work: ${resolved.length}.'); | 1178 reporter.log('Excess resolution work: ${resolved.length}.'); |
| 1165 for (Element e in resolved) { | 1179 for (Element e in resolved) { |
| 1166 reporter.reportWarningMessage(e, | 1180 reporter.reportWarningMessage(e, |
| 1167 MessageKind.GENERIC, | 1181 MessageKind.GENERIC, |
| 1168 {'text': 'Warning: $e resolved but not compiled.'}); | 1182 {'text': 'Warning: $e resolved but not compiled.'}); |
| 1169 } | 1183 } |
| 1170 } | 1184 } |
| 1171 | 1185 |
| 1172 WorldImpact analyzeElement(Element element) { | 1186 WorldImpact analyzeElement(Element element) |
| 1187 => selfTask.measureSubtask("Compiler.analyzeElement", () { |
| 1173 assert(invariant(element, | 1188 assert(invariant(element, |
| 1174 element.impliesType || | 1189 element.impliesType || |
| 1175 element.isField || | 1190 element.isField || |
| 1176 element.isFunction || | 1191 element.isFunction || |
| 1177 element.isConstructor || | 1192 element.isConstructor || |
| 1178 element.isGetter || | 1193 element.isGetter || |
| 1179 element.isSetter, | 1194 element.isSetter, |
| 1180 message: 'Unexpected element kind: ${element.kind}')); | 1195 message: 'Unexpected element kind: ${element.kind}')); |
| 1181 assert(invariant(element, element is AnalyzableElement, | 1196 assert(invariant(element, element is AnalyzableElement, |
| 1182 message: 'Element $element is not analyzable.')); | 1197 message: 'Element $element is not analyzable.')); |
| 1183 assert(invariant(element, element.isDeclaration)); | 1198 assert(invariant(element, element.isDeclaration)); |
| 1184 return resolution.computeWorldImpact(element); | 1199 return resolution.computeWorldImpact(element); |
| 1185 } | 1200 }); |
| 1186 | 1201 |
| 1187 WorldImpact analyze(ResolutionWorkItem work, | 1202 WorldImpact analyze(ResolutionWorkItem work, ResolutionEnqueuer world) |
| 1188 ResolutionEnqueuer world) { | 1203 => selfTask.measureSubtask("Compiler.analyze", () { |
| 1189 assert(invariant(work.element, identical(world, enqueuer.resolution))); | 1204 assert(invariant(work.element, identical(world, enqueuer.resolution))); |
| 1190 assert(invariant(work.element, !work.isAnalyzed, | 1205 assert(invariant(work.element, !work.isAnalyzed, |
| 1191 message: 'Element ${work.element} has already been analyzed')); | 1206 message: 'Element ${work.element} has already been analyzed')); |
| 1192 if (shouldPrintProgress) { | 1207 if (shouldPrintProgress) { |
| 1193 // TODO(ahe): Add structured diagnostics to the compiler API and | 1208 // TODO(ahe): Add structured diagnostics to the compiler API and |
| 1194 // use it to separate this from the --verbose option. | 1209 // use it to separate this from the --verbose option. |
| 1195 if (phase == PHASE_RESOLVING) { | 1210 if (phase == PHASE_RESOLVING) { |
| 1196 reporter.log( | 1211 reporter.log( |
| 1197 'Resolved ${enqueuer.resolution.processedElements.length} ' | 1212 'Resolved ${enqueuer.resolution.processedElements.length} ' |
| 1198 'elements.'); | 1213 'elements.'); |
| 1199 progress.reset(); | 1214 progress.reset(); |
| 1200 } | 1215 } |
| 1201 } | 1216 } |
| 1202 AstElement element = work.element; | 1217 AstElement element = work.element; |
| 1203 if (world.hasBeenProcessed(element)) { | 1218 if (world.hasBeenProcessed(element)) { |
| 1204 return const WorldImpact(); | 1219 return const WorldImpact(); |
| 1205 } | 1220 } |
| 1206 WorldImpact worldImpact = analyzeElement(element); | 1221 WorldImpact worldImpact = analyzeElement(element); |
| 1207 backend.onElementResolved(element, element.resolvedAst.elements); | 1222 backend.onElementResolved(element, element.resolvedAst.elements); |
| 1208 world.registerProcessedElement(element); | 1223 world.registerProcessedElement(element); |
| 1209 return worldImpact; | 1224 return worldImpact; |
| 1210 } | 1225 }); |
| 1211 | 1226 |
| 1212 WorldImpact codegen(CodegenWorkItem work, CodegenEnqueuer world) { | 1227 WorldImpact codegen(CodegenWorkItem work, CodegenEnqueuer world) { |
| 1213 assert(invariant(work.element, identical(world, enqueuer.codegen))); | 1228 assert(invariant(work.element, identical(world, enqueuer.codegen))); |
| 1214 if (shouldPrintProgress) { | 1229 if (shouldPrintProgress) { |
| 1215 // TODO(ahe): Add structured diagnostics to the compiler API and | 1230 // TODO(ahe): Add structured diagnostics to the compiler API and |
| 1216 // use it to separate this from the --verbose option. | 1231 // use it to separate this from the --verbose option. |
| 1217 reporter.log( | 1232 reporter.log( |
| 1218 'Compiled ${enqueuer.codegen.generatedCode.length} methods.'); | 1233 'Compiled ${enqueuer.codegen.generatedCode.length} methods.'); |
| 1219 progress.reset(); | 1234 progress.reset(); |
| 1220 } | 1235 } |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2079 if (_otherDependencies == null) { | 2094 if (_otherDependencies == null) { |
| 2080 _otherDependencies = new Setlet<Element>(); | 2095 _otherDependencies = new Setlet<Element>(); |
| 2081 } | 2096 } |
| 2082 _otherDependencies.add(element.implementation); | 2097 _otherDependencies.add(element.implementation); |
| 2083 } | 2098 } |
| 2084 | 2099 |
| 2085 Iterable<Element> get otherDependencies { | 2100 Iterable<Element> get otherDependencies { |
| 2086 return _otherDependencies != null ? _otherDependencies : const <Element>[]; | 2101 return _otherDependencies != null ? _otherDependencies : const <Element>[]; |
| 2087 } | 2102 } |
| 2088 } | 2103 } |
| OLD | NEW |