bug fixes...
authorbdemsky <bdemsky>
Wed, 23 Mar 2011 09:25:46 +0000 (09:25 +0000)
committerbdemsky <bdemsky>
Wed, 23 Mar 2011 09:25:46 +0000 (09:25 +0000)
Robust/src/Analysis/Pointer/Delta.java
Robust/src/Analysis/Pointer/Edge.java
Robust/src/Analysis/Pointer/Graph.java
Robust/src/Analysis/Pointer/Pointer.java
Robust/src/IR/FieldDescriptor.java

index 7a94cb45b98fdb20e3f6f900e866de8925364354..ba9b18940ce39efbc13ab192f21e55d0e5ae3030 100644 (file)
@@ -151,7 +151,7 @@ public class Delta {
        if (!newdelta.heapedgeadd.containsKey(e.src)) {
          newdelta.heapedgeadd.put(e.src, new MySet<Edge>());
        }
-       newdelta.heapedgeadd.get(e.src).add(e);
+       newdelta.heapedgeadd.get(e.src).add(e.makeOld());
       }
     }
     return newdelta;
@@ -199,6 +199,25 @@ public class Delta {
       Edge.mergeEdgeInto(varedgeadd.get(e.srcvar), e);
   }
 
+
+  public void addEdgeClear(Edge e) {
+    if (e.src!=null) {
+      addHeapEdgeClear(e);
+    } else {
+      addVarEdgeClear(e);
+    }
+  }
+
+  public void addHeapEdgeClear(Edge e) {
+    if (heapedgeremove.containsKey(e.src))
+      heapedgeremove.get(e.src).remove(e);
+  }
+
+  public void addVarEdgeClear(Edge e) {
+    if (varedgeremove.containsKey(e.srcvar))
+      varedgeremove.get(e.srcvar).remove(e);
+  }
+
   public void removeEdges(MySet<Edge> eset) {
     for(Edge e:eset) {
       removeEdge(e);
index fcdc1217a39479f91a5415f09c81e408eedf2ec1..854c841d39114beadfad92044b384960b3d8c8b2 100644 (file)
@@ -21,6 +21,7 @@ public class Edge {
   public static final int SUMSNG=4;
   public static final int SUMSUM=8;
   public static final int NEW=16;
+  public static final int MASK=15;
 
   public String toString() {
     String taintlist="";
@@ -203,12 +204,23 @@ public class Edge {
     return e;
   }
 
-  public Edge makeStatus(AllocFactory factory) {
-    Edge e=new Edge();
-    e.fd=fd;
-    e.src=factory.getAllocNode(src, (statuspredicate|3)==0);
-    e.dst=factory.getAllocNode(dst, (statuspredicate|5)==0);
-    return e;
+  public Edge[] makeStatus(AllocFactory factory) {
+    int numedges=Integer.bitCount(statuspredicate&MASK);
+
+    Edge[] earray=new Edge[numedges];
+    int mask=1;
+    int edgeindex=0;
+    for(int count=0;count<4;count++) {
+      if ((mask&statuspredicate)==mask) {
+       Edge e=new Edge();
+       e.fd=fd;
+       e.src=factory.getAllocNode(src, (mask|3)==0);
+       e.dst=factory.getAllocNode(dst, (mask|5)==0);
+       earray[edgeindex++]=e;
+      }
+      mask=mask<<1;
+    }
+    return earray;
   }
 
   public boolean subsumes(Edge e) {
@@ -249,6 +261,14 @@ public class Edge {
     return e;
   }
 
+  public static MySet<Edge> makeOld(MySet<Edge> old) {
+    MySet<Edge> newedge=new MySet<Edge>();
+    for(Edge eold:old) {
+      newedge.add(eold.makeOld());
+    }
+    return newedge;
+  }
+
   public static void mergeEdgesInto(MySet<Edge> orig, MySet<Edge> merge) {
     for(Edge e:merge) {
       if (orig.contains(e)) {
index 705966d9aee6f182fb4065ab43f6daab40c19cc1..1467f9e644f1a340f661e2553763c24d1e38d172 100644 (file)
@@ -15,6 +15,29 @@ public class Graph {
   HashMap<TempDescriptor, MySet<Edge>> varMap;
   HashMap<AllocNode, MySet<Edge>> backMap;
   MySet<Edge> strongUpdateSet;
+  HashMap<AllocNode, MySet<Edge>> callNewEdges;
+  HashMap<Edge, MySet<Edge>> callOldEdges;
+
+  public void addCallEdge(Edge e) {
+    MySet<Edge> eset;
+    if ((eset=callNewEdges.get(e.src))==null) {
+      eset=new MySet<Edge>();
+      callNewEdges.put(e.src, eset);
+    }
+    if (eset.contains(e)) {
+      e=e.merge(eset.get(e));
+    }
+    eset.add(e);
+
+    if ((eset=callNewEdges.get(e.dst))==null) {
+      eset=new MySet<Edge>();
+      callNewEdges.put(e.dst, eset);
+    }
+    if (eset.contains(e)) {
+      e=e.merge(eset.get(e));
+    }
+    eset.add(e);
+  }
 
   public void check() {
     for(Map.Entry<AllocNode, MySet<Edge>> entry:nodeMap.entrySet()) {
index b44671a0334d3a904795a3e0e3866ca01a65cdaf..51e35ec1ab54f3e3ae5ee71a811385db1472fac4 100644 (file)
@@ -639,7 +639,7 @@ public class Pointer implements HeapAnalysis{
        AllocNode node=tovisit.pop();
        MySet<Edge> edges=GraphManip.getEdges(graph, delta, node);
        if (!edges.isEmpty()) {
-         newDelta.heapedgeadd.put(node, edges);
+         newDelta.heapedgeadd.put(node, Edge.makeOld(edges));
          edgeset.addAll(edges);
          for(Edge e:edges) {
            if (!nodeset.contains(e.dst)&&(oldnodeset==null||!oldnodeset.contains(e.dst))) {
@@ -859,6 +859,8 @@ public class Pointer implements HeapAnalysis{
       graph.callTargets=newtargets;
       graph.callNodeAges=new HashSet<AllocNode>();
       graph.callOldNodes=new HashSet<AllocNode>();
+      graph.callNewEdges=new HashMap<AllocNode, MySet<Edge>>();
+      graph.callOldEdges=new HashMap<Edge,MySet<Edge>>();
 
       //Apply diffs to graph
       applyDiffs(graph, delta, true);
@@ -904,7 +906,7 @@ public class Pointer implements HeapAnalysis{
        if (!newDelta.heapedgeadd.containsKey(src)) {
          newDelta.heapedgeadd.put(src, new MySet<Edge>());
        }
-       newDelta.heapedgeadd.get(src).add(e);
+       newDelta.heapedgeadd.get(src).add(e.makeOld());
        if (!nodeset.contains(e.dst)&&!oldnodeset.contains(e.dst)) {
          nodeset.add(e.dst);
          tovisit.add(e.dst);
@@ -916,6 +918,7 @@ public class Pointer implements HeapAnalysis{
       //Compute call targets
       HashSet<MethodDescriptor> newtargets=computeTargets(fcall, newDelta);
       graph.callTargets.addAll(newtargets);
+
       //add in new nodeset and edgeset
       oldnodeset.addAll(nodeset);
       oldedgeset.addAll(edgeset);
@@ -932,7 +935,36 @@ public class Pointer implements HeapAnalysis{
 
       //Move new edges that should be summarized
       processSummarization(graph, delta);
-      
+
+      Set<FlatSESEEnterNode> seseCallers=OoOJava?taskAnalysis.getTransitiveExecutingRBlocks(fcall):null;
+      //Check if the new nodes allow us to insert a new edge
+      for(AllocNode node:nodeset) {
+       if (graph.callNewEdges.containsKey(node)) {
+         for(Iterator<Edge> eit=graph.callNewEdges.get(node).iterator();eit.hasNext();) {
+           Edge e=eit.next();
+           if ((graph.callNodeAges.contains(e.src)||graph.reachNode.contains(e.src))&&
+               (graph.callNodeAges.contains(e.dst)||graph.reachNode.contains(e.dst))) {
+             Edge edgetoadd=e.copy();//we need our own copy to modify below
+             eit.remove();
+             if (seseCallers!=null)
+               edgetoadd.taintModify(seseCallers);
+             mergeCallEdge(graph, delta, edgetoadd);
+           }
+         }
+       }
+      }
+
+      for(Edge e:edgeset) {
+       //See if these edges would allow an old edge to be added
+       if (graph.callOldEdges.containsKey(e)) {
+         for(Edge adde:graph.callOldEdges.get(e)) {
+           Edge ecopy=adde.copy();
+           ecopy.statuspredicate=e.statuspredicate;
+           mergeCallEdge(graph, delta, ecopy);
+         }
+       }
+      }
+
       //Add in new external edges
       graph.externalEdgeSet.addAll(externaledgeset);
       //Apply diffs to graph
@@ -1064,22 +1096,58 @@ public class Pointer implements HeapAnalysis{
        /* Need to age node in existing graph*/
        summarizeInGraph(graph, newDelta, node);
       }
+      if (graph.callNewEdges.containsKey(node)) {
+       for(Iterator<Edge> eit=graph.callNewEdges.get(node).iterator();eit.hasNext();) {
+         Edge e=eit.next();
+         if ((graph.callNodeAges.contains(e.src)||graph.reachNode.contains(e.src))&&
+             (graph.callNodeAges.contains(e.dst)||graph.reachNode.contains(e.dst))) {
+           Edge edgetoadd=e.copy();//we need our own copy to modify below
+           eit.remove();
+           if (seseCallers!=null)
+             edgetoadd.taintModify(seseCallers);
+           mergeCallEdge(graph, newDelta, edgetoadd);
+         }
+       }
+      }
     }
+
     //Add heap edges in
     for(Map.Entry<AllocNode, MySet<Edge>> entry:delta.heapedgeadd.entrySet()) {
       for(Edge e:entry.getValue()) {
        boolean addedge=false;
        Edge edgetoadd=null;
        if (e.statuspredicate==Edge.NEW) {
-         edgetoadd=e.copy();//we need our own copy to modify below
+         if ((graph.callNodeAges.contains(e.src)||graph.reachNode.contains(e.src))&&
+             (graph.callNodeAges.contains(e.dst)||graph.reachNode.contains(e.dst))) {
+           edgetoadd=e.copy();//we need our own copy to modify below
+         } else {
+           graph.addCallEdge(e);
+         }
        } else {
-         Edge origEdgeKey=e.makeStatus(allocFactory);
-         if (oldgraph.nodeMap.containsKey(origEdgeKey.src)&&
-             oldgraph.nodeMap.get(origEdgeKey.src).contains(origEdgeKey)) {
-           Edge origEdge=oldgraph.nodeMap.get(origEdgeKey.src).get(origEdgeKey);
-           //copy the predicate
-           origEdgeKey.statuspredicate=origEdge.statuspredicate;
-           edgetoadd=origEdgeKey;
+         Edge[] edgeArray=e.makeStatus(allocFactory);
+
+         int statuspredicate=0;
+         for(int i=0;i<edgeArray.length;i++) {
+           Edge origEdgeKey=edgeArray[i];
+           if (graph.reachEdge.contains(origEdgeKey)) {
+             Edge origEdge=graph.reachEdge.get(origEdgeKey);
+             //copy the predicate
+             statuspredicate=statuspredicate|origEdge.statuspredicate;
+           }
+           if (!graph.callOldEdges.containsKey(origEdgeKey)) {
+             graph.callOldEdges.put(origEdgeKey, new MySet<Edge>());
+           }
+           if (graph.callOldEdges.get(origEdgeKey).contains(e)) {
+             Edge olde=graph.callOldEdges.get(origEdgeKey).get(e);
+             graph.callOldEdges.get(origEdgeKey).add(olde.merge(e));
+           } else {
+             graph.callOldEdges.get(origEdgeKey).add(e);
+           }
+         }
+         if (statuspredicate!=0) {
+           Edge newe=e.copy();
+           newe.statuspredicate=statuspredicate;
+           edgetoadd=newe;
          }
        }
        if (seseCallers!=null&&edgetoadd!=null)
@@ -1122,13 +1190,14 @@ public class Pointer implements HeapAnalysis{
 
   public void mergeCallEdge(Graph graph, Delta newDelta, Edge edgetoadd) {
     if (edgetoadd!=null) {
-      Edge match=graph.getMatch(edgetoadd);
+      newDelta.addEdgeClear(edgetoadd);
 
+      Edge match=graph.getMatch(edgetoadd);
+      
       if (match==null||!match.subsumes(edgetoadd)) {
        Edge mergededge=edgetoadd.merge(match);
        newDelta.addEdge(mergededge);
        graph.callerEdges.add(mergededge);
-       //System.out.println("ADDING: "+ mergededge);
       }
     }
   }
index 337ddde0caa8757feeddb756fdb5555c6334091f..47162867ac2ac2361972d05a04720f8b789ebf18 100644 (file)
@@ -101,7 +101,7 @@ public class FieldDescriptor extends Descriptor {
   }
 
   public String toStringBrief() {
-    return td.toString()+" "+getSymbol();
+    return td.toPrettyString()+" "+getSymbol();
   }
 
   public String toPrettyStringBrief() {