changes
authorbdemsky <bdemsky>
Wed, 9 Mar 2011 21:54:19 +0000 (21:54 +0000)
committerbdemsky <bdemsky>
Wed, 9 Mar 2011 21:54:19 +0000 (21:54 +0000)
Robust/src/Analysis/Pointer/Edge.java
Robust/src/Analysis/Pointer/Graph.java
Robust/src/Analysis/Pointer/Pointer.java

index 49884471179f469ac1b222b4ac35607948020596..c4175afcc598bd9537359691633c4bf73aa52f76 100644 (file)
@@ -76,6 +76,14 @@ public class Edge {
     return e;
   }
 
+  public Edge merge(Edge e) {
+    if (e==null)
+      return this;
+    Edge newe=copy();
+    newe.statuspredicate=mergeStatus(statuspredicate, e.statuspredicate);
+    return newe;
+  }
+
   public Edge rewrite(AllocNode single, AllocNode summary) {
     Edge e=copy();
     if (e.src==single)
@@ -98,6 +106,14 @@ public class Edge {
     return e;
   }
 
+  public boolean subsumes(Edge e) {
+    return subsumes(this.statuspredicate, e.statuspredicate);
+  }
+
+  public static boolean subsumes(int status1, int status2) {
+    return ((status1&NEW)==NEW)&&((status1|status2)==status1);
+  }
+
   public Edge makeOld() {
     Edge e=new Edge();
     e.fd=fd;
index 4460bf07875e9299628f0c578218f6e070f7818b..5c98abf2dc91d0812fc212f71f313a274d7bd1e6 100644 (file)
@@ -47,6 +47,16 @@ public class Graph {
     return nodeAges.contains(node)||parent!=null&&parent.nodeAges.contains(node);
   }
 
+  public Edge getMatch(Edge old) {
+    if (old.srcvar!=null) {
+      MySet<Edge> edges=varMap.get(old.srcvar);
+      return edges.get(old);
+    } else {
+      MySet<Edge> edges=nodeMap.get(old.src);
+      return edges.get(old);
+    }
+  }
+
   public MySet<Edge> getEdges(TempDescriptor tmp) {
     if (varMap.containsKey(tmp))
       return varMap.get(tmp);
index c97052320416eb2104bb665ce98cb83d4ca025f2..e7b4bede27401dfd61f6085e65b65ab4dde2a4f8 100644 (file)
@@ -86,6 +86,10 @@ public class Pointer {
     }
   }
 
+  /* This function builds the last delta for a basic block.  It
+   * handles the case for the first time the basic block is
+   * evaluated.*/
+
   void buildInitDelta(Graph graph, Delta newDelta) {
     //First compute the set of temps
     HashSet<TempDescriptor> tmpSet=new HashSet<TempDescriptor>();
@@ -134,6 +138,8 @@ public class Pointer {
     }
   }
 
+  /* This function build the delta for the exit of a basic block. */
+
   void generateFinalDelta(BBlock bblock, Delta delta, Graph graph) {
     Delta newDelta=new Delta(null, false);
     if (delta.getInit()) {
@@ -240,6 +246,9 @@ public class Pointer {
     }
   }
 
+  /* This function compute the edges for the this variable for a
+   * callee if it exists. */
+
   void processThisTargets(HashSet<ClassDescriptor> targetSet, Graph graph, Delta delta, Delta newDelta, HashSet<AllocNode> nodeset, Stack<AllocNode> tovisit, MySet<Edge> edgeset, TempDescriptor tmpthis, HashSet<AllocNode> oldnodeset) {
     //Handle the this temp
     if (tmpthis!=null) {
@@ -263,6 +272,8 @@ public class Pointer {
     }
   }
 
+  /* This function compute the edges for a call's parameters. */
+
   void processParams(Graph graph, Delta delta, Delta newDelta, HashSet<AllocNode> nodeset, Stack<AllocNode> tovisit, MySet<Edge> edgeset, FlatCall fcall, boolean diff) {
     //Go through each temp
     for(int i=0;i<fcall.numArgs();i++) {
@@ -279,6 +290,8 @@ public class Pointer {
     }
   }
 
+  /* This function computes the reachable nodes for a callee. */
+
   void computeReachableNodes(Graph graph, Delta delta, Delta newDelta, HashSet<AllocNode> nodeset, Stack<AllocNode> tovisit, MySet<Edge> edgeset, HashSet<AllocNode> oldnodeset) {
       while(!tovisit.isEmpty()) {
        AllocNode node=tovisit.pop();
@@ -430,6 +443,9 @@ public class Pointer {
       }
     }
   }
+
+  /* This function removes the caller reachable edges from the
+   * callee's heap. */
   
   void removeEdges(Delta delta, HashSet<AllocNode> nodeset, MySet<Edge> edgeset, MySet<Edge> externaledgeset) {
     //Want to remove the set of internal edges
@@ -544,7 +560,7 @@ public class Pointer {
     return delta;
   }
 
-  
+  /* This function applies callee deltas to the caller heap. */
 
   Delta applyCallDelta(Delta delta, BBlock bblock) {
     Delta newDelta=new Delta(null, false);
@@ -588,7 +604,12 @@ public class Pointer {
          }
        }
        if (edgetoadd!=null) {
-         newDelta.addHeapEdge(edgetoadd);
+         Edge match=graph.getMatch(edgetoadd);
+         if (match==null||!match.subsumes(edgetoadd)) {
+           Edge mergededge=edgetoadd.merge(match);
+           //XXXXXXXXXXXXX;
+           newDelta.addHeapEdge(mergededge);
+         }
        }
       }
     }
@@ -616,7 +637,7 @@ public class Pointer {
        newDelta.addEdge(newedge);
       }
     }
-    
+
     return newDelta;
   }
 
@@ -638,8 +659,10 @@ public class Pointer {
     MySet<Edge> backedges=graph.getBackEdges(singleNode);
     for(Edge e:backedges) {
       if (e.dst==singleNode) {
-       Edge rewrite=e.rewrite(singleNode, summaryNode);
-       newDelta.removeEdge(e);
+       //Need to get original edge so that predicate will be correct
+       Edge match=graph.getMatch(e);
+       Edge rewrite=match.rewrite(singleNode, summaryNode);
+       newDelta.removeEdge(match);
        newDelta.addEdge(rewrite);
       }
     }
@@ -1189,6 +1212,13 @@ public class Pointer {
          //We have a new edge
          diffedges.add(e);
          dstedges.add(e);
+       } else {
+         Edge origedge=dstedges.get(e);
+         if (!origedge.subsumes(e)) {
+           Edge mergededge=origedge.merge(e);
+           diffedges.add(mergededge);
+           dstedges.add(mergededge);
+         }
        }
       }
       //Done with edge set...