changes
authorbdemsky <bdemsky>
Fri, 4 Feb 2011 00:23:00 +0000 (00:23 +0000)
committerbdemsky <bdemsky>
Fri, 4 Feb 2011 00:23:00 +0000 (00:23 +0000)
Robust/src/Analysis/Pointer/BasicBlock.java
Robust/src/Analysis/Pointer/GraphManip.java
Robust/src/Analysis/Pointer/Pointer.java

index deb93469981455a4c7568180a9b008865f461eac..4746bd74bd7980fe4b2f7ae11b106c30f9eba1e2 100644 (file)
@@ -42,7 +42,7 @@ public class BasicBlock {
     }
   }
 
-  public static BasicBlock getBBlock(FlatMethod fm) {
+  public static BasicBlock getBBlock(FlatMethod fm, boolean breakcalls) {
     BBlock exit=null;
     Stack<FlatNode> toprocess=new Stack<FlatNode>();
     HashMap<FlatNode, BBlock> map=new HashMap<FlatNode, BBlock>();
@@ -58,7 +58,7 @@ public class BasicBlock {
       if (fn.kind()==FKind.FlatExit)
        exit=block;
       do {
-       if (pm.numNext(fn)!=1) {
+       if (pm.numNext(fn)!=1||(fn.kind()==FKind.FlatCall&&breakcalls)) {
          for(int i=0;i<pm.numNext(fn);i++) {
            FlatNode fnext=pm.getNext(fn,i);
            if (!map.containsKey(fnext)) {
index 2dbb449a7f9f56b603990edea28d2acabc8479bc..5a74f7b476d45510f4de6a7006150bf54229c622 100644 (file)
@@ -70,6 +70,21 @@ public class GraphManip {
     return nodes;
   }
 
+  static HashSet<Edge> getEdges(Graph graph, Delta delta, AllocNode node) {
+    HashSet<Edge> nodes=new HashSet<Edge>();
+    HashSet<Edge> removeedges=delta.heapedgeremove.get(node);
+    for(Edge e:graph.getEdges(node)) {
+      if ((removeedges==null||!removeedges.contains(e)))
+       nodes.add(e);
+    }
+    if (delta.heapedgeadd.containsKey(node))
+      for(Edge e:delta.heapedgeadd.get(node)) {
+       nodes.add(e);
+      }
+    
+    return nodes;
+  }
+
   static HashSet<AllocNode> getDiffNodes(Delta delta, TempDescriptor tmp) {
     HashSet<AllocNode> nodes=new HashSet<AllocNode>();
     HashSet<Edge> removeedges=delta.varedgeremove.get(tmp);
index e1abdda684580495e56cb2991375188fe93a48d6..9b4e57799ecb5800ad640312be957f927742c718 100644 (file)
@@ -29,7 +29,7 @@ public class Pointer {
 
   public BasicBlock getBBlock(FlatMethod fm) {
     if (!blockMap.containsKey(fm))
-      blockMap.put(fm, BasicBlock.getBBlock(fm));
+      blockMap.put(fm, BasicBlock.getBBlock(fm, true));
     return blockMap.get(fm);
   }
   
@@ -178,6 +178,7 @@ public class Pointer {
     case FKind.FlatExit:
       return processFlatNop(node, delta, newgraph);
     case FKind.FlatCall:
+      return processFlatCall((FlatCall) node, delta, newgraph);
     case FKind.FlatSESEEnterNode:
     case FKind.FlatSESEExitNode:
       throw new Error("Unimplemented node:"+node);
@@ -186,6 +187,74 @@ public class Pointer {
     }
   }
 
+  Delta processFlatCall(FlatCall fcall, Delta delta, Graph newgraph) {
+    Delta newDelta=new Delta(null, false);
+
+    if (delta.getInit()) {
+      HashSet<Edge> edgeset=new HashSet<Edge>();
+      HashSet<AllocNode> nodeset=new HashSet<AllocNode>();
+      HashSet<ClassDescriptor> targetSet=new HashSet<ClassDescriptor>();
+      Stack<AllocNode> tovisit=new Stack<AllocNode>();
+      TempDescriptor tmpthis=fc.getThis();
+
+      //Handle the this temp
+      if (tmpthis!=null) {
+       HashSet<Edge> edges=GraphManip.getEdges(graph, delta, tmpthis);
+       newdelta.varedgeadd.put(tmpthis, (HashSet<Edge>) edges.clone());
+       edgeset.addAll(edges);
+       for(Edge e:edges) {
+         AllocNode dstnode=e.dst;
+         if (!nodeset.contains(dstnode)) {
+           TypeDescriptor type=dstnode.getType();
+           if (!type.isArray()) {
+             targetSet.add(type.getClassDesc());
+           } else {
+             //arrays don't have code
+             targetSet.add(typeUtil.getClass(TypeUtil.ObjectClass));
+           }
+           nodeset.add(dstnode);
+           tovisit.add(dstnode);
+         }
+       }
+      }
+
+      //Go through each temp
+      for(int i=0;i<fc.numArgs();i++) {
+       TempDescriptor tmp=fc.getArg(i);
+       HashSet<Edge> edges=GraphManip.getEdges(graph, delta, tmp);
+       newdelta.varedgeadd.put(tmp, (HashSet<Edge>) edges.clone());
+       edgeset.addAll(edges);
+       for(Edge e:edges) {
+         if (!nodeset.contains(e.dst)) {
+           nodeset.add(e.dst);
+           tovisit.add(e.dst);
+         }
+       }
+      }
+      
+      //Traverse all reachable nodes
+      while(!tovisit.isEmpty()) {
+       AllocNode node=tovisit.pop();
+       HashSet<Edge> edges=GraphManip.getEdges(graph, delta, node);
+       newdelta.heapedgeadd.put(node, (HashSet<Edge>) edges.clone());
+       edgeset.addAll(edges);
+       for(Edge e:edges) {
+         if (!nodeset.contains(e.dst)) {
+           nodeset.add(e.dst);
+           tovisit.add(e.dst);
+         }
+       }
+      }
+      
+      //Apply diffs to graph
+      applyDiffs(graph, delta);
+    } else {
+
+      //Apply diffs to graph
+      applyDiffs(graph, delta);
+    }
+  }
+
   void applyDiffs(Graph graph, Delta delta) {
     //Add hidden base edges
     for(Map.Entry<AllocNode, HashSet<Edge>> e: delta.baseheapedge.entrySet()) {