From 1b4be9f805f681f73e5d1b6446e8048004bd9c32 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 11 Mar 2011 06:31:55 +0000 Subject: [PATCH] a few more bugs fixed...lots of debug code --- Robust/src/Analysis/Pointer/AllocFactory.java | 4 ++ Robust/src/Analysis/Pointer/Delta.java | 31 +++++----- Robust/src/Analysis/Pointer/Edge.java | 11 +++- Robust/src/Analysis/Pointer/Pointer.java | 56 ++++++++++++------- 4 files changed, 67 insertions(+), 35 deletions(-) diff --git a/Robust/src/Analysis/Pointer/AllocFactory.java b/Robust/src/Analysis/Pointer/AllocFactory.java index 8a12bd23..7a281315 100644 --- a/Robust/src/Analysis/Pointer/AllocFactory.java +++ b/Robust/src/Analysis/Pointer/AllocFactory.java @@ -36,6 +36,10 @@ public class AllocFactory { return false; } + public String toString() { + return getID(); + } + public String getID() { if (summary) return "SUM"+allocsite; diff --git a/Robust/src/Analysis/Pointer/Delta.java b/Robust/src/Analysis/Pointer/Delta.java index 94d805e0..38f69c67 100644 --- a/Robust/src/Analysis/Pointer/Delta.java +++ b/Robust/src/Analysis/Pointer/Delta.java @@ -62,19 +62,19 @@ public class Delta { public void print() { System.out.println("----------------------------------------------"); - System.out.println("baseheapedge empty:"+baseheapedge.isEmpty()); - System.out.println("basevaredge empty:"+basevaredge.isEmpty()); - System.out.println("heapedgeadd empty:"+heapedgeadd.isEmpty()); - System.out.println("heapedgeremove empty:"+heapedgeremove.isEmpty()); - System.out.println("varedgeadd empty:"+varedgeadd.isEmpty()); + System.out.println("baseheapedge:"+baseheapedge); + System.out.println("basevaredge:"+basevaredge); + System.out.println("heapedgeadd:"+heapedgeadd); + System.out.println("heapedgeremove:"+heapedgeremove); + System.out.println("varedgeadd:"+varedgeadd); if (varedgeremove==null) - System.out.println("varedge remove: null"); + System.out.println("varedgeremove: null"); else - System.out.println("varedgeremove empty:"+varedgeremove.isEmpty()); - System.out.println("baseNodeAges empty:"+baseNodeAges.isEmpty()); - System.out.println("addNodeAges empty:"+addNodeAges.isEmpty()); - System.out.println("baseOldNodes empty:"+baseOldNodes.isEmpty()); - System.out.println("addOldNodes empty:"+addOldNodes.isEmpty()); + System.out.println("varedgeremove:"+varedgeremove); + System.out.println("baseNodeAges:"+baseNodeAges); + System.out.println("addNodeAges:"+addNodeAges); + System.out.println("baseOldNodes:"+baseOldNodes); + System.out.println("addOldNodes:"+addOldNodes); } private Delta() { @@ -99,9 +99,12 @@ public class Delta { for(Map.Entry> entry:varedgeadd.entrySet()) { TempDescriptor origTmp=entry.getKey(); TempDescriptor newTmp=tmpMap.get(entry.getKey()); - newdelta.varedgeadd.put(newTmp, new MySet()); - for(Edge e:entry.getValue()) { - newdelta.varedgeadd.get(newTmp).add(e.rewrite(origTmp, newTmp)); + MySet edgeset=entry.getValue(); + if (!edgeset.isEmpty()) { + newdelta.varedgeadd.put(newTmp, new MySet()); + for(Edge e:edgeset) { + newdelta.varedgeadd.get(newTmp).add(e.rewrite(origTmp, newTmp)); + } } } newdelta.varedgeremove=varedgeremove; diff --git a/Robust/src/Analysis/Pointer/Edge.java b/Robust/src/Analysis/Pointer/Edge.java index e2f25b6a..61fdbb42 100644 --- a/Robust/src/Analysis/Pointer/Edge.java +++ b/Robust/src/Analysis/Pointer/Edge.java @@ -15,6 +15,15 @@ public class Edge { public static final int SUMSUM=8; public static final int NEW=16; + public String toString() { + if (srcvar!=null) + return "<"+srcvar+", "+dst+">"; + else if (fd!=null) + return "<"+src+", "+statuspredicate+", "+fd+", "+dst+">"; + else + return "<"+src+", "+statuspredicate+", [], "+dst+">"; + } + public static int mergeStatus(int stat1, int stat2) { int status=stat1|stat2; return ((status&NEW)==NEW)?NEW:status; @@ -123,7 +132,7 @@ public class Edge { } public static boolean subsumes(int status1, int status2) { - return ((status1&NEW)==NEW)&&((status1|status2)==status1); + return ((status1&NEW)==NEW)||((status1|status2)==status1); } public Edge makeOld() { diff --git a/Robust/src/Analysis/Pointer/Pointer.java b/Robust/src/Analysis/Pointer/Pointer.java index a0b8441f..af03fdf7 100644 --- a/Robust/src/Analysis/Pointer/Pointer.java +++ b/Robust/src/Analysis/Pointer/Pointer.java @@ -18,6 +18,7 @@ public class Pointer { AllocFactory allocFactory; LinkedList toprocess; TempDescriptor returntmp; + int plotcount=0; public Pointer(State state, TypeUtil typeUtil) { this.state=state; @@ -59,15 +60,19 @@ public class Pointer { toprocess.add(buildInitialContext()); while(!toprocess.isEmpty()) { Delta delta=toprocess.remove(); - delta.print(); PPoint ppoint=delta.getBlock(); BBlock bblock=ppoint.getBBlock(); Vector nodes=bblock.nodes(); int startindex=0; + System.out.println("BB BEGIN"); + delta.print(); + if (ppoint.getIndex()==-1) { //Build base graph for entrance to this basic block + System.out.println("INIT"); delta=applyInitDelta(delta, bblock); } else { + System.out.println("CALL"); startindex=ppoint.getIndex()+1; delta=applyCallDelta(delta, bblock); } @@ -76,12 +81,21 @@ public class Pointer { //Compute delta at exit of each node for(int i=startindex; i e:bbgraphMap.entrySet()) { Graph g=e.getValue(); - try { - PrintWriter pw=new PrintWriter(new FileWriter("BB"+debugindex+".dot")); - g.printGraph(pw, "BB"); - pw.close(); - } catch (Exception ex) { - ex.printStackTrace(); - } + plotGraph(g,"BB"+debugindex); debugindex++; } for(Map.Entry e:graphMap.entrySet()) { FlatNode fn=e.getKey(); Graph g=e.getValue(); - try { - PrintWriter pw=new PrintWriter(new FileWriter("FN"+fn.toString().replace(' ','_')+".dot")); - g.printGraph(pw, fn.toString()); - pw.close(); - } catch (Exception ex) { - ex.printStackTrace(); - } + plotGraph(g,"FN"+fn.toString()+debugindex); debugindex++; } for(FlatMethod fm:blockMap.keySet()) { @@ -116,6 +118,17 @@ public class Pointer { } } + void plotGraph(Graph g, String name) { + try { + PrintWriter pw=new PrintWriter(new FileWriter(name.toString().replace(' ','_')+".dot")); + g.printGraph(pw, name); + pw.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + /* This function builds the last delta for a basic block. It * handles the case for the first time the basic block is * evaluated.*/ @@ -180,6 +193,7 @@ public class Pointer { HashSet tmpSet=new HashSet(); tmpSet.addAll(delta.basevaredge.keySet()); tmpSet.addAll(delta.varedgeadd.keySet()); + System.out.println(tmpSet); for(TempDescriptor tmp:tmpSet) { /* Start with the new incoming edges */ MySet newbaseedge=delta.basevaredge.get(tmp); @@ -241,6 +255,8 @@ public class Pointer { } } } + System.out.println("FINAL"); + newDelta.print(); /* Now we need to propagate newdelta */ if (!newDelta.heapedgeadd.isEmpty()||!newDelta.heapedgeremove.isEmpty()||!newDelta.varedgeadd.isEmpty()||!newDelta.addNodeAges.isEmpty()||!newDelta.addOldNodes.isEmpty()) { @@ -880,7 +896,7 @@ public class Pointer { HashSet dstNodes=GraphManip.getNodes(graph, delta, dst); MySet edgesToAdd=GraphManip.genEdges(dstNodes, fd, srcNodes); MySet edgesToRemove=null; - if (dstNodes.size()==1&&!dstNodes.iterator().next().isSummary()) { + if (dstNodes.size()==1&&!dstNodes.iterator().next().isSummary()&&fd!=null) { /* Can do a strong update */ edgesToRemove=GraphManip.getEdges(graph, delta, dstNodes, fd); graph.strongUpdateSet=edgesToRemove; @@ -900,13 +916,13 @@ public class Pointer { MySet edgesToRemove=null; if (newDstNodes.size()!=0) { - if (dstNodes.size()>1&&!dstNodes.iterator().next().isSummary()) { + if (dstNodes.size()>1&&!dstNodes.iterator().next().isSummary()&&fd!=null) { /* Need to undo strong update */ if (graph.strongUpdateSet!=null) { edgesToAdd.addAll(graph.strongUpdateSet); graph.strongUpdateSet=null; //Prevent future strong updates } - } else if (dstNodes.size()==1&&newDstNodes.size()==1&&!newDstNodes.iterator().next().isSummary()&&graph.strongUpdateSet!=null) { + } else if (dstNodes.size()==1&&newDstNodes.size()==1&&!newDstNodes.iterator().next().isSummary()&&graph.strongUpdateSet!=null&&fd!=null) { edgesToRemove=GraphManip.getEdges(graph, delta, dstNodes, fd); graph.strongUpdateSet.addAll(edgesToRemove); } @@ -914,7 +930,7 @@ public class Pointer { } //Kill new edges - if (graph.strongUpdateSet!=null) { + if (graph.strongUpdateSet!=null&&fd!=null) { MySet otherEdgesToRemove=GraphManip.getDiffEdges(delta, dstNodes); if (edgesToRemove!=null) edgesToRemove.addAll(otherEdgesToRemove); @@ -1364,7 +1380,7 @@ public class Pointer { } } //Done with edge set... - if (diffedges.size()>=0) { + if (diffedges.size()>0) { //completely new newdelta.basevaredge.put(tmpsrc,diffedges); } -- 2.34.1