Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 trydart.caching_compiler; | 5 library trydart.caching_compiler; |
| 6 | 6 |
| 7 import 'dart:profiler' show | 7 import 'dart:profiler' show |
| 8 UserTag; | 8 UserTag; |
| 9 | 9 |
| 10 import 'package:compiler/compiler.dart' show | 10 import 'package:compiler/compiler.dart' show |
| 11 CompilerInputProvider, | 11 CompilerInputProvider, |
| 12 CompilerOutputProvider, | 12 CompilerOutputProvider, |
| 13 Diagnostic, | 13 Diagnostic, |
| 14 DiagnosticHandler; | 14 DiagnosticHandler; |
| 15 | 15 |
| 16 import 'package:compiler/implementation/apiimpl.dart' show | 16 import 'package:compiler/implementation/apiimpl.dart' show |
| 17 Compiler; | 17 Compiler; |
| 18 | 18 |
| 19 import 'package:compiler/implementation/dart2jslib.dart' show | 19 import 'package:compiler/implementation/dart2jslib.dart' show |
| 20 LibraryLoaderTask, // TODO(ahe): Remove this import. | |
|
ahe
2014/06/24 09:49:20
Changes in this file, LGTM!
| |
| 21 NullSink; | 20 NullSink; |
| 22 | 21 |
| 23 import 'package:compiler/implementation/js_backend/js_backend.dart' show | 22 import 'package:compiler/implementation/js_backend/js_backend.dart' show |
| 24 JavaScriptBackend; | 23 JavaScriptBackend; |
| 25 | 24 |
| 26 import 'package:compiler/implementation/elements/elements.dart' show | 25 import 'package:compiler/implementation/elements/elements.dart' show |
| 27 LibraryElement; | 26 LibraryElement; |
| 28 | 27 |
| 29 void clearLibraryLoader(LibraryLoaderTask libraryLoader) { | |
| 30 // TODO(ahe): Move this method to [LibraryLoader]. | |
| 31 libraryLoader | |
| 32 ..libraryResourceUriMap.clear() | |
| 33 ..libraryNames.clear(); | |
| 34 } | |
| 35 | |
| 36 void reuseLibrary( | |
| 37 LibraryLoaderTask libraryLoader, | |
| 38 LibraryElement library) { | |
| 39 // TODO(ahe): Move this method to [LibraryLoader]. | |
| 40 String name = library.getLibraryOrScriptName(); | |
| 41 Uri resourceUri = library.entryCompilationUnit.script.resourceUri; | |
| 42 libraryLoader | |
| 43 ..libraryResourceUriMap[resourceUri] = library | |
| 44 ..libraryNames[name] = library; | |
| 45 } | |
| 46 | |
| 47 Compiler reuseCompiler( | 28 Compiler reuseCompiler( |
| 48 {DiagnosticHandler diagnosticHandler, | 29 {DiagnosticHandler diagnosticHandler, |
| 49 CompilerInputProvider inputProvider, | 30 CompilerInputProvider inputProvider, |
| 50 CompilerOutputProvider outputProvider, | 31 CompilerOutputProvider outputProvider, |
| 51 List<String> options: const [], | 32 List<String> options: const [], |
| 52 Compiler cachedCompiler, | 33 Compiler cachedCompiler, |
| 53 Uri libraryRoot, | 34 Uri libraryRoot, |
| 54 Uri packageRoot, | 35 Uri packageRoot, |
| 55 bool packagesAreImmutable: false}) { | 36 bool packagesAreImmutable: false}) { |
| 56 UserTag oldTag = new UserTag('reuseCompiler').makeCurrent(); | 37 UserTag oldTag = new UserTag('reuseCompiler').makeCurrent(); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 ..precompiledFunction.clear() | 140 ..precompiledFunction.clear() |
| 160 ..precompiledConstructorNames.clear() | 141 ..precompiledConstructorNames.clear() |
| 161 ..hasMakeConstantList = false | 142 ..hasMakeConstantList = false |
| 162 ..elementDescriptors.clear(); | 143 ..elementDescriptors.clear(); |
| 163 | 144 |
| 164 backend | 145 backend |
| 165 ..preMirrorsMethodCount = 0; | 146 ..preMirrorsMethodCount = 0; |
| 166 | 147 |
| 167 Map libraries = new Map.from(compiler.libraries); | 148 Map libraries = new Map.from(compiler.libraries); |
| 168 compiler.libraries.clear(); | 149 compiler.libraries.clear(); |
| 169 clearLibraryLoader(compiler.libraryLoader); | 150 compiler.libraryLoader.reset(); |
| 170 libraries.forEach((String uri, LibraryElement library) { | 151 libraries.forEach((String uri, LibraryElement library) { |
| 171 if (library.isPlatformLibrary || | 152 if (library.isPlatformLibrary || |
| 172 (packagesAreImmutable && library.isPackageLibrary)) { | 153 (packagesAreImmutable && library.isPackageLibrary)) { |
| 173 compiler.libraries[uri] = library; | 154 compiler.libraries[uri] = library; |
| 174 reuseLibrary(compiler.libraryLoader, library); | 155 compiler.libraryLoader.reuseLibrary(library); |
| 175 } | 156 } |
| 176 }); | 157 }); |
| 177 } | 158 } |
| 178 oldTag.makeCurrent(); | 159 oldTag.makeCurrent(); |
| 179 return compiler; | 160 return compiler; |
| 180 } | 161 } |
| OLD | NEW |