a few more bugs fixed...lots of debug code
authorbdemsky <bdemsky>
Fri, 11 Mar 2011 06:31:55 +0000 (06:31 +0000)
committerbdemsky <bdemsky>
Fri, 11 Mar 2011 06:31:55 +0000 (06:31 +0000)
Robust/src/Analysis/Pointer/AllocFactory.java
Robust/src/Analysis/Pointer/Delta.java
Robust/src/Analysis/Pointer/Edge.java
Robust/src/Analysis/Pointer/Pointer.java

index 8a12bd230b3b9aab5eca400f9b00b71ca8586ea7..7a281315cb09bd9c3db97a3adbe67150d87363d8 100644 (file)
@@ -36,6 +36,10 @@ public class AllocFactory {
       return false;
     }
 
+    public String toString() {
+      return getID();
+    }
+
     public String getID() {
       if (summary)
        return "SUM"+allocsite;
index 94d805e0791544b33d1246067a4865f872d8b006..38f69c67ccd4232e25293faa990b5858c602de4f 100644 (file)
@@ -62,19 +62,19 @@ public class Delta {
 
   public void print() {
     System.out.println("----------------------------------------------");
-    System.out.println("baseheapedge empty:"+baseheapedge.isEmpty());
-    System.out.println("basevaredge empty:"+basevaredge.isEmpty());
-    System.out.println("heapedgeadd empty:"+heapedgeadd.isEmpty());
-    System.out.println("heapedgeremove empty:"+heapedgeremove.isEmpty());
-    System.out.println("varedgeadd empty:"+varedgeadd.isEmpty());
+    System.out.println("baseheapedge:"+baseheapedge);
+    System.out.println("basevaredge:"+basevaredge);
+    System.out.println("heapedgeadd:"+heapedgeadd);
+    System.out.println("heapedgeremove:"+heapedgeremove);
+    System.out.println("varedgeadd:"+varedgeadd);
     if (varedgeremove==null)
-      System.out.println("varedge remove: null");
+      System.out.println("varedgeremove: null");
     else
-      System.out.println("varedgeremove empty:"+varedgeremove.isEmpty());
-    System.out.println("baseNodeAges empty:"+baseNodeAges.isEmpty());
-    System.out.println("addNodeAges empty:"+addNodeAges.isEmpty());
-    System.out.println("baseOldNodes empty:"+baseOldNodes.isEmpty());
-    System.out.println("addOldNodes empty:"+addOldNodes.isEmpty());
+      System.out.println("varedgeremove:"+varedgeremove);
+    System.out.println("baseNodeAges:"+baseNodeAges);
+    System.out.println("addNodeAges:"+addNodeAges);
+    System.out.println("baseOldNodes:"+baseOldNodes);
+    System.out.println("addOldNodes:"+addOldNodes);
   }
 
   private Delta() {
@@ -99,9 +99,12 @@ public class Delta {
     for(Map.Entry<TempDescriptor, MySet<Edge>> entry:varedgeadd.entrySet()) {
       TempDescriptor origTmp=entry.getKey();
       TempDescriptor newTmp=tmpMap.get(entry.getKey());
-      newdelta.varedgeadd.put(newTmp, new MySet<Edge>());
-      for(Edge e:entry.getValue()) {
-       newdelta.varedgeadd.get(newTmp).add(e.rewrite(origTmp, newTmp));
+      MySet<Edge> edgeset=entry.getValue();
+      if (!edgeset.isEmpty()) {
+       newdelta.varedgeadd.put(newTmp, new MySet<Edge>());
+       for(Edge e:edgeset) {
+         newdelta.varedgeadd.get(newTmp).add(e.rewrite(origTmp, newTmp));
+       }
       }
     }
     newdelta.varedgeremove=varedgeremove;
index e2f25b6a66c03b02c0faa895814b56aa3f86c387..61fdbb421e2ff58d027cb733f98f07958125c863 100644 (file)
@@ -15,6 +15,15 @@ public class Edge {
   public static final int SUMSUM=8;
   public static final int NEW=16;
 
+  public String toString() {
+    if (srcvar!=null)
+      return "<"+srcvar+", "+dst+">";
+    else if (fd!=null)
+      return "<"+src+", "+statuspredicate+", "+fd+", "+dst+">";
+    else
+      return "<"+src+", "+statuspredicate+", [], "+dst+">";
+  }
+
   public static int mergeStatus(int stat1, int stat2) {
     int status=stat1|stat2;
     return ((status&NEW)==NEW)?NEW:status;
@@ -123,7 +132,7 @@ public class Edge {
   }
 
   public static boolean subsumes(int status1, int status2) {
-    return ((status1&NEW)==NEW)&&((status1|status2)==status1);
+    return ((status1&NEW)==NEW)||((status1|status2)==status1);
   }
 
   public Edge makeOld() {
index a0b8441f4af2df181a52f8d886fd962741305c6c..af03fdf74ddff960d677beac76491170dc914544 100644 (file)
@@ -18,6 +18,7 @@ public class Pointer {
   AllocFactory allocFactory;
   LinkedList<Delta> toprocess;
   TempDescriptor returntmp;
+  int plotcount=0;
 
   public Pointer(State state, TypeUtil typeUtil) {
     this.state=state;
@@ -59,15 +60,19 @@ public class Pointer {
     toprocess.add(buildInitialContext());
     while(!toprocess.isEmpty()) {
       Delta delta=toprocess.remove();
-      delta.print();
       PPoint ppoint=delta.getBlock();
       BBlock bblock=ppoint.getBBlock();
       Vector<FlatNode> nodes=bblock.nodes();
       int startindex=0;
+      System.out.println("BB BEGIN");
+      delta.print();
+
       if (ppoint.getIndex()==-1) {
        //Build base graph for entrance to this basic block
+       System.out.println("INIT");
        delta=applyInitDelta(delta, bblock);
       } else {
+       System.out.println("CALL");
        startindex=ppoint.getIndex()+1;
        delta=applyCallDelta(delta, bblock);
       }
@@ -76,12 +81,21 @@ public class Pointer {
       //Compute delta at exit of each node
       for(int i=startindex; i<nodes.size();i++) {
        FlatNode currNode=nodes.get(i);
+       System.out.println("["+plotcount+"]");
+       System.out.println(currNode);
+       delta.print();
+
        if (!graphMap.containsKey(currNode)) {
          graphMap.put(currNode, new Graph(graph));
        }
        nodeGraph=graphMap.get(currNode);
+       plotGraph(nodeGraph,"S"+plotcount+currNode);
        delta=processNode(bblock, i, currNode, delta, nodeGraph);
+       plotGraph(nodeGraph,"N"+plotcount+currNode);
+       plotcount++;
       }
+      System.out.println("LOOPEXIT");
+      delta.print();
       generateFinalDelta(bblock, delta, nodeGraph);
     }
 
@@ -89,26 +103,14 @@ public class Pointer {
     int debugindex=0;
     for(Map.Entry<BBlock, Graph> e:bbgraphMap.entrySet()) {
       Graph g=e.getValue();
-      try {
-       PrintWriter pw=new PrintWriter(new FileWriter("BB"+debugindex+".dot"));
-       g.printGraph(pw, "BB");
-       pw.close();
-      } catch (Exception ex) {
-       ex.printStackTrace();
-      }
+      plotGraph(g,"BB"+debugindex);
       debugindex++;
     }
 
     for(Map.Entry<FlatNode, Graph> e:graphMap.entrySet()) {
       FlatNode fn=e.getKey();
       Graph g=e.getValue();
-      try {
-       PrintWriter pw=new PrintWriter(new FileWriter("FN"+fn.toString().replace(' ','_')+".dot"));
-       g.printGraph(pw, fn.toString());
-       pw.close();
-      } catch (Exception ex) {
-       ex.printStackTrace();
-      }
+      plotGraph(g,"FN"+fn.toString()+debugindex);
       debugindex++;
     }
     for(FlatMethod fm:blockMap.keySet()) {
@@ -116,6 +118,17 @@ public class Pointer {
     }
   }
 
+  void plotGraph(Graph g, String name) {
+    try {
+      PrintWriter pw=new PrintWriter(new FileWriter(name.toString().replace(' ','_')+".dot"));
+      g.printGraph(pw, name);
+      pw.close();
+    } catch (Exception ex) {
+      ex.printStackTrace();
+    }
+  }
+  
+
   /* This function builds the last delta for a basic block.  It
    * handles the case for the first time the basic block is
    * evaluated.*/
@@ -180,6 +193,7 @@ public class Pointer {
       HashSet<TempDescriptor> tmpSet=new HashSet<TempDescriptor>();
       tmpSet.addAll(delta.basevaredge.keySet());
       tmpSet.addAll(delta.varedgeadd.keySet());
+      System.out.println(tmpSet);
       for(TempDescriptor tmp:tmpSet) {
        /* Start with the new incoming edges */
        MySet<Edge> newbaseedge=delta.basevaredge.get(tmp);
@@ -241,6 +255,8 @@ public class Pointer {
        }
       }
     }
+    System.out.println("FINAL");
+    newDelta.print();
 
     /* Now we need to propagate newdelta */
     if (!newDelta.heapedgeadd.isEmpty()||!newDelta.heapedgeremove.isEmpty()||!newDelta.varedgeadd.isEmpty()||!newDelta.addNodeAges.isEmpty()||!newDelta.addOldNodes.isEmpty()) {
@@ -880,7 +896,7 @@ public class Pointer {
       HashSet<AllocNode> dstNodes=GraphManip.getNodes(graph, delta, dst);
       MySet<Edge> edgesToAdd=GraphManip.genEdges(dstNodes, fd, srcNodes);
       MySet<Edge> edgesToRemove=null;
-      if (dstNodes.size()==1&&!dstNodes.iterator().next().isSummary()) {
+      if (dstNodes.size()==1&&!dstNodes.iterator().next().isSummary()&&fd!=null) {
        /* Can do a strong update */
        edgesToRemove=GraphManip.getEdges(graph, delta, dstNodes, fd);
        graph.strongUpdateSet=edgesToRemove;
@@ -900,13 +916,13 @@ public class Pointer {
 
       MySet<Edge> edgesToRemove=null;
       if (newDstNodes.size()!=0) {
-       if (dstNodes.size()>1&&!dstNodes.iterator().next().isSummary()) {
+       if (dstNodes.size()>1&&!dstNodes.iterator().next().isSummary()&&fd!=null) {
          /* Need to undo strong update */
          if (graph.strongUpdateSet!=null) {
            edgesToAdd.addAll(graph.strongUpdateSet);
            graph.strongUpdateSet=null; //Prevent future strong updates
          }
-       } else if (dstNodes.size()==1&&newDstNodes.size()==1&&!newDstNodes.iterator().next().isSummary()&&graph.strongUpdateSet!=null) {
+       } else if (dstNodes.size()==1&&newDstNodes.size()==1&&!newDstNodes.iterator().next().isSummary()&&graph.strongUpdateSet!=null&&fd!=null) {
          edgesToRemove=GraphManip.getEdges(graph, delta, dstNodes, fd);
          graph.strongUpdateSet.addAll(edgesToRemove);
        }
@@ -914,7 +930,7 @@ public class Pointer {
       }
 
       //Kill new edges
-      if (graph.strongUpdateSet!=null) {
+      if (graph.strongUpdateSet!=null&&fd!=null) {
        MySet<Edge> otherEdgesToRemove=GraphManip.getDiffEdges(delta, dstNodes);
        if (edgesToRemove!=null)
          edgesToRemove.addAll(otherEdgesToRemove);
@@ -1364,7 +1380,7 @@ public class Pointer {
        }
       }
       //Done with edge set...
-      if (diffedges.size()>=0) {
+      if (diffedges.size()>0) {
        //completely new
        newdelta.basevaredge.put(tmpsrc,diffedges);
       }