Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Unified Diff: compiler/java/com/google/dart/compiler/DartCompiler.java

Issue 10389074: Cache unresolved units separately from libraries (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/AnalysisUtility.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/DartCompiler.java
===================================================================
--- compiler/java/com/google/dart/compiler/DartCompiler.java (revision 7495)
+++ compiler/java/com/google/dart/compiler/DartCompiler.java (working copy)
@@ -855,13 +855,15 @@
private final Map<URI, LibraryUnit> resolvedLibraries;
private final Map<URI,DartUnit> parsedUnits;
private Collection<LibraryUnit> librariesToProcess;
+ private final SystemLibraryManager libraryManager;
private SelectiveCompiler(LibrarySource app, Map<URI, LibraryUnit> resolvedLibraries,
Map<URI,DartUnit> parsedUnits, CompilerConfiguration config,
- DartCompilerMainContext context) {
+ DartCompilerMainContext context, SystemLibraryManager libraryManager) {
super(app, Collections.<LibrarySource>emptyList(), config, context);
this.resolvedLibraries = resolvedLibraries;
this.parsedUnits = parsedUnits;
+ this.libraryManager = libraryManager;
addResolvedLibraries(resolvedLibraries);
}
@@ -884,7 +886,17 @@
// Remove the parsed unit from the map if present
// so that it will not be consumed a 2nd time if it is sourced by multiple libraries
DartUnit parsedUnit = parsedUnits.remove(srcUri);
- return parsedUnit == null ? super.parse(dartSrc, prefixes, diet) : parsedUnit;
+ if (parsedUnit != null) {
+ return parsedUnit;
+ }
+ if (libraryManager != null) {
+ URI fileUri = libraryManager.resolveDartUri(srcUri);
+ parsedUnit = parsedUnits.remove(fileUri);
+ if (parsedUnit != null) {
+ return parsedUnit;
+ }
+ }
+ return super.parse(dartSrc, prefixes, diet);
}
}
@@ -1148,7 +1160,7 @@
CompilerConfiguration config, DartArtifactProvider provider, DartCompilerListener listener)
throws IOException {
HashMap<URI, LibraryUnit> resolvedLibs = new HashMap<URI, LibraryUnit>();
- return analyzeLibraries(lib, resolvedLibs, parsedUnits, config, provider, listener, false).get(lib.getUri());
+ return analyzeLibraries(lib, resolvedLibs, parsedUnits, config, provider, null, listener, false).get(lib.getUri());
}
/**
@@ -1166,6 +1178,7 @@
* will not be used), but resolution and type-analysis will be
* invoked
* @param provider A mechanism for specifying where code should be generated
+ * @param libraryManager
* @param listener An object notified when compilation errors occur
* @param resolveAllNewLibs <code>true</code> if all new libraries should be resolved
* or false if only the library specified by the "lib" parameter should be resolved
@@ -1175,14 +1188,14 @@
*/
public static Map<URI, LibraryUnit> analyzeLibraries(LibrarySource lib,
Map<URI, LibraryUnit> resolvedLibs, Map<URI, DartUnit> parsedUnits,
- CompilerConfiguration config, DartArtifactProvider provider, DartCompilerListener listener,
- boolean resolveAllNewLibs) throws IOException {
+ CompilerConfiguration config, DartArtifactProvider provider, SystemLibraryManager libraryManager,
+ DartCompilerListener listener, boolean resolveAllNewLibs) throws IOException {
lib.getClass(); // Quick null check.
provider.getClass(); // Quick null check.
listener.getClass(); // Quick null check.
resolvedLibs.getClass(); // Quick null check.
DartCompilerMainContext context = new DartCompilerMainContext(lib, provider, listener, config);
- Compiler compiler = new SelectiveCompiler(lib, resolvedLibs, parsedUnits, config, context);
+ Compiler compiler = new SelectiveCompiler(lib, resolvedLibs, parsedUnits, config, context, libraryManager);
LibraryUnit topLibUnit = compiler.updateAndResolve();
if (topLibUnit == null) {
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/AnalysisUtility.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698