more changes
authorbdemsky <bdemsky>
Thu, 27 Jan 2011 19:46:30 +0000 (19:46 +0000)
committerbdemsky <bdemsky>
Thu, 27 Jan 2011 19:46:30 +0000 (19:46 +0000)
Robust/src/Analysis/Pointer/Delta.java
Robust/src/Analysis/Pointer/Pointer.java

index 842b6f7e0ca56d02c87bac55a1fad17324ac6c88..a0a49c728fbbd7bc9fffe1d1a299ce1157112de9 100644 (file)
@@ -36,11 +36,11 @@ public class Delta {
     return block;
   }
 
-  public void setBlock(BBLock block) {
+  public void setBlock(BBlock block) {
     this.block=block;
   }
 
-  public Delta diffBlock(BBLock bblock) {
+  public Delta diffBlock(BBlock bblock) {
     Delta newdelta=new Delta();
     newdelta.baseheapedge=baseheapedge;
     newdelta.basevaredge=basevaredge;
index 93e80bd5b145e5370a960dbb2e7affaafce4553d..a1269846b198f0d0794f5b8493efa3140c715d55 100644 (file)
@@ -57,36 +57,37 @@ public class Pointer {
       delta=applyInitDelta(delta, bblock);
       Graph graph=bbgraphMap.get(bblock);
 
+      Graph nodeGraph=null;
       //Compute delta at exit of each node
       for(int i=0; i<nodes.size();i++) {
        FlatNode currNode=nodes.get(i);
        if (!graphMap.containsKey(currNode)) {
          graphMap.put(currNode, new Graph(graph));
        }
-       Graph nodeGraph=graphMap.get(currNode);
+       nodeGraph=graphMap.get(currNode);
        delta=processNode(currNode, delta, nodeGraph);
       }
-      generateFinalDelta(nodeGraph, delta)
+      generateFinalDelta(delta, nodeGraph);
     }    
   }
 
   void generateFinalDelta(Delta delta, Graph graph) {
     Delta newDelta=new Delta(null, false);
-    if (delta.isInit()) {
+    if (delta.getInit()) {
       //First compute the set of temps
       HashSet<TempDescriptor> tmpSet=new HashSet<TempDescriptor>();
       tmpSet.addAll(graph.varMap.keySet());
       tmpSet.addAll(graph.parent.varMap.keySet());
 
       //Next build the temp map part of the delta
-      for(tmp:tmpSet) {
+      for(TempDescriptor tmp:tmpSet) {
        HashSet<Edge> edgeSet=new HashSet<Edge>();
        /* Get target set */
        if (graph.varMap.containsKey(tmp))
          edgeSet.addAll(graph.varMap.get(tmp));
        else
          edgeSet.addAll(graph.parent.varMap.get(tmp));
-       newdelta.varedgeadd.put(tmp, edgeset);
+       newDelta.varedgeadd.put(tmp, edgeSet);
       }
 
       //Next compute the set of src allocnodes
@@ -94,18 +95,67 @@ public class Pointer {
       nodeSet.addAll(graph.nodeMap.keySet());
       nodeSet.addAll(graph.parent.nodeMap.keySet());
 
-      for(node:nodeSet) {
+      for(AllocNode node:nodeSet) {
        HashSet<Edge> edgeSet=new HashSet<Edge>();
        /* Get edge set */
        if (graph.nodeMap.containsKey(node))
          edgeSet.addAll(graph.nodeMap.get(node));
        else
          edgeSet.addAll(graph.parent.nodeMap.get(node));
-       newdelta.heapedgeadd.put(node, edgeset);
+       newDelta.heapedgeadd.put(node, edgeSet);
       }
     } else {
-      
-      
+      /* We can break the old delta...it is done being used */
+      /* First we will build variable edges */
+      HashSet<TempDescriptor> tmpSet=new HashSet<TempDescriptor>();
+      tmpSet.addAll(delta.basevaredge.keySet());
+      tmpSet.addAll(delta.varedgeadd.keySet());
+      for(TempDescriptor tmp:tmpSet) {
+       /* Start with the new incoming edges */
+       HashSet<Edge> newbaseedge=delta.basevaredge.get(tmp);
+       /* Remove the remove set */
+       newbaseedge.removeAll(delta.varedgeremove.get(tmp));
+       /* Add in the new set*/
+       newbaseedge.addAll(delta.varedgeadd.get(tmp));
+       /* Store the results */
+       newDelta.varedgeadd.put(tmp, newbaseedge);
+      }
+
+      /* Next we build heap edges */
+      HashSet<AllocNode> nodeSet=new HashSet<AllocNode>();
+      nodeSet.addAll(delta.baseheapedge.keySet());
+      nodeSet.addAll(delta.heapedgeadd.keySet());
+      nodeSet.addAll(delta.heapedgeremove.keySet());
+      for(AllocNode node:nodeSet) {
+       /* Start with the new incoming edges */
+       HashSet<Edge> newheapedge=(HashSet<Edge>) delta.baseheapedge.get(node).clone();
+       /* Remove the remove set */
+       newheapedge.removeAll(delta.heapedgeremove.get(node));
+       /* Add in the add set */
+       newheapedge.addAll(delta.heapedgeadd.get(node));
+       newDelta.heapedgeadd.put(node, newheapedge);
+
+       /* Also need to subtract off some edges */
+       HashSet<Edge> removeset=delta.heapedgeremove.get(node);
+       /* Remove the newly created edges..no need to propagate a diff for those */
+       removeset.removeAll(delta.baseheapedge.get(node));
+       newDelta.heapedgeremove.put(node, removeset);
+      }
+    }
+    /* Now we need to propagate newdelta */
+    if (!newDelta.heapedgeadd.isEmpty()||!newDelta.heapedgeremove.isEmpty()||!newDelta.varedgeadd.isEmpty()) {
+      /* We have a delta to propagate */
+      BBlock curr=delta.getBlock();
+      Vector<BBlock> blockvector=curr.next();
+      for(int i=0;i<blockvector.size();i++) {
+       if (i==0) {
+         newDelta.setBlock(blockvector.get(i));
+         toprocess.add(newDelta);
+       } else {
+         toprocess.add(newDelta.diffBlock(blockvector.get(i)));
+       }
+      }
+
     }
   }