| 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 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2012 compiler.checker.check(element); | 2018 compiler.checker.check(element); |
| 2013 } | 2019 } |
| 2014 WorldImpact worldImpact = | 2020 WorldImpact worldImpact = |
| 2015 compiler.backend.impactTransformer.transformResolutionImpact( | 2021 compiler.backend.impactTransformer.transformResolutionImpact( |
| 2016 resolutionImpact); | 2022 resolutionImpact); |
| 2017 return worldImpact; | 2023 return worldImpact; |
| 2018 }); | 2024 }); |
| 2019 } | 2025 } |
| 2020 | 2026 |
| 2021 @override | 2027 @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 |
| 2022 bool hasBeenResolved(Element element) { | 2035 bool hasBeenResolved(Element element) { |
| 2023 return _worldImpactCache.containsKey(element); | 2036 return _worldImpactCache.containsKey(element); |
| 2024 } | 2037 } |
| 2025 } | 2038 } |
| 2026 | 2039 |
| 2027 // TODO(johnniwinther): Move [ParserTask], [PatchParserTask], [DietParserTask] | 2040 // TODO(johnniwinther): Move [ParserTask], [PatchParserTask], [DietParserTask] |
| 2028 // and [ScannerTask] here. | 2041 // and [ScannerTask] here. |
| 2029 class _CompilerParsing implements Parsing { | 2042 class _CompilerParsing implements Parsing { |
| 2030 final Compiler compiler; | 2043 final Compiler compiler; |
| 2031 | 2044 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2068 if (_otherDependencies == null) { | 2081 if (_otherDependencies == null) { |
| 2069 _otherDependencies = new Setlet<Element>(); | 2082 _otherDependencies = new Setlet<Element>(); |
| 2070 } | 2083 } |
| 2071 _otherDependencies.add(element.implementation); | 2084 _otherDependencies.add(element.implementation); |
| 2072 } | 2085 } |
| 2073 | 2086 |
| 2074 Iterable<Element> get otherDependencies { | 2087 Iterable<Element> get otherDependencies { |
| 2075 return _otherDependencies != null ? _otherDependencies : const <Element>[]; | 2088 return _otherDependencies != null ? _otherDependencies : const <Element>[]; |
| 2076 } | 2089 } |
| 2077 } | 2090 } |
| OLD | NEW |