// callee to that context
protected ExistPredSet preds;
-
+ public Taint reTaint(FlatNode fn) {
+ Taint out=new Taint(sese, stallSite, var, allocSite, fn, preds);
+ out = (Taint) Canonical.makeCanonical( out );
+ return out;
+ }
public static Taint factory( FlatSESEEnterNode sese,
TempDescriptor insetVar,
protected HashSet<Taint> taints;
+ public static TaintSet factory(HashSet<Taint> taints) {
+ TaintSet out = new TaintSet(taints);
+ out = (TaintSet) Canonical.makeCanonical( out );
+ return out;
+ }
+
+ public TaintSet reTaint(FlatNode fn) {
+ HashSet<Taint> taintset=new HashSet<Taint>();
+ for(Taint t:taints) {
+ if (t.getWhereDefined()!=fn) {
+ t=t.reTaint(fn);
+ }
+ taintset.add(t);
+ }
+
+ TaintSet out=new TaintSet(taintset);
+ out = (TaintSet) Canonical.makeCanonical( out );
+ return out;
+ }
+
public static TaintSet factory() {
TaintSet out = new TaintSet();
out = (TaintSet) Canonical.makeCanonical( out );
taints = new HashSet<Taint>();
}
+ protected TaintSet(HashSet<Taint> taints) {
+ this.taints = taints;
+ }
+
public Set<Taint> getTaints() {
return taints;
}
if (!heapedgeadd.containsKey(e.src))
heapedgeadd.put(e.src, new MySet<Edge>(e));
else
- heapedgeadd.get(e.src).add(e);
+ Edge.mergeEdgeInto(heapedgeadd.get(e.src), e);
}
public void addVarEdge(Edge e) {
if (!varedgeadd.containsKey(e.srcvar))
varedgeadd.put(e.srcvar, new MySet<Edge>(e));
else
- varedgeadd.get(e.srcvar).add(e);
+ Edge.mergeEdgeInto(varedgeadd.get(e.srcvar), e);
}
public void removeEdges(MySet<Edge> eset) {
return false;
}
- public Edge changeSrcVar(TempDescriptor tmp) {
+ public Edge changeSrcVar(TempDescriptor tmp, TaintSet taintset) {
Edge e=new Edge();
e.fd=fd;
e.srcvar=srcvar;
e.dst=dst;
e.statuspredicate=NEW;
+ if (taints==null)
+ e.taints=taintset;
+ else if (taintset==null)
+ e.taints=taints;
+ else
+ e.taints=taints.merge(taintset);
+ return e;
+ }
+
+ public Edge changeSrc(FieldDescriptor newfd, AllocNode srcnode) {
+ Edge e=new Edge();
+ e.fd=newfd;
+ e.src=srcnode;
+ e.dst=dst;
+ e.statuspredicate=NEW;
if (taints!=null)
e.taints=taints;
return e;
orig.add(e);
}
}
+
+ public static void mergeEdgeInto(MySet<Edge> orig, Edge e) {
+ if (orig.contains(e)) {
+ Edge old=orig.get(e);
+ e=e.merge(old);
+ }
+ orig.add(e);
+ }
}
\ No newline at end of file
import IR.*;
import Analysis.Pointer.AllocFactory.AllocNode;
import java.util.*;
+import Analysis.Disjoint.TaintSet;
public class GraphManip {
static MySet<Edge> genEdges(TempDescriptor tmp, HashSet<AllocNode> dstSet) {
static MySet<Edge> genEdges(TempDescriptor tmp, MySet<Edge> dstSet) {
MySet<Edge> edgeset=new MySet<Edge>();
for(Edge e:dstSet) {
- edgeset.add(e.changeSrcVar(tmp));
+ edgeset.add(e.changeSrcVar(tmp, null));
}
return edgeset;
}
return edgeset;
}
+ static MySet<Edge> genEdges(HashSet<AllocNode> srcSet, FieldDescriptor fd, MySet<Edge> dstSet) {
+ MySet<Edge> edgeset=new MySet<Edge>();
+ for(AllocNode srcnode:srcSet) {
+ for(Edge dstedge:dstSet) {
+ edgeset.add(dstedge.changeSrc(fd, srcnode));
+ }
+ }
+ return edgeset;
+ }
+
static MySet<Edge> getDiffEdges(Delta delta, TempDescriptor tmp) {
MySet<Edge> edges=new MySet<Edge>();
MySet<Edge> removeedges=delta.varedgeremove.get(tmp);
return edgeset;
}
- static MySet<Edge> dereference(Graph graph, Delta delta, TempDescriptor dst, MySet<Edge> srcEdges, FieldDescriptor fd) {
+ static MySet<Edge> dereference(Graph graph, Delta delta, TempDescriptor dst, MySet<Edge> srcEdges, FieldDescriptor fd, FlatNode fn) {
MySet<Edge> edgeset=new MySet<Edge>();
for(Edge edge:srcEdges) {
+ TaintSet ts=edge.getTaints();
+ if (ts!=null)
+ ts=ts.reTaint(fn);
MySet<Edge> removeedges=delta.heapedgeremove.get(edge.dst);
for(Edge e:graph.getEdges(edge.dst)) {
if (e.fd==fd&&(removeedges==null||!removeedges.contains(e))) {
- e=e.changeSrcVar(dst);
+ e=e.changeSrcVar(dst, ts);
if (!edgeset.contains(e))
edgeset.add(e);
else {
if (delta.heapedgeadd.containsKey(edge.dst))
for(Edge e:delta.heapedgeadd.get(edge.dst)) {
if (e.fd==fd) {
- e=e.changeSrcVar(dst);
+ e=e.changeSrcVar(dst, ts);
if (!edgeset.contains(e))
edgeset.add(e);
else {
return edgeset;
}
- static MySet<Edge> diffDereference(Delta delta, TempDescriptor dst, MySet<Edge> srcEdges, FieldDescriptor fd) {
+ static MySet<Edge> diffDereference(Delta delta, TempDescriptor dst, MySet<Edge> srcEdges, FieldDescriptor fd, FlatNode fn) {
MySet<Edge> edgeset=new MySet<Edge>();
for(Edge edge:srcEdges) {
+ TaintSet ts=edge.getTaints();
+ if (ts!=null)
+ ts=ts.reTaint(fn);
MySet<Edge> removeedges=delta.heapedgeremove.get(edge.dst);
if (delta.baseheapedge.containsKey(edge.dst)) {
for(Edge e:delta.baseheapedge.get(edge.dst)) {
if (e.fd==fd&&(removeedges==null||!removeedges.contains(e))) {
- e=e.changeSrcVar(dst);
+ e=e.changeSrcVar(dst, ts);
if (!edgeset.contains(e))
edgeset.add(e);
else {
if (delta.heapedgeadd.containsKey(edge.dst))
for(Edge e:delta.heapedgeadd.get(edge.dst)) {
if (e.fd==fd) {
- e=e.changeSrcVar(dst);
+ e=e.changeSrcVar(dst, ts);
if (!edgeset.contains(e))
edgeset.add(e);
else {
else
graph.nodeMap.put(node, new MySet<Edge>());
}
- graph.nodeMap.get(node).addAll(edgestoadd);
+ Edge.mergeEdgesInto(graph.nodeMap.get(node),edgestoadd);
if (genbackwards) {
for(Edge eadd:edgestoadd) {
if (!graph.backMap.containsKey(eadd.dst))
TempDescriptor tmp=e.getKey();
MySet<Edge> edgestoadd=e.getValue();
if (graph.varMap.containsKey(tmp)) {
- graph.varMap.get(tmp).addAll(edgestoadd);
+ Edge.mergeEdgesInto(graph.varMap.get(tmp), edgestoadd);
} else
graph.varMap.put(tmp, (MySet<Edge>) edgestoadd.clone());
if (genbackwards) {
return delta;
if (delta.getInit()) {
- HashSet<AllocNode> srcNodes=GraphManip.getNodes(graph, delta, src);
+ MySet<Edge> srcEdges=GraphManip.getEdges(graph, delta, src);
HashSet<AllocNode> dstNodes=GraphManip.getNodes(graph, delta, dst);
- MySet<Edge> edgesToAdd=GraphManip.genEdges(dstNodes, fd, srcNodes);
+ MySet<Edge> edgesToAdd=GraphManip.genEdges(dstNodes, fd, srcEdges);
MySet<Edge> edgesToRemove=null;
if (dstNodes.size()==1&&!dstNodes.iterator().next().isSummary()&&fd!=null) {
/* Can do a strong update */
} else {
/* First look at new sources */
MySet<Edge> edgesToAdd=new MySet<Edge>();
- HashSet<AllocNode> newSrcNodes=GraphManip.getDiffNodes(delta, src);
- HashSet<AllocNode> srcNodes=GraphManip.getNodes(graph, delta, src);
+ MySet<Edge> newSrcEdges=GraphManip.getDiffEdges(delta, src);
+ MySet<Edge> srcEdges=GraphManip.getEdges(graph, delta, src);
HashSet<AllocNode> dstNodes=GraphManip.getNodes(graph, delta, dst);
HashSet<AllocNode> newDstNodes=GraphManip.getDiffNodes(delta, dst);
edgesToRemove=GraphManip.getEdges(graph, delta, dstNodes, fd);
graph.strongUpdateSet.addAll(edgesToRemove);
}
- edgesToAdd.addAll(GraphManip.genEdges(newDstNodes, fd, srcNodes));
+ Edge.mergeEdgesInto(edgesToAdd, GraphManip.genEdges(newDstNodes, fd, srcEdges));
}
//Kill new edges
}
//Next look at new destinations
- edgesToAdd.addAll(GraphManip.genEdges(dstNodes, fd, newSrcNodes));
+ Edge.mergeEdgesInto(edgesToAdd, GraphManip.genEdges(dstNodes, fd, newSrcEdges));
/* Update diff */
updateHeapDelta(graph, delta, edgesToAdd, edgesToRemove);
return delta;
if (delta.getInit()) {
MySet<Edge> srcedges=GraphManip.getEdges(graph, delta, src);
- MySet<Edge> edgesToAdd=GraphManip.dereference(graph, delta, dst, srcedges, fd);
+ MySet<Edge> edgesToAdd=GraphManip.dereference(graph, delta, dst, srcedges, fd, node);
MySet<Edge> edgesToRemove=GraphManip.getEdges(graph, delta, dst);
updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove);
applyDiffs(graph, delta);
} else {
/* First compute new objects we read fields of */
MySet<Edge> allsrcedges=GraphManip.getEdges(graph, delta, src);
- MySet<Edge> edgesToAdd=GraphManip.diffDereference(delta, dst, allsrcedges, fd);
+ MySet<Edge> edgesToAdd=GraphManip.diffDereference(delta, dst, allsrcedges, fd, node);
/* Next compute new targets of fields */
MySet<Edge> newsrcedges=GraphManip.getDiffEdges(delta, src);
- MySet<Edge> newfdedges=GraphManip.dereference(graph, delta, dst, newsrcedges, fd);
+ MySet<Edge> newfdedges=GraphManip.dereference(graph, delta, dst, newsrcedges, fd, node);
/* Compute the union, and then the set of edges */
Edge.mergeEdgesInto(edgesToAdd, newfdedges);
//We have a new edge
diffedges.add(e);
dstedges.add(e);
+ } else {
+ Edge origedge=dstedges.get(e);
+ if (!origedge.subsumes(e)) {
+ Edge mergededge=origedge.merge(e);
+ diffedges.add(mergededge);
+ dstedges.add(mergededge);
+ }
}
}
//Done with edge set...