public void print() {
System.out.println("----------------------------------------------");
- System.out.println("baseheapedge empty:"+baseheapedge.isEmpty());
- System.out.println("basevaredge empty:"+basevaredge.isEmpty());
- System.out.println("heapedgeadd empty:"+heapedgeadd.isEmpty());
- System.out.println("heapedgeremove empty:"+heapedgeremove.isEmpty());
- System.out.println("varedgeadd empty:"+varedgeadd.isEmpty());
+ System.out.println("baseheapedge:"+baseheapedge);
+ System.out.println("basevaredge:"+basevaredge);
+ System.out.println("heapedgeadd:"+heapedgeadd);
+ System.out.println("heapedgeremove:"+heapedgeremove);
+ System.out.println("varedgeadd:"+varedgeadd);
if (varedgeremove==null)
- System.out.println("varedge remove: null");
+ System.out.println("varedgeremove: null");
else
- System.out.println("varedgeremove empty:"+varedgeremove.isEmpty());
- System.out.println("baseNodeAges empty:"+baseNodeAges.isEmpty());
- System.out.println("addNodeAges empty:"+addNodeAges.isEmpty());
- System.out.println("baseOldNodes empty:"+baseOldNodes.isEmpty());
- System.out.println("addOldNodes empty:"+addOldNodes.isEmpty());
+ System.out.println("varedgeremove:"+varedgeremove);
+ System.out.println("baseNodeAges:"+baseNodeAges);
+ System.out.println("addNodeAges:"+addNodeAges);
+ System.out.println("baseOldNodes:"+baseOldNodes);
+ System.out.println("addOldNodes:"+addOldNodes);
}
private Delta() {
for(Map.Entry<TempDescriptor, MySet<Edge>> entry:varedgeadd.entrySet()) {
TempDescriptor origTmp=entry.getKey();
TempDescriptor newTmp=tmpMap.get(entry.getKey());
- newdelta.varedgeadd.put(newTmp, new MySet<Edge>());
- for(Edge e:entry.getValue()) {
- newdelta.varedgeadd.get(newTmp).add(e.rewrite(origTmp, newTmp));
+ MySet<Edge> edgeset=entry.getValue();
+ if (!edgeset.isEmpty()) {
+ newdelta.varedgeadd.put(newTmp, new MySet<Edge>());
+ for(Edge e:edgeset) {
+ newdelta.varedgeadd.get(newTmp).add(e.rewrite(origTmp, newTmp));
+ }
}
}
newdelta.varedgeremove=varedgeremove;
AllocFactory allocFactory;
LinkedList<Delta> toprocess;
TempDescriptor returntmp;
+ int plotcount=0;
public Pointer(State state, TypeUtil typeUtil) {
this.state=state;
toprocess.add(buildInitialContext());
while(!toprocess.isEmpty()) {
Delta delta=toprocess.remove();
- delta.print();
PPoint ppoint=delta.getBlock();
BBlock bblock=ppoint.getBBlock();
Vector<FlatNode> nodes=bblock.nodes();
int startindex=0;
+ System.out.println("BB BEGIN");
+ delta.print();
+
if (ppoint.getIndex()==-1) {
//Build base graph for entrance to this basic block
+ System.out.println("INIT");
delta=applyInitDelta(delta, bblock);
} else {
+ System.out.println("CALL");
startindex=ppoint.getIndex()+1;
delta=applyCallDelta(delta, bblock);
}
//Compute delta at exit of each node
for(int i=startindex; i<nodes.size();i++) {
FlatNode currNode=nodes.get(i);
+ System.out.println("["+plotcount+"]");
+ System.out.println(currNode);
+ delta.print();
+
if (!graphMap.containsKey(currNode)) {
graphMap.put(currNode, new Graph(graph));
}
nodeGraph=graphMap.get(currNode);
+ plotGraph(nodeGraph,"S"+plotcount+currNode);
delta=processNode(bblock, i, currNode, delta, nodeGraph);
+ plotGraph(nodeGraph,"N"+plotcount+currNode);
+ plotcount++;
}
+ System.out.println("LOOPEXIT");
+ delta.print();
generateFinalDelta(bblock, delta, nodeGraph);
}
int debugindex=0;
for(Map.Entry<BBlock, Graph> e:bbgraphMap.entrySet()) {
Graph g=e.getValue();
- try {
- PrintWriter pw=new PrintWriter(new FileWriter("BB"+debugindex+".dot"));
- g.printGraph(pw, "BB");
- pw.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
+ plotGraph(g,"BB"+debugindex);
debugindex++;
}
for(Map.Entry<FlatNode, Graph> e:graphMap.entrySet()) {
FlatNode fn=e.getKey();
Graph g=e.getValue();
- try {
- PrintWriter pw=new PrintWriter(new FileWriter("FN"+fn.toString().replace(' ','_')+".dot"));
- g.printGraph(pw, fn.toString());
- pw.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
+ plotGraph(g,"FN"+fn.toString()+debugindex);
debugindex++;
}
for(FlatMethod fm:blockMap.keySet()) {
}
}
+ void plotGraph(Graph g, String name) {
+ try {
+ PrintWriter pw=new PrintWriter(new FileWriter(name.toString().replace(' ','_')+".dot"));
+ g.printGraph(pw, name);
+ pw.close();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+
/* This function builds the last delta for a basic block. It
* handles the case for the first time the basic block is
* evaluated.*/
HashSet<TempDescriptor> tmpSet=new HashSet<TempDescriptor>();
tmpSet.addAll(delta.basevaredge.keySet());
tmpSet.addAll(delta.varedgeadd.keySet());
+ System.out.println(tmpSet);
for(TempDescriptor tmp:tmpSet) {
/* Start with the new incoming edges */
MySet<Edge> newbaseedge=delta.basevaredge.get(tmp);
}
}
}
+ System.out.println("FINAL");
+ newDelta.print();
/* Now we need to propagate newdelta */
if (!newDelta.heapedgeadd.isEmpty()||!newDelta.heapedgeremove.isEmpty()||!newDelta.varedgeadd.isEmpty()||!newDelta.addNodeAges.isEmpty()||!newDelta.addOldNodes.isEmpty()) {
HashSet<AllocNode> dstNodes=GraphManip.getNodes(graph, delta, dst);
MySet<Edge> edgesToAdd=GraphManip.genEdges(dstNodes, fd, srcNodes);
MySet<Edge> edgesToRemove=null;
- if (dstNodes.size()==1&&!dstNodes.iterator().next().isSummary()) {
+ if (dstNodes.size()==1&&!dstNodes.iterator().next().isSummary()&&fd!=null) {
/* Can do a strong update */
edgesToRemove=GraphManip.getEdges(graph, delta, dstNodes, fd);
graph.strongUpdateSet=edgesToRemove;
MySet<Edge> edgesToRemove=null;
if (newDstNodes.size()!=0) {
- if (dstNodes.size()>1&&!dstNodes.iterator().next().isSummary()) {
+ if (dstNodes.size()>1&&!dstNodes.iterator().next().isSummary()&&fd!=null) {
/* Need to undo strong update */
if (graph.strongUpdateSet!=null) {
edgesToAdd.addAll(graph.strongUpdateSet);
graph.strongUpdateSet=null; //Prevent future strong updates
}
- } else if (dstNodes.size()==1&&newDstNodes.size()==1&&!newDstNodes.iterator().next().isSummary()&&graph.strongUpdateSet!=null) {
+ } else if (dstNodes.size()==1&&newDstNodes.size()==1&&!newDstNodes.iterator().next().isSummary()&&graph.strongUpdateSet!=null&&fd!=null) {
edgesToRemove=GraphManip.getEdges(graph, delta, dstNodes, fd);
graph.strongUpdateSet.addAll(edgesToRemove);
}
}
//Kill new edges
- if (graph.strongUpdateSet!=null) {
+ if (graph.strongUpdateSet!=null&&fd!=null) {
MySet<Edge> otherEdgesToRemove=GraphManip.getDiffEdges(delta, dstNodes);
if (edgesToRemove!=null)
edgesToRemove.addAll(otherEdgesToRemove);
}
}
//Done with edge set...
- if (diffedges.size()>=0) {
+ if (diffedges.size()>0) {
//completely new
newdelta.basevaredge.put(tmpsrc,diffedges);
}