From: bdemsky Date: Wed, 2 Mar 2011 23:20:17 +0000 (+0000) Subject: more code cleanup X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=01c8789ff554f104d02ce7d998d730a454af797e;p=IRC.git more code cleanup --- diff --git a/Robust/src/Analysis/Pointer/Pointer.java b/Robust/src/Analysis/Pointer/Pointer.java index aae36b2c..bb31a9c0 100644 --- a/Robust/src/Analysis/Pointer/Pointer.java +++ b/Robust/src/Analysis/Pointer/Pointer.java @@ -284,59 +284,40 @@ public class Pointer { return targets; } - Delta processFlatCall(BBlock callblock, int callindex, FlatCall fcall, Delta delta, Graph graph) { - Delta newDelta=new Delta(null, false); - - if (delta.getInit()) { - MySet edgeset=new MySet(); - HashSet nodeset=new HashSet(); - HashSet targetSet=new HashSet(); - Stack tovisit=new Stack(); - TempDescriptor tmpthis=fcall.getThis(); - //Handle the this temp - processThisTargets(targetSet, graph, delta, newDelta, nodeset, tovisit, edgeset, tmpthis, null); + void fixMapping(FlatCall fcall, HashSet targets, MySet oldedgeset, Delta newDelta, BBlock callblock, int callindex) { + Delta basedelta=null; + TempDescriptor tmpthis=fcall.getThis(); - //Go through each temp - processParams(graph, delta, newDelta, nodeset, tovisit, edgeset, fcall, false); + for(MethodDescriptor calledmd:targets) { + FlatMethod fm=state.getMethodFlat(calledmd); + boolean newmethod=false; - //Traverse all reachable nodes - computeReachableNodes(graph, delta, newDelta, nodeset, tovisit, edgeset, null); - - //Compute call targets - HashSet targets=computeTargets(fcall, newDelta); - - //Fix mapping - for(MethodDescriptor calledmd:targets) { - FlatMethod fm=state.getMethodFlat(calledmd); - - //Build tmpMap - HashMap tmpMap=new HashMap(); - int offset=0; - if(tmpthis!=null) { - tmpMap.put(tmpthis, fm.getParameter(offset++)); - } - for(int i=0;i tmpMap=new HashMap(); + int offset=0; + if(tmpthis!=null) { + tmpMap.put(tmpthis, fm.getParameter(offset++)); + } + for(int i=0;i()); - } + //Get basicblock for the method + BasicBlock block=getBBlock(fm); + + //Hook up exits + if (!callMap.containsKey(fcall)) { + callMap.put(fcall, new HashSet()); + } + + Delta returnDelta=null; + + if (!callMap.get(fcall).contains(block.getStart())) { callMap.get(fcall).add(block.getStart()); + newmethod=true; - //If we have an existing exit, build delta - Delta returnDelta=null; - //Hook up return if (!returnMap.containsKey(block.getExit())) { returnMap.put(block.getExit(), new HashSet()); @@ -359,6 +340,53 @@ public class Pointer { } } } + + if (oldedgeset==null) { + //First build of this graph + //Build and enqueue delta...safe to just use existing delta + Delta d=newDelta.changeParams(tmpMap, new PPoint(block.getStart())); + toprocess.add(d); + } else if (newmethod) { + if (basedelta==null) { + basedelta=newDelta.buildBase(oldedgeset); + } + //Build and enqueue delta + Delta d=basedelta.changeParams(tmpMap, new PPoint(block.getStart())); + toprocess.add(d); + } else { + //Build and enqueue delta + Delta d=newDelta.changeParams(tmpMap, new PPoint(block.getStart())); + toprocess.add(d); + } + } + } + + + Delta processFlatCall(BBlock callblock, int callindex, FlatCall fcall, Delta delta, Graph graph) { + Delta newDelta=new Delta(null, false); + + if (delta.getInit()) { + MySet edgeset=new MySet(); + HashSet nodeset=new HashSet(); + HashSet targetSet=new HashSet(); + Stack tovisit=new Stack(); + TempDescriptor tmpthis=fcall.getThis(); + + //Handle the this temp + processThisTargets(targetSet, graph, delta, newDelta, nodeset, tovisit, edgeset, tmpthis, null); + + //Go through each temp + processParams(graph, delta, newDelta, nodeset, tovisit, edgeset, fcall, false); + + //Traverse all reachable nodes + computeReachableNodes(graph, delta, newDelta, nodeset, tovisit, edgeset, null); + + //Compute call targets + HashSet targets=computeTargets(fcall, newDelta); + + //Fix mapping + fixMapping(fcall, targets, null, newDelta, callblock, callindex); + graph.reachNode=nodeset; graph.reachEdge=edgeset; @@ -399,74 +427,9 @@ public class Pointer { //add in new nodeset and edgeset oldnodeset.addAll(nodeset); oldedgeset.addAll(edgeset); - Delta basedelta=null; //Fix mapping - for(MethodDescriptor calledmd:targets) { - FlatMethod fm=state.getMethodFlat(calledmd); - boolean newmethod=false; - - //Get basicblock for the method - BasicBlock block=getBBlock(fm); - - //Hook up exits - if (!callMap.containsKey(fcall)) { - callMap.put(fcall, new HashSet()); - } - - Delta returnDelta=null; - - if (!callMap.get(fcall).contains(block.getStart())) { - callMap.get(fcall).add(block.getStart()); - newmethod=true; - - //Hook up exits - if (!returnMap.containsKey(block.getExit())) { - returnMap.put(block.getExit(), new HashSet()); - } - returnMap.get(block.getExit()).add(new PPoint(callblock, callindex)); - - if (bbgraphMap.containsKey(block.getExit())) { - //Need to push existing results to current node - if (returnDelta==null) { - returnDelta=new Delta(null, false); - buildInitDelta(bbgraphMap.get(block.getExit()), returnDelta); - if (!returnDelta.heapedgeadd.isEmpty()||!returnDelta.heapedgeremove.isEmpty()||!returnDelta.varedgeadd.isEmpty()) { - returnDelta.setBlock(new PPoint(callblock, callindex)); - toprocess.add(returnDelta); - } - } else { - if (!returnDelta.heapedgeadd.isEmpty()||!returnDelta.heapedgeremove.isEmpty()||!returnDelta.varedgeadd.isEmpty()) { - toprocess.add(returnDelta.diffBlock(new PPoint(callblock, callindex))); - } - } - } - } - - //Build tmpMap - HashMap tmpMap=new HashMap(); - int offset=0; - if(tmpthis!=null) { - tmpMap.put(tmpthis, fm.getParameter(offset++)); - } - for(int i=0;i