Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No cache #26

Merged
merged 3 commits into from Jan 31, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions dev/build.xml
Expand Up @@ -276,6 +276,7 @@
<target name="checkstyle" description="Static analysis of source">
<gwt.checkstyle>
<fileset dir="core/src">
<filename name="com/google/gwt/dev/jjs/impl/jribble/JribbleProtos.java" negate="yes" />
<filename name="com/google/gwt/dev/shell/remoteui/RemoteMessageProto.java" negate="yes" />
<filename name="com/google/gwt/dev/asm/**/*.java" negate="yes" />
<filename name="com/google/gwt/dev/js/rhino/**/*.java" negate="yes" />
Expand Down
Expand Up @@ -15,6 +15,7 @@
*/
package com.google.gwt.dev.javac;

import com.google.gwt.dev.jjs.ast.JDeclaredType;
import com.google.gwt.dev.jjs.impl.GwtAstBuilder;
import com.google.gwt.dev.util.DiskCacheToken;

Expand Down Expand Up @@ -151,8 +152,8 @@ public String getTypeName() {
}

@Override
public byte[] getTypesSerialized() {
return astToken.readByteArray();
public List<JDeclaredType> getTypes() {
return getTypesFromSerialized(astToken.readByteArray());
}

@Override
Expand Down
Expand Up @@ -21,7 +21,6 @@
import com.google.gwt.dev.jjs.CorrelationFactory.DummyCorrelationFactory;
import com.google.gwt.dev.jjs.ast.JDeclaredType;
import com.google.gwt.dev.jjs.impl.GwtAstBuilder;
import com.google.gwt.dev.jjs.impl.jribble.JribbleLoader;
import com.google.gwt.dev.js.ast.JsRootScope;
import com.google.gwt.dev.resource.Resource;
import com.google.gwt.dev.util.StringInterner;
Expand Down Expand Up @@ -238,10 +237,13 @@ public void run() {
buildThread.start();

ArrayList<CompilationUnitBuilder> javaBuilders = new ArrayList<CompilationUnitBuilder>();
ArrayList<CompilationUnitBuilder> jribbleBuilders = new ArrayList<CompilationUnitBuilder>();
for (CompilationUnitBuilder builder : builders) {
if (builder.isJribble()) {
jribbleBuilders.add(builder);
/*
* No Java compilation is necessary for Jribble, so start building
* them immediately.
*/
buildQueue.add(builder);
} else {
javaBuilders.add(builder);
}
Expand All @@ -250,10 +252,6 @@ public void run() {
Event jdtCompilerEvent = SpeedTracerLogger.start(eventType);
try {
compiler.doCompile(javaBuilders);

JribbleLoader jribbleLoader = new JribbleLoader(Thread
.currentThread().getContextClassLoader(), buildQueue);
jribbleLoader.load(jribbleBuilders);
} finally {
jdtCompilerEvent.end();
}
Expand Down
52 changes: 31 additions & 21 deletions dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java
Expand Up @@ -212,7 +212,8 @@ public static boolean isClassnameGenerated(String className) {

/**
* Returns the unit as an instance of {@link CachedCompilationUnit}, making a
* copy if necessary.
* copy if necessary. Returns <code>null</code> if the unit should not be
* cached.
*/
public abstract CachedCompilationUnit asCachedCompilationUnit();

Expand Down Expand Up @@ -302,7 +303,7 @@ public final Map<String, String> getAnonymousClassMap() {
* Returns the full abstract path of the resource. If a resource has been
* re-rooted, this path should include any path prefix that was stripped.
*
* @see com.google.gwt.dev.resource.Resource#getPath()
* @see com.google.gwt.dev.resource.Resource#getPath()
* @see com.google.gwt.dev.resource.Resource#getPathPrefix()
*/
public abstract String getResourcePath();
Expand All @@ -315,23 +316,7 @@ public final Map<String, String> getAnonymousClassMap() {
/**
* Returns the GWT AST types in this unit.
*/
public List<JDeclaredType> getTypes() {
try {
byte[] bytes = getTypesSerialized();
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes));
return JProgram.deserializeTypes(ois);
} catch (IOException e) {
throw new RuntimeException("Unexpected IOException on in-memory stream", e);
} catch (ClassNotFoundException e) {
throw new RuntimeException("Unexpected error deserializing AST for '" + getTypeName() + "'",
e);
}
}

/**
* Returns the GWT AST types in this unit in serialized form.
*/
public abstract byte[] getTypesSerialized();
public abstract List<JDeclaredType> getTypes();

@Deprecated
public final boolean hasAnonymousClasses() {
Expand Down Expand Up @@ -370,6 +355,13 @@ public final int hashCode() {
@Deprecated
public abstract boolean isSuperSource();

/**
* Whether this unit should be persisted to disk.
*/
public boolean shouldBePersisted() {
return true;
}

/**
* Overridden to finalize; always returns {@link #getResourceLocation()}.
*/
Expand All @@ -383,7 +375,9 @@ public final String toString() {
* {@link CachedCompilationUnit}.
*/
protected final Object writeReplace() {
return asCachedCompilationUnit();
CachedCompilationUnit cachedUnit = asCachedCompilationUnit();
assert cachedUnit != null;
return cachedUnit;
}

/**
Expand All @@ -398,6 +392,22 @@ protected final Object writeReplace() {

abstract CategorizedProblem[] getProblems();

/**
* Read types from a serialized byte array. This is a helper method for
* subclasses that persist their types by serializing the GWT representations.
*/
List<JDeclaredType> getTypesFromSerialized(byte[] serialized) {
try {
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(serialized));
return JProgram.deserializeTypes(ois);
} catch (IOException e) {
throw new RuntimeException("Unexpected IOException on in-memory stream", e);
} catch (ClassNotFoundException e) {
throw new RuntimeException("Unexpected error deserializing AST for '" + getTypeName() + "'",
e);
}
}

private List<String> getJdtClassNames(String topLevelClass) {
List<String> classNames = new ArrayList<String>();
for (CompiledClass cc : getCompiledClasses()) {
Expand All @@ -412,7 +422,7 @@ private List<String> getJdtClassNames(String topLevelClass) {
private List<String> getTopLevelClasses() {
List<String> topLevelClasses = new ArrayList<String>();
for (CompiledClass cc : getCompiledClasses()) {
if (cc.getEnclosingClass() == null) {
if (cc.isTopLevel()) {
topLevelClasses.add(cc.getInternalName());
}
}
Expand Down