From 68d717e92690af10cbe81384fcc6c8664e58fca5 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Wed, 9 Mar 2011 21:54:19 +0000 Subject: [PATCH] changes --- Robust/src/Analysis/Pointer/Edge.java | 16 ++++++++++ Robust/src/Analysis/Pointer/Graph.java | 10 ++++++ Robust/src/Analysis/Pointer/Pointer.java | 40 +++++++++++++++++++++--- 3 files changed, 61 insertions(+), 5 deletions(-) diff --git a/Robust/src/Analysis/Pointer/Edge.java b/Robust/src/Analysis/Pointer/Edge.java index 49884471..c4175afc 100644 --- a/Robust/src/Analysis/Pointer/Edge.java +++ b/Robust/src/Analysis/Pointer/Edge.java @@ -76,6 +76,14 @@ public class Edge { return e; } + public Edge merge(Edge e) { + if (e==null) + return this; + Edge newe=copy(); + newe.statuspredicate=mergeStatus(statuspredicate, e.statuspredicate); + return newe; + } + public Edge rewrite(AllocNode single, AllocNode summary) { Edge e=copy(); if (e.src==single) @@ -98,6 +106,14 @@ public class Edge { return e; } + public boolean subsumes(Edge e) { + return subsumes(this.statuspredicate, e.statuspredicate); + } + + public static boolean subsumes(int status1, int status2) { + return ((status1&NEW)==NEW)&&((status1|status2)==status1); + } + public Edge makeOld() { Edge e=new Edge(); e.fd=fd; diff --git a/Robust/src/Analysis/Pointer/Graph.java b/Robust/src/Analysis/Pointer/Graph.java index 4460bf07..5c98abf2 100644 --- a/Robust/src/Analysis/Pointer/Graph.java +++ b/Robust/src/Analysis/Pointer/Graph.java @@ -47,6 +47,16 @@ public class Graph { return nodeAges.contains(node)||parent!=null&&parent.nodeAges.contains(node); } + public Edge getMatch(Edge old) { + if (old.srcvar!=null) { + MySet edges=varMap.get(old.srcvar); + return edges.get(old); + } else { + MySet edges=nodeMap.get(old.src); + return edges.get(old); + } + } + public MySet getEdges(TempDescriptor tmp) { if (varMap.containsKey(tmp)) return varMap.get(tmp); diff --git a/Robust/src/Analysis/Pointer/Pointer.java b/Robust/src/Analysis/Pointer/Pointer.java index c9705232..e7b4bede 100644 --- a/Robust/src/Analysis/Pointer/Pointer.java +++ b/Robust/src/Analysis/Pointer/Pointer.java @@ -86,6 +86,10 @@ public class Pointer { } } + /* This function builds the last delta for a basic block. It + * handles the case for the first time the basic block is + * evaluated.*/ + void buildInitDelta(Graph graph, Delta newDelta) { //First compute the set of temps HashSet tmpSet=new HashSet(); @@ -134,6 +138,8 @@ public class Pointer { } } + /* This function build the delta for the exit of a basic block. */ + void generateFinalDelta(BBlock bblock, Delta delta, Graph graph) { Delta newDelta=new Delta(null, false); if (delta.getInit()) { @@ -240,6 +246,9 @@ public class Pointer { } } + /* This function compute the edges for the this variable for a + * callee if it exists. */ + void processThisTargets(HashSet targetSet, Graph graph, Delta delta, Delta newDelta, HashSet nodeset, Stack tovisit, MySet edgeset, TempDescriptor tmpthis, HashSet oldnodeset) { //Handle the this temp if (tmpthis!=null) { @@ -263,6 +272,8 @@ public class Pointer { } } + /* This function compute the edges for a call's parameters. */ + void processParams(Graph graph, Delta delta, Delta newDelta, HashSet nodeset, Stack tovisit, MySet edgeset, FlatCall fcall, boolean diff) { //Go through each temp for(int i=0;i nodeset, Stack tovisit, MySet edgeset, HashSet oldnodeset) { while(!tovisit.isEmpty()) { AllocNode node=tovisit.pop(); @@ -430,6 +443,9 @@ public class Pointer { } } } + + /* This function removes the caller reachable edges from the + * callee's heap. */ void removeEdges(Delta delta, HashSet nodeset, MySet edgeset, MySet externaledgeset) { //Want to remove the set of internal edges @@ -544,7 +560,7 @@ public class Pointer { return delta; } - + /* This function applies callee deltas to the caller heap. */ Delta applyCallDelta(Delta delta, BBlock bblock) { Delta newDelta=new Delta(null, false); @@ -588,7 +604,12 @@ public class Pointer { } } if (edgetoadd!=null) { - newDelta.addHeapEdge(edgetoadd); + Edge match=graph.getMatch(edgetoadd); + if (match==null||!match.subsumes(edgetoadd)) { + Edge mergededge=edgetoadd.merge(match); + //XXXXXXXXXXXXX; + newDelta.addHeapEdge(mergededge); + } } } } @@ -616,7 +637,7 @@ public class Pointer { newDelta.addEdge(newedge); } } - + return newDelta; } @@ -638,8 +659,10 @@ public class Pointer { MySet backedges=graph.getBackEdges(singleNode); for(Edge e:backedges) { if (e.dst==singleNode) { - Edge rewrite=e.rewrite(singleNode, summaryNode); - newDelta.removeEdge(e); + //Need to get original edge so that predicate will be correct + Edge match=graph.getMatch(e); + Edge rewrite=match.rewrite(singleNode, summaryNode); + newDelta.removeEdge(match); newDelta.addEdge(rewrite); } } @@ -1189,6 +1212,13 @@ public class Pointer { //We have a new edge diffedges.add(e); dstedges.add(e); + } else { + Edge origedge=dstedges.get(e); + if (!origedge.subsumes(e)) { + Edge mergededge=origedge.merge(e); + diffedges.add(mergededge); + dstedges.add(mergededge); + } } } //Done with edge set... -- 2.34.1