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 'closure.dart' as closureMapping show ClosureTask; | 10 import 'closure.dart' as closureMapping show ClosureTask; |
(...skipping 21 matching lines...) Expand all Loading... |
32 import 'dump_info.dart' show DumpInfoTask; | 32 import 'dump_info.dart' show DumpInfoTask; |
33 import 'elements/elements.dart'; | 33 import 'elements/elements.dart'; |
34 import 'elements/entities.dart'; | 34 import 'elements/entities.dart'; |
35 import 'elements/modelx.dart' show ErroneousElementX; | 35 import 'elements/modelx.dart' show ErroneousElementX; |
36 import 'elements/resolution_types.dart' | 36 import 'elements/resolution_types.dart' |
37 show | 37 show |
38 ResolutionDartType, | 38 ResolutionDartType, |
39 ResolutionDynamicType, | 39 ResolutionDynamicType, |
40 ResolutionInterfaceType, | 40 ResolutionInterfaceType, |
41 Types; | 41 Types; |
42 import 'enqueue.dart' show Enqueuer, EnqueueTask, ResolutionEnqueuer; | 42 import 'enqueue.dart' |
| 43 show DeferredAction, Enqueuer, EnqueueTask, ResolutionEnqueuer; |
43 import 'environment.dart'; | 44 import 'environment.dart'; |
44 import 'id_generator.dart'; | 45 import 'id_generator.dart'; |
45 import 'io/source_information.dart' show SourceInformation; | 46 import 'io/source_information.dart' show SourceInformation; |
46 import 'js_backend/backend.dart' show JavaScriptBackend; | 47 import 'js_backend/backend.dart' show JavaScriptBackend; |
47 import 'library_loader.dart' | 48 import 'library_loader.dart' |
48 show | 49 show |
49 ElementScanner, | 50 ElementScanner, |
50 LibraryLoader, | 51 LibraryLoader, |
51 LibraryLoaderTask, | 52 LibraryLoaderTask, |
52 LoadedLibraries, | 53 LoadedLibraries, |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 /// This operation assumes an unclosed resolution queue and is only supported | 569 /// This operation assumes an unclosed resolution queue and is only supported |
569 /// when the '--analyze-main' option is used. | 570 /// when the '--analyze-main' option is used. |
570 Future<LibraryElement> analyzeUri(Uri libraryUri, | 571 Future<LibraryElement> analyzeUri(Uri libraryUri, |
571 {bool skipLibraryWithPartOfTag: true}) { | 572 {bool skipLibraryWithPartOfTag: true}) { |
572 assert(options.analyzeMain); | 573 assert(options.analyzeMain); |
573 reporter.log('Analyzing $libraryUri (${options.buildId})'); | 574 reporter.log('Analyzing $libraryUri (${options.buildId})'); |
574 return libraryLoader | 575 return libraryLoader |
575 .loadLibrary(libraryUri, skipFileWithPartOfTag: true) | 576 .loadLibrary(libraryUri, skipFileWithPartOfTag: true) |
576 .then((LibraryElement library) { | 577 .then((LibraryElement library) { |
577 if (library == null) return null; | 578 if (library == null) return null; |
578 enqueuer.resolution.applyImpact(computeImpactForLibrary(library)); | 579 ResolutionEnqueuer resolutionEnqueuer = startResolution(); |
579 emptyQueue(enqueuer.resolution, onProgress: showResolutionProgress); | 580 resolutionEnqueuer.applyImpact(computeImpactForLibrary(library)); |
580 enqueuer.resolution.logSummary(reporter.log); | 581 emptyQueue(resolutionEnqueuer, onProgress: showResolutionProgress); |
| 582 resolutionEnqueuer.logSummary(reporter.log); |
581 return library; | 583 return library; |
582 }); | 584 }); |
583 } | 585 } |
584 | 586 |
| 587 /// Starts the resolution phase, creating the [ResolutionEnqueuer] if not |
| 588 /// already created. |
| 589 /// |
| 590 /// During normal compilation resolution only started once, but through |
| 591 /// [analyzeUri] resolution is started repeatedly. |
| 592 ResolutionEnqueuer startResolution() { |
| 593 ResolutionEnqueuer resolutionEnqueuer; |
| 594 if (enqueuer.hasResolution) { |
| 595 resolutionEnqueuer = enqueuer.resolution; |
| 596 } else { |
| 597 resolutionEnqueuer = enqueuer.createResolutionEnqueuer(); |
| 598 backend.onResolutionStart(resolutionEnqueuer); |
| 599 } |
| 600 resolutionEnqueuer.addDeferredActions(libraryLoader.pullDeferredActions()); |
| 601 return resolutionEnqueuer; |
| 602 } |
| 603 |
585 /// Performs the compilation when all libraries have been loaded. | 604 /// Performs the compilation when all libraries have been loaded. |
586 void compileLoadedLibraries() => | 605 void compileLoadedLibraries() => |
587 selfTask.measureSubtask("Compiler.compileLoadedLibraries", () { | 606 selfTask.measureSubtask("Compiler.compileLoadedLibraries", () { |
588 Enqueuer resolutionEnqueuer = enqueuer.createResolutionEnqueuer(); | 607 ResolutionEnqueuer resolutionEnqueuer = startResolution(); |
589 WorldImpact mainImpact = computeMain(); | 608 WorldImpact mainImpact = computeMain(); |
590 | 609 |
591 mirrorUsageAnalyzerTask.analyzeUsage(mainApp); | 610 mirrorUsageAnalyzerTask.analyzeUsage(mainApp); |
592 | 611 |
593 // In order to see if a library is deferred, we must compute the | 612 // In order to see if a library is deferred, we must compute the |
594 // compile-time constants that are metadata. This means adding | 613 // compile-time constants that are metadata. This means adding |
595 // something to the resolution queue. So we cannot wait with | 614 // something to the resolution queue. So we cannot wait with |
596 // this until after the resolution queue is processed. | 615 // this until after the resolution queue is processed. |
597 deferredLoadTask.beforeResolution(this); | 616 deferredLoadTask.beforeResolution(this); |
598 impactStrategy = backend.createImpactStrategy( | 617 impactStrategy = backend.createImpactStrategy( |
(...skipping 1444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2043 if (library != null && library.isSynthesized) { | 2062 if (library != null && library.isSynthesized) { |
2044 return null; | 2063 return null; |
2045 } | 2064 } |
2046 if (library == null && required) { | 2065 if (library == null && required) { |
2047 throw new SpannableAssertionFailure( | 2066 throw new SpannableAssertionFailure( |
2048 library, "The library '${uri}' was not found."); | 2067 library, "The library '${uri}' was not found."); |
2049 } | 2068 } |
2050 return library; | 2069 return library; |
2051 } | 2070 } |
2052 } | 2071 } |
OLD | NEW |