From: bdemsky Date: Thu, 10 Mar 2011 07:40:55 +0000 (+0000) Subject: bug fixes... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=52e32e1ac928d0844933909c077c48057fb0c292;p=IRC.git bug fixes... --- diff --git a/Robust/src/Analysis/Pointer/Delta.java b/Robust/src/Analysis/Pointer/Delta.java index 9419412b..7c3e37b7 100644 --- a/Robust/src/Analysis/Pointer/Delta.java +++ b/Robust/src/Analysis/Pointer/Delta.java @@ -16,6 +16,16 @@ public class Delta { HashMap baseOldNodes; HashMap addOldNodes; + public Delta check() { + for(Map.Entry> entry:heapedgeadd.entrySet()) { + AllocNode node=entry.getKey(); + for(Edge e:entry.getValue()) + if (e.src!=node) + throw new Error(e.src+" is not equal to "+node); + } + return this; + } + boolean init; PPoint block; diff --git a/Robust/src/Analysis/Pointer/Graph.java b/Robust/src/Analysis/Pointer/Graph.java index 55ecd9af..265153c9 100644 --- a/Robust/src/Analysis/Pointer/Graph.java +++ b/Robust/src/Analysis/Pointer/Graph.java @@ -15,6 +15,21 @@ public class Graph { HashMap> backMap; MySet strongUpdateSet; + public void check() { + for(Map.Entry> entry:nodeMap.entrySet()) { + AllocNode node=entry.getKey(); + for(Edge e:entry.getValue()) + if (e.src!=node) + throw new Error(); + } + for(Map.Entry> entry:varMap.entrySet()) { + TempDescriptor tmp=entry.getKey(); + for(Edge e:entry.getValue()) + if (e.srcvar!=tmp) + throw new Error(); + } + } + /* Need this information for mapping in callee results */ MySet reachEdge; HashSet reachNode; @@ -61,8 +76,6 @@ public class Graph { } } - - public MySet getEdges(TempDescriptor tmp) { if (varMap.containsKey(tmp)) return varMap.get(tmp); @@ -79,7 +92,7 @@ public class Graph { else return emptySet; } - public static MySet emptySet=new MySet(); + public static MySet emptySet=new MySet(true); public void printGraph(PrintWriter output, String name) { output.println("digraph \""+name+"\" {"); @@ -101,6 +114,8 @@ public class Graph { if (childvarMap!=null&&childvarMap.containsKey(tmp)) continue; for(Edge e:entry.getValue()) { + if (e.srcvar!=tmp) + throw new Error(e.srcvar +" is not equal to "+tmp); AllocNode n=e.dst; output.println("\t"+tmp.getSymbol()+"->"+n.getID()+";"); } @@ -114,6 +129,8 @@ public class Graph { if (childNodeMap!=null&&childNodeMap.containsKey(node)) continue; for(Edge e:entry.getValue()) { + if (e.src!=node) + throw new Error(e.src+" is not equal to "+node); AllocNode n=e.dst; String src=node.getID(); String dst=n.getID(); diff --git a/Robust/src/Analysis/Pointer/MySet.java b/Robust/src/Analysis/Pointer/MySet.java index 7e1400b9..a3d523bf 100644 --- a/Robust/src/Analysis/Pointer/MySet.java +++ b/Robust/src/Analysis/Pointer/MySet.java @@ -3,6 +3,12 @@ import java.util.*; public class MySet extends AbstractSet { HashMap map; + boolean locked; + public MySet(boolean locked) { + this.locked=locked; + map=new HashMap(); + } + public MySet() { map=new HashMap(); } @@ -27,10 +33,14 @@ public class MySet extends AbstractSet { } public boolean remove(Object obj) { + if (locked) + throw new Error(); return map.remove(obj)!=null; } public boolean add(T obj) { + if (locked) + throw new Error(); return map.put(obj, obj)==null; } diff --git a/Robust/src/Analysis/Pointer/Pointer.java b/Robust/src/Analysis/Pointer/Pointer.java index 4afeae91..102e2ab8 100644 --- a/Robust/src/Analysis/Pointer/Pointer.java +++ b/Robust/src/Analysis/Pointer/Pointer.java @@ -112,7 +112,9 @@ public class Pointer { } debugindex++; } - + for(FlatMethod fm:blockMap.keySet()) { + fm.printMethod(); + } } /* This function builds the last delta for a basic block. It @@ -247,7 +249,8 @@ public class Pointer { newDelta.setBlock(new PPoint(blockvector.get(i))); toprocess.add(newDelta); } else { - toprocess.add(newDelta.diffBlock(new PPoint(blockvector.get(i)))); + Delta d=newDelta.diffBlock(new PPoint(blockvector.get(i))); + toprocess.add(d); } } } @@ -857,7 +860,9 @@ public class Pointer { if (srcNodes.size()==1&&!srcNodes.iterator().next().isSummary()) { /* Can do a strong update */ edgesToRemove=GraphManip.getEdges(graph, delta, srcNodes, fd); - } + graph.strongUpdateSet=edgesToRemove; + } else + graph.strongUpdateSet=new MySet(); /* Update diff */ updateHeapDelta(graph, delta, edgesToAdd, edgesToRemove); applyDiffs(graph, delta); @@ -872,18 +877,29 @@ public class Pointer { MySet edgesToRemove=null; if (newSrcNodes.size()!=0) { - if (srcNodes.size()==1&&!srcNodes.iterator().next().isSummary()) { + if (srcNodes.size()>1&&!srcNodes.iterator().next().isSummary()) { /* Need to undo strong update */ if (graph.strongUpdateSet!=null) { edgesToAdd.addAll(graph.strongUpdateSet); - graph.strongUpdateSet.clear(); + graph.strongUpdateSet=null; //Prevent future strong updates } - } else if (srcNodes.size()==0&&newSrcNodes.size()==1&&!newSrcNodes.iterator().next().isSummary()&&graph.strongUpdateSet==null) { + } else if (srcNodes.size()==1&&newSrcNodes.size()==1&&!newSrcNodes.iterator().next().isSummary()&&graph.strongUpdateSet!=null) { edgesToRemove=GraphManip.getEdges(graph, delta, srcNodes, fd); + graph.strongUpdateSet.addAll(edgesToRemove); } edgesToAdd.addAll(GraphManip.genEdges(newSrcNodes, fd, dstNodes)); } + //Kill new edges + if (graph.strongUpdateSet!=null) { + MySet otherEdgesToRemove=GraphManip.getDiffEdges(delta, srcNodes); + if (edgesToRemove!=null) + edgesToRemove.addAll(otherEdgesToRemove); + else + edgesToRemove=otherEdgesToRemove; + graph.strongUpdateSet.addAll(otherEdgesToRemove); + } + //Next look at new destinations edgesToAdd.addAll(GraphManip.genEdges(srcNodes, fd, newDstNodes)); @@ -905,7 +921,7 @@ public class Pointer { FlatReturnNode frn=(FlatReturnNode)node; src=frn.getReturnTemp(); dst=returntmp; - if (src==null) { + if (src==null||!src.getType().isPtr()) { //This is a NOP applyDiffs(graph, delta); return delta; @@ -917,7 +933,7 @@ public class Pointer { } if (delta.getInit()) { HashSet srcnodes=GraphManip.getNodes(graph, delta, src); - MySet edgesToAdd=GraphManip.genEdges(src, srcnodes); + MySet edgesToAdd=GraphManip.genEdges(dst, srcnodes); MySet edgesToRemove=GraphManip.getEdges(graph, delta, dst); updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove); applyDiffs(graph, delta); @@ -926,7 +942,7 @@ public class Pointer { HashSet newSrcNodes=GraphManip.getDiffNodes(delta, src); /* Compute the union, and then the set of edges */ - MySet edgesToAdd=GraphManip.genEdges(src, newSrcNodes); + MySet edgesToAdd=GraphManip.genEdges(dst, newSrcNodes); /* Compute set of edges to remove */ MySet edgesToRemove=GraphManip.getDiffEdges(delta, dst); @@ -956,7 +972,7 @@ public class Pointer { if (delta.getInit()) { HashSet srcnodes=GraphManip.getNodes(graph, delta, src); HashSet fdnodes=GraphManip.getNodes(graph, delta, srcnodes, fd); - MySet edgesToAdd=GraphManip.genEdges(src, fdnodes); + MySet edgesToAdd=GraphManip.genEdges(dst, fdnodes); MySet edgesToRemove=GraphManip.getEdges(graph, delta, dst); updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove); applyDiffs(graph, delta); @@ -971,7 +987,7 @@ public class Pointer { HashSet newTargets=new HashSet(); newTargets.addAll(newfdnodes); newTargets.addAll(difffdnodes); - MySet edgesToAdd=GraphManip.genEdges(src, newTargets); + MySet edgesToAdd=GraphManip.genEdges(dst, newTargets); /* Compute set of edges to remove */ MySet edgesToRemove=GraphManip.getDiffEdges(delta, dst); @@ -1057,7 +1073,7 @@ public class Pointer { //Add it into the diffs delta.varedgeadd.put(tmp, newedges); //Remove the old edges - delta.varedgeremove.put(tmp, graph.getEdges(tmp)); + delta.varedgeremove.put(tmp, (MySet) graph.getEdges(tmp).clone()); //Apply incoming diffs to graph applyDiffs(graph, delta); //Note that we create a single node