[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Soot 1.2.4 released



On Fri, Nov 22, 2002 at 02:18:23PM -0800, Stephen Andrew Neuendorffer wrote:
> Suggestion to Ondrej:
> The above situation is rather frustrating for those of us using soot for 
> creating new classes.  Perhaps whenever someone invokes a method that 
> breaks the caches in the hierarchy, the method could automatically set a 
> dirty flag.  Then, the next time getActiveHierarchy(), or 
> getActiveFastHierarchy() is called, the above creation would happen 
> automatically...  It's very frustrating to run a transformation and have 
> the transformation create improper bytecode because I forgot to reset the 
> hierarchy.

The old Hierarchy checked that the Scene hadn't changed in every
method. For the new version, I wanted to avoid the overhead. But
if it only has to check on getActiveFastHierarchy(), not in every
FastHierarchy method, that's fine. I've made the Scene set the active
FastHierarchy to null whenever the Scene is modified. That way, you just
call getOrMakeFastHierarchy(), and it will make a new one if it needs
to. The patch is below, and it will appear in the next release (which
will hopefully be sooner than it took for the last release).

Ondrej

Index: 1.2.4.dev.19/src/soot/Scene.java
--- 1.2.4.dev.19/src/soot/Scene.java Fri, 02 Aug 2002 13:47:07 -0400 olhota (soot/X/33_Scene.java 1.13.1.1.1.2.1.25.1.10.1.6 644)
+++ 1.2.4.dev.19(w)/src/soot/Scene.java Mon, 25 Nov 2002 13:00:04 -0500 olhota (soot/X/33_Scene.java 1.13.1.1.1.2.1.25.1.10.1.6 644)
@@ -197,6 +197,12 @@
 
     private int stateCount;
     public int getState() { return this.stateCount; }
+    private void modifyHierarchy() {
+        stateCount++;
+        activeFastHierarchy = null;
+        activeSideEffectAnalysis = null;
+        activePointsToAnalysis = null;
+    }
 
     /** Returns the options map associated with phaseName. 
       * If a leading . is present in phaseName, strip it! */
@@ -291,7 +297,7 @@
 
         nameToClass.put(c.getName(), c);
         c.setInScene(true);
-        this.stateCount++;
+        modifyHierarchy();
     }
 
     public void removeClass(SootClass c)
@@ -302,7 +308,7 @@
         classes.remove(c);
         nameToClass.remove(c.getName());
         c.setInScene(false);
-        this.stateCount++;
+        modifyHierarchy();
     }
 
     public boolean containsClass(String className)