From e21bec856fd5866d1d56d9c98aed8b56f24c90ad Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 4 Feb 2011 00:23:00 +0000 Subject: [PATCH] changes --- Robust/src/Analysis/Pointer/BasicBlock.java | 4 +- Robust/src/Analysis/Pointer/GraphManip.java | 15 +++++ Robust/src/Analysis/Pointer/Pointer.java | 71 ++++++++++++++++++++- 3 files changed, 87 insertions(+), 3 deletions(-) diff --git a/Robust/src/Analysis/Pointer/BasicBlock.java b/Robust/src/Analysis/Pointer/BasicBlock.java index deb93469..4746bd74 100644 --- a/Robust/src/Analysis/Pointer/BasicBlock.java +++ b/Robust/src/Analysis/Pointer/BasicBlock.java @@ -42,7 +42,7 @@ public class BasicBlock { } } - public static BasicBlock getBBlock(FlatMethod fm) { + public static BasicBlock getBBlock(FlatMethod fm, boolean breakcalls) { BBlock exit=null; Stack toprocess=new Stack(); HashMap map=new HashMap(); @@ -58,7 +58,7 @@ public class BasicBlock { 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 getEdges(Graph graph, Delta delta, AllocNode node) { + HashSet nodes=new HashSet(); + HashSet 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 getDiffNodes(Delta delta, TempDescriptor tmp) { HashSet nodes=new HashSet(); HashSet removeedges=delta.varedgeremove.get(tmp); diff --git a/Robust/src/Analysis/Pointer/Pointer.java b/Robust/src/Analysis/Pointer/Pointer.java index e1abdda6..9b4e5779 100644 --- a/Robust/src/Analysis/Pointer/Pointer.java +++ b/Robust/src/Analysis/Pointer/Pointer.java @@ -29,7 +29,7 @@ public class Pointer { 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); } @@ -178,6 +178,7 @@ public class Pointer { 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); @@ -186,6 +187,74 @@ public class Pointer { } } + Delta processFlatCall(FlatCall fcall, Delta delta, Graph newgraph) { + Delta newDelta=new Delta(null, false); + + if (delta.getInit()) { + HashSet edgeset=new HashSet(); + HashSet nodeset=new HashSet(); + HashSet targetSet=new HashSet(); + Stack tovisit=new Stack(); + TempDescriptor tmpthis=fc.getThis(); + + //Handle the this temp + if (tmpthis!=null) { + HashSet edges=GraphManip.getEdges(graph, delta, tmpthis); + newdelta.varedgeadd.put(tmpthis, (HashSet) 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 edges=GraphManip.getEdges(graph, delta, tmp); + newdelta.varedgeadd.put(tmp, (HashSet) 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 edges=GraphManip.getEdges(graph, delta, node); + newdelta.heapedgeadd.put(node, (HashSet) 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> e: delta.baseheapedge.entrySet()) { -- 2.34.1