| 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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 for (Uri libraryUri in librariesToAnalyzeWhenRun) { | 613 for (Uri libraryUri in librariesToAnalyzeWhenRun) { |
| 614 enqueuer.resolution.applyImpact(computeImpactForLibrary( | 614 enqueuer.resolution.applyImpact(computeImpactForLibrary( |
| 615 libraryLoader.lookupLibrary(libraryUri))); | 615 libraryLoader.lookupLibrary(libraryUri))); |
| 616 } | 616 } |
| 617 } | 617 } |
| 618 } | 618 } |
| 619 if (deferredLoadTask.isProgramSplit) { | 619 if (deferredLoadTask.isProgramSplit) { |
| 620 enqueuer.resolution | 620 enqueuer.resolution |
| 621 .applyImpact(backend.computeDeferredLoadingImpact()); | 621 .applyImpact(backend.computeDeferredLoadingImpact()); |
| 622 } | 622 } |
| 623 // Elements required by enqueueHelpers are global dependencies | |
| 624 // that are not pulled in by a particular element. | |
| 625 enqueuer.resolution.applyImpact(backend.computeHelpersImpact()); | |
| 626 resolveLibraryMetadata(); | 623 resolveLibraryMetadata(); |
| 627 reporter.log('Resolving...'); | 624 reporter.log('Resolving...'); |
| 625 MethodElement mainMethod; |
| 628 if (mainFunction != null && !mainFunction.isMalformed) { | 626 if (mainFunction != null && !mainFunction.isMalformed) { |
| 629 mainFunction.computeType(resolution); | 627 mainFunction.computeType(resolution); |
| 628 mainMethod = mainFunction; |
| 630 } | 629 } |
| 631 | 630 |
| 632 processQueue(enqueuer.resolution, mainFunction, | 631 processQueue(enqueuer.resolution, mainMethod, libraryLoader.libraries, |
| 633 onProgress: showResolutionProgress); | 632 onProgress: showResolutionProgress); |
| 634 enqueuer.resolution.logSummary(reporter.log); | 633 enqueuer.resolution.logSummary(reporter.log); |
| 635 | 634 |
| 636 _reporter.reportSuppressedMessagesSummary(); | 635 _reporter.reportSuppressedMessagesSummary(); |
| 637 | 636 |
| 638 if (compilationFailed) { | 637 if (compilationFailed) { |
| 639 if (!options.generateCodeWithCompileTimeErrors) return; | 638 if (!options.generateCodeWithCompileTimeErrors) return; |
| 640 if (!backend | 639 if (!backend |
| 641 .enableCodegenWithErrorsIfSupported(NO_LOCATION_SPANNABLE)) { | 640 .enableCodegenWithErrorsIfSupported(NO_LOCATION_SPANNABLE)) { |
| 642 return; | 641 return; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 reporter.log('Compiling...'); | 679 reporter.log('Compiling...'); |
| 681 phase = PHASE_COMPILING; | 680 phase = PHASE_COMPILING; |
| 682 | 681 |
| 683 codegenWorldBuilder.open(closedWorld); | 682 codegenWorldBuilder.open(closedWorld); |
| 684 enqueuer.codegen.applyImpact(backend.onCodegenStart(closedWorld)); | 683 enqueuer.codegen.applyImpact(backend.onCodegenStart(closedWorld)); |
| 685 if (compileAll) { | 684 if (compileAll) { |
| 686 libraryLoader.libraries.forEach((LibraryElement library) { | 685 libraryLoader.libraries.forEach((LibraryElement library) { |
| 687 enqueuer.codegen.applyImpact(computeImpactForLibrary(library)); | 686 enqueuer.codegen.applyImpact(computeImpactForLibrary(library)); |
| 688 }); | 687 }); |
| 689 } | 688 } |
| 690 processQueue(enqueuer.codegen, mainFunction, | 689 processQueue(enqueuer.codegen, mainMethod, libraryLoader.libraries, |
| 691 onProgress: showCodegenProgress); | 690 onProgress: showCodegenProgress); |
| 692 enqueuer.codegen.logSummary(reporter.log); | 691 enqueuer.codegen.logSummary(reporter.log); |
| 693 | 692 |
| 694 int programSize = backend.assembleProgram(closedWorld); | 693 int programSize = backend.assembleProgram(closedWorld); |
| 695 | 694 |
| 696 if (options.dumpInfo) { | 695 if (options.dumpInfo) { |
| 697 dumpInfoTask.reportSize(programSize); | 696 dumpInfoTask.reportSize(programSize); |
| 698 dumpInfoTask.dumpInfo(closedWorld); | 697 dumpInfoTask.dumpInfo(closedWorld); |
| 699 } | 698 } |
| 700 | 699 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 () => selfTask.measureSubtask("world.applyImpact", () { | 800 () => selfTask.measureSubtask("world.applyImpact", () { |
| 802 enqueuer.applyImpact( | 801 enqueuer.applyImpact( |
| 803 selfTask.measureSubtask("work.run", () => work.run()), | 802 selfTask.measureSubtask("work.run", () => work.run()), |
| 804 impactSource: work.element); | 803 impactSource: work.element); |
| 805 })); | 804 })); |
| 806 }); | 805 }); |
| 807 }); | 806 }); |
| 808 } | 807 } |
| 809 | 808 |
| 810 void processQueue(Enqueuer enqueuer, MethodElement mainMethod, | 809 void processQueue(Enqueuer enqueuer, MethodElement mainMethod, |
| 810 Iterable<LibraryEntity> libraries, |
| 811 {void onProgress()}) { | 811 {void onProgress()}) { |
| 812 selfTask.measureSubtask("Compiler.processQueue", () { | 812 selfTask.measureSubtask("Compiler.processQueue", () { |
| 813 enqueuer.open(impactStrategy); | 813 enqueuer.open(impactStrategy, mainMethod, libraries); |
| 814 enqueuer.applyImpact(enqueuer.nativeEnqueuer | |
| 815 .processNativeClasses(libraryLoader.libraries)); | |
| 816 if (mainMethod != null && !mainMethod.isMalformed) { | |
| 817 enqueuer.applyImpact(backend.computeMainImpact(mainMethod, | |
| 818 forResolution: enqueuer.isResolutionQueue)); | |
| 819 } | |
| 820 if (options.verbose) { | 814 if (options.verbose) { |
| 821 progress.reset(); | 815 progress.reset(); |
| 822 } | 816 } |
| 823 emptyQueue(enqueuer, onProgress: onProgress); | 817 emptyQueue(enqueuer, onProgress: onProgress); |
| 824 enqueuer.queueIsClosed = true; | 818 enqueuer.queueIsClosed = true; |
| 825 enqueuer.close(); | 819 enqueuer.close(); |
| 826 // Notify the impact strategy impacts are no longer needed for this | 820 // Notify the impact strategy impacts are no longer needed for this |
| 827 // enqueuer. | 821 // enqueuer. |
| 828 impactStrategy.onImpactUsed(enqueuer.impactUse); | 822 impactStrategy.onImpactUsed(enqueuer.impactUse); |
| 829 backend.onQueueClosed(); | 823 backend.onQueueClosed(); |
| (...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1921 /// An element environment base on a [Compiler]. | 1915 /// An element environment base on a [Compiler]. |
| 1922 class _CompilerElementEnvironment implements ElementEnvironment { | 1916 class _CompilerElementEnvironment implements ElementEnvironment { |
| 1923 final Compiler _compiler; | 1917 final Compiler _compiler; |
| 1924 | 1918 |
| 1925 _CompilerElementEnvironment(this._compiler); | 1919 _CompilerElementEnvironment(this._compiler); |
| 1926 | 1920 |
| 1927 LibraryProvider get _libraryProvider => _compiler.libraryLoader; | 1921 LibraryProvider get _libraryProvider => _compiler.libraryLoader; |
| 1928 Resolution get _resolution => _compiler.resolution; | 1922 Resolution get _resolution => _compiler.resolution; |
| 1929 | 1923 |
| 1930 @override | 1924 @override |
| 1925 LibraryEntity get mainLibrary => _compiler.mainApp; |
| 1926 |
| 1927 @override |
| 1928 FunctionEntity get mainFunction => _compiler.mainFunction; |
| 1929 |
| 1930 @override |
| 1931 ResolutionInterfaceType getThisType(ClassElement cls) { | 1931 ResolutionInterfaceType getThisType(ClassElement cls) { |
| 1932 cls.ensureResolved(_resolution); | 1932 cls.ensureResolved(_resolution); |
| 1933 return cls.thisType; | 1933 return cls.thisType; |
| 1934 } | 1934 } |
| 1935 | 1935 |
| 1936 @override | 1936 @override |
| 1937 ResolutionInterfaceType getRawType(ClassElement cls) { | 1937 ResolutionInterfaceType getRawType(ClassElement cls) { |
| 1938 cls.ensureResolved(_resolution); | 1938 cls.ensureResolved(_resolution); |
| 1939 return cls.rawType; | 1939 return cls.rawType; |
| 1940 } | 1940 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2034 if (library != null && library.isSynthesized) { | 2034 if (library != null && library.isSynthesized) { |
| 2035 return null; | 2035 return null; |
| 2036 } | 2036 } |
| 2037 if (library == null && required) { | 2037 if (library == null && required) { |
| 2038 throw new SpannableAssertionFailure( | 2038 throw new SpannableAssertionFailure( |
| 2039 library, "The library '${uri}' was not found."); | 2039 library, "The library '${uri}' was not found."); |
| 2040 } | 2040 } |
| 2041 return library; | 2041 return library; |
| 2042 } | 2042 } |
| 2043 } | 2043 } |
| OLD | NEW |