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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 enqueuer.resolution.applyImpact(computeImpactForLibrary(library)); | 578 enqueuer.resolution.applyImpact(computeImpactForLibrary(library)); |
579 emptyQueue(enqueuer.resolution, onProgress: showResolutionProgress); | 579 emptyQueue(enqueuer.resolution, onProgress: showResolutionProgress); |
580 enqueuer.resolution.logSummary(reporter.log); | 580 enqueuer.resolution.logSummary(reporter.log); |
581 return library; | 581 return library; |
582 }); | 582 }); |
583 } | 583 } |
584 | 584 |
585 /// Performs the compilation when all libraries have been loaded. | 585 /// Performs the compilation when all libraries have been loaded. |
586 void compileLoadedLibraries() => | 586 void compileLoadedLibraries() => |
587 selfTask.measureSubtask("Compiler.compileLoadedLibraries", () { | 587 selfTask.measureSubtask("Compiler.compileLoadedLibraries", () { |
| 588 Enqueuer resolutionEnqueuer = enqueuer.createResolutionEnqueuer(); |
588 WorldImpact mainImpact = computeMain(); | 589 WorldImpact mainImpact = computeMain(); |
589 | 590 |
590 mirrorUsageAnalyzerTask.analyzeUsage(mainApp); | 591 mirrorUsageAnalyzerTask.analyzeUsage(mainApp); |
591 | 592 |
592 // In order to see if a library is deferred, we must compute the | 593 // In order to see if a library is deferred, we must compute the |
593 // compile-time constants that are metadata. This means adding | 594 // compile-time constants that are metadata. This means adding |
594 // something to the resolution queue. So we cannot wait with | 595 // something to the resolution queue. So we cannot wait with |
595 // this until after the resolution queue is processed. | 596 // this until after the resolution queue is processed. |
596 deferredLoadTask.beforeResolution(this); | 597 deferredLoadTask.beforeResolution(this); |
597 impactStrategy = backend.createImpactStrategy( | 598 impactStrategy = backend.createImpactStrategy( |
598 supportDeferredLoad: deferredLoadTask.isProgramSplit, | 599 supportDeferredLoad: deferredLoadTask.isProgramSplit, |
599 supportDumpInfo: options.dumpInfo, | 600 supportDumpInfo: options.dumpInfo, |
600 supportSerialization: serialization.supportSerialization); | 601 supportSerialization: serialization.supportSerialization); |
601 | 602 |
602 phase = PHASE_RESOLVING; | 603 phase = PHASE_RESOLVING; |
603 enqueuer.resolution.applyImpact(mainImpact); | 604 resolutionEnqueuer.applyImpact(mainImpact); |
604 if (options.resolveOnly) { | 605 if (options.resolveOnly) { |
605 libraryLoader.libraries.where((LibraryElement library) { | 606 libraryLoader.libraries.where((LibraryElement library) { |
606 return !serialization.isDeserialized(library); | 607 return !serialization.isDeserialized(library); |
607 }).forEach((LibraryElement library) { | 608 }).forEach((LibraryElement library) { |
608 reporter.log('Enqueuing ${library.canonicalUri}'); | 609 reporter.log('Enqueuing ${library.canonicalUri}'); |
609 enqueuer.resolution.applyImpact(computeImpactForLibrary(library)); | 610 resolutionEnqueuer.applyImpact(computeImpactForLibrary(library)); |
610 }); | 611 }); |
611 } else if (analyzeAll) { | 612 } else if (analyzeAll) { |
612 libraryLoader.libraries.forEach((LibraryElement library) { | 613 libraryLoader.libraries.forEach((LibraryElement library) { |
613 reporter.log('Enqueuing ${library.canonicalUri}'); | 614 reporter.log('Enqueuing ${library.canonicalUri}'); |
614 enqueuer.resolution.applyImpact(computeImpactForLibrary(library)); | 615 resolutionEnqueuer.applyImpact(computeImpactForLibrary(library)); |
615 }); | 616 }); |
616 } else if (options.analyzeMain) { | 617 } else if (options.analyzeMain) { |
617 if (mainApp != null) { | 618 if (mainApp != null) { |
618 enqueuer.resolution.applyImpact(computeImpactForLibrary(mainApp)); | 619 resolutionEnqueuer.applyImpact(computeImpactForLibrary(mainApp)); |
619 } | 620 } |
620 if (librariesToAnalyzeWhenRun != null) { | 621 if (librariesToAnalyzeWhenRun != null) { |
621 for (Uri libraryUri in librariesToAnalyzeWhenRun) { | 622 for (Uri libraryUri in librariesToAnalyzeWhenRun) { |
622 enqueuer.resolution.applyImpact(computeImpactForLibrary( | 623 resolutionEnqueuer.applyImpact(computeImpactForLibrary( |
623 libraryLoader.lookupLibrary(libraryUri))); | 624 libraryLoader.lookupLibrary(libraryUri))); |
624 } | 625 } |
625 } | 626 } |
626 } | 627 } |
627 if (deferredLoadTask.isProgramSplit) { | 628 if (deferredLoadTask.isProgramSplit) { |
628 enqueuer.resolution | 629 resolutionEnqueuer |
629 .applyImpact(backend.computeDeferredLoadingImpact()); | 630 .applyImpact(backend.computeDeferredLoadingImpact()); |
630 } | 631 } |
631 resolveLibraryMetadata(); | 632 resolveLibraryMetadata(); |
632 reporter.log('Resolving...'); | 633 reporter.log('Resolving...'); |
633 MethodElement mainMethod; | 634 MethodElement mainMethod; |
634 if (mainFunction != null && !mainFunction.isMalformed) { | 635 if (mainFunction != null && !mainFunction.isMalformed) { |
635 mainFunction.computeType(resolution); | 636 mainFunction.computeType(resolution); |
636 mainMethod = mainFunction; | 637 mainMethod = mainFunction; |
637 } | 638 } |
638 | 639 |
639 processQueue(enqueuer.resolution, mainMethod, libraryLoader.libraries, | 640 processQueue(resolutionEnqueuer, mainMethod, libraryLoader.libraries, |
640 onProgress: showResolutionProgress); | 641 onProgress: showResolutionProgress); |
641 enqueuer.resolution.logSummary(reporter.log); | 642 resolutionEnqueuer.logSummary(reporter.log); |
642 | 643 |
643 _reporter.reportSuppressedMessagesSummary(); | 644 _reporter.reportSuppressedMessagesSummary(); |
644 | 645 |
645 if (compilationFailed) { | 646 if (compilationFailed) { |
646 if (!options.generateCodeWithCompileTimeErrors) return; | 647 if (!options.generateCodeWithCompileTimeErrors) return; |
647 if (!backend | 648 if (!backend |
648 .enableCodegenWithErrorsIfSupported(NO_LOCATION_SPANNABLE)) { | 649 .enableCodegenWithErrorsIfSupported(NO_LOCATION_SPANNABLE)) { |
649 return; | 650 return; |
650 } | 651 } |
651 } | 652 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 | 703 |
703 int programSize = backend.assembleProgram(closedWorld); | 704 int programSize = backend.assembleProgram(closedWorld); |
704 | 705 |
705 if (options.dumpInfo) { | 706 if (options.dumpInfo) { |
706 dumpInfoTask.reportSize(programSize); | 707 dumpInfoTask.reportSize(programSize); |
707 dumpInfoTask.dumpInfo(closedWorld); | 708 dumpInfoTask.dumpInfo(closedWorld); |
708 } | 709 } |
709 | 710 |
710 backend.onCodegenEnd(); | 711 backend.onCodegenEnd(); |
711 | 712 |
712 checkQueues(enqueuer.resolution, codegenEnqueuer); | 713 checkQueues(resolutionEnqueuer, codegenEnqueuer); |
713 }); | 714 }); |
714 | 715 |
715 /// Perform the steps needed to fully end the resolution phase. | 716 /// Perform the steps needed to fully end the resolution phase. |
716 ClosedWorldRefiner closeResolution() { | 717 ClosedWorldRefiner closeResolution() { |
717 phase = PHASE_DONE_RESOLVING; | 718 phase = PHASE_DONE_RESOLVING; |
718 | 719 |
719 ClosedWorldImpl world = resolutionWorldBuilder.closeWorld(reporter); | 720 ClosedWorldImpl world = resolutionWorldBuilder.closeWorld(reporter); |
720 // Compute whole-program-knowledge that the backend needs. (This might | 721 // Compute whole-program-knowledge that the backend needs. (This might |
721 // require the information computed in [world.closeWorld].) | 722 // require the information computed in [world.closeWorld].) |
722 backend.onResolutionComplete(world, world); | 723 backend.onResolutionComplete(world, world); |
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2042 if (library != null && library.isSynthesized) { | 2043 if (library != null && library.isSynthesized) { |
2043 return null; | 2044 return null; |
2044 } | 2045 } |
2045 if (library == null && required) { | 2046 if (library == null && required) { |
2046 throw new SpannableAssertionFailure( | 2047 throw new SpannableAssertionFailure( |
2047 library, "The library '${uri}' was not found."); | 2048 library, "The library '${uri}' was not found."); |
2048 } | 2049 } |
2049 return library; | 2050 return library; |
2050 } | 2051 } |
2051 } | 2052 } |
OLD | NEW |