From cc15df28d6fec87c69472e0ee8f3952764f5fc4c Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 10 Mar 2011 09:23:17 +0000 Subject: [PATCH] even more bug fixes...3 test cases work --- Robust/src/Analysis/Pointer/BasicBlock.java | 3 +- Robust/src/Analysis/Pointer/Delta.java | 4 ++ Robust/src/Analysis/Pointer/Graph.java | 4 ++ Robust/src/Analysis/Pointer/GraphManip.java | 22 ++++--- Robust/src/Analysis/Pointer/Pointer.java | 67 +++++++++++++-------- 5 files changed, 67 insertions(+), 33 deletions(-) diff --git a/Robust/src/Analysis/Pointer/BasicBlock.java b/Robust/src/Analysis/Pointer/BasicBlock.java index b58ae1e4..2f6e9903 100644 --- a/Robust/src/Analysis/Pointer/BasicBlock.java +++ b/Robust/src/Analysis/Pointer/BasicBlock.java @@ -89,9 +89,10 @@ public class BasicBlock { break; } block.nodes.add(fn); + if (fn.kind()==FKind.FlatExit) + exit=block; } while(true); } - return new BasicBlock(map.get(fm), exit); } } diff --git a/Robust/src/Analysis/Pointer/Delta.java b/Robust/src/Analysis/Pointer/Delta.java index 743b8dbf..e150f02c 100644 --- a/Robust/src/Analysis/Pointer/Delta.java +++ b/Robust/src/Analysis/Pointer/Delta.java @@ -19,6 +19,8 @@ public class Delta { public Delta check() { for(Map.Entry> entry:heapedgeadd.entrySet()) { AllocNode node=entry.getKey(); + if (node==null) + throw new Error("null node key"); for(Edge e:entry.getValue()) if (e.src!=node) throw new Error(e.src+" is not equal to "+node); @@ -26,6 +28,8 @@ public class Delta { for(Map.Entry> entry:varedgeadd.entrySet()) { TempDescriptor tmp=entry.getKey(); + if (tmp==null) + throw new Error("null temp key"); for(Edge e:entry.getValue()) if (e.srcvar!=tmp) throw new Error(e.srcvar+" is not equal to "+tmp); diff --git a/Robust/src/Analysis/Pointer/Graph.java b/Robust/src/Analysis/Pointer/Graph.java index 265153c9..6ad79aaa 100644 --- a/Robust/src/Analysis/Pointer/Graph.java +++ b/Robust/src/Analysis/Pointer/Graph.java @@ -18,12 +18,16 @@ public class Graph { public void check() { for(Map.Entry> entry:nodeMap.entrySet()) { AllocNode node=entry.getKey(); + if (node==null) + throw new Error("Null node key"); for(Edge e:entry.getValue()) if (e.src!=node) throw new Error(); } for(Map.Entry> entry:varMap.entrySet()) { TempDescriptor tmp=entry.getKey(); + if (tmp==null) + throw new Error("Null tmp key"); for(Edge e:entry.getValue()) if (e.srcvar!=tmp) throw new Error(); diff --git a/Robust/src/Analysis/Pointer/GraphManip.java b/Robust/src/Analysis/Pointer/GraphManip.java index a899fc5b..ea998fae 100644 --- a/Robust/src/Analysis/Pointer/GraphManip.java +++ b/Robust/src/Analysis/Pointer/GraphManip.java @@ -26,10 +26,13 @@ public class GraphManip { static MySet getDiffEdges(Delta delta, TempDescriptor tmp) { MySet edges=new MySet(); MySet removeedges=delta.varedgeremove.get(tmp); - - for(Edge e:delta.basevaredge.get(tmp)) { - if (removeedges==null||!removeedges.contains(e)) - edges.add(e); + + MySet baseedges=delta.basevaredge.get(tmp); + if (baseedges!=null) { + for(Edge e:baseedges) { + if (removeedges==null||!removeedges.contains(e)) + edges.add(e); + } } if (delta.varedgeadd.containsKey(tmp)) for(Edge e:delta.varedgeadd.get(tmp)) { @@ -88,11 +91,14 @@ public class GraphManip { static HashSet getDiffNodes(Delta delta, TempDescriptor tmp) { HashSet nodes=new HashSet(); MySet removeedges=delta.varedgeremove.get(tmp); + + MySet baseEdges=delta.basevaredge.get(tmp); - for(Edge e:delta.basevaredge.get(tmp)) { - if (removeedges==null||!removeedges.contains(e)) - nodes.add(e.dst); - } + if (baseEdges!=null) + for(Edge e:baseEdges) { + if (removeedges==null||!removeedges.contains(e)) + nodes.add(e.dst); + } if (delta.varedgeadd.containsKey(tmp)) for(Edge e:delta.varedgeadd.get(tmp)) { nodes.add(e.dst); diff --git a/Robust/src/Analysis/Pointer/Pointer.java b/Robust/src/Analysis/Pointer/Pointer.java index af467a28..0c73bd53 100644 --- a/Robust/src/Analysis/Pointer/Pointer.java +++ b/Robust/src/Analysis/Pointer/Pointer.java @@ -71,7 +71,6 @@ public class Pointer { startindex=ppoint.getIndex()+1; delta=applyCallDelta(delta, bblock); } - Graph graph=bbgraphMap.get(bblock); Graph nodeGraph=null; //Compute delta at exit of each node @@ -185,6 +184,8 @@ public class Pointer { /* Start with the new incoming edges */ MySet newbaseedge=delta.basevaredge.get(tmp); /* Remove the remove set */ + if (newbaseedge==null) + newbaseedge=new MySet(); newbaseedge.removeAll(delta.varedgeremove.get(tmp)); /* Add in the new set*/ newbaseedge.addAll(delta.varedgeadd.get(tmp)); @@ -200,7 +201,7 @@ public class Pointer { nodeSet.addAll(delta.heapedgeremove.keySet()); for(AllocNode node:nodeSet) { /* Start with the new incoming edges */ - MySet newheapedge=(MySet) delta.baseheapedge.get(node).clone(); + MySet newheapedge=new MySet(delta.baseheapedge.get(node)); /* Remove the remove set */ MySet removeset=delta.heapedgeremove.get(node); @@ -244,14 +245,32 @@ public class Pointer { /* Now we need to propagate newdelta */ if (!newDelta.heapedgeadd.isEmpty()||!newDelta.heapedgeremove.isEmpty()||!newDelta.varedgeadd.isEmpty()||!newDelta.addNodeAges.isEmpty()||!newDelta.addOldNodes.isEmpty()) { /* We have a delta to propagate */ - Vector blockvector=bblock.next(); - for(int i=0;i blockvector=bblock.next(); + for(int i=0;i exitblocknodes=block.getExit().nodes(); + FlatExit fexit=(FlatExit)exitblocknodes.get(exitblocknodes.size()-1); + buildInitDelta(graphMap.get(fexit), returnDelta); if (!returnDelta.heapedgeadd.isEmpty()||!returnDelta.heapedgeremove.isEmpty()||!returnDelta.varedgeadd.isEmpty()) { returnDelta.setBlock(new PPoint(callblock, callindex)); toprocess.add(returnDelta); @@ -500,7 +522,6 @@ public class Pointer { delta.removeEdge(e); } } - Delta processFlatCall(BBlock callblock, int callindex, FlatCall fcall, Delta delta, Graph graph) { Delta newDelta=new Delta(null, false); @@ -610,7 +631,7 @@ public class Pointer { Graph oldgraph=(ppoint.getIndex()==0)? bbgraphMap.get(bblock): graphMap.get(nodes.get(ppoint.getIndex()-1)); - + //Age outside nodes if necessary for(Iterator nodeit=delta.addNodeAges.iterator();nodeit.hasNext();) { AllocNode node=nodeit.next(); @@ -624,7 +645,6 @@ public class Pointer { summarizeInGraph(graph, newDelta, node); } } - //Add heap edges in for(Map.Entry> entry:delta.heapedgeadd.entrySet()) { for(Edge e:entry.getValue()) { @@ -645,7 +665,6 @@ public class Pointer { mergeEdge(graph, newDelta, edgetoadd); } } - //Add external edges in for(Edge e:graph.externalEdgeSet) { //First did we age the source @@ -671,15 +690,15 @@ public class Pointer { } //Add edge for return value if (fcall.getReturnTemp()!=null) { - MySet returnedge=newDelta.varedgeadd.get(returntmp); - for(Edge e:returnedge) { - Edge newedge=e.copy(); - newedge.srcvar=fcall.getReturnTemp(); - if (graph.getEdges(fcall.getReturnTemp())==null||!graph.getEdges(fcall.getReturnTemp()).contains(newedge)) - newDelta.addEdge(newedge); - } + MySet returnedge=delta.varedgeadd.get(returntmp); + if (returnedge!=null) + for(Edge e:returnedge) { + Edge newedge=e.copy(); + newedge.srcvar=fcall.getReturnTemp(); + if (graph.getEdges(fcall.getReturnTemp())==null||!graph.getEdges(fcall.getReturnTemp()).contains(newedge)) + newDelta.addEdge(newedge); + } } - applyDiffs(graph, newDelta); return newDelta; } @@ -690,7 +709,7 @@ public class Pointer { if (match==null||!match.subsumes(edgetoadd)) { Edge mergededge=edgetoadd.merge(match); - newDelta.addHeapEdge(mergededge); + newDelta.addEdge(mergededge); } } } -- 2.34.1