even more bug fixes...3 test cases work
authorbdemsky <bdemsky>
Thu, 10 Mar 2011 09:23:17 +0000 (09:23 +0000)
committerbdemsky <bdemsky>
Thu, 10 Mar 2011 09:23:17 +0000 (09:23 +0000)
Robust/src/Analysis/Pointer/BasicBlock.java
Robust/src/Analysis/Pointer/Delta.java
Robust/src/Analysis/Pointer/Graph.java
Robust/src/Analysis/Pointer/GraphManip.java
Robust/src/Analysis/Pointer/Pointer.java

index b58ae1e481c812da6ac45f78409f7c2cfabda31d..2f6e990317a79b5e59e84fe95409641a4278b506 100644 (file)
@@ -89,9 +89,10 @@ public class BasicBlock {
          break;
        }
        block.nodes.add(fn);
+       if (fn.kind()==FKind.FlatExit)
+         exit=block;
       } while(true);
     }
-
     return new BasicBlock(map.get(fm), exit);
   }
 }
index 743b8dbf7f805822449fbd1cc6ec6977b62bbab1..e150f02c3943b2aecedf4976c02e33bc77645f03 100644 (file)
@@ -19,6 +19,8 @@ public class Delta {
   public Delta check() {
     for(Map.Entry<AllocNode, MySet<Edge>> entry:heapedgeadd.entrySet()) {
       AllocNode node=entry.getKey();
+      if (node==null)
+       throw new Error("null node key");
       for(Edge e:entry.getValue())
        if (e.src!=node)
          throw new Error(e.src+" is not equal to "+node);
@@ -26,6 +28,8 @@ public class Delta {
 
     for(Map.Entry<TempDescriptor, MySet<Edge>> entry:varedgeadd.entrySet()) {
       TempDescriptor tmp=entry.getKey();
+      if (tmp==null)
+       throw new Error("null temp key");
       for(Edge e:entry.getValue())
        if (e.srcvar!=tmp)
          throw new Error(e.srcvar+" is not equal to "+tmp);
index 265153c969691109e56e87492b70eb87cd54be39..6ad79aaae17aabc2d7f82c28df434e47ff021692 100644 (file)
@@ -18,12 +18,16 @@ public class Graph {
   public void check() {
     for(Map.Entry<AllocNode, MySet<Edge>> entry:nodeMap.entrySet()) {
       AllocNode node=entry.getKey();
+      if (node==null)
+       throw new Error("Null node key");
       for(Edge e:entry.getValue())
        if (e.src!=node)
          throw new Error();
     }
     for(Map.Entry<TempDescriptor, MySet<Edge>> entry:varMap.entrySet()) {
       TempDescriptor tmp=entry.getKey();
+      if (tmp==null)
+       throw new Error("Null tmp key");
       for(Edge e:entry.getValue())
        if (e.srcvar!=tmp)
          throw new Error();
index a899fc5b67d3ba3d505033a713d3140f2df28dff..ea998fae5f78f95e19550fbb79ffb5424712612b 100644 (file)
@@ -26,10 +26,13 @@ public class GraphManip {
   static MySet<Edge> getDiffEdges(Delta delta, TempDescriptor tmp) {
     MySet<Edge> edges=new MySet<Edge>();
     MySet<Edge> removeedges=delta.varedgeremove.get(tmp);
-
-    for(Edge e:delta.basevaredge.get(tmp)) {
-      if (removeedges==null||!removeedges.contains(e))
-       edges.add(e);
+    
+    MySet<Edge> baseedges=delta.basevaredge.get(tmp);
+    if (baseedges!=null) {
+      for(Edge e:baseedges) {
+       if (removeedges==null||!removeedges.contains(e))
+         edges.add(e);
+      }
     }
     if (delta.varedgeadd.containsKey(tmp))
       for(Edge e:delta.varedgeadd.get(tmp)) {
@@ -88,11 +91,14 @@ public class GraphManip {
   static HashSet<AllocNode> getDiffNodes(Delta delta, TempDescriptor tmp) {
     HashSet<AllocNode> nodes=new HashSet<AllocNode>();
     MySet<Edge> removeedges=delta.varedgeremove.get(tmp);
+    
+    MySet<Edge> baseEdges=delta.basevaredge.get(tmp);
 
-    for(Edge e:delta.basevaredge.get(tmp)) {
-      if (removeedges==null||!removeedges.contains(e))
-       nodes.add(e.dst);
-    }
+    if (baseEdges!=null)
+      for(Edge e:baseEdges) {
+       if (removeedges==null||!removeedges.contains(e))
+         nodes.add(e.dst);
+      }
     if (delta.varedgeadd.containsKey(tmp))
       for(Edge e:delta.varedgeadd.get(tmp)) {
        nodes.add(e.dst);
index af467a283156e489d57f68c12b5f483e248cac2d..0c73bd53ab01d6228a18008f202f4276af0c189e 100644 (file)
@@ -71,7 +71,6 @@ public class Pointer {
        startindex=ppoint.getIndex()+1;
        delta=applyCallDelta(delta, bblock);
       }
-
       Graph graph=bbgraphMap.get(bblock);
       Graph nodeGraph=null;
       //Compute delta at exit of each node
@@ -185,6 +184,8 @@ public class Pointer {
        /* Start with the new incoming edges */
        MySet<Edge> newbaseedge=delta.basevaredge.get(tmp);
        /* Remove the remove set */
+       if (newbaseedge==null)
+         newbaseedge=new MySet<Edge>();
        newbaseedge.removeAll(delta.varedgeremove.get(tmp));
        /* Add in the new set*/
        newbaseedge.addAll(delta.varedgeadd.get(tmp));
@@ -200,7 +201,7 @@ public class Pointer {
       nodeSet.addAll(delta.heapedgeremove.keySet());
       for(AllocNode node:nodeSet) {
        /* Start with the new incoming edges */
-       MySet<Edge> newheapedge=(MySet<Edge>) delta.baseheapedge.get(node).clone();
+       MySet<Edge> newheapedge=new MySet<Edge>(delta.baseheapedge.get(node));
        /* Remove the remove set */
        MySet<Edge> removeset=delta.heapedgeremove.get(node);
 
@@ -244,14 +245,32 @@ public class Pointer {
     /* Now we need to propagate newdelta */
     if (!newDelta.heapedgeadd.isEmpty()||!newDelta.heapedgeremove.isEmpty()||!newDelta.varedgeadd.isEmpty()||!newDelta.addNodeAges.isEmpty()||!newDelta.addOldNodes.isEmpty()) {
       /* We have a delta to propagate */
-      Vector<BBlock> blockvector=bblock.next();
-      for(int i=0;i<blockvector.size();i++) {
-       if (i==0) {
-         newDelta.setBlock(new PPoint(blockvector.get(i)));
-         toprocess.add(newDelta);
-       } else {
-         Delta d=newDelta.diffBlock(new PPoint(blockvector.get(i)));
-         toprocess.add(d);
+
+      if (returnMap.containsKey(bblock)) {
+       //exit of call block
+       boolean first=true;
+
+       for(PPoint caller:returnMap.get(bblock)) {
+         if (first) {
+           newDelta.setBlock(caller);
+           toprocess.add(newDelta);
+           first=false;
+         } else {
+           Delta d=newDelta.diffBlock(caller);
+           toprocess.add(d);
+         }
+       }
+      } else {
+       //normal block
+       Vector<BBlock> blockvector=bblock.next();
+       for(int i=0;i<blockvector.size();i++) {
+         if (i==0) {
+           newDelta.setBlock(new PPoint(blockvector.get(i)));
+           toprocess.add(newDelta);
+         } else {
+           Delta d=newDelta.diffBlock(new PPoint(blockvector.get(i)));
+           toprocess.add(d);
+         }
        }
       }
     }
@@ -273,6 +292,7 @@ public class Pointer {
       return processSetFieldElementNode(node, delta, newgraph);
     case FKind.FlatMethod:
     case FKind.FlatExit:
+    case FKind.FlatGenReachNode:
       return processFlatNop(node, delta, newgraph);
     case FKind.FlatCall:
       return processFlatCall(bblock, index, (FlatCall) node, delta, newgraph);
@@ -405,7 +425,9 @@ public class Pointer {
          //Need to push existing results to current node
          if (returnDelta==null) {
            returnDelta=new Delta(null, false);
-           buildInitDelta(bbgraphMap.get(block.getExit()), returnDelta);
+           Vector<FlatNode> exitblocknodes=block.getExit().nodes();
+           FlatExit fexit=(FlatExit)exitblocknodes.get(exitblocknodes.size()-1);
+           buildInitDelta(graphMap.get(fexit), returnDelta);
            if (!returnDelta.heapedgeadd.isEmpty()||!returnDelta.heapedgeremove.isEmpty()||!returnDelta.varedgeadd.isEmpty()) {
              returnDelta.setBlock(new PPoint(callblock, callindex));
              toprocess.add(returnDelta);
@@ -500,7 +522,6 @@ public class Pointer {
       delta.removeEdge(e);
     }
   }
-  
 
   Delta processFlatCall(BBlock callblock, int callindex, FlatCall fcall, Delta delta, Graph graph) {
     Delta newDelta=new Delta(null, false);
@@ -610,7 +631,7 @@ public class Pointer {
     Graph oldgraph=(ppoint.getIndex()==0)?
       bbgraphMap.get(bblock):
       graphMap.get(nodes.get(ppoint.getIndex()-1));
-    
+
     //Age outside nodes if necessary
     for(Iterator<AllocNode> nodeit=delta.addNodeAges.iterator();nodeit.hasNext();) {
       AllocNode node=nodeit.next();
@@ -624,7 +645,6 @@ public class Pointer {
        summarizeInGraph(graph, newDelta, node);
       }
     }
-    
     //Add heap edges in
     for(Map.Entry<AllocNode, MySet<Edge>> entry:delta.heapedgeadd.entrySet()) {
       for(Edge e:entry.getValue()) {
@@ -645,7 +665,6 @@ public class Pointer {
        mergeEdge(graph, newDelta, edgetoadd);
       }
     }
-
     //Add external edges in
     for(Edge e:graph.externalEdgeSet) {
       //First did we age the source
@@ -671,15 +690,15 @@ public class Pointer {
     }
     //Add edge for return value
     if (fcall.getReturnTemp()!=null) {
-      MySet<Edge> returnedge=newDelta.varedgeadd.get(returntmp);
-      for(Edge e:returnedge) {
-       Edge newedge=e.copy();
-       newedge.srcvar=fcall.getReturnTemp();
-       if (graph.getEdges(fcall.getReturnTemp())==null||!graph.getEdges(fcall.getReturnTemp()).contains(newedge))
-         newDelta.addEdge(newedge);
-      }
+      MySet<Edge> returnedge=delta.varedgeadd.get(returntmp);
+      if (returnedge!=null)
+       for(Edge e:returnedge) {
+         Edge newedge=e.copy();
+         newedge.srcvar=fcall.getReturnTemp();
+         if (graph.getEdges(fcall.getReturnTemp())==null||!graph.getEdges(fcall.getReturnTemp()).contains(newedge))
+           newDelta.addEdge(newedge);
+       }
     }
-
     applyDiffs(graph, newDelta);
     return newDelta;
   }
@@ -690,7 +709,7 @@ public class Pointer {
 
       if (match==null||!match.subsumes(edgetoadd)) {
        Edge mergededge=edgetoadd.merge(match);
-       newDelta.addHeapEdge(mergededge);
+       newDelta.addEdge(mergededge);
       }
     }
   }