static MySet<Edge> getDiffEdges(Delta delta, TempDescriptor tmp) {
MySet<Edge> edges=new MySet<Edge>();
MySet<Edge> removeedges=delta.varedgeremove.get(tmp);
-
- for(Edge e:delta.basevaredge.get(tmp)) {
- if (removeedges==null||!removeedges.contains(e))
- edges.add(e);
+
+ MySet<Edge> 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)) {
static HashSet<AllocNode> getDiffNodes(Delta delta, TempDescriptor tmp) {
HashSet<AllocNode> nodes=new HashSet<AllocNode>();
MySet<Edge> removeedges=delta.varedgeremove.get(tmp);
+
+ MySet<Edge> 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);
startindex=ppoint.getIndex()+1;
delta=applyCallDelta(delta, bblock);
}
-
Graph graph=bbgraphMap.get(bblock);
Graph nodeGraph=null;
//Compute delta at exit of each node
/* Start with the new incoming edges */
MySet<Edge> newbaseedge=delta.basevaredge.get(tmp);
/* Remove the remove set */
+ if (newbaseedge==null)
+ newbaseedge=new MySet<Edge>();
newbaseedge.removeAll(delta.varedgeremove.get(tmp));
/* Add in the new set*/
newbaseedge.addAll(delta.varedgeadd.get(tmp));
nodeSet.addAll(delta.heapedgeremove.keySet());
for(AllocNode node:nodeSet) {
/* Start with the new incoming edges */
- MySet<Edge> newheapedge=(MySet<Edge>) delta.baseheapedge.get(node).clone();
+ MySet<Edge> newheapedge=new MySet<Edge>(delta.baseheapedge.get(node));
/* Remove the remove set */
MySet<Edge> removeset=delta.heapedgeremove.get(node);
/* 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<BBlock> blockvector=bblock.next();
- for(int i=0;i<blockvector.size();i++) {
- if (i==0) {
- newDelta.setBlock(new PPoint(blockvector.get(i)));
- toprocess.add(newDelta);
- } else {
- Delta d=newDelta.diffBlock(new PPoint(blockvector.get(i)));
- toprocess.add(d);
+
+ if (returnMap.containsKey(bblock)) {
+ //exit of call block
+ boolean first=true;
+
+ for(PPoint caller:returnMap.get(bblock)) {
+ if (first) {
+ newDelta.setBlock(caller);
+ toprocess.add(newDelta);
+ first=false;
+ } else {
+ Delta d=newDelta.diffBlock(caller);
+ toprocess.add(d);
+ }
+ }
+ } else {
+ //normal block
+ Vector<BBlock> blockvector=bblock.next();
+ for(int i=0;i<blockvector.size();i++) {
+ if (i==0) {
+ newDelta.setBlock(new PPoint(blockvector.get(i)));
+ toprocess.add(newDelta);
+ } else {
+ Delta d=newDelta.diffBlock(new PPoint(blockvector.get(i)));
+ toprocess.add(d);
+ }
}
}
}
return processSetFieldElementNode(node, delta, newgraph);
case FKind.FlatMethod:
case FKind.FlatExit:
+ case FKind.FlatGenReachNode:
return processFlatNop(node, delta, newgraph);
case FKind.FlatCall:
return processFlatCall(bblock, index, (FlatCall) node, delta, newgraph);
//Need to push existing results to current node
if (returnDelta==null) {
returnDelta=new Delta(null, false);
- buildInitDelta(bbgraphMap.get(block.getExit()), returnDelta);
+ Vector<FlatNode> 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);
delta.removeEdge(e);
}
}
-
Delta processFlatCall(BBlock callblock, int callindex, FlatCall fcall, Delta delta, Graph graph) {
Delta newDelta=new Delta(null, false);
Graph oldgraph=(ppoint.getIndex()==0)?
bbgraphMap.get(bblock):
graphMap.get(nodes.get(ppoint.getIndex()-1));
-
+
//Age outside nodes if necessary
for(Iterator<AllocNode> nodeit=delta.addNodeAges.iterator();nodeit.hasNext();) {
AllocNode node=nodeit.next();
summarizeInGraph(graph, newDelta, node);
}
}
-
//Add heap edges in
for(Map.Entry<AllocNode, MySet<Edge>> entry:delta.heapedgeadd.entrySet()) {
for(Edge e:entry.getValue()) {
mergeEdge(graph, newDelta, edgetoadd);
}
}
-
//Add external edges in
for(Edge e:graph.externalEdgeSet) {
//First did we age the source
}
//Add edge for return value
if (fcall.getReturnTemp()!=null) {
- MySet<Edge> 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<Edge> 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;
}
if (match==null||!match.subsumes(edgetoadd)) {
Edge mergededge=edgetoadd.merge(match);
- newDelta.addHeapEdge(mergededge);
+ newDelta.addEdge(mergededge);
}
}
}