From 8893786494ab3c22168f2b9326bb496424545d42 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Wed, 23 Mar 2011 09:25:46 +0000 Subject: [PATCH] bug fixes... --- Robust/src/Analysis/Pointer/Delta.java | 21 +++++- Robust/src/Analysis/Pointer/Edge.java | 32 ++++++-- Robust/src/Analysis/Pointer/Graph.java | 23 ++++++ Robust/src/Analysis/Pointer/Pointer.java | 95 ++++++++++++++++++++---- Robust/src/IR/FieldDescriptor.java | 2 +- 5 files changed, 152 insertions(+), 21 deletions(-) diff --git a/Robust/src/Analysis/Pointer/Delta.java b/Robust/src/Analysis/Pointer/Delta.java index 7a94cb45..ba9b1894 100644 --- a/Robust/src/Analysis/Pointer/Delta.java +++ b/Robust/src/Analysis/Pointer/Delta.java @@ -151,7 +151,7 @@ public class Delta { if (!newdelta.heapedgeadd.containsKey(e.src)) { newdelta.heapedgeadd.put(e.src, new MySet()); } - 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 eset) { for(Edge e:eset) { removeEdge(e); diff --git a/Robust/src/Analysis/Pointer/Edge.java b/Robust/src/Analysis/Pointer/Edge.java index fcdc1217..854c841d 100644 --- a/Robust/src/Analysis/Pointer/Edge.java +++ b/Robust/src/Analysis/Pointer/Edge.java @@ -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 makeOld(MySet old) { + MySet newedge=new MySet(); + for(Edge eold:old) { + newedge.add(eold.makeOld()); + } + return newedge; + } + public static void mergeEdgesInto(MySet orig, MySet merge) { for(Edge e:merge) { if (orig.contains(e)) { diff --git a/Robust/src/Analysis/Pointer/Graph.java b/Robust/src/Analysis/Pointer/Graph.java index 705966d9..1467f9e6 100644 --- a/Robust/src/Analysis/Pointer/Graph.java +++ b/Robust/src/Analysis/Pointer/Graph.java @@ -15,6 +15,29 @@ public class Graph { HashMap> varMap; HashMap> backMap; MySet strongUpdateSet; + HashMap> callNewEdges; + HashMap> callOldEdges; + + public void addCallEdge(Edge e) { + MySet eset; + if ((eset=callNewEdges.get(e.src))==null) { + eset=new MySet(); + 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(); + callNewEdges.put(e.dst, eset); + } + if (eset.contains(e)) { + e=e.merge(eset.get(e)); + } + eset.add(e); + } public void check() { for(Map.Entry> entry:nodeMap.entrySet()) { diff --git a/Robust/src/Analysis/Pointer/Pointer.java b/Robust/src/Analysis/Pointer/Pointer.java index b44671a0..51e35ec1 100644 --- a/Robust/src/Analysis/Pointer/Pointer.java +++ b/Robust/src/Analysis/Pointer/Pointer.java @@ -639,7 +639,7 @@ public class Pointer implements HeapAnalysis{ AllocNode node=tovisit.pop(); MySet 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(); graph.callOldNodes=new HashSet(); + graph.callNewEdges=new HashMap>(); + graph.callOldEdges=new HashMap>(); //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()); } - 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 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 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 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 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> 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()); + } + 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); } } } diff --git a/Robust/src/IR/FieldDescriptor.java b/Robust/src/IR/FieldDescriptor.java index 337ddde0..47162867 100644 --- a/Robust/src/IR/FieldDescriptor.java +++ b/Robust/src/IR/FieldDescriptor.java @@ -101,7 +101,7 @@ public class FieldDescriptor extends Descriptor { } public String toStringBrief() { - return td.toString()+" "+getSymbol(); + return td.toPrettyString()+" "+getSymbol(); } public String toPrettyStringBrief() { -- 2.34.1