| 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, | |
| 141 WorldImpact; | 140 WorldImpact; |
| 142 import 'util/util.dart' show | 141 import 'util/util.dart' show |
| 143 Link, | 142 Link, |
| 144 Setlet; | 143 Setlet; |
| 145 import 'world.dart' show | 144 import 'world.dart' show |
| 146 World; | 145 World; |
| 147 | 146 |
| 148 abstract class Compiler { | 147 abstract class Compiler { |
| 149 | 148 |
| 150 final Stopwatch totalCompileTime = new Stopwatch(); | 149 final Stopwatch totalCompileTime = new Stopwatch(); |
| 151 int nextFreeClassId = 0; | 150 int nextFreeClassId = 0; |
| 152 World world; | 151 World world; |
| 153 Types types; | 152 Types types; |
| 154 _CompilerCoreTypes _coreTypes; | 153 _CompilerCoreTypes _coreTypes; |
| 155 _CompilerDiagnosticReporter _reporter; | 154 _CompilerDiagnosticReporter _reporter; |
| 156 _CompilerResolution _resolution; | 155 _CompilerResolution _resolution; |
| 157 _CompilerParsing _parsing; | 156 _CompilerParsing _parsing; |
| 158 | 157 |
| 159 final CacheStrategy cacheStrategy; | 158 final CacheStrategy cacheStrategy; |
| 160 | 159 |
| 161 ImpactStrategy impactStrategy = const ImpactStrategy(); | |
| 162 | |
| 163 /** | 160 /** |
| 164 * Map from token to the first preceding comment token. | 161 * Map from token to the first preceding comment token. |
| 165 */ | 162 */ |
| 166 final TokenMap commentMap = new TokenMap(); | 163 final TokenMap commentMap = new TokenMap(); |
| 167 | 164 |
| 168 /** | 165 /** |
| 169 * Records global dependencies, that is, dependencies that don't | 166 * Records global dependencies, that is, dependencies that don't |
| 170 * correspond to a particular element. | 167 * correspond to a particular element. |
| 171 * | 168 * |
| 172 * We should get rid of this and ensure that all dependencies are | 169 * 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... |
| 971 void compileLoadedLibraries() { | 968 void compileLoadedLibraries() { |
| 972 computeMain(); | 969 computeMain(); |
| 973 | 970 |
| 974 mirrorUsageAnalyzerTask.analyzeUsage(mainApp); | 971 mirrorUsageAnalyzerTask.analyzeUsage(mainApp); |
| 975 | 972 |
| 976 // In order to see if a library is deferred, we must compute the | 973 // In order to see if a library is deferred, we must compute the |
| 977 // compile-time constants that are metadata. This means adding | 974 // compile-time constants that are metadata. This means adding |
| 978 // something to the resolution queue. So we cannot wait with | 975 // something to the resolution queue. So we cannot wait with |
| 979 // this until after the resolution queue is processed. | 976 // this until after the resolution queue is processed. |
| 980 deferredLoadTask.beforeResolution(this); | 977 deferredLoadTask.beforeResolution(this); |
| 981 impactStrategy = backend.createImpactStrategy( | |
| 982 supportDeferredLoad: deferredLoadTask.isProgramSplit, | |
| 983 supportDumpInfo: dumpInfo); | |
| 984 | 978 |
| 985 phase = PHASE_RESOLVING; | 979 phase = PHASE_RESOLVING; |
| 986 if (analyzeAll) { | 980 if (analyzeAll) { |
| 987 libraryLoader.libraries.forEach((LibraryElement library) { | 981 libraryLoader.libraries.forEach((LibraryElement library) { |
| 988 reporter.log('Enqueuing ${library.canonicalUri}'); | 982 reporter.log('Enqueuing ${library.canonicalUri}'); |
| 989 fullyEnqueueLibrary(library, enqueuer.resolution); | 983 fullyEnqueueLibrary(library, enqueuer.resolution); |
| 990 }); | 984 }); |
| 991 } else if (analyzeMain) { | 985 } else if (analyzeMain) { |
| 992 if (mainApp != null) { | 986 if (mainApp != null) { |
| 993 fullyEnqueueLibrary(mainApp, enqueuer.resolution); | 987 fullyEnqueueLibrary(mainApp, enqueuer.resolution); |
| (...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2018 compiler.checker.check(element); | 2012 compiler.checker.check(element); |
| 2019 } | 2013 } |
| 2020 WorldImpact worldImpact = | 2014 WorldImpact worldImpact = |
| 2021 compiler.backend.impactTransformer.transformResolutionImpact( | 2015 compiler.backend.impactTransformer.transformResolutionImpact( |
| 2022 resolutionImpact); | 2016 resolutionImpact); |
| 2023 return worldImpact; | 2017 return worldImpact; |
| 2024 }); | 2018 }); |
| 2025 } | 2019 } |
| 2026 | 2020 |
| 2027 @override | 2021 @override |
| 2028 void uncacheWorldImpact(Element element) { | |
| 2029 assert(invariant(element, _worldImpactCache[element] != null, | |
| 2030 message: "WorldImpact not computed for $element.")); | |
| 2031 _worldImpactCache[element] = const WorldImpact(); | |
| 2032 } | |
| 2033 | |
| 2034 @override | |
| 2035 bool hasBeenResolved(Element element) { | 2022 bool hasBeenResolved(Element element) { |
| 2036 return _worldImpactCache.containsKey(element); | 2023 return _worldImpactCache.containsKey(element); |
| 2037 } | 2024 } |
| 2038 } | 2025 } |
| 2039 | 2026 |
| 2040 // TODO(johnniwinther): Move [ParserTask], [PatchParserTask], [DietParserTask] | 2027 // TODO(johnniwinther): Move [ParserTask], [PatchParserTask], [DietParserTask] |
| 2041 // and [ScannerTask] here. | 2028 // and [ScannerTask] here. |
| 2042 class _CompilerParsing implements Parsing { | 2029 class _CompilerParsing implements Parsing { |
| 2043 final Compiler compiler; | 2030 final Compiler compiler; |
| 2044 | 2031 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2081 if (_otherDependencies == null) { | 2068 if (_otherDependencies == null) { |
| 2082 _otherDependencies = new Setlet<Element>(); | 2069 _otherDependencies = new Setlet<Element>(); |
| 2083 } | 2070 } |
| 2084 _otherDependencies.add(element.implementation); | 2071 _otherDependencies.add(element.implementation); |
| 2085 } | 2072 } |
| 2086 | 2073 |
| 2087 Iterable<Element> get otherDependencies { | 2074 Iterable<Element> get otherDependencies { |
| 2088 return _otherDependencies != null ? _otherDependencies : const <Element>[]; | 2075 return _otherDependencies != null ? _otherDependencies : const <Element>[]; |
| 2089 } | 2076 } |
| 2090 } | 2077 } |
| OLD | NEW |