From: bdemsky <bdemsky>
Date: Wed, 9 Mar 2011 21:54:19 +0000 (+0000)
Subject: changes
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=68d717e92690af10cbe81384fcc6c8664e58fca5;p=IRC.git

changes
---

diff --git a/Robust/src/Analysis/Pointer/Edge.java b/Robust/src/Analysis/Pointer/Edge.java
index 49884471..c4175afc 100644
--- a/Robust/src/Analysis/Pointer/Edge.java
+++ b/Robust/src/Analysis/Pointer/Edge.java
@@ -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;
diff --git a/Robust/src/Analysis/Pointer/Graph.java b/Robust/src/Analysis/Pointer/Graph.java
index 4460bf07..5c98abf2 100644
--- a/Robust/src/Analysis/Pointer/Graph.java
+++ b/Robust/src/Analysis/Pointer/Graph.java
@@ -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);
diff --git a/Robust/src/Analysis/Pointer/Pointer.java b/Robust/src/Analysis/Pointer/Pointer.java
index c9705232..e7b4bede 100644
--- a/Robust/src/Analysis/Pointer/Pointer.java
+++ b/Robust/src/Analysis/Pointer/Pointer.java
@@ -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...