| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 import 'types/types.dart' as ti; | 130 import 'types/types.dart' as ti; |
| 131 import 'universe/call_structure.dart' show | 131 import 'universe/call_structure.dart' show |
| 132 CallStructure; | 132 CallStructure; |
| 133 import 'universe/selector.dart' show | 133 import 'universe/selector.dart' show |
| 134 Selector; | 134 Selector; |
| 135 import 'universe/universe.dart' show | 135 import 'universe/universe.dart' show |
| 136 Universe; | 136 Universe; |
| 137 import 'universe/use.dart' show | 137 import 'universe/use.dart' show |
| 138 StaticUse; | 138 StaticUse; |
| 139 import 'universe/world_impact.dart' show | 139 import 'universe/world_impact.dart' show |
| 140 ImpactStrategy, |
| 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 { |
| 148 | 149 |
| 149 final Stopwatch totalCompileTime = new Stopwatch(); | 150 final Stopwatch totalCompileTime = new Stopwatch(); |
| 150 int nextFreeClassId = 0; | 151 int nextFreeClassId = 0; |
| 151 World world; | 152 World world; |
| 152 Types types; | 153 Types types; |
| 153 _CompilerCoreTypes _coreTypes; | 154 _CompilerCoreTypes _coreTypes; |
| 154 _CompilerDiagnosticReporter _reporter; | 155 _CompilerDiagnosticReporter _reporter; |
| 155 _CompilerResolution _resolution; | 156 _CompilerResolution _resolution; |
| 156 _CompilerParsing _parsing; | 157 _CompilerParsing _parsing; |
| 157 | 158 |
| 158 final CacheStrategy cacheStrategy; | 159 final CacheStrategy cacheStrategy; |
| 159 | 160 |
| 161 ImpactStrategy impactStrategy = const ImpactStrategy(); |
| 162 |
| 160 /** | 163 /** |
| 161 * Map from token to the first preceding comment token. | 164 * Map from token to the first preceding comment token. |
| 162 */ | 165 */ |
| 163 final TokenMap commentMap = new TokenMap(); | 166 final TokenMap commentMap = new TokenMap(); |
| 164 | 167 |
| 165 /** | 168 /** |
| 166 * Records global dependencies, that is, dependencies that don't | 169 * Records global dependencies, that is, dependencies that don't |
| 167 * correspond to a particular element. | 170 * correspond to a particular element. |
| 168 * | 171 * |
| 169 * We should get rid of this and ensure that all dependencies are | 172 * We should get rid of this and ensure that all dependencies are |
| (...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 void compileLoadedLibraries() { | 971 void compileLoadedLibraries() { |
| 969 computeMain(); | 972 computeMain(); |
| 970 | 973 |
| 971 mirrorUsageAnalyzerTask.analyzeUsage(mainApp); | 974 mirrorUsageAnalyzerTask.analyzeUsage(mainApp); |
| 972 | 975 |
| 973 // In order to see if a library is deferred, we must compute the | 976 // In order to see if a library is deferred, we must compute the |
| 974 // compile-time constants that are metadata. This means adding | 977 // compile-time constants that are metadata. This means adding |
| 975 // something to the resolution queue. So we cannot wait with | 978 // something to the resolution queue. So we cannot wait with |
| 976 // this until after the resolution queue is processed. | 979 // this until after the resolution queue is processed. |
| 977 deferredLoadTask.beforeResolution(this); | 980 deferredLoadTask.beforeResolution(this); |
| 981 impactStrategy = backend.createImpactStrategy( |
| 982 supportDeferredLoad: deferredLoadTask.isProgramSplit, |
| 983 supportDumpInfo: dumpInfo); |
| 978 | 984 |
| 979 phase = PHASE_RESOLVING; | 985 phase = PHASE_RESOLVING; |
| 980 if (analyzeAll) { | 986 if (analyzeAll) { |
| 981 libraryLoader.libraries.forEach((LibraryElement library) { | 987 libraryLoader.libraries.forEach((LibraryElement library) { |
| 982 reporter.log('Enqueuing ${library.canonicalUri}'); | 988 reporter.log('Enqueuing ${library.canonicalUri}'); |
| 983 fullyEnqueueLibrary(library, enqueuer.resolution); | 989 fullyEnqueueLibrary(library, enqueuer.resolution); |
| 984 }); | 990 }); |
| 985 } else if (analyzeMain) { | 991 } else if (analyzeMain) { |
| 986 if (mainApp != null) { | 992 if (mainApp != null) { |
| 987 fullyEnqueueLibrary(mainApp, enqueuer.resolution); | 993 fullyEnqueueLibrary(mainApp, enqueuer.resolution); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 | 1129 |
| 1124 backend.registerMainHasArguments(world); | 1130 backend.registerMainHasArguments(world); |
| 1125 } | 1131 } |
| 1126 world.addToWorkList(main); | 1132 world.addToWorkList(main); |
| 1127 } | 1133 } |
| 1128 if (verbose) { | 1134 if (verbose) { |
| 1129 progress.reset(); | 1135 progress.reset(); |
| 1130 } | 1136 } |
| 1131 emptyQueue(world); | 1137 emptyQueue(world); |
| 1132 world.queueIsClosed = true; | 1138 world.queueIsClosed = true; |
| 1139 // Notify the impact strategy impacts are no longer needed for this |
| 1140 // enqueuer. |
| 1141 impactStrategy.onImpactUsed(world.impactUse); |
| 1133 backend.onQueueClosed(); | 1142 backend.onQueueClosed(); |
| 1134 assert(compilationFailed || world.checkNoEnqueuedInvokedInstanceMethods()); | 1143 assert(compilationFailed || world.checkNoEnqueuedInvokedInstanceMethods()); |
| 1135 } | 1144 } |
| 1136 | 1145 |
| 1137 /** | 1146 /** |
| 1138 * Perform various checks of the queues. This includes checking that | 1147 * Perform various checks of the queues. This includes checking that |
| 1139 * the queues are empty (nothing was added after we stopped | 1148 * the queues are empty (nothing was added after we stopped |
| 1140 * processing the queues). Also compute the number of methods that | 1149 * processing the queues). Also compute the number of methods that |
| 1141 * were resolved, but not compiled (aka excess resolution). | 1150 * were resolved, but not compiled (aka excess resolution). |
| 1142 */ | 1151 */ |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2012 compiler.checker.check(element); | 2021 compiler.checker.check(element); |
| 2013 } | 2022 } |
| 2014 WorldImpact worldImpact = | 2023 WorldImpact worldImpact = |
| 2015 compiler.backend.impactTransformer.transformResolutionImpact( | 2024 compiler.backend.impactTransformer.transformResolutionImpact( |
| 2016 resolutionImpact); | 2025 resolutionImpact); |
| 2017 return worldImpact; | 2026 return worldImpact; |
| 2018 }); | 2027 }); |
| 2019 } | 2028 } |
| 2020 | 2029 |
| 2021 @override | 2030 @override |
| 2031 void uncacheWorldImpact(Element element) { |
| 2032 assert(invariant(element, _worldImpactCache[element] != null, |
| 2033 message: "WorldImpact not computed for $element.")); |
| 2034 _worldImpactCache[element] = const WorldImpact(); |
| 2035 } |
| 2036 |
| 2037 @override |
| 2038 void emptyCache() { |
| 2039 for (Element element in _worldImpactCache.keys) { |
| 2040 _worldImpactCache[element] = const WorldImpact(); |
| 2041 } |
| 2042 } |
| 2043 |
| 2044 @override |
| 2022 bool hasBeenResolved(Element element) { | 2045 bool hasBeenResolved(Element element) { |
| 2023 return _worldImpactCache.containsKey(element); | 2046 return _worldImpactCache.containsKey(element); |
| 2024 } | 2047 } |
| 2025 } | 2048 } |
| 2026 | 2049 |
| 2027 // TODO(johnniwinther): Move [ParserTask], [PatchParserTask], [DietParserTask] | 2050 // TODO(johnniwinther): Move [ParserTask], [PatchParserTask], [DietParserTask] |
| 2028 // and [ScannerTask] here. | 2051 // and [ScannerTask] here. |
| 2029 class _CompilerParsing implements Parsing { | 2052 class _CompilerParsing implements Parsing { |
| 2030 final Compiler compiler; | 2053 final Compiler compiler; |
| 2031 | 2054 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2068 if (_otherDependencies == null) { | 2091 if (_otherDependencies == null) { |
| 2069 _otherDependencies = new Setlet<Element>(); | 2092 _otherDependencies = new Setlet<Element>(); |
| 2070 } | 2093 } |
| 2071 _otherDependencies.add(element.implementation); | 2094 _otherDependencies.add(element.implementation); |
| 2072 } | 2095 } |
| 2073 | 2096 |
| 2074 Iterable<Element> get otherDependencies { | 2097 Iterable<Element> get otherDependencies { |
| 2075 return _otherDependencies != null ? _otherDependencies : const <Element>[]; | 2098 return _otherDependencies != null ? _otherDependencies : const <Element>[]; |
| 2076 } | 2099 } |
| 2077 } | 2100 } |
| OLD | NEW |