fix mistake....allocnodes are like disjoint heapregionnodes...
authorbdemsky <bdemsky>
Tue, 22 Mar 2011 09:15:09 +0000 (09:15 +0000)
committerbdemsky <bdemsky>
Tue, 22 Mar 2011 09:15:09 +0000 (09:15 +0000)
create new class allocsitenode which is like allocsite from disjointness...
hacked rcr file so it would compile with this change..unclear if it will work correctly

Robust/src/Analysis/Disjoint/EffectsAnalysis.java
Robust/src/Analysis/Pointer/AllocFactory.java
Robust/src/Analysis/Pointer/Pointer.java
Robust/src/IR/Flat/RuntimeConflictResolver.java

index 42826e807d4e6503e8367d2d11db2d955553e579..59a8ae97e06235efe158f57aef8ec52320131e88 100644 (file)
@@ -7,6 +7,7 @@ import java.io.*;
 import IR.*;
 import IR.Flat.*;
 import Analysis.Pointer.Edge;
+import Analysis.Pointer.AllocFactory.AllocNode;
 
 /////////////////////////////////////////////
 // 
@@ -147,7 +148,7 @@ public class EffectsAnalysis {
   public void analyzeFlatFieldNode(Set<Edge> sources, FieldDescriptor fld, FlatNode currentProgramPoint) {
     for (Edge edge:sources) {
       TaintSet  taintSet      = edge.getTaints();
-      Alloc     affectedAlloc = edge.getDst();
+      Alloc     affectedAlloc = edge.getDst().getAllocSite();
       Effect    effect        = new Effect(affectedAlloc, Effect.read, fld);
 
       if (taintSet!=null)
@@ -190,7 +191,7 @@ public class EffectsAnalysis {
   public void analyzeFlatSetFieldNode(Set<Edge> dstedges, FieldDescriptor fld, FlatNode currentProgramPoint) {
     for (Edge edge:dstedges) {
       TaintSet taintSet = edge.getTaints();
-      Alloc affectedAlloc = edge.getDst();
+      Alloc affectedAlloc = edge.getDst().getAllocSite();
       Effect effect = new Effect(affectedAlloc, Effect.write, fld);       
       if (taintSet!=null)
        for (Taint taint:taintSet.getTaints()) {
index 0e0ab7e65b826eb7aac29ffcd86767a668eae05b..ed997a9eb346e21eec2494e8adbf387166671227 100644 (file)
@@ -6,12 +6,14 @@ import IR.*;
 import IR.Flat.*;
 
 public class AllocFactory {
-  public static AllocNode dummyNode=new AllocNode(-1, null, false);
+  public static AllocSiteNode dummySite=new AllocSiteNode(-1, null);
+  public static AllocNode dummyNode=new AllocNode(-1, null, false, dummySite);
 
-  public static class AllocNode implements Alloc {
+  public static class AllocNode {
     int allocsite;
     boolean summary;
     FlatNew node;
+    AllocSiteNode as;
     
     public AllocNode(int allocsite, FlatNew node, boolean summary) {
       this.allocsite=allocsite;
@@ -19,6 +21,17 @@ public class AllocFactory {
       this.node=node;
     }
 
+    public AllocNode(int allocsite, FlatNew node, boolean summary, AllocSiteNode as) {
+      this.allocsite=allocsite;
+      this.summary=summary;
+      this.node=node;
+      this.as=as;
+    }
+
+    public AllocSiteNode getAllocSite() {
+      return as;
+    }
+
     public TypeDescriptor getType() {
       return node.getType();
     }
@@ -47,10 +60,6 @@ public class AllocFactory {
       return false;
     }
 
-    public String toStringBrief() {
-      return getID();
-    }
-    
     public String toString() {
       return getID();
     }
@@ -63,9 +72,56 @@ public class AllocFactory {
     }
   }
 
+  public static class AllocSiteNode implements Alloc {
+    int allocsite;
+    FlatNew node;
+    
+    public AllocSiteNode(int allocsite, FlatNew node) {
+      this.allocsite=allocsite;
+      this.node=node;
+    }
+
+    public TypeDescriptor getType() {
+      return node.getType();
+    }
+
+    public FlatNew getFlatNew() {
+      return node;
+    }
+
+    public int getUniqueAllocSiteID() {
+      return allocsite;
+    }
+
+    public int hashCode() {
+      return allocsite;
+    }
+    
+    public boolean equals(Object o) {
+      if (o instanceof AllocSiteNode) {
+       AllocSiteNode an=(AllocSiteNode)o;
+       return (allocsite==an.allocsite);
+      }
+      return false;
+    }
+
+    public String toStringBrief() {
+      return getID();
+    }
+    
+    public String toString() {
+      return getID();
+    }
+
+    public String getID() {
+      return "N"+allocsite;
+    }
+  }
+
   public AllocFactory(State state, TypeUtil typeUtil) {
     allocMap=new HashMap<FlatNew, Integer>();
     allocNodeMap=new HashMap<AllocNode, AllocNode>();
+    allocSiteMap=new HashMap<AllocSiteNode, AllocSiteNode>();
     this.typeUtil=typeUtil;
     ClassDescriptor stringcd=typeUtil.getClass(TypeUtil.StringClass);
     TypeDescriptor stringtd=new TypeDescriptor(stringcd);
@@ -87,6 +143,7 @@ public class AllocFactory {
     AllocNode key=new AllocNode(site, node, isSummary);
     if (!allocNodeMap.containsKey(key)) {
       allocNodeMap.put(key, key);
+      key.as=getAllocSite(key);
       return key;
     } else
       return allocNodeMap.get(key);
@@ -97,12 +154,23 @@ public class AllocFactory {
     AllocNode key=new AllocNode(site, node.node, isSummary);
     if (!allocNodeMap.containsKey(key)) {
       allocNodeMap.put(key, key);
+      key.as=getAllocSite(key);
       return key;
     } else
       return allocNodeMap.get(key);
   }
 
+  public AllocSiteNode getAllocSite(AllocNode node) {
+    AllocSiteNode as=new AllocSiteNode(node.allocsite, node.node);
+    if (!allocSiteMap.containsKey(as)) {
+      allocSiteMap.put(as, as);
+      return as;
+    } else
+      return allocSiteMap.get(as);
+  }
+
   HashMap<AllocNode, AllocNode> allocNodeMap;
+  HashMap<AllocSiteNode, AllocSiteNode> allocSiteMap;
   HashMap<FlatNew, Integer> allocMap;
   TypeUtil typeUtil;
   int siteCounter=2;
index dd0c943f8bed3fd80834c168922d106e82138195..4666894a4466f73081c738dce3c1a592f13f1836 100644 (file)
@@ -444,7 +444,7 @@ public class Pointer implements HeapAnalysis{
     if (delta.getInit()) {
       removeInitTaints(null, delta, graph);
       for (TempDescriptor tmp:sese.getInVarSet()) {
-       Taint taint=Taint.factory(sese,  null, tmp, AllocFactory.dummyNode, sese, ReachGraph.predsEmpty);
+       Taint taint=Taint.factory(sese,  null, tmp, AllocFactory.dummySite, sese, ReachGraph.predsEmpty);
        MySet<Edge> edges=GraphManip.getEdges(graph, delta, tmp);
        for(Edge e:edges) {
          Edge newe=e.addTaint(taint);
@@ -454,7 +454,7 @@ public class Pointer implements HeapAnalysis{
     } else {
       removeDiffTaints(null, delta);
       for (TempDescriptor tmp:sese.getInVarSet()) {
-       Taint taint=Taint.factory(sese,  null, tmp, AllocFactory.dummyNode, sese, ReachGraph.predsEmpty);
+       Taint taint=Taint.factory(sese,  null, tmp, AllocFactory.dummySite, sese, ReachGraph.predsEmpty);
        MySet<Edge> edges=GraphManip.getDiffEdges(delta, tmp);
        for(Edge e:edges) {
          Edge newe=e.addTaint(taint);
@@ -975,9 +975,9 @@ public class Pointer implements HeapAnalysis{
       delta.addVarEdge(e);
     }
   }
+  
   public Alloc getAllocationSiteFromFlatNew(FlatNew node) {
-    return allocFactory.getAllocNode(node, false);
+    return allocFactory.getAllocNode(node, false).getAllocSite();
   }
  
   void processSumHeapEdgeSet(HashMap<AllocNode, MySet<Edge>> map, Delta delta, Graph graph) {
@@ -1308,13 +1308,13 @@ public class Pointer implements HeapAnalysis{
       MySet<Edge> dstEdges=GraphManip.getEdges(graph, delta, dst);
 
       if (OoOJava&&!accessible.isAccessible(node, src)) {
-       Taint srcStallTaint=Taint.factory(node,  src, AllocFactory.dummyNode, node, ReachGraph.predsEmpty);
+       Taint srcStallTaint=Taint.factory(node,  src, AllocFactory.dummySite, node, ReachGraph.predsEmpty);
        srcEdges=Edge.taintAll(srcEdges, srcStallTaint);
        updateVarDelta(graph, delta, src, srcEdges, null);
       }
 
       if (OoOJava&&!accessible.isAccessible(node, dst)) {
-       Taint dstStallTaint=Taint.factory(node,  dst, AllocFactory.dummyNode, node, ReachGraph.predsEmpty);
+       Taint dstStallTaint=Taint.factory(node,  dst, AllocFactory.dummySite, node, ReachGraph.predsEmpty);
        dstEdges=Edge.taintAll(dstEdges, dstStallTaint);
        updateVarDelta(graph, delta, dst, dstEdges, null);
       }
@@ -1344,13 +1344,13 @@ public class Pointer implements HeapAnalysis{
       MySet<Edge> newDstEdges=GraphManip.getDiffEdges(delta, dst);
 
       if (OoOJava&&!accessible.isAccessible(node, src)) {
-       Taint srcStallTaint=Taint.factory(node,  src, AllocFactory.dummyNode, node, ReachGraph.predsEmpty);
+       Taint srcStallTaint=Taint.factory(node,  src, AllocFactory.dummySite, node, ReachGraph.predsEmpty);
        newSrcEdges=Edge.taintAll(newSrcEdges, srcStallTaint);
        updateVarDelta(graph, delta, src, newSrcEdges, null);
       }
 
       if (OoOJava&&!accessible.isAccessible(node, dst)) {
-       Taint dstStallTaint=Taint.factory(node,  dst, AllocFactory.dummyNode, node, ReachGraph.predsEmpty);
+       Taint dstStallTaint=Taint.factory(node,  dst, AllocFactory.dummySite, node, ReachGraph.predsEmpty);
        newDstEdges=Edge.taintAll(newDstEdges, dstStallTaint);
        updateVarDelta(graph, delta, dst, newDstEdges, null);
       }
@@ -1456,7 +1456,7 @@ public class Pointer implements HeapAnalysis{
       dst=ffn.getDst();
     }
     if (OoOJava&&!accessible.isAccessible(node, src)) {
-      taint=TaintSet.factory(Taint.factory(node,  src, AllocFactory.dummyNode, node, ReachGraph.predsEmpty));
+      taint=TaintSet.factory(Taint.factory(node,  src, AllocFactory.dummySite, node, ReachGraph.predsEmpty));
     }
 
     //Do nothing for non pointers
index 484f146f755d99bdb976a3a409407909a45647e9..23b90ee43ea3ce6e70290def3049d6fe52385f99 100644 (file)
@@ -513,7 +513,7 @@ public class RuntimeConflictResolver {
     //TODO what if we have more than one way in?! >< i.e. more than 1 temp descriptor...
     Set<Edge> insetVars = ptrGraph.getEdges(var);
     for(Edge invar: insetVars) {
-      Alloc rootKey = invar.getSrcAlloc();
+      Alloc rootKey = invar.getSrcAlloc().getAllocSite();
       
       if(!created.contains(rootKey)) {
         //null       -> no transitions by reading this object (does not apply to its references
@@ -546,7 +546,7 @@ public class RuntimeConflictResolver {
     for(Edge e: edges) {
       //since we're starting from a src, it should match...
       assert e.getSrcAlloc().equals(curr.alloc);
-      Alloc dst = e.getDst();
+      Alloc dst = e.getDst().getAllocSite();
       String field = e.getFieldDesc().getSafeSymbol();
       ce = et.getCombinedEffects(curr.alloc, field);
       ConcreteRuntimeObjNode child;