From: bdemsky Date: Thu, 10 Mar 2011 08:13:27 +0000 (+0000) Subject: more bug fixes...two examples working X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=affc28fef08890526ac6a5089508026c4266cc99;p=IRC.git more bug fixes...two examples working --- diff --git a/Robust/src/Analysis/Pointer/Delta.java b/Robust/src/Analysis/Pointer/Delta.java index 7c3e37b7..743b8dbf 100644 --- a/Robust/src/Analysis/Pointer/Delta.java +++ b/Robust/src/Analysis/Pointer/Delta.java @@ -23,6 +23,13 @@ public class Delta { if (e.src!=node) throw new Error(e.src+" is not equal to "+node); } + + for(Map.Entry> entry:varedgeadd.entrySet()) { + TempDescriptor tmp=entry.getKey(); + for(Edge e:entry.getValue()) + if (e.srcvar!=tmp) + throw new Error(e.srcvar+" is not equal to "+tmp); + } return this; } @@ -69,7 +76,12 @@ public class Delta { //Update variable edge mappings newdelta.varedgeadd=new HashMap>(); for(Map.Entry> entry:varedgeadd.entrySet()) { - varedgeadd.put(tmpMap.get(entry.getKey()), entry.getValue()); + 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)); + } } newdelta.varedgeremove=varedgeremove; newdelta.addNodeAges=addNodeAges; diff --git a/Robust/src/Analysis/Pointer/Edge.java b/Robust/src/Analysis/Pointer/Edge.java index fe62bb57..e2f25b6a 100644 --- a/Robust/src/Analysis/Pointer/Edge.java +++ b/Robust/src/Analysis/Pointer/Edge.java @@ -97,6 +97,14 @@ public class Edge { return e; } + public Edge rewrite(TempDescriptor orig, TempDescriptor newtmp) { + Edge e=copy(); + if (e.srcvar!=orig) + throw new Error("Mismatched temps"); + e.srcvar=newtmp; + return e; + } + public boolean statusDominates(Edge other) { return (statuspredicate==NEW)|| ((other.statuspredicate|statuspredicate)==statuspredicate); diff --git a/Robust/src/Analysis/Pointer/MySet.java b/Robust/src/Analysis/Pointer/MySet.java index a3d523bf..17202315 100644 --- a/Robust/src/Analysis/Pointer/MySet.java +++ b/Robust/src/Analysis/Pointer/MySet.java @@ -48,6 +48,20 @@ public class MySet extends AbstractSet { return map.containsKey(obj); } + public boolean removeAll(Collection c) { + if (c!=null) + return super.removeAll(c); + else + return false; + } + + public boolean addAll(Collection c) { + if (c!=null) + return super.addAll(c); + else + return false; + } + public T get(T obj) { return map.get(obj); } diff --git a/Robust/src/Analysis/Pointer/Pointer.java b/Robust/src/Analysis/Pointer/Pointer.java index 102e2ab8..af467a28 100644 --- a/Robust/src/Analysis/Pointer/Pointer.java +++ b/Robust/src/Analysis/Pointer/Pointer.java @@ -191,6 +191,7 @@ public class Pointer { /* Store the results */ newDelta.varedgeadd.put(tmp, newbaseedge); } + delta.basevaredge.clear(); /* Next we build heap edges */ HashSet nodeSet=new HashSet(); @@ -471,6 +472,7 @@ public class Pointer { for(TempDescriptor tmp:temps) { //Compute set of edges from given node MySet edges=new MySet(delta.basevaredge.get(tmp)); + edges.removeAll(delta.varedgeremove.get(tmp)); edges.addAll(delta.varedgeadd.get(tmp)); @@ -855,11 +857,11 @@ public class Pointer { if (delta.getInit()) { HashSet srcNodes=GraphManip.getNodes(graph, delta, src); HashSet dstNodes=GraphManip.getNodes(graph, delta, dst); - MySet edgesToAdd=GraphManip.genEdges(srcNodes, fd, dstNodes); + MySet edgesToAdd=GraphManip.genEdges(dstNodes, fd, srcNodes); MySet edgesToRemove=null; - if (srcNodes.size()==1&&!srcNodes.iterator().next().isSummary()) { + if (dstNodes.size()==1&&!dstNodes.iterator().next().isSummary()) { /* Can do a strong update */ - edgesToRemove=GraphManip.getEdges(graph, delta, srcNodes, fd); + edgesToRemove=GraphManip.getEdges(graph, delta, dstNodes, fd); graph.strongUpdateSet=edgesToRemove; } else graph.strongUpdateSet=new MySet(); @@ -876,23 +878,23 @@ public class Pointer { MySet edgesToRemove=null; - if (newSrcNodes.size()!=0) { - if (srcNodes.size()>1&&!srcNodes.iterator().next().isSummary()) { + if (newDstNodes.size()!=0) { + if (dstNodes.size()>1&&!dstNodes.iterator().next().isSummary()) { /* Need to undo strong update */ if (graph.strongUpdateSet!=null) { edgesToAdd.addAll(graph.strongUpdateSet); graph.strongUpdateSet=null; //Prevent future strong updates } - } else if (srcNodes.size()==1&&newSrcNodes.size()==1&&!newSrcNodes.iterator().next().isSummary()&&graph.strongUpdateSet!=null) { - edgesToRemove=GraphManip.getEdges(graph, delta, srcNodes, fd); + } else if (dstNodes.size()==1&&newDstNodes.size()==1&&!newDstNodes.iterator().next().isSummary()&&graph.strongUpdateSet!=null) { + edgesToRemove=GraphManip.getEdges(graph, delta, dstNodes, fd); graph.strongUpdateSet.addAll(edgesToRemove); } - edgesToAdd.addAll(GraphManip.genEdges(newSrcNodes, fd, dstNodes)); + edgesToAdd.addAll(GraphManip.genEdges(newDstNodes, fd, srcNodes)); } //Kill new edges if (graph.strongUpdateSet!=null) { - MySet otherEdgesToRemove=GraphManip.getDiffEdges(delta, srcNodes); + MySet otherEdgesToRemove=GraphManip.getDiffEdges(delta, dstNodes); if (edgesToRemove!=null) edgesToRemove.addAll(otherEdgesToRemove); else @@ -901,7 +903,7 @@ public class Pointer { } //Next look at new destinations - edgesToAdd.addAll(GraphManip.genEdges(srcNodes, fd, newDstNodes)); + edgesToAdd.addAll(GraphManip.genEdges(dstNodes, fd, newSrcNodes)); /* Update diff */ updateHeapDelta(graph, delta, edgesToAdd, edgesToRemove); @@ -1264,6 +1266,7 @@ public class Pointer { mergeVarEdges(graph, delta, newdelta); mergeAges(graph, delta, newdelta); } + return newdelta; }