}
}
- public static BasicBlock getBBlock(FlatMethod fm) {
+ public static BasicBlock getBBlock(FlatMethod fm, boolean breakcalls) {
BBlock exit=null;
Stack<FlatNode> toprocess=new Stack<FlatNode>();
HashMap<FlatNode, BBlock> map=new HashMap<FlatNode, BBlock>();
if (fn.kind()==FKind.FlatExit)
exit=block;
do {
- if (pm.numNext(fn)!=1) {
+ if (pm.numNext(fn)!=1||(fn.kind()==FKind.FlatCall&&breakcalls)) {
for(int i=0;i<pm.numNext(fn);i++) {
FlatNode fnext=pm.getNext(fn,i);
if (!map.containsKey(fnext)) {
return nodes;
}
+ static HashSet<Edge> getEdges(Graph graph, Delta delta, AllocNode node) {
+ HashSet<Edge> nodes=new HashSet<Edge>();
+ HashSet<Edge> removeedges=delta.heapedgeremove.get(node);
+ for(Edge e:graph.getEdges(node)) {
+ if ((removeedges==null||!removeedges.contains(e)))
+ nodes.add(e);
+ }
+ if (delta.heapedgeadd.containsKey(node))
+ for(Edge e:delta.heapedgeadd.get(node)) {
+ nodes.add(e);
+ }
+
+ return nodes;
+ }
+
static HashSet<AllocNode> getDiffNodes(Delta delta, TempDescriptor tmp) {
HashSet<AllocNode> nodes=new HashSet<AllocNode>();
HashSet<Edge> removeedges=delta.varedgeremove.get(tmp);
public BasicBlock getBBlock(FlatMethod fm) {
if (!blockMap.containsKey(fm))
- blockMap.put(fm, BasicBlock.getBBlock(fm));
+ blockMap.put(fm, BasicBlock.getBBlock(fm, true));
return blockMap.get(fm);
}
case FKind.FlatExit:
return processFlatNop(node, delta, newgraph);
case FKind.FlatCall:
+ return processFlatCall((FlatCall) node, delta, newgraph);
case FKind.FlatSESEEnterNode:
case FKind.FlatSESEExitNode:
throw new Error("Unimplemented node:"+node);
}
}
+ Delta processFlatCall(FlatCall fcall, Delta delta, Graph newgraph) {
+ Delta newDelta=new Delta(null, false);
+
+ if (delta.getInit()) {
+ HashSet<Edge> edgeset=new HashSet<Edge>();
+ HashSet<AllocNode> nodeset=new HashSet<AllocNode>();
+ HashSet<ClassDescriptor> targetSet=new HashSet<ClassDescriptor>();
+ Stack<AllocNode> tovisit=new Stack<AllocNode>();
+ TempDescriptor tmpthis=fc.getThis();
+
+ //Handle the this temp
+ if (tmpthis!=null) {
+ HashSet<Edge> edges=GraphManip.getEdges(graph, delta, tmpthis);
+ newdelta.varedgeadd.put(tmpthis, (HashSet<Edge>) edges.clone());
+ edgeset.addAll(edges);
+ for(Edge e:edges) {
+ AllocNode dstnode=e.dst;
+ if (!nodeset.contains(dstnode)) {
+ TypeDescriptor type=dstnode.getType();
+ if (!type.isArray()) {
+ targetSet.add(type.getClassDesc());
+ } else {
+ //arrays don't have code
+ targetSet.add(typeUtil.getClass(TypeUtil.ObjectClass));
+ }
+ nodeset.add(dstnode);
+ tovisit.add(dstnode);
+ }
+ }
+ }
+
+ //Go through each temp
+ for(int i=0;i<fc.numArgs();i++) {
+ TempDescriptor tmp=fc.getArg(i);
+ HashSet<Edge> edges=GraphManip.getEdges(graph, delta, tmp);
+ newdelta.varedgeadd.put(tmp, (HashSet<Edge>) edges.clone());
+ edgeset.addAll(edges);
+ for(Edge e:edges) {
+ if (!nodeset.contains(e.dst)) {
+ nodeset.add(e.dst);
+ tovisit.add(e.dst);
+ }
+ }
+ }
+
+ //Traverse all reachable nodes
+ while(!tovisit.isEmpty()) {
+ AllocNode node=tovisit.pop();
+ HashSet<Edge> edges=GraphManip.getEdges(graph, delta, node);
+ newdelta.heapedgeadd.put(node, (HashSet<Edge>) edges.clone());
+ edgeset.addAll(edges);
+ for(Edge e:edges) {
+ if (!nodeset.contains(e.dst)) {
+ nodeset.add(e.dst);
+ tovisit.add(e.dst);
+ }
+ }
+ }
+
+ //Apply diffs to graph
+ applyDiffs(graph, delta);
+ } else {
+
+ //Apply diffs to graph
+ applyDiffs(graph, delta);
+ }
+ }
+
void applyDiffs(Graph graph, Delta delta) {
//Add hidden base edges
for(Map.Entry<AllocNode, HashSet<Edge>> e: delta.baseheapedge.entrySet()) {