aboutsummaryrefslogtreecommitdiffstats
path: root/asm
diff options
context:
space:
mode:
authoraclement <aclement>2005-02-04 13:42:54 +0000
committeraclement <aclement>2005-02-04 13:42:54 +0000
commit953fd4340f6eb6c578d591be9a0d601daf35ca6d (patch)
tree9afc5ec7176acee4f8f43343c53c96a5e2c35e10 /asm
parent874a0b997ef069c362c255e0c1cfcf0b25136d78 (diff)
downloadaspectj-953fd4340f6eb6c578d591be9a0d601daf35ca6d.tar.gz
aspectj-953fd4340f6eb6c578d591be9a0d601daf35ca6d.zip
Fix for atrocious incremental compilation performance.
Diffstat (limited to 'asm')
-rw-r--r--asm/src/org/aspectj/asm/AsmManager.java39
-rw-r--r--asm/src/org/aspectj/asm/IHierarchy.java2
-rw-r--r--asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java20
3 files changed, 44 insertions, 17 deletions
diff --git a/asm/src/org/aspectj/asm/AsmManager.java b/asm/src/org/aspectj/asm/AsmManager.java
index f7c81df06..60645f3b0 100644
--- a/asm/src/org/aspectj/asm/AsmManager.java
+++ b/asm/src/org/aspectj/asm/AsmManager.java
@@ -41,9 +41,7 @@ public class AsmManager {
public static boolean attemptIncrementalModelRepairs = false;
// for debugging ...
-// static {
-// setReporting("c:/model.nfo",true,true,true,true);
-// }
+
// For offline debugging, you can now ask for the AsmManager to
@@ -54,7 +52,9 @@ public class AsmManager {
private static String dumpFilename = "";
private static boolean reporting = false;
-
+// static {
+// setReporting("c:/model.nfo",true,true,true,true);
+// }
protected AsmManager() {
hierarchy = new AspectJElementHierarchy();
@@ -417,6 +417,11 @@ public class AsmManager {
//===================== DELTA PROCESSING CODE ============== start ==========//
+ // XXX shouldn't be aware of the delimiter
+ private String getFilename(String hid) {
+ return hid.substring(0,hid.indexOf("|"));
+ }
+
// This code is *SLOW* but it isnt worth fixing until we address the
// bugs in binary weaving.
public void fixupStructureModel(Writer fw,List filesToBeCompiled,Set files_added,Set files_deleted) throws IOException {
@@ -433,7 +438,7 @@ public class AsmManager {
Set filesToRemoveFromStructureModel = new HashSet(filesToBeCompiled);
filesToRemoveFromStructureModel.addAll(files_deleted);
-
+ Set deletedNodes = new HashSet();
for (Iterator iter = filesToRemoveFromStructureModel.iterator(); iter.hasNext();) {
File fileForCompilation = (File) iter.next();
String correctedPath = AsmManager.getDefault().getCanonicalFilePath(fileForCompilation);
@@ -444,15 +449,15 @@ public class AsmManager {
fw.write("Deleting "+progElem+" node for file "+fileForCompilation+"\n");
}
removeNode(progElem);
- verifyAssumption(
- model.removeFromFileMap(correctedPath.toString()),
- "Whilst repairing model, couldn't remove entry for file: "+correctedPath.toString()+" from the filemap");
+ deletedNodes.add(getFilename(progElem.getHandleIdentifier()));
+ if (!model.removeFromFileMap(correctedPath.toString()))
+ throw new RuntimeException("Whilst repairing model, couldn't remove entry for file: "+correctedPath.toString()+" from the filemap");
modelModified = true;
}
}
if (modelModified) {
model.flushTypeMap();
- model.flushHandleMap();
+ model.updateHandleMap(deletedNodes);
}
}
@@ -641,26 +646,26 @@ public class AsmManager {
*/
private void removeNode(IProgramElement progElem) {
- StringBuffer flightrecorder = new StringBuffer();
+// StringBuffer flightrecorder = new StringBuffer();
try {
- flightrecorder.append("In removeNode, about to chuck away: "+progElem+"\n");
+// flightrecorder.append("In removeNode, about to chuck away: "+progElem+"\n");
verifyAssumption(progElem!=null);
boolean deleteOK = false;
IProgramElement parent = progElem.getParent();
- flightrecorder.append("Parent of it is "+parent+"\n");
+// flightrecorder.append("Parent of it is "+parent+"\n");
List kids = parent.getChildren();
- flightrecorder.append("Which has "+kids.size()+" kids\n");
+// flightrecorder.append("Which has "+kids.size()+" kids\n");
for (int i =0 ;i<kids.size();i++) {
- flightrecorder.append("Comparing with "+kids.get(i)+"\n");
+// flightrecorder.append("Comparing with "+kids.get(i)+"\n");
if (kids.get(i).equals(progElem)) {
kids.remove(i);
- flightrecorder.append("Removing it\n");
+// flightrecorder.append("Removing it\n");
deleteOK=true;
break;
}
}
- verifyAssumption(deleteOK,flightrecorder.toString());
+// verifyAssumption(deleteOK,flightrecorder.toString());
// Are there any kids left for this node?
if (parent.getChildren().size()==0 && parent.getParent()!=null &&
(parent.getKind().equals(IProgramElement.Kind.CODE) ||
@@ -672,7 +677,7 @@ public class AsmManager {
}
} catch (NullPointerException npe ){
// Occurred when commenting out other 2 ras classes in wsif?? reproducable?
- System.err.println(flightrecorder.toString());
+// System.err.println(flightrecorder.toString());
npe.printStackTrace();
}
}
diff --git a/asm/src/org/aspectj/asm/IHierarchy.java b/asm/src/org/aspectj/asm/IHierarchy.java
index 95b00996b..481147cd8 100644
--- a/asm/src/org/aspectj/asm/IHierarchy.java
+++ b/asm/src/org/aspectj/asm/IHierarchy.java
@@ -99,4 +99,6 @@ public interface IHierarchy extends Serializable {
public void flushTypeMap();
public void flushHandleMap();
+
+ public void updateHandleMap(Set deletedFiles);
} \ No newline at end of file
diff --git a/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java b/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java
index 448540802..5d3d7a0a2 100644
--- a/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java
+++ b/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java
@@ -367,5 +367,25 @@ public class AspectJElementHierarchy implements IHierarchy {
public void flushHandleMap() {
handleMap.clear();
}
+
+ public void updateHandleMap(Set deletedFiles) {
+ // Only delete the entries we need to from the handle map - for performance reasons
+ List forRemoval = new ArrayList();
+ Set k = handleMap.keySet();
+ for (Iterator iter = k.iterator(); iter.hasNext();) {
+ String handle = (String) iter.next();
+ if (deletedFiles.contains(getFilename(handle))) forRemoval.add(handle);
+ }
+ for (Iterator iter = forRemoval.iterator(); iter.hasNext();) {
+ String handle = (String) iter.next();
+ handleMap.remove(handle);
+ }
+ }
+
+ // XXX shouldn't be aware of the delimiter
+ private String getFilename(String hid) {
+ return hid.substring(0,hid.indexOf("|"));
+ }
+
}