From 094452de860ddac09fe89bf9dee4f26df2bf80da Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 17 Mar 2011 05:44:05 +0000 Subject: [PATCH] compiling again... --- Robust/src/Analysis/Pointer/Edge.java | 22 ++++++ Robust/src/Analysis/Pointer/GraphManip.java | 76 +++++++++++++++++++++ Robust/src/Analysis/Pointer/Pointer.java | 27 ++++---- 3 files changed, 110 insertions(+), 15 deletions(-) diff --git a/Robust/src/Analysis/Pointer/Edge.java b/Robust/src/Analysis/Pointer/Edge.java index c13a7d5d..35b7187e 100644 --- a/Robust/src/Analysis/Pointer/Edge.java +++ b/Robust/src/Analysis/Pointer/Edge.java @@ -4,6 +4,7 @@ import IR.*; import Analysis.Pointer.AllocFactory.AllocNode; import Analysis.Disjoint.Taint; import Analysis.Disjoint.TaintSet; +import Analysis.Pointer.MySet; public class Edge { FieldDescriptor fd; @@ -102,6 +103,17 @@ public class Edge { return false; } + public Edge changeSrcVar(TempDescriptor tmp) { + Edge e=new Edge(); + e.fd=fd; + e.srcvar=srcvar; + e.dst=dst; + e.statuspredicate=NEW; + if (taints!=null) + e.taints=taints; + return e; + } + public Edge copy() { Edge e=new Edge(); e.fd=fd; @@ -180,4 +192,14 @@ public class Edge { e.statuspredicate=val; return e; } + + public static void mergeEdgesInto(MySet orig, MySet merge) { + for(Edge e:merge) { + if (orig.contains(e)) { + Edge old=orig.get(e); + e=e.merge(old); + } + orig.add(e); + } + } } \ No newline at end of file diff --git a/Robust/src/Analysis/Pointer/GraphManip.java b/Robust/src/Analysis/Pointer/GraphManip.java index ad41bf82..9ee46a88 100644 --- a/Robust/src/Analysis/Pointer/GraphManip.java +++ b/Robust/src/Analysis/Pointer/GraphManip.java @@ -13,6 +13,14 @@ public class GraphManip { return edgeset; } + static MySet genEdges(TempDescriptor tmp, MySet dstSet) { + MySet edgeset=new MySet(); + for(Edge e:dstSet) { + edgeset.add(e.changeSrcVar(tmp)); + } + return edgeset; + } + static MySet genEdges(HashSet srcSet, FieldDescriptor fd, HashSet dstSet) { MySet edgeset=new MySet(); for(AllocNode srcnode:srcSet) { @@ -200,6 +208,74 @@ public class GraphManip { return edgeset; } + static MySet dereference(Graph graph, Delta delta, TempDescriptor dst, MySet srcEdges, FieldDescriptor fd) { + MySet edgeset=new MySet(); + for(Edge edge:srcEdges) { + MySet 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); + if (!edgeset.contains(e)) + edgeset.add(e); + else { + Edge preve=edgeset.get(e); + e=e.merge(preve); + edgeset.add(e); + } + } + } + if (delta.heapedgeadd.containsKey(edge.dst)) + for(Edge e:delta.heapedgeadd.get(edge.dst)) { + if (e.fd==fd) { + e=e.changeSrcVar(dst); + if (!edgeset.contains(e)) + edgeset.add(e); + else { + Edge preve=edgeset.get(e); + e=e.merge(preve); + edgeset.add(e); + } + } + } + } + return edgeset; + } + + static MySet diffDereference(Delta delta, TempDescriptor dst, MySet srcEdges, FieldDescriptor fd) { + MySet edgeset=new MySet(); + for(Edge edge:srcEdges) { + MySet 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); + if (!edgeset.contains(e)) + edgeset.add(e); + else { + Edge preve=edgeset.get(e); + e=e.merge(preve); + edgeset.add(e); + } + } + } + } + if (delta.heapedgeadd.containsKey(edge.dst)) + for(Edge e:delta.heapedgeadd.get(edge.dst)) { + if (e.fd==fd) { + e=e.changeSrcVar(dst); + if (!edgeset.contains(e)) + edgeset.add(e); + else { + Edge preve=edgeset.get(e); + e=e.merge(preve); + edgeset.add(e); + } + } + } + } + return edgeset; + } + static HashSet getNodes(Graph graph, Delta delta, HashSet srcNodes, FieldDescriptor fd) { HashSet nodes=new HashSet(); for(AllocNode node:srcNodes) { diff --git a/Robust/src/Analysis/Pointer/Pointer.java b/Robust/src/Analysis/Pointer/Pointer.java index 50b4974c..cca1f978 100644 --- a/Robust/src/Analysis/Pointer/Pointer.java +++ b/Robust/src/Analysis/Pointer/Pointer.java @@ -1339,17 +1339,17 @@ public class Pointer { dst=fcn.getDst(); } if (delta.getInit()) { - HashSet srcnodes=GraphManip.getNodes(graph, delta, src); - MySet edgesToAdd=GraphManip.genEdges(dst, srcnodes); + MySet srcedges=GraphManip.getEdges(graph, delta, src); + MySet edgesToAdd=GraphManip.genEdges(dst, srcedges); MySet edgesToRemove=GraphManip.getEdges(graph, delta, dst); updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove); applyDiffs(graph, delta); } else { /* First compute new src nodes */ - HashSet newSrcNodes=GraphManip.getDiffNodes(delta, src); + MySet newSrcEdges=GraphManip.getDiffEdges(delta, src); /* Compute the union, and then the set of edges */ - MySet edgesToAdd=GraphManip.genEdges(dst, newSrcNodes); + MySet edgesToAdd=GraphManip.genEdges(dst, newSrcEdges); /* Compute set of edges to remove */ MySet edgesToRemove=GraphManip.getDiffEdges(delta, dst); @@ -1380,24 +1380,21 @@ public class Pointer { if (!dst.getType().isPtr()) return delta; if (delta.getInit()) { - HashSet srcnodes=GraphManip.getNodes(graph, delta, src); - HashSet fdnodes=GraphManip.getNodes(graph, delta, srcnodes, fd); - MySet edgesToAdd=GraphManip.genEdges(dst, fdnodes); + MySet srcedges=GraphManip.getEdges(graph, delta, src); + MySet edgesToAdd=GraphManip.dereference(graph, delta, dst, srcedges, fd); MySet edgesToRemove=GraphManip.getEdges(graph, delta, dst); updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove); applyDiffs(graph, delta); } else { /* First compute new objects we read fields of */ - HashSet allsrcnodes=GraphManip.getNodes(graph, delta, src); - HashSet difffdnodes=GraphManip.getDiffNodes(delta, allsrcnodes, fd); + MySet allsrcedges=GraphManip.getEdges(graph, delta, src); + MySet edgesToAdd=GraphManip.diffDereference(delta, dst, allsrcedges, fd); /* Next compute new targets of fields */ - HashSet newsrcnodes=GraphManip.getDiffNodes(delta, src); - HashSet newfdnodes=GraphManip.getNodes(graph, delta, newsrcnodes, fd); + MySet newsrcedges=GraphManip.getDiffEdges(delta, src); + MySet newfdedges=GraphManip.dereference(graph, delta, dst, newsrcedges, fd); + /* Compute the union, and then the set of edges */ - HashSet newTargets=new HashSet(); - newTargets.addAll(newfdnodes); - newTargets.addAll(difffdnodes); - MySet edgesToAdd=GraphManip.genEdges(dst, newTargets); + Edge.mergeEdgesInto(edgesToAdd, newfdedges); /* Compute set of edges to remove */ MySet edgesToRemove=GraphManip.getDiffEdges(delta, dst); -- 2.34.1