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
import IR.*;
import IR.Flat.*;
import Analysis.Pointer.Edge;
+import Analysis.Pointer.AllocFactory.AllocNode;
/////////////////////////////////////////////
//
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)
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()) {
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;
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();
}
return false;
}
- public String toStringBrief() {
- return getID();
- }
-
public String toString() {
return getID();
}
}
}
+ 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);
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);
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;
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);
} 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);
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) {
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);
}
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);
}
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
//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
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;