aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracolyer <acolyer>2006-02-24 15:00:18 +0000
committeracolyer <acolyer>2006-02-24 15:00:18 +0000
commit66165173b34678ee428d4f4d791168f8cb5f231c (patch)
tree7db2761f727d0ee5dbedac9f9dcdf2be132fd6a8
parentc6677a313dded568cc368960c836a118a6276f6b (diff)
downloadaspectj-66165173b34678ee428d4f4d791168f8cb5f231c.tar.gz
aspectj-66165173b34678ee428d4f4d791168f8cb5f231c.zip
Completed: Improve ajc memory usage
Determine how much state to hold in AjState based on whether the environment we're running in supports incremental compilation
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java11
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java38
-rw-r--r--org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjStateTest.java1
3 files changed, 40 insertions, 10 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
index 4f6c664c7..3b68dc315 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
@@ -119,6 +119,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
private IProgressListener progressListener = null;
+ private boolean environmentSupportsIncrementalCompilation = false;
private int compiledCount;
private int sourceFileCount;
@@ -145,6 +146,10 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
super();
this.handler = CountingMessageHandler.makeCountingMessageHandler(holder);
}
+
+ public void environmentSupportsIncrementalCompilation(boolean itDoes) {
+ this.environmentSupportsIncrementalCompilation = itDoes;
+ }
/** @return true if we should generate a model as a side-effect */
public boolean doGenerateModel() {
@@ -185,6 +190,8 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
this.state = new AjState(this);
}
+ this.state.setCouldBeSubsequentIncrementalBuild(this.environmentSupportsIncrementalCompilation);
+
boolean canIncremental = state.prepareForNextBuild(buildConfig);
if (!canIncremental && !batch) { // retry as batch?
CompilationAndWeavingContext.leavingPhase(ct);
@@ -992,6 +999,10 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
private void setBuildConfig(AjBuildConfig buildConfig) {
this.buildConfig = buildConfig;
+ if (!this.environmentSupportsIncrementalCompilation) {
+ this.environmentSupportsIncrementalCompilation =
+ (buildConfig.isIncrementalMode() || buildConfig.isIncrementalFileMode());
+ }
handler.reset();
}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java
index e901f057e..799130ba2 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java
@@ -42,11 +42,9 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers;
import org.aspectj.org.eclipse.jdt.internal.core.builder.ReferenceCollection;
import org.aspectj.org.eclipse.jdt.internal.core.builder.StringSet;
-import org.aspectj.org.eclipse.jdt.internal.core.util.Util;
import org.aspectj.util.FileUtil;
import org.aspectj.weaver.IWeaver;
import org.aspectj.weaver.ReferenceType;
-import org.aspectj.weaver.ReferenceTypeDelegate;
import org.aspectj.weaver.ResolvedMember;
import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.UnresolvedType;
@@ -60,9 +58,11 @@ import org.aspectj.weaver.bcel.UnwovenClassFile;
*/
public class AjState {
private AjBuildManager buildManager;
+ private boolean couldBeSubsequentIncrementalBuild = false;
// SECRETAPI static so beware of multi-threading bugs...
public static IStateListener stateListener = null;
+ public static boolean FORCE_INCREMENTAL_DURING_TESTING = false;
private IHierarchy structureModel;
private IRelationshipMap relmap;
@@ -175,6 +175,10 @@ public class AjState {
this.buildManager = buildManager;
}
+ public void setCouldBeSubsequentIncrementalBuild(boolean yesThereCould) {
+ this.couldBeSubsequentIncrementalBuild = yesThereCould;
+ }
+
void successfulCompile(AjBuildConfig config,boolean wasFullBuild) {
buildConfig = config;
lastSuccessfulBuildTime = currentBuildTime;
@@ -187,7 +191,11 @@ public class AjState {
*/
boolean prepareForNextBuild(AjBuildConfig newBuildConfig) {
currentBuildTime = System.currentTimeMillis();
-
+
+ if (!maybeIncremental()) {
+ return false;
+ }
+
if (this.batchBuildRequiredThisTime) {
this.batchBuildRequiredThisTime = false;
return false;
@@ -433,8 +441,12 @@ public class AjState {
return thisTime;
}
+ private boolean maybeIncremental() {
+ return (FORCE_INCREMENTAL_DURING_TESTING || this.couldBeSubsequentIncrementalBuild);
+ }
+
public Map /* String -> List<ucf> */ getBinaryFilesToCompile(boolean firstTime) {
- if (lastSuccessfulBuildTime == -1 || buildConfig == null) {
+ if (lastSuccessfulBuildTime == -1 || buildConfig == null || !maybeIncremental()) {
return binarySourceFiles;
}
// else incremental...
@@ -595,6 +607,10 @@ public class AjState {
}
public void noteResult(InterimCompilationResult result) {
+ if (!maybeIncremental()) {
+ return;
+ }
+
File sourceFile = new File(result.fileName());
CompilationResult cr = result.result();
@@ -1028,13 +1044,15 @@ public class AjState {
public void recordBinarySource(String fromPathName, List unwovenClassFiles) {
this.binarySourceFiles.put(fromPathName,unwovenClassFiles);
- List simpleClassFiles = new LinkedList();
- for (Iterator iter = unwovenClassFiles.iterator(); iter.hasNext();) {
- UnwovenClassFile ucf = (UnwovenClassFile) iter.next();
- ClassFile cf = getClassFileFor(ucf);
- simpleClassFiles.add(cf);
+ if (this.maybeIncremental()) {
+ List simpleClassFiles = new LinkedList();
+ for (Iterator iter = unwovenClassFiles.iterator(); iter.hasNext();) {
+ UnwovenClassFile ucf = (UnwovenClassFile) iter.next();
+ ClassFile cf = getClassFileFor(ucf);
+ simpleClassFiles.add(cf);
+ }
+ this.inputClassFilesBySource.put(fromPathName,simpleClassFiles);
}
- this.inputClassFilesBySource.put(fromPathName,simpleClassFiles);
}
/**
diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjStateTest.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjStateTest.java
index 7df629835..67980c672 100644
--- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjStateTest.java
+++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjStateTest.java
@@ -24,6 +24,7 @@ public class AjStateTest extends TestCase {
private AjBuildConfig newConfig;
public void testNoChange() {
+ aRightState.setCouldBeSubsequentIncrementalBuild(true);
assertTrue("Can do incremental",aRightState.prepareForNextBuild(newConfig));
}