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

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

Issue 9464044: Updates incremental compilation tests to work w/o code generation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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
Index: compiler/java/com/google/dart/compiler/DartCompiler.java
diff --git a/compiler/java/com/google/dart/compiler/DartCompiler.java b/compiler/java/com/google/dart/compiler/DartCompiler.java
index 5ff544d4048a447352359fc23b8a123e593d2b55..74c93bd277c2075b6a07c052a9c8c1892a02b01d 100644
--- a/compiler/java/com/google/dart/compiler/DartCompiler.java
+++ b/compiler/java/com/google/dart/compiler/DartCompiler.java
@@ -1,4 +1,4 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -70,8 +70,10 @@ import java.util.Set;
*/
public class DartCompiler {
+
public static final String EXTENSION_DEPS = "deps";
public static final String EXTENSION_LOG = "log";
+ public static final String EXTENSION_TIMESTAMP = "timestamp";
public static final String CORELIB_URL_SPEC = "dart:core";
public static final String MAIN_ENTRY_POINT_NAME = "main";
@@ -257,7 +259,7 @@ public class DartCompiler {
if (!incremental
|| (libIsDartUri && !usePrecompiledDartLibs)
- || isSourceOutOfDate(dartSrc, libSrc)) {
+ || isSourceOutOfDate(dartSrc)) {
DartUnit unit = parse(dartSrc, lib.getPrefixes(), false);
// If we just parsed unit of library, report problems with its "#import" declarations.
@@ -446,10 +448,11 @@ public class DartCompiler {
/**
* Determines whether the given source is out-of-date with respect to its artifacts.
*/
- private boolean isSourceOutOfDate(DartSource dartSrc, LibrarySource libSrc) {
+ private boolean isSourceOutOfDate(DartSource dartSrc) {
TraceEvent logEvent =
Tracer.canTrace() ? Tracer.start(DartEventType.IS_SOURCE_OUTOFDATE, "src",
dartSrc.getName()) : null;
+
try {
// If incremental compilation is disabled, just return true to force all
// units to be recompiled.
@@ -457,17 +460,31 @@ public class DartCompiler {
return true;
}
- for (Backend backend : backends) {
+ if (checkOnly) {
TraceEvent backendEvent =
- Tracer.canTrace() ? Tracer.start(DartEventType.BACKEND_OUTOFDATE, "be", backend
- .getClass().getCanonicalName(), "src", dartSrc.getName()) : null;
+ Tracer.canTrace() ? Tracer.start(DartEventType.TIMESTAMP_OUTOFDATE,
+ "src", dartSrc.getName()) : null;
try {
- if (backend.isOutOfDate(dartSrc, context)) {
+ if (context.isOutOfDate(dartSrc, dartSrc, EXTENSION_TIMESTAMP)) {
return true;
}
} finally {
Tracer.end(backendEvent);
}
+ } else {
+ // TODO(zundel): remove this case when code generation goes away
+ for (Backend backend : backends) {
+ TraceEvent backendEvent =
+ Tracer.canTrace() ? Tracer.start(DartEventType.BACKEND_OUTOFDATE, "be", backend
+ .getClass().getCanonicalName(), "src", dartSrc.getName()) : null;
+ try {
+ if (backend.isOutOfDate(dartSrc, context)) {
+ return true;
+ }
+ } finally {
+ Tracer.end(backendEvent);
+ }
+ }
}
return false;
} finally {
@@ -751,6 +768,8 @@ public class DartCompiler {
continue;
}
+ updateAnalysisTimestamp(unit);
+
// Run all compiler phases including AST simplification and symbol
// resolution. This must run in serial.
for (DartCompilationPhase phase : phases) {
@@ -772,21 +791,19 @@ public class DartCompiler {
// To help support the IDE, notify the listener that this unit is compiled.
context.unitCompiled(unit);
- if (checkOnly) {
- continue;
- }
-
- // Run the unit through all the backends. This loop can also be
- // parallelized.
- for (Backend be : config.getBackends()) {
- TraceEvent backendEvent =
- Tracer.canTrace() ? Tracer.start(DartEventType.BACKEND_COMPILE, "be", be
- .getClass().getSimpleName(), "lib", lib.getName(), "unit", unit
- .getSourceName()) : null;
- try {
- be.compileUnit(unit, unit.getSource(), context, typeProvider);
- } finally {
- Tracer.end(backendEvent);
+ if (!checkOnly) {
+ // Run the unit through all the backends. This loop can also be
+ // parallelized.
+ for (Backend be : config.getBackends()) {
+ TraceEvent backendEvent =
+ Tracer.canTrace() ? Tracer.start(DartEventType.BACKEND_COMPILE, "be", be
+ .getClass().getSimpleName(), "lib", lib.getName(), "unit", unit
+ .getSourceName()) : null;
+ try {
+ be.compileUnit(unit, unit.getSource(), context, typeProvider);
+ } finally {
+ Tracer.end(backendEvent);
+ }
}
}
@@ -800,7 +817,7 @@ public class DartCompiler {
}
// Persist the DEPS file.
- if (persist && !checkOnly) {
+ if (persist) {
lib.writeDeps(context);
}
}
@@ -808,11 +825,18 @@ public class DartCompiler {
if (compilerMetrics != null) {
compilerMetrics.endCompileLibrariesTime();
}
-
Tracer.end(logEvent);
}
}
+ private void updateAnalysisTimestamp(DartUnit unit) throws IOException {
+ // Update timestamp.
+ Writer writer = context.getArtifactWriter(unit.getSource(), "", EXTENSION_TIMESTAMP);
+ String timestampData = String.format("%d\n", System.currentTimeMillis());
+ writer.write(timestampData);
+ writer.close();
+ }
+
private void packageApp() throws IOException {
TraceEvent logEvent = Tracer.canTrace() ? Tracer.start(DartEventType.PACKAGE_APP) : null;

Powered by Google App Engine
This is Rietveld 408576698