1 package Analysis.Pointer;
5 import Analysis.Liveness;
6 import Analysis.Pointer.BasicBlock.BBlock;
7 import Analysis.Pointer.AllocFactory.AllocNode;
8 import Analysis.Disjoint.Alloc;
9 import Analysis.Disjoint.Taint;
10 import Analysis.Disjoint.TaintSet;
11 import Analysis.Disjoint.Canonical;
12 import Analysis.Disjoint.HeapAnalysis;
13 import Analysis.CallGraph.CallGraph;
14 import Analysis.OoOJava.RBlockRelationAnalysis;
15 import Analysis.OoOJava.Accessible;
16 import Analysis.Disjoint.ExistPred;
17 import Analysis.Disjoint.ReachGraph;
18 import Analysis.Disjoint.EffectsAnalysis;
19 import Analysis.Disjoint.BuildStateMachines;
23 public class Pointer implements HeapAnalysis{
24 HashMap<FlatMethod, BasicBlock> blockMap;
25 HashMap<BBlock, Graph> bbgraphMap;
26 HashMap<FlatNode, Graph> graphMap;
27 HashMap<FlatCall, Set<BBlock>> callMap;
28 HashMap<BBlock, Set<PPoint>> returnMap;
29 HashMap<BBlock, Set<TempDescriptor>> bblivetemps;
31 private boolean OoOJava=false;
35 AllocFactory allocFactory;
36 LinkedList<Delta> toprocess;
37 TempDescriptor returntmp;
38 RBlockRelationAnalysis taskAnalysis;
39 EffectsAnalysis effectsAnalysis;
40 Accessible accessible;
42 public Pointer(State state, TypeUtil typeUtil, CallGraph callGraph, RBlockRelationAnalysis taskAnalysis, Liveness liveness) {
43 this(state, typeUtil);
44 this.callGraph=callGraph;
46 this.taskAnalysis=taskAnalysis;
47 this.effectsAnalysis=new EffectsAnalysis();
48 effectsAnalysis.state=state;
49 effectsAnalysis.buildStateMachines=new BuildStateMachines();
50 accessible=new Accessible(state, callGraph, taskAnalysis, liveness);
51 accessible.doAnalysis();
52 State.logEvent("Done Writing Accessible Analysis");
55 public Pointer(State state, TypeUtil typeUtil) {
57 this.blockMap=new HashMap<FlatMethod, BasicBlock>();
58 this.bbgraphMap=new HashMap<BBlock, Graph>();
59 this.bblivetemps=new HashMap<BBlock, Set<TempDescriptor>>();
60 this.graphMap=new HashMap<FlatNode, Graph>();
61 this.callMap=new HashMap<FlatCall, Set<BBlock>>();
62 this.returnMap=new HashMap<BBlock, Set<PPoint>>();
63 this.typeUtil=typeUtil;
64 this.allocFactory=new AllocFactory(state, typeUtil);
65 this.toprocess=new LinkedList<Delta>();
66 ClassDescriptor stringcd=typeUtil.getClass(TypeUtil.ObjectClass);
67 this.returntmp=new TempDescriptor("RETURNVAL", stringcd);
70 public EffectsAnalysis getEffectsAnalysis() {
71 return effectsAnalysis;
74 public BasicBlock getBBlock(FlatMethod fm) {
75 if (!blockMap.containsKey(fm)) {
76 blockMap.put(fm, BasicBlock.getBBlock(fm));
77 Hashtable<FlatNode, Set<TempDescriptor>> livemap=Liveness.computeLiveTemps(fm);
78 for(BBlock bblock:blockMap.get(fm).getBlocks()) {
79 FlatNode fn=bblock.nodes.get(0);
81 HashSet<TempDescriptor> fmset=new HashSet<TempDescriptor>();
82 fmset.addAll((List<TempDescriptor>)Arrays.asList(fm.writesTemps()));
83 bblivetemps.put(bblock, fmset);
85 Set<TempDescriptor> livetemps=livemap.get(fn);
86 bblivetemps.put(bblock, livetemps);
87 livetemps.add(returntmp);
91 return blockMap.get(fm);
94 Delta buildInitialContext() {
95 MethodDescriptor md=typeUtil.getMain();
96 FlatMethod fm=state.getMethodFlat(md);
97 BasicBlock bb=getBBlock(fm);
98 BBlock start=bb.getStart();
99 Delta delta=new Delta(new PPoint(start), true);
100 MySet<Edge> arrayset=new MySet<Edge>();
101 MySet<Edge> varset=new MySet<Edge>();
102 Edge arrayedge=new Edge(allocFactory.StringArray, null, allocFactory.Strings);
103 Edge stringedge=new Edge(fm.getParameter(0), allocFactory.StringArray);
104 delta.addHeapEdge(arrayedge);
105 delta.addVarEdge(stringedge);
111 public Graph getGraph(FlatNode fn) {
112 return graphMap.get(fn);
115 public void doAnalysis() {
117 toprocess.add(buildInitialContext());
119 while(!toprocess.isEmpty()) {
120 Delta delta=toprocess.remove();
121 PPoint ppoint=delta.getBlock();
122 BBlock bblock=ppoint.getBBlock();
123 Vector<FlatNode> nodes=bblock.nodes();
126 if (ppoint.getIndex()==-1) {
127 //Build base graph for entrance to this basic block
128 //System.out.println("Processing "+bblock.nodes.get(0).toString().replace(' ','_'));
130 delta=applyInitDelta(delta, bblock);
131 //System.out.println("Generating:");
134 //System.out.println("Processing Call "+bblock.nodes.get(ppoint.getIndex()).toString().replace(' ','_'));
137 startindex=ppoint.getIndex()+1;
138 delta=applyCallDelta(delta, bblock);
139 //System.out.println("Generating:");
142 Graph graph=bbgraphMap.get(bblock);
143 Graph nodeGraph=null;
144 boolean init=delta.getInit();
145 if (!init&&delta.isEmpty())
148 //Compute delta at exit of each node
149 for(int i=startindex; i<nodes.size();i++) {
150 FlatNode currNode=nodes.get(i);
151 //System.out.println("Start Processing "+currNode);
152 if (!graphMap.containsKey(currNode)) {
153 if (isNEEDED(currNode))
154 graphMap.put(currNode, new Graph(graph));
157 //base graph works for us
158 graphMap.put(currNode, new Graph(graph));
160 //just use previous graph
161 graphMap.put(currNode, graphMap.get(nodes.get(i-1)));
165 nodeGraph=graphMap.get(currNode);
166 delta=processNode(bblock, i, currNode, delta, nodeGraph);
167 //System.out.println("Processing "+currNode+" and generating delta:");
170 generateFinalDelta(bblock, delta, nodeGraph);
176 for(Map.Entry<BBlock, Graph> e:bbgraphMap.entrySet()) {
177 Graph g=e.getValue();
178 plotGraph(g,"BB"+e.getKey().nodes.get(0).toString().replace(' ','_'));
182 for(FlatMethod fm:blockMap.keySet()) {
183 System.out.println(fm.printMethod());
185 for(Map.Entry<FlatNode, Graph> e:graphMap.entrySet()) {
186 FlatNode fn=e.getKey();
187 Graph g=e.getValue();
188 plotGraph(g,"FN"+fn.toString()+debugindex);
193 State.logEvent("Done With Pointer Analysis");
197 effectsAnalysis.buildStateMachines.writeStateMachines();
198 State.logEvent("Done Writing State Machines");
202 void plotGraph(Graph g, String name) {
204 PrintWriter pw=new PrintWriter(new FileWriter(name.toString().replace(' ','_')+".dot"));
205 g.printGraph(pw, name);
207 } catch (Exception ex) {
208 ex.printStackTrace();
213 /* This function builds the last delta for a basic block. It
214 * handles the case for the first time the basic block is
217 void buildInitDelta(Graph graph, Delta newDelta) {
218 //First compute the set of temps
219 HashSet<TempDescriptor> tmpSet=new HashSet<TempDescriptor>();
220 tmpSet.addAll(graph.varMap.keySet());
221 tmpSet.addAll(graph.parent.varMap.keySet());
223 //Next build the temp map part of the delta
224 for(TempDescriptor tmp:tmpSet) {
225 MySet<Edge> edgeSet=new MySet<Edge>();
227 if (graph.varMap.containsKey(tmp))
228 edgeSet.addAll(graph.varMap.get(tmp));
230 edgeSet.addAll(graph.parent.varMap.get(tmp));
231 newDelta.varedgeadd.put(tmp, edgeSet);
234 //Next compute the set of src allocnodes
235 HashSet<AllocNode> nodeSet=new HashSet<AllocNode>();
236 nodeSet.addAll(graph.nodeMap.keySet());
237 nodeSet.addAll(graph.parent.nodeMap.keySet());
239 for(AllocNode node:nodeSet) {
240 MySet<Edge> edgeSet=new MySet<Edge>();
242 if (graph.nodeMap.containsKey(node))
243 edgeSet.addAll(graph.nodeMap.get(node));
245 edgeSet.addAll(graph.parent.nodeMap.get(node));
246 newDelta.heapedgeadd.put(node, edgeSet);
249 if (graph.oldNodes.containsKey(node)) {
251 } else if (graph.parent.oldNodes.containsKey(node)) {
252 //parent graphs only contain true...no need to check
253 newDelta.addOldNodes.put(node, Boolean.TRUE);
257 for(AllocNode node:graph.oldNodes.keySet()) {
258 if (graph.oldNodes.get(node).booleanValue())
259 newDelta.addOldNodes.put(node, Boolean.TRUE);
262 for(AllocNode node:graph.parent.oldNodes.keySet()) {
263 //make sure child doesn't override
264 if (!graph.oldNodes.containsKey(node))
265 newDelta.addOldNodes.put(node, Boolean.TRUE);
268 newDelta.addNodeAges.addAll(graph.nodeAges);
269 newDelta.addNodeAges.addAll(graph.parent.nodeAges);
272 /* This function build the delta for the exit of a basic block. */
274 void generateFinalDelta(BBlock bblock, Delta delta, Graph graph) {
275 Delta newDelta=new Delta(null, false);
276 if (delta.getInit()) {
277 buildInitDelta(graph, newDelta);
279 /* We can break the old delta...it is done being used */
280 /* First we will build variable edges */
281 HashSet<TempDescriptor> tmpSet=new HashSet<TempDescriptor>();
282 tmpSet.addAll(delta.basevaredge.keySet());
283 tmpSet.addAll(delta.varedgeadd.keySet());
284 for(TempDescriptor tmp:tmpSet) {
285 /* Start with the new incoming edges */
286 MySet<Edge> newbaseedge=delta.basevaredge.get(tmp);
287 /* Remove the remove set */
288 if (newbaseedge==null)
289 newbaseedge=new MySet<Edge>();
290 newbaseedge.removeAll(delta.varedgeremove.get(tmp));
291 /* Add in the new set*/
292 newbaseedge.addAll(delta.varedgeadd.get(tmp));
293 /* Store the results */
294 newDelta.varedgeadd.put(tmp, newbaseedge);
296 delta.basevaredge.clear();
298 /* Next we build heap edges */
299 HashSet<AllocNode> nodeSet=new HashSet<AllocNode>();
300 nodeSet.addAll(delta.baseheapedge.keySet());
301 nodeSet.addAll(delta.heapedgeadd.keySet());
302 nodeSet.addAll(delta.heapedgeremove.keySet());
303 for(AllocNode node:nodeSet) {
304 /* Start with the new incoming edges */
305 MySet<Edge> newheapedge=new MySet<Edge>(delta.baseheapedge.get(node));
306 /* Remove the remove set */
307 MySet<Edge> removeset=delta.heapedgeremove.get(node);
310 newheapedge.removeAll(removeset);
312 /* Add in the add set */
313 MySet<Edge> settoadd=delta.heapedgeadd.get(node);
315 newheapedge.addAll(settoadd);
316 newDelta.heapedgeadd.put(node, newheapedge);
318 /* Remove the newly created edges..no need to propagate a diff for those */
319 if (removeset!=null) {
320 removeset.removeAll(delta.baseheapedge.get(node));
321 newDelta.heapedgeremove.put(node, removeset);
325 /* Compute new ages */
326 newDelta.addNodeAges.addAll(delta.baseNodeAges);
327 newDelta.addNodeAges.addAll(delta.addNodeAges);
328 HashSet<AllocNode> oldNodes=new HashSet<AllocNode>();
330 /* Compute whether old nodes survive */
331 oldNodes.addAll(delta.baseOldNodes.keySet());
332 oldNodes.addAll(delta.addOldNodes.keySet());
333 for(AllocNode node:oldNodes) {
334 if (delta.addOldNodes.containsKey(node)) {
335 if (delta.addOldNodes.get(node).booleanValue()) {
336 newDelta.addOldNodes.put(node, Boolean.TRUE);
339 if (delta.baseOldNodes.get(node).booleanValue()) {
340 newDelta.addOldNodes.put(node, Boolean.TRUE);
346 /* Now we need to propagate newdelta */
347 if (!newDelta.heapedgeadd.isEmpty()||!newDelta.heapedgeremove.isEmpty()||!newDelta.varedgeadd.isEmpty()||!newDelta.addNodeAges.isEmpty()||!newDelta.addOldNodes.isEmpty()) {
348 /* We have a delta to propagate */
349 if (returnMap.containsKey(bblock)) {
353 for(PPoint caller:returnMap.get(bblock)) {
354 //System.out.println("Sending Return BBlock to "+caller.getBBlock().nodes.get(caller.getIndex()).toString().replace(' ','_'));
357 newDelta.setBlock(caller);
358 toprocess.add(newDelta);
361 Delta d=newDelta.diffBlock(caller);
367 Vector<BBlock> blockvector=bblock.next();
368 for(int i=0;i<blockvector.size();i++) {
369 //System.out.println("Sending BBlock to "+blockvector.get(i).nodes.get(0).toString().replace(' ','_'));
372 newDelta.setBlock(new PPoint(blockvector.get(i)));
373 toprocess.add(newDelta);
375 Delta d=newDelta.diffBlock(new PPoint(blockvector.get(i)));
381 //System.out.println("EMPTY DELTA");
382 //System.out.println("delta");
384 //System.out.println("newDelta");
389 boolean isNEEDED(FlatNode node) {
390 switch(node.kind()) {
391 case FKind.FlatSetFieldNode: {
392 FlatSetFieldNode n=(FlatSetFieldNode)node;
393 return n.getSrc().getType().isPtr();
395 case FKind.FlatSetElementNode: {
396 FlatSetElementNode n=(FlatSetElementNode)node;
397 return n.getSrc().getType().isPtr();
399 case FKind.FlatFieldNode: {
400 FlatFieldNode n=(FlatFieldNode)node;
401 return n.getDst().getType().isPtr();
403 case FKind.FlatElementNode: {
404 FlatElementNode n=(FlatElementNode)node;
405 return n.getDst().getType().isPtr();
411 Delta processNode(BBlock bblock, int index, FlatNode node, Delta delta, Graph newgraph) {
412 switch(node.kind()) {
414 return processNewNode((FlatNew)node, delta, newgraph);
415 case FKind.FlatFieldNode:
416 case FKind.FlatElementNode:
417 return processFieldElementNode(node, delta, newgraph);
418 case FKind.FlatCastNode:
419 case FKind.FlatOpNode:
420 case FKind.FlatReturnNode:
421 return processCopyNode(node, delta, newgraph);
422 case FKind.FlatSetFieldNode:
423 case FKind.FlatSetElementNode:
424 return processSetFieldElementNode(node, delta, newgraph);
425 case FKind.FlatSESEEnterNode:
426 return processSESEEnterNode((FlatSESEEnterNode) node, delta, newgraph);
427 case FKind.FlatSESEExitNode:
428 return processSESEExitNode((FlatSESEExitNode) node, delta, newgraph);
429 case FKind.FlatMethod:
431 case FKind.FlatBackEdge:
432 case FKind.FlatGenReachNode:
433 return processFlatNop(node, delta, newgraph);
435 return processFlatCall(bblock, index, (FlatCall) node, delta, newgraph);
437 throw new Error("Unrecognized node:"+node);
441 Delta processSESEEnterNode(FlatSESEEnterNode sese, Delta delta, Graph graph) {
443 return processFlatNop(sese, delta, graph);
444 if (delta.getInit()) {
445 removeInitTaints(null, delta, graph);
446 for (TempDescriptor tmp:sese.getInVarSet()) {
447 Taint taint=Taint.factory(sese, null, tmp, AllocFactory.dummySite, sese, ReachGraph.predsEmpty);
448 MySet<Edge> edges=GraphManip.getEdges(graph, delta, tmp);
450 Edge newe=e.addTaint(taint);
451 delta.addVarEdge(newe);
455 removeDiffTaints(null, delta);
456 for (TempDescriptor tmp:sese.getInVarSet()) {
457 Taint taint=Taint.factory(sese, null, tmp, AllocFactory.dummySite, sese, ReachGraph.predsEmpty);
458 MySet<Edge> edges=GraphManip.getDiffEdges(delta, tmp);
460 Edge newe=e.addTaint(taint);
461 delta.addVarEdge(newe);
467 applyDiffs(graph, delta);
471 private boolean isRecursive(FlatSESEEnterNode sese) {
472 MethodDescriptor md=sese.getmdEnclosing();
473 boolean isrecursive=callGraph.getCalleeSet(md).contains(md);
477 Delta processSESEExitNode(FlatSESEExitNode seseexit, Delta delta, Graph graph) {
479 return processFlatNop(seseexit, delta, graph);
480 FlatSESEEnterNode sese=seseexit.getFlatEnter();
481 //Strip Taints from this SESE
482 if (delta.getInit()) {
483 removeInitTaints(isRecursive(sese)?null:sese, delta, graph);
485 removeDiffTaints(isRecursive(sese)?null:sese, delta);
487 applyDiffs(graph, delta);
491 void removeDiffTaints(FlatSESEEnterNode sese, Delta delta) {
492 //Start with variable edges
494 MySet<Edge> edgestoadd=new MySet<Edge>();
495 MySet<Edge> edgestoremove=new MySet<Edge>();
497 //Process base diff edges
498 processEdgeMap(sese, delta.basevaredge, null, delta.varedgeremove, edgestoremove, edgestoadd);
499 //Process delta edges
500 processEdgeMap(sese, delta.varedgeadd, null, null, edgestoremove, edgestoadd);
501 for(Edge e:edgestoremove) {
502 delta.removeVarEdge(e);
504 for(Edge e:edgestoadd) {
511 MySet<Edge> edgestoadd=new MySet<Edge>();
512 MySet<Edge> edgestoremove=new MySet<Edge>();
514 //Process base diff edges
515 processEdgeMap(sese, delta.baseheapedge, null, delta.heapedgeremove, edgestoremove, edgestoadd);
516 //Process delta edges
517 processEdgeMap(sese, delta.heapedgeadd, null, null, edgestoremove, edgestoadd);
518 for(Edge e:edgestoremove) {
519 delta.removeHeapEdge(e);
521 for(Edge e:edgestoadd) {
522 delta.addHeapEdge(e);
527 void removeInitTaints(FlatSESEEnterNode sese, Delta delta, Graph graph) {
528 //Start with variable edges
530 MySet<Edge> edgestoadd=new MySet<Edge>();
531 MySet<Edge> edgestoremove=new MySet<Edge>();
533 //Process parent edges
534 processEdgeMap(sese, graph.parent.varMap, graph.varMap, delta.varedgeremove, edgestoremove, edgestoadd);
535 //Process graph edges
536 processEdgeMap(sese, graph.varMap, null, delta.varedgeremove, edgestoremove, edgestoadd);
537 //Process delta edges
538 processEdgeMap(sese, delta.varedgeadd, null, null, edgestoremove, edgestoadd);
539 for(Edge e:edgestoremove) {
540 delta.removeVarEdge(e);
542 for(Edge e:edgestoadd) {
549 MySet<Edge> edgestoadd=new MySet<Edge>();
550 MySet<Edge> edgestoremove=new MySet<Edge>();
552 //Process parent edges
553 processEdgeMap(sese, graph.parent.nodeMap, graph.nodeMap, delta.heapedgeremove, edgestoremove, edgestoadd);
554 //Process graph edges
555 processEdgeMap(sese, graph.nodeMap, null, delta.heapedgeremove, edgestoremove, edgestoadd);
556 //Process delta edges
557 processEdgeMap(sese, delta.heapedgeadd, null, null, edgestoremove, edgestoadd);
558 for(Edge e:edgestoremove) {
559 delta.removeHeapEdge(e);
561 for(Edge e:edgestoadd) {
562 delta.addHeapEdge(e);
567 void processEdgeMap(FlatSESEEnterNode sese, HashMap<?, MySet<Edge>> edgemap, HashMap<?, MySet<Edge>> childmap, HashMap<?, MySet<Edge>> removemap, MySet<Edge> edgestoremove, MySet<Edge> edgestoadd) {
568 for(Map.Entry<?, MySet<Edge>> entry:edgemap.entrySet()) {
569 //If the parent map exists and overrides this entry, skip it
570 if (childmap!=null&&childmap.containsKey(entry.getKey()))
572 for(Edge e:entry.getValue()) {
573 //check whether this edge has been removed
574 if (removemap!=null&&removemap.containsKey(entry.getKey())&&
575 removemap.get(entry.getKey()).contains(e))
578 TaintSet ts=e.getTaints();
580 //update non-null taint set
582 newts=Canonical.removeInContextTaintsNP(ts, sese);
584 edgestoremove.add(e);
585 edgestoadd.add(e.changeTaintSet(newts));
591 /* This function compute the edges for the this variable for a
592 * callee if it exists. */
594 void processThisTargets(HashSet<ClassDescriptor> targetSet, Graph graph, Delta delta, Delta newDelta, HashSet<AllocNode> nodeset, Stack<AllocNode> tovisit, MySet<Edge> edgeset, TempDescriptor tmpthis, HashSet<AllocNode> oldnodeset) {
595 //Handle the this temp
597 MySet<Edge> edges=(oldnodeset!=null)?GraphManip.getDiffEdges(delta, tmpthis):GraphManip.getEdges(graph, delta, tmpthis);
598 newDelta.varedgeadd.put(tmpthis, (MySet<Edge>) edges.clone());
599 edgeset.addAll(edges);
601 AllocNode dstnode=e.dst;
602 if (!nodeset.contains(dstnode)&&(oldnodeset==null||!oldnodeset.contains(dstnode))) {
603 TypeDescriptor type=dstnode.getType();
604 if (!type.isArray()) {
605 targetSet.add(type.getClassDesc());
607 //arrays don't have code
608 targetSet.add(typeUtil.getClass(TypeUtil.ObjectClass));
610 nodeset.add(dstnode);
611 tovisit.add(dstnode);
617 /* This function compute the edges for a call's parameters. */
619 void processParams(Graph graph, Delta delta, Delta newDelta, HashSet<AllocNode> nodeset, Stack<AllocNode> tovisit, MySet<Edge> edgeset, FlatCall fcall, boolean diff) {
620 //Go through each temp
621 for(int i=0;i<fcall.numArgs();i++) {
622 TempDescriptor tmp=fcall.getArg(i);
623 MySet<Edge> edges=diff?GraphManip.getDiffEdges(delta, tmp):GraphManip.getEdges(graph, delta, tmp);
624 newDelta.varedgeadd.put(tmp, (MySet<Edge>) edges.clone());
625 edgeset.addAll(edges);
627 if (!nodeset.contains(e.dst)) {
635 /* This function computes the reachable nodes for a callee. */
637 void computeReachableNodes(Graph graph, Delta delta, Delta newDelta, HashSet<AllocNode> nodeset, Stack<AllocNode> tovisit, MySet<Edge> edgeset, HashSet<AllocNode> oldnodeset) {
638 while(!tovisit.isEmpty()) {
639 AllocNode node=tovisit.pop();
640 MySet<Edge> edges=GraphManip.getEdges(graph, delta, node);
641 if (!edges.isEmpty()) {
642 newDelta.heapedgeadd.put(node, Edge.makeOld(edges));
643 edgeset.addAll(edges);
645 if (!nodeset.contains(e.dst)&&(oldnodeset==null||!oldnodeset.contains(e.dst))) {
654 HashSet<MethodDescriptor> computeTargets(FlatCall fcall, Delta newDelta) {
655 TempDescriptor tmpthis=fcall.getThis();
656 MethodDescriptor md=fcall.getMethod();
657 HashSet<MethodDescriptor> targets=new HashSet<MethodDescriptor>();
662 for(Edge e:newDelta.varedgeadd.get(tmpthis)) {
663 AllocNode node=e.dst;
664 ClassDescriptor cd=node.getType().getClassDesc();
665 //Figure out exact method called and add to set
666 MethodDescriptor calledmd=cd.getCalledMethod(md);
667 targets.add(calledmd);
673 void fixMapping(FlatCall fcall, HashSet<MethodDescriptor> targets, MySet<Edge> oldedgeset, Delta newDelta, BBlock callblock, int callindex) {
674 Delta basedelta=null;
675 TempDescriptor tmpthis=fcall.getThis();
677 for(MethodDescriptor calledmd:targets) {
678 FlatMethod fm=state.getMethodFlat(calledmd);
679 boolean newmethod=false;
682 HashMap<TempDescriptor, TempDescriptor> tmpMap=new HashMap<TempDescriptor, TempDescriptor>();
685 tmpMap.put(tmpthis, fm.getParameter(offset++));
687 for(int i=0;i<fcall.numArgs();i++) {
688 TempDescriptor tmp=fcall.getArg(i);
689 tmpMap.put(tmp,fm.getParameter(i+offset));
692 //Get basicblock for the method
693 BasicBlock block=getBBlock(fm);
696 if (!callMap.containsKey(fcall)) {
697 callMap.put(fcall, new HashSet<BBlock>());
700 Delta returnDelta=null;
701 if (!callMap.get(fcall).contains(block.getStart())) {
702 callMap.get(fcall).add(block.getStart());
706 if (!returnMap.containsKey(block.getExit())) {
707 returnMap.put(block.getExit(), new HashSet<PPoint>());
709 returnMap.get(block.getExit()).add(new PPoint(callblock, callindex));
711 if (bbgraphMap.containsKey(block.getExit())) {
712 //Need to push existing results to current node
713 if (returnDelta==null) {
714 returnDelta=new Delta(null, false);
715 Vector<FlatNode> exitblocknodes=block.getExit().nodes();
716 FlatExit fexit=(FlatExit)exitblocknodes.get(exitblocknodes.size()-1);
717 buildInitDelta(graphMap.get(fexit), returnDelta);
718 if (!returnDelta.heapedgeadd.isEmpty()||!returnDelta.heapedgeremove.isEmpty()||!returnDelta.varedgeadd.isEmpty()) {
719 returnDelta.setBlock(new PPoint(callblock, callindex));
720 toprocess.add(returnDelta);
723 if (!returnDelta.heapedgeadd.isEmpty()||!returnDelta.heapedgeremove.isEmpty()||!returnDelta.varedgeadd.isEmpty()) {
724 toprocess.add(returnDelta.diffBlock(new PPoint(callblock, callindex)));
730 if (oldedgeset==null) {
731 //First build of this graph
732 //Build and enqueue delta...safe to just use existing delta
733 Delta d=newDelta.changeParams(tmpMap, new PPoint(block.getStart()));
734 //System.out.println("AProcessing "+block.getStart().nodes.get(0).toString().replace(' ','_'));
737 } else if (newmethod) {
738 if (basedelta==null) {
739 basedelta=newDelta.buildBase(oldedgeset);
741 //Build and enqueue delta
742 Delta d=basedelta.changeParams(tmpMap, new PPoint(block.getStart()));
743 //System.out.println("BProcessing "+block.getStart().nodes.get(0).toString().replace(' ','_'));
747 //Build and enqueue delta
748 Delta d=newDelta.changeParams(tmpMap, new PPoint(block.getStart()));
749 //System.out.println("CProcessing "+block.getStart().nodes.get(0).toString().replace(' ','_'));
757 /* This function computes all edges that start outside of the callee
758 * context and go into the callee context */
760 void computeExternalEdges(Graph graph, Delta delta, HashSet<AllocNode> nodeset, HashSet<AllocNode> deltaset, MySet<Edge> externaledgeset) {
761 //Do heap edges first
762 HashSet<AllocNode> externalnodes=new HashSet<AllocNode>();
763 externalnodes.addAll(delta.baseheapedge.keySet());
764 externalnodes.addAll(delta.heapedgeadd.keySet());
765 externalnodes.addAll(delta.heapedgeremove.keySet());
766 //remove allinternal nodes
767 externalnodes.removeAll(nodeset);
768 for(AllocNode extNode:externalnodes) {
769 //Compute set of edges from given node
770 MySet<Edge> edges=new MySet<Edge>(delta.baseheapedge.get(extNode));
771 edges.removeAll(delta.heapedgeremove.get(extNode));
772 edges.addAll(delta.heapedgeadd.get(extNode));
775 if (nodeset.contains(e.dst))
776 externaledgeset.add(e);
781 HashSet<TempDescriptor> temps=new HashSet<TempDescriptor>();
782 temps.addAll(delta.basevaredge.keySet());
783 temps.addAll(delta.varedgeadd.keySet());
784 temps.addAll(delta.varedgeremove.keySet());
785 //remove allinternal nodes
786 temps.removeAll(nodeset);
788 for(TempDescriptor tmp:temps) {
789 //Compute set of edges from given node
790 MySet<Edge> edges=new MySet<Edge>(delta.basevaredge.get(tmp));
792 edges.removeAll(delta.varedgeremove.get(tmp));
793 edges.addAll(delta.varedgeadd.get(tmp));
796 if (nodeset.contains(e.dst))
797 externaledgeset.add(e);
802 /* This function removes the caller reachable edges from the
805 void removeEdges(Graph graph, Delta delta, HashSet<AllocNode> nodeset, MySet<Edge> edgeset, MySet<Edge> externaledgeset) {
806 //Want to remove the set of internal edges
807 for(Edge e:edgeset) {
808 if (e.src!=null&&!graph.callerEdges.contains(e)) {
809 delta.removeHeapEdge(e);
813 //Want to remove the set of external edges
814 for(Edge e:externaledgeset) {
815 //want to remove the set of internal edges
816 if (!graph.callerEdges.contains(e))
821 Delta processFlatCall(BBlock callblock, int callindex, FlatCall fcall, Delta delta, Graph graph) {
822 Delta newDelta=new Delta(null, false);
824 if (delta.getInit()) {
825 MySet<Edge> edgeset=new MySet<Edge>();
826 MySet<Edge> externaledgeset=new MySet<Edge>();
827 HashSet<AllocNode> nodeset=new HashSet<AllocNode>();
828 HashSet<ClassDescriptor> targetSet=new HashSet<ClassDescriptor>();
829 Stack<AllocNode> tovisit=new Stack<AllocNode>();
830 TempDescriptor tmpthis=fcall.getThis();
831 graph.callerEdges=new MySet<Edge>();
833 //Handle the this temp
834 processThisTargets(targetSet, graph, delta, newDelta, nodeset, tovisit, edgeset, tmpthis, null);
836 //Go through each temp
837 processParams(graph, delta, newDelta, nodeset, tovisit, edgeset, fcall, false);
839 //Traverse all reachable nodes
840 computeReachableNodes(graph, delta, newDelta, nodeset, tovisit, edgeset, null);
842 //Compute call targets
843 HashSet<MethodDescriptor> newtargets=computeTargets(fcall, newDelta);
846 fixMapping(fcall, newtargets, null, newDelta, callblock, callindex);
848 //Compute edges into region to splice out
849 computeExternalEdges(graph, delta, nodeset, null, externaledgeset);
851 //Splice out internal edges
852 removeEdges(graph, delta, nodeset, edgeset, externaledgeset);
854 //store data structures
855 graph.externalEdgeSet=externaledgeset;
856 graph.reachNode=nodeset;
857 graph.reachEdge=edgeset;
859 graph.callTargets=newtargets;
860 graph.callNodeAges=new HashSet<AllocNode>();
861 graph.callOldNodes=new HashSet<AllocNode>();
862 graph.callNewEdges=new HashMap<AllocNode, MySet<Edge>>();
863 graph.callOldEdges=new HashMap<Edge,MySet<Edge>>();
865 //Apply diffs to graph
866 applyDiffs(graph, delta, true);
868 MySet<Edge> edgeset=new MySet<Edge>();
869 MySet<Edge> externaledgeset=new MySet<Edge>();
870 HashSet<AllocNode> nodeset=new HashSet<AllocNode>();
871 MySet<Edge> oldedgeset=graph.reachEdge;
872 HashSet<AllocNode> oldnodeset=graph.reachNode;
874 HashSet<ClassDescriptor> targetSet=new HashSet<ClassDescriptor>();
875 Stack<AllocNode> tovisit=new Stack<AllocNode>();
876 TempDescriptor tmpthis=fcall.getThis();
877 //Fix up delta to get rid of unnecessary heap edge removals
878 for(Map.Entry<AllocNode, MySet<Edge>> entry:delta.heapedgeremove.entrySet()) {
879 for(Iterator<Edge> eit=entry.getValue().iterator();eit.hasNext();) {
881 if (graph.callerEdges.contains(e))
886 //Fix up delta to get rid of unnecessary var edge removals
887 for(Map.Entry<TempDescriptor, MySet<Edge>> entry:delta.varedgeremove.entrySet()) {
888 for(Iterator<Edge> eit=entry.getValue().iterator();eit.hasNext();) {
890 if (graph.callerEdges.contains(e))
895 //Handle the this temp
896 processThisTargets(targetSet, graph, delta, newDelta, nodeset, tovisit, edgeset, tmpthis, oldnodeset);
898 //Go through each temp
899 processParams(graph, delta, newDelta, nodeset, tovisit, edgeset, fcall, true);
900 //Go through each new heap edge that starts from old node
901 MySet<Edge> newedges=GraphManip.getDiffEdges(delta, oldnodeset);
902 edgeset.addAll(newedges);
903 for(Edge e:newedges) {
904 //Add new edges that start from old node to newDelta
906 if (!newDelta.heapedgeadd.containsKey(src)) {
907 newDelta.heapedgeadd.put(src, new MySet<Edge>());
909 newDelta.heapedgeadd.get(src).add(e.makeOld());
910 if (!nodeset.contains(e.dst)&&!oldnodeset.contains(e.dst)) {
916 //Traverse all reachable nodes
917 computeReachableNodes(graph, delta, newDelta, nodeset, tovisit, edgeset, oldnodeset);
918 //Compute call targets
919 HashSet<MethodDescriptor> newtargets=computeTargets(fcall, newDelta);
920 graph.callTargets.addAll(newtargets);
922 //add in new nodeset and edgeset
923 oldnodeset.addAll(nodeset);
924 oldedgeset.addAll(edgeset);
926 fixMapping(fcall, graph.callTargets, oldedgeset, newDelta, callblock, callindex);
927 //Compute edges into region to splice out
928 computeExternalEdges(graph, delta, oldnodeset, nodeset, externaledgeset);
930 //Splice out internal edges
931 removeEdges(graph, delta, nodeset, edgeset, externaledgeset);
933 //Add external edges back in
934 processCallExternal(graph, delta, externaledgeset);
936 //Move new edges that should be summarized
937 processSummarization(graph, delta);
939 Set<FlatSESEEnterNode> seseCallers=OoOJava?taskAnalysis.getTransitiveExecutingRBlocks(fcall):null;
940 //Check if the new nodes allow us to insert a new edge
941 for(AllocNode node:nodeset) {
942 if (graph.callNewEdges.containsKey(node)) {
943 for(Iterator<Edge> eit=graph.callNewEdges.get(node).iterator();eit.hasNext();) {
945 if ((graph.callNodeAges.contains(e.src)||graph.reachNode.contains(e.src))&&
946 (graph.callNodeAges.contains(e.dst)||graph.reachNode.contains(e.dst))) {
947 Edge edgetoadd=e.copy();//we need our own copy to modify below
949 if (seseCallers!=null)
950 edgetoadd.taintModify(seseCallers);
951 mergeCallEdge(graph, delta, edgetoadd);
957 for(Edge e:edgeset) {
958 //See if these edges would allow an old edge to be added
959 if (graph.callOldEdges.containsKey(e)) {
960 for(Edge adde:graph.callOldEdges.get(e)) {
961 Edge ecopy=adde.copy();
962 ecopy.statuspredicate=e.statuspredicate;
963 mergeCallEdge(graph, delta, ecopy);
968 //Add in new external edges
969 graph.externalEdgeSet.addAll(externaledgeset);
970 //Apply diffs to graph
971 applyDiffs(graph, delta);
976 void processSummarization(Graph graph, Delta delta) {
977 processSumHeapEdgeSet(delta.heapedgeadd, delta, graph);
978 processSumHeapEdgeSet(delta.baseheapedge, delta, graph);
979 processSumVarEdgeSet(delta.varedgeadd, delta, graph);
980 processSumVarEdgeSet(delta.basevaredge, delta, graph);
983 void processSumVarEdgeSet(HashMap<TempDescriptor, MySet<Edge>> map, Delta delta, Graph graph) {
984 MySet<Edge> edgestoadd=new MySet<Edge>();
985 MySet<Edge> edgestoremove=new MySet<Edge>();
986 for(Iterator<Map.Entry<TempDescriptor, MySet<Edge>>> eit=map.entrySet().iterator();eit.hasNext();) {
987 Map.Entry<TempDescriptor, MySet<Edge>> entry=eit.next();
988 MySet<Edge> edgeset=entry.getValue();
990 for(Edge e:edgeset) {
992 boolean rewrite=false;
993 if (copy.dst!=null&&graph.callNodeAges.contains(copy.dst)) {
994 copy.dst=allocFactory.getAllocNode(copy.dst, true);
998 edgestoremove.add(e);
999 edgestoadd.add(copy);
1003 for(Edge e:edgestoremove) {
1004 delta.removeVarEdge(e);
1006 for(Edge e:edgestoadd) {
1007 delta.addVarEdge(e);
1011 public Alloc getAllocationSiteFromFlatNew(FlatNew node) {
1012 return allocFactory.getAllocNode(node, false).getAllocSite();
1015 void processSumHeapEdgeSet(HashMap<AllocNode, MySet<Edge>> map, Delta delta, Graph graph) {
1016 MySet<Edge> edgestoadd=new MySet<Edge>();
1017 MySet<Edge> edgestoremove=new MySet<Edge>();
1018 for(Iterator<Map.Entry<AllocNode, MySet<Edge>>> eit=map.entrySet().iterator();eit.hasNext();) {
1019 Map.Entry<AllocNode, MySet<Edge>> entry=eit.next();
1020 AllocNode node=entry.getKey();
1021 MySet<Edge> edgeset=entry.getValue();
1023 for(Edge e:edgeset) {
1025 boolean rewrite=false;
1026 if (copy.src!=null&&graph.callNodeAges.contains(copy.src)) {
1027 copy.src=allocFactory.getAllocNode(copy.src, true);
1030 if (copy.dst!=null&&graph.callNodeAges.contains(copy.dst)) {
1031 copy.dst=allocFactory.getAllocNode(copy.dst, true);
1035 edgestoremove.add(e);
1036 edgestoadd.add(copy);
1040 for(Edge e:edgestoremove) {
1041 delta.removeHeapEdge(e);
1043 for(Edge e:edgestoadd) {
1044 delta.addHeapEdge(e);
1048 //Handle external edges
1049 void processCallExternal(Graph graph, Delta newDelta, MySet<Edge> externalEdgeSet) {
1050 //Add external edges in
1051 for(Edge e:externalEdgeSet) {
1052 //First did we age the source
1053 Edge newedge=e.copy();
1054 if (newedge.src!=null&&!e.src.isSummary()&&graph.callNodeAges.contains(e.src)) {
1055 AllocNode summaryNode=allocFactory.getAllocNode(newedge.src, true);
1056 newedge.src=summaryNode;
1059 if (graph.callNodeAges.contains(e.dst)&&!e.dst.isSummary()) {
1060 if (graph.callOldNodes.contains(e.dst)) {
1062 Edge copy=newedge.copy();
1063 mergeEdge(graph, newDelta, copy);
1065 //Now add summarized node
1066 newedge.dst=allocFactory.getAllocNode(newedge.dst, true);
1067 mergeCallEdge(graph, newDelta, newedge);
1069 //Add edge to single node
1070 mergeEdge(graph, newDelta, newedge);
1075 /* This function applies callee deltas to the caller heap. */
1077 Delta applyCallDelta(Delta delta, BBlock bblock) {
1078 Delta newDelta=new Delta(null, false);
1079 Vector<FlatNode> nodes=bblock.nodes();
1080 PPoint ppoint=delta.getBlock();
1081 FlatCall fcall=(FlatCall)nodes.get(ppoint.getIndex());
1082 Graph graph=graphMap.get(fcall);
1083 Graph oldgraph=(ppoint.getIndex()==0)?
1084 bbgraphMap.get(bblock):
1085 graphMap.get(nodes.get(ppoint.getIndex()-1));
1086 Set<FlatSESEEnterNode> seseCallers=OoOJava?taskAnalysis.getTransitiveExecutingRBlocks(fcall):null;
1088 //Age outside nodes if necessary
1089 for(Iterator<AllocNode> nodeit=delta.addNodeAges.iterator();nodeit.hasNext();) {
1090 AllocNode node=nodeit.next();
1091 if (!graph.callNodeAges.contains(node)) {
1092 graph.callNodeAges.add(node);
1093 newDelta.addNodeAges.add(node);
1095 if (!graph.reachNode.contains(node)&&!node.isSummary()) {
1096 /* Need to age node in existing graph*/
1097 summarizeInGraph(graph, newDelta, node);
1099 if (graph.callNewEdges.containsKey(node)) {
1100 for(Iterator<Edge> eit=graph.callNewEdges.get(node).iterator();eit.hasNext();) {
1102 if ((graph.callNodeAges.contains(e.src)||graph.reachNode.contains(e.src))&&
1103 (graph.callNodeAges.contains(e.dst)||graph.reachNode.contains(e.dst))) {
1104 Edge edgetoadd=e.copy();//we need our own copy to modify below
1106 if (seseCallers!=null)
1107 edgetoadd.taintModify(seseCallers);
1108 mergeCallEdge(graph, newDelta, edgetoadd);
1115 for(Map.Entry<AllocNode, MySet<Edge>> entry:delta.heapedgeadd.entrySet()) {
1116 for(Edge e:entry.getValue()) {
1117 boolean addedge=false;
1118 Edge edgetoadd=null;
1119 if (e.statuspredicate==Edge.NEW) {
1120 if ((graph.callNodeAges.contains(e.src)||graph.reachNode.contains(e.src))&&
1121 (graph.callNodeAges.contains(e.dst)||graph.reachNode.contains(e.dst))) {
1122 edgetoadd=e.copy();//we need our own copy to modify below
1124 graph.addCallEdge(e);
1127 Edge[] edgeArray=e.makeStatus(allocFactory);
1129 int statuspredicate=0;
1130 for(int i=0;i<edgeArray.length;i++) {
1131 Edge origEdgeKey=edgeArray[i];
1132 if (graph.reachEdge.contains(origEdgeKey)) {
1133 Edge origEdge=graph.reachEdge.get(origEdgeKey);
1134 //copy the predicate
1135 statuspredicate=statuspredicate|origEdge.statuspredicate;
1137 if (!graph.callOldEdges.containsKey(origEdgeKey)) {
1138 graph.callOldEdges.put(origEdgeKey, new MySet<Edge>());
1140 if (graph.callOldEdges.get(origEdgeKey).contains(e)) {
1141 Edge olde=graph.callOldEdges.get(origEdgeKey).get(e);
1142 graph.callOldEdges.get(origEdgeKey).add(olde.merge(e));
1144 graph.callOldEdges.get(origEdgeKey).add(e);
1147 if (statuspredicate!=0) {
1149 newe.statuspredicate=statuspredicate;
1153 if (seseCallers!=null&&edgetoadd!=null)
1154 edgetoadd.taintModify(seseCallers);
1155 mergeCallEdge(graph, newDelta, edgetoadd);
1159 processCallExternal(graph, newDelta, graph.externalEdgeSet);
1161 //Add edge for return value
1162 if (fcall.getReturnTemp()!=null) {
1163 MySet<Edge> returnedge=delta.varedgeadd.get(returntmp);
1164 if (returnedge!=null)
1165 for(Edge e:returnedge) {
1166 Edge newedge=e.copy();
1167 newedge.srcvar=fcall.getReturnTemp();
1168 if (seseCallers!=null)
1169 newedge.taintModify(seseCallers);
1170 if (graph.getEdges(fcall.getReturnTemp())==null||!graph.getEdges(fcall.getReturnTemp()).contains(newedge))
1171 newDelta.addEdge(newedge);
1174 applyDiffs(graph, newDelta);
1178 public void mergeEdge(Graph graph, Delta newDelta, Edge edgetoadd) {
1179 if (edgetoadd!=null) {
1180 Edge match=graph.getMatch(edgetoadd);
1182 if (match==null||!match.subsumes(edgetoadd)) {
1183 Edge mergededge=edgetoadd.merge(match);
1184 newDelta.addEdge(mergededge);
1189 /* This is a call produced edge...need to remember this */
1191 public void mergeCallEdge(Graph graph, Delta newDelta, Edge edgetoadd) {
1192 if (edgetoadd!=null) {
1193 newDelta.addEdgeClear(edgetoadd);
1195 Edge match=graph.getMatch(edgetoadd);
1197 if (match==null||!match.subsumes(edgetoadd)) {
1198 Edge mergededge=edgetoadd.merge(match);
1199 newDelta.addEdge(mergededge);
1200 graph.callerEdges.add(mergededge);
1206 /* Summarizes out of context nodes in graph */
1207 void summarizeInGraph(Graph graph, Delta newDelta, AllocNode singleNode) {
1208 AllocNode summaryNode=allocFactory.getAllocNode(singleNode, true);
1210 //Handle outgoing heap edges
1211 MySet<Edge> edgeset=graph.getEdges(singleNode);
1213 for(Edge e:edgeset) {
1214 Edge rewrite=e.rewrite(singleNode, summaryNode);
1216 newDelta.removeHeapEdge(e);
1217 mergeCallEdge(graph, newDelta, rewrite);
1220 //Handle incoming edges
1221 MySet<Edge> backedges=graph.getBackEdges(singleNode);
1222 for(Edge e:backedges) {
1223 if (e.dst==singleNode) {
1224 //Need to get original edge so that predicate will be correct
1225 Edge match=graph.getMatch(e);
1227 Edge rewrite=match.rewrite(singleNode, summaryNode);
1228 newDelta.removeEdge(match);
1229 mergeCallEdge(graph, newDelta, rewrite);
1235 void applyDiffs(Graph graph, Delta delta) {
1236 applyDiffs(graph, delta, false);
1239 void applyDiffs(Graph graph, Delta delta, boolean genbackwards) {
1240 //build backwards map if requested
1241 if (genbackwards&&graph.backMap==null) {
1242 graph.backMap=new HashMap<AllocNode, MySet<Edge>>();
1243 if (graph.parent.backMap==null) {
1244 graph.parent.backMap=new HashMap<AllocNode, MySet<Edge>>();
1245 for(Map.Entry<AllocNode, MySet<Edge>> entry:graph.nodeMap.entrySet()) {
1246 for(Edge e:entry.getValue()) {
1247 if (!graph.parent.backMap.containsKey(e.dst))
1248 graph.parent.backMap.put(e.dst, new MySet<Edge>());
1249 graph.parent.backMap.get(e.dst).add(e);
1252 for(Map.Entry<TempDescriptor, MySet<Edge>> entry:graph.varMap.entrySet()) {
1253 for(Edge e:entry.getValue()) {
1254 if (!graph.parent.backMap.containsKey(e.dst))
1255 graph.parent.backMap.put(e.dst, new MySet<Edge>());
1256 graph.parent.backMap.get(e.dst).add(e);
1262 //Add hidden base edges
1263 for(Map.Entry<AllocNode, MySet<Edge>> e: delta.baseheapedge.entrySet()) {
1264 AllocNode node=e.getKey();
1265 MySet<Edge> edges=e.getValue();
1266 if (graph.nodeMap.containsKey(node)) {
1267 MySet<Edge> nodeEdges=graph.nodeMap.get(node);
1268 nodeEdges.addAll(edges);
1273 for(Map.Entry<AllocNode, MySet<Edge>> e: delta.heapedgeremove.entrySet()) {
1274 AllocNode node=e.getKey();
1275 MySet<Edge> edgestoremove=e.getValue();
1276 if (graph.nodeMap.containsKey(node)) {
1277 //Just apply diff to current map
1278 graph.nodeMap.get(node).removeAll(edgestoremove);
1280 //Generate diff from parent graph
1281 MySet<Edge> parentedges=graph.parent.nodeMap.get(node);
1282 if (parentedges!=null) {
1283 MySet<Edge> newedgeset=Util.setSubtract(parentedges, edgestoremove);
1284 graph.nodeMap.put(node, newedgeset);
1290 for(Map.Entry<AllocNode, MySet<Edge>> e: delta.heapedgeadd.entrySet()) {
1291 AllocNode node=e.getKey();
1292 MySet<Edge> edgestoadd=e.getValue();
1293 //If we have not done a subtract, then
1294 if (!graph.nodeMap.containsKey(node)) {
1295 //Copy the parent entry
1296 if (graph.parent.nodeMap.containsKey(node))
1297 graph.nodeMap.put(node, (MySet<Edge>)graph.parent.nodeMap.get(node).clone());
1299 graph.nodeMap.put(node, new MySet<Edge>());
1301 Edge.mergeEdgesInto(graph.nodeMap.get(node),edgestoadd);
1303 for(Edge eadd:edgestoadd) {
1304 if (!graph.backMap.containsKey(eadd.dst))
1305 graph.backMap.put(eadd.dst, new MySet<Edge>());
1306 graph.backMap.get(eadd.dst).add(eadd);
1312 for(Map.Entry<TempDescriptor, MySet<Edge>> e: delta.varedgeremove.entrySet()) {
1313 TempDescriptor tmp=e.getKey();
1314 MySet<Edge> edgestoremove=e.getValue();
1316 if (graph.varMap.containsKey(tmp)) {
1317 //Just apply diff to current map
1318 graph.varMap.get(tmp).removeAll(edgestoremove);
1319 } else if (graph.parent.varMap.containsKey(tmp)) {
1320 //Generate diff from parent graph
1321 MySet<Edge> parentedges=graph.parent.varMap.get(tmp);
1322 MySet<Edge> newedgeset=Util.setSubtract(parentedges, edgestoremove);
1323 graph.varMap.put(tmp, newedgeset);
1328 for(Map.Entry<TempDescriptor, MySet<Edge>> e: delta.varedgeadd.entrySet()) {
1329 TempDescriptor tmp=e.getKey();
1330 MySet<Edge> edgestoadd=e.getValue();
1331 if (graph.varMap.containsKey(tmp)) {
1332 Edge.mergeEdgesInto(graph.varMap.get(tmp), edgestoadd);
1334 graph.varMap.put(tmp, (MySet<Edge>) edgestoadd.clone());
1336 for(Edge eadd:edgestoadd) {
1337 if (!graph.backMap.containsKey(eadd.dst))
1338 graph.backMap.put(eadd.dst, new MySet<Edge>());
1339 graph.backMap.get(eadd.dst).add(eadd);
1344 //Add node additions
1345 for(AllocNode node:delta.addNodeAges) {
1346 graph.nodeAges.add(node);
1349 for(Map.Entry<AllocNode, Boolean> nodeentry:delta.addOldNodes.entrySet()) {
1350 AllocNode node=nodeentry.getKey();
1351 Boolean ispresent=nodeentry.getValue();
1352 graph.oldNodes.put(node, ispresent);
1355 Delta processSetFieldElementNode(FlatNode node, Delta delta, Graph graph) {
1359 if (node.kind()==FKind.FlatSetElementNode) {
1360 FlatSetElementNode fen=(FlatSetElementNode) node;
1365 FlatSetFieldNode ffn=(FlatSetFieldNode) node;
1371 if (delta.getInit()) {
1372 MySet<Edge> dstEdges=GraphManip.getEdges(graph, delta, dst);
1374 if (OoOJava&&!accessible.isAccessible(node, dst)) {
1375 Taint dstStallTaint=Taint.factory(node, dst, AllocFactory.dummySite, node, ReachGraph.predsEmpty);
1376 dstEdges=Edge.taintAll(dstEdges, dstStallTaint);
1377 updateVarDelta(graph, delta, dst, dstEdges, null);
1380 effectsAnalysis.analyzeFlatSetFieldNode(dstEdges, fd, node);
1383 //Do nothing for non pointers
1384 if (!src.getType().isPtr()) {
1388 MySet<Edge> srcEdges=GraphManip.getEdges(graph, delta, src);
1389 if (OoOJava&&!accessible.isAccessible(node, src)) {
1390 Taint srcStallTaint=Taint.factory(node, src, AllocFactory.dummySite, node, ReachGraph.predsEmpty);
1391 srcEdges=Edge.taintAll(srcEdges, srcStallTaint);
1392 updateVarDelta(graph, delta, src, srcEdges, null);
1395 MySet<Edge> edgesToAdd=GraphManip.genEdges(dstEdges, fd, srcEdges);
1396 MySet<Edge> edgesToRemove=null;
1397 if (dstEdges.size()==1&&!dstEdges.iterator().next().dst.isSummary()&&fd!=null) {
1398 /* Can do a strong update */
1399 edgesToRemove=GraphManip.getEdges(graph, delta, dstEdges, fd);
1400 graph.strongUpdateSet=edgesToRemove;
1402 graph.strongUpdateSet=new MySet<Edge>();
1405 updateHeapDelta(graph, delta, edgesToAdd, edgesToRemove);
1406 applyDiffs(graph, delta);
1408 MySet<Edge> newDstEdges=GraphManip.getDiffEdges(delta, dst);
1410 if (OoOJava&&!accessible.isAccessible(node, dst)) {
1411 Taint dstStallTaint=Taint.factory(node, dst, AllocFactory.dummySite, node, ReachGraph.predsEmpty);
1412 newDstEdges=Edge.taintAll(newDstEdges, dstStallTaint);
1413 updateVarDelta(graph, delta, dst, newDstEdges, null);
1417 effectsAnalysis.analyzeFlatSetFieldNode(newDstEdges, fd, node);
1420 if (!src.getType().isPtr()) {
1424 /* Next look at new sources */
1426 MySet<Edge> edgesToAdd=new MySet<Edge>();
1427 MySet<Edge> newSrcEdges=GraphManip.getDiffEdges(delta, src);
1428 MySet<Edge> srcEdges=GraphManip.getEdges(graph, delta, src);
1429 HashSet<AllocNode> dstNodes=GraphManip.getNodes(graph, delta, dst);
1431 if (OoOJava&&!accessible.isAccessible(node, src)) {
1432 Taint srcStallTaint=Taint.factory(node, src, AllocFactory.dummySite, node, ReachGraph.predsEmpty);
1433 newSrcEdges=Edge.taintAll(newSrcEdges, srcStallTaint);
1434 updateVarDelta(graph, delta, src, newSrcEdges, null);
1437 MySet<Edge> edgesToRemove=null;
1438 if (newDstEdges.size()!=0) {
1439 if (dstNodes.size()>1&&!dstNodes.iterator().next().isSummary()&&fd!=null) {
1440 /* Need to undo strong update */
1441 if (graph.strongUpdateSet!=null) {
1442 edgesToAdd.addAll(graph.strongUpdateSet);
1443 graph.strongUpdateSet=null; //Prevent future strong updates
1445 } else if (dstNodes.size()==1&&newDstEdges.size()==1&&!newDstEdges.iterator().next().dst.isSummary()&&graph.strongUpdateSet!=null&&fd!=null) {
1446 edgesToRemove=GraphManip.getEdges(graph, delta, dstNodes, fd);
1447 graph.strongUpdateSet.addAll(edgesToRemove);
1449 Edge.mergeEdgesInto(edgesToAdd, GraphManip.genEdges(newDstEdges, fd, srcEdges));
1453 if (graph.strongUpdateSet!=null&&fd!=null) {
1454 MySet<Edge> otherEdgesToRemove=GraphManip.getDiffEdges(delta, dstNodes, fd);
1455 if (edgesToRemove!=null)
1456 edgesToRemove.addAll(otherEdgesToRemove);
1458 edgesToRemove=otherEdgesToRemove;
1459 graph.strongUpdateSet.addAll(otherEdgesToRemove);
1462 //Next look at new destinations
1463 Edge.mergeEdgesInto(edgesToAdd, GraphManip.genEdges(dstNodes, fd, newSrcEdges));
1466 updateHeapDelta(graph, delta, edgesToAdd, edgesToRemove);
1467 applyDiffs(graph, delta);
1472 Delta processCopyNode(FlatNode node, Delta delta, Graph graph) {
1475 if (node.kind()==FKind.FlatOpNode) {
1476 FlatOpNode fon=(FlatOpNode) node;
1479 } else if (node.kind()==FKind.FlatReturnNode) {
1480 FlatReturnNode frn=(FlatReturnNode)node;
1481 src=frn.getReturnTemp();
1483 if (src==null||!src.getType().isPtr()) {
1485 applyDiffs(graph, delta);
1489 FlatCastNode fcn=(FlatCastNode) node;
1493 if (delta.getInit()) {
1494 MySet<Edge> srcedges=GraphManip.getEdges(graph, delta, src);
1495 MySet<Edge> edgesToAdd=GraphManip.genEdges(dst, srcedges);
1496 MySet<Edge> edgesToRemove=GraphManip.getEdges(graph, delta, dst);
1497 updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove);
1498 applyDiffs(graph, delta);
1500 /* First compute new src nodes */
1501 MySet<Edge> newSrcEdges=GraphManip.getDiffEdges(delta, src);
1503 /* Compute the union, and then the set of edges */
1504 MySet<Edge> edgesToAdd=GraphManip.genEdges(dst, newSrcEdges);
1506 /* Compute set of edges to remove */
1507 MySet<Edge> edgesToRemove=GraphManip.getDiffEdges(delta, dst);
1510 updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove);
1511 applyDiffs(graph, delta);
1516 Delta processFieldElementNode(FlatNode node, Delta delta, Graph graph) {
1520 TaintSet taint=null;
1522 if (node.kind()==FKind.FlatElementNode) {
1523 FlatElementNode fen=(FlatElementNode) node;
1528 FlatFieldNode ffn=(FlatFieldNode) node;
1533 if (OoOJava&&!accessible.isAccessible(node, src)) {
1534 taint=TaintSet.factory(Taint.factory(node, src, AllocFactory.dummySite, node, ReachGraph.predsEmpty));
1537 //Do nothing for non pointers
1538 if (delta.getInit()) {
1539 MySet<Edge> srcedges=GraphManip.getEdges(graph, delta, src);
1542 srcedges=Edge.taintAll(srcedges, taint);
1543 updateVarDelta(graph, delta, src, srcedges, null);
1545 effectsAnalysis.analyzeFlatFieldNode(srcedges, fd, node);
1547 if (!dst.getType().isPtr())
1550 MySet<Edge> edgesToAdd=GraphManip.dereference(graph, delta, dst, srcedges, fd, node);
1551 MySet<Edge> edgesToRemove=GraphManip.getEdges(graph, delta, dst);
1553 updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove);
1554 applyDiffs(graph, delta);
1556 MySet<Edge> newsrcedges=GraphManip.getDiffEdges(delta, src);
1559 newsrcedges=Edge.taintAll(newsrcedges, taint);
1560 updateVarDelta(graph, delta, src, newsrcedges, null);
1562 effectsAnalysis.analyzeFlatFieldNode(newsrcedges, fd, node);
1564 if (!dst.getType().isPtr())
1567 /* First compute new objects we read fields of */
1568 MySet<Edge> allsrcedges=GraphManip.getEdges(graph, delta, src);
1569 MySet<Edge> edgesToAdd=GraphManip.diffDereference(delta, dst, allsrcedges, fd, node);
1570 /* Next compute new targets of fields */
1571 MySet<Edge> newfdedges=GraphManip.dereference(graph, delta, dst, newsrcedges, fd, node);
1573 /* Compute the union, and then the set of edges */
1574 Edge.mergeEdgesInto(edgesToAdd, newfdedges);
1576 /* Compute set of edges to remove */
1577 MySet<Edge> edgesToRemove=GraphManip.getDiffEdges(delta, dst);
1581 updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove);
1582 applyDiffs(graph, delta);
1588 void updateVarDelta(Graph graph, Delta delta, TempDescriptor tmp, MySet<Edge> edgestoAdd, MySet<Edge> edgestoRemove) {
1589 MySet<Edge> edgeAdd=delta.varedgeadd.get(tmp);
1590 MySet<Edge> edgeRemove=delta.varedgeremove.get(tmp);
1591 MySet<Edge> existingEdges=graph.getEdges(tmp);
1592 if (edgestoRemove!=null)
1593 for(Edge e: edgestoRemove) {
1594 //remove edge from delta
1597 //if the edge is already in the graph, add an explicit remove to the delta
1598 if (existingEdges.contains(e))
1599 delta.removeVarEdge(e);
1601 for(Edge e: edgestoAdd) {
1602 //Remove the edge from the remove set
1603 if (edgeRemove!=null)
1604 edgeRemove.remove(e);
1605 //Explicitly add it to the add set unless it is already in the graph
1606 if (typeUtil.isSuperorType(tmp.getType(), e.dst.getType())) {
1607 if (!existingEdges.contains(e)) {
1608 delta.addVarEdge(e);
1610 //See if the old edge subsumes the new one
1611 Edge olde=existingEdges.get(e);
1612 if (!olde.subsumes(e)) {
1613 delta.addVarEdge(olde.merge(e));
1620 void updateHeapDelta(Graph graph, Delta delta, MySet<Edge> edgestoAdd, MySet<Edge> edgestoRemove) {
1621 if (edgestoRemove!=null)
1622 for(Edge e: edgestoRemove) {
1623 AllocNode src=e.src;
1624 MySet<Edge> edgeAdd=delta.heapedgeadd.get(src);
1625 MySet<Edge> existingEdges=graph.getEdges(src);
1626 //remove edge from delta
1629 //if the edge is already in the graph, add an explicit remove to the delta
1630 if (existingEdges.contains(e)) {
1631 delta.removeHeapEdge(e);
1634 if (edgestoAdd!=null)
1635 for(Edge e: edgestoAdd) {
1636 AllocNode src=e.src;
1637 MySet<Edge> edgeRemove=delta.heapedgeremove.get(src);
1638 MySet<Edge> existingEdges=graph.getEdges(src);
1639 //Remove the edge from the remove set
1640 if (edgeRemove!=null)
1641 edgeRemove.remove(e);
1642 //Explicitly add it to the add set unless it is already in the graph
1643 if (!existingEdges.contains(e)) {
1644 delta.addHeapEdge(e);
1646 //See if the old edge subsumes the new one
1647 Edge olde=existingEdges.get(e);
1648 if (!olde.subsumes(e)) {
1649 delta.addHeapEdge(olde.merge(e));
1655 Delta processFlatNop(FlatNode node, Delta delta, Graph graph) {
1656 applyDiffs(graph, delta);
1660 Delta processNewNode(FlatNew node, Delta delta, Graph graph) {
1661 AllocNode summary=allocFactory.getAllocNode(node, true);
1662 AllocNode single=allocFactory.getAllocNode(node, false);
1663 TempDescriptor tmp=node.getDst();
1665 if (delta.getInit()) {
1666 /* We don't have to deal with summarization here... The
1667 * intuition is that this is the only place where we generate
1668 * nodes for this allocation site and this is the first time
1669 * we've analyzed this site */
1672 Edge e=new Edge(tmp, single);
1673 //Build new Edge set
1674 MySet<Edge> newedges=new MySet<Edge>();
1676 //Add it into the diffs
1677 delta.varedgeadd.put(tmp, newedges);
1678 //Remove the old edges
1679 MySet<Edge> oldedges=graph.getEdges(tmp);
1680 if (!oldedges.isEmpty())
1681 delta.varedgeremove.put(tmp, (MySet<Edge>) oldedges);
1682 //Apply incoming diffs to graph
1683 applyDiffs(graph, delta);
1684 //Note that we create a single node
1685 delta.addNodeAges.add(single);
1687 if (delta.addOldNodes.containsKey(single)||delta.baseOldNodes.containsKey(single)) {
1688 delta.addOldNodes.put(single, Boolean.FALSE);
1691 /* 1. Fix up the variable edge additions */
1693 for(Iterator<Map.Entry<TempDescriptor, MySet<Edge>>> entryIt=delta.varedgeadd.entrySet().iterator();entryIt.hasNext();) {
1694 Map.Entry<TempDescriptor, MySet<Edge>> entry=entryIt.next();
1696 if (entry.getKey()==tmp) {
1697 /* Check if this is the tmp we overwrite */
1700 /* Otherwise, check if the target of the edge is changed... */
1701 summarizeSet(entry.getValue(), graph.varMap.get(entry.getKey()), single, summary);
1705 /* 2. Fix up the base variable edges */
1707 for(Iterator<Map.Entry<TempDescriptor, MySet<Edge>>> entryIt=delta.basevaredge.entrySet().iterator();entryIt.hasNext();) {
1708 Map.Entry<TempDescriptor, MySet<Edge>> entry=entryIt.next();
1709 TempDescriptor entrytmp=entry.getKey();
1710 if (entrytmp==tmp) {
1711 /* Check is this is the tmp we overwrite, if so add to remove set */
1712 Util.relationUpdate(delta.varedgeremove, tmp, null, entry.getValue());
1714 /* Check if the target of the edge is changed */
1715 MySet<Edge> newset=(MySet<Edge>)entry.getValue().clone();
1716 MySet<Edge> removeset=shrinkSet(newset, graph.varMap.get(entrytmp), single, summary);
1717 Util.relationUpdate(delta.varedgeremove, entrytmp, newset, removeset);
1718 Util.relationUpdate(delta.varedgeadd, entrytmp, null, newset);
1723 /* 3. Fix up heap edge additions */
1725 HashMap<AllocNode, MySet<Edge>> addheapedge=new HashMap<AllocNode, MySet<Edge>>();
1726 for(Iterator<Map.Entry<AllocNode, MySet<Edge>>> entryIt=delta.heapedgeadd.entrySet().iterator();entryIt.hasNext();) {
1727 Map.Entry<AllocNode, MySet<Edge>> entry=entryIt.next();
1728 MySet<Edge> edgeset=entry.getValue();
1729 AllocNode allocnode=entry.getKey();
1730 if (allocnode==single) {
1732 summarizeSet(edgeset, graph.nodeMap.get(summary), single, summary);
1733 addheapedge.put(summary, edgeset);
1735 summarizeSet(edgeset, graph.nodeMap.get(allocnode), single, summary);
1739 /* Merge in diffs */
1741 for(Map.Entry<AllocNode, MySet<Edge>> entry:addheapedge.entrySet()) {
1742 AllocNode allocnode=entry.getKey();
1743 Util.relationUpdate(delta.heapedgeadd, allocnode, null, entry.getValue());
1746 /* 4. Fix up the base heap edges */
1748 for(Iterator<Map.Entry<AllocNode, MySet<Edge>>> entryIt=delta.baseheapedge.entrySet().iterator();entryIt.hasNext();) {
1749 Map.Entry<AllocNode, MySet<Edge>> entry=entryIt.next();
1750 MySet<Edge> edgeset=entry.getValue();
1751 AllocNode allocnode=entry.getKey();
1752 if (allocnode==single) {
1755 AllocNode addnode=(allocnode==single)?summary:allocnode;
1757 MySet<Edge> newset=(MySet<Edge>) edgeset.clone();
1758 MySet<Edge> removeset=shrinkSet(newset, graph.nodeMap.get(addnode), single, summary);
1759 Util.relationUpdate(delta.heapedgeadd, addnode, null, newset);
1760 Util.relationUpdate(delta.heapedgeremove, allocnode, null, removeset);
1763 /* Update Node Ages...If the base or addNodeAges set contains a
1764 * single node, it now should also contain a summary node... No
1765 * need to generate a single node as that has already been
1767 if (delta.baseNodeAges.contains(single)||delta.addNodeAges.contains(single)) {
1768 delta.addNodeAges.add(summary);
1771 //Kill the old node if someone tries to add it
1772 if (delta.addOldNodes.containsKey(single)||delta.baseOldNodes.containsKey(single)) {
1773 delta.addOldNodes.put(single, Boolean.FALSE);
1776 //Apply incoming diffs to graph
1777 applyDiffs(graph, delta);
1782 /* This function builds a new edge set where oldnode is summarized into new node */
1784 void summarizeSet(MySet<Edge> edgeset, MySet<Edge> oldedgeset, AllocNode oldnode, AllocNode sumnode) {
1785 MySet<Edge> newSet=null;
1786 for(Iterator<Edge> edgeit=edgeset.iterator();edgeit.hasNext();) {
1787 Edge e=edgeit.next();
1788 if (e.dst==oldnode||e.src==oldnode) {
1790 newSet=new MySet<Edge>();
1795 if (e.dst==oldnode) {
1798 if (e.src==oldnode) {
1801 if (oldedgeset==null||!oldedgeset.contains(e))
1806 edgeset.addAll(newSet);
1809 /* Shrinks the incoming set to just include rewritten values.
1810 * Returns a set of the original rewritten values */
1812 MySet<Edge> shrinkSet(MySet<Edge> edgeset, MySet<Edge> oldedgeset, AllocNode oldnode, AllocNode newnode) {
1813 MySet<Edge> newSet=null;
1814 MySet<Edge> removeSet=null;
1815 for(Iterator<Edge> edgeit=edgeset.iterator();edgeit.hasNext();) {
1816 Edge e=edgeit.next();
1818 if (e.dst==oldnode||e.src==oldnode) {
1820 newSet=new MySet<Edge>();
1821 removeSet=new MySet<Edge>();
1830 if (oldedgeset==null||!oldedgeset.contains(e))
1835 edgeset.addAll(newSet);
1839 /* This function returns a completely new Delta... It is safe to
1842 Delta applyInitDelta(Delta delta, BBlock block) {
1843 //Apply delta to graph
1844 boolean newGraph=false;
1845 if (!bbgraphMap.containsKey(block)) {
1846 bbgraphMap.put(block, new Graph(null));
1849 Graph graph=bbgraphMap.get(block);
1852 Delta newdelta=new Delta(null, true);
1853 //Add in heap edges and throw away original diff
1855 for(Map.Entry<AllocNode, MySet<Edge>> entry:delta.heapedgeadd.entrySet()) {
1856 graph.nodeMap.put(entry.getKey(), new MySet<Edge>(entry.getValue()));
1858 //Add in var edges and throw away original diff
1859 Set<TempDescriptor> livetemps=bblivetemps.get(block);
1861 for(Map.Entry<TempDescriptor, MySet<Edge>> entry:delta.varedgeadd.entrySet()) {
1862 if (livetemps.contains(entry.getKey()))
1863 graph.varMap.put(entry.getKey(), new MySet<Edge>(entry.getValue()));
1865 //Record that this is initial set...
1866 graph.nodeAges.addAll(delta.addNodeAges);
1868 for(Map.Entry<AllocNode, Boolean> oldentry:delta.addOldNodes.entrySet()) {
1869 if (oldentry.getValue().booleanValue()) {
1870 graph.oldNodes.put(oldentry.getKey(), Boolean.TRUE);
1875 Delta newdelta=new Delta(null, false);
1876 //merge in heap edges and variables
1877 mergeHeapEdges(graph, delta, newdelta);
1878 mergeVarEdges(graph, delta, newdelta, block);
1879 mergeAges(graph, delta, newdelta);
1884 /* This function merges in the heap edges. It updates delta to be
1887 void mergeHeapEdges(Graph graph, Delta delta, Delta newdelta) {
1889 for(Map.Entry<AllocNode, MySet<Edge>> heapedge:delta.heapedgeadd.entrySet()) {
1890 AllocNode nsrc=heapedge.getKey();
1891 MySet<Edge> edges=heapedge.getValue();
1893 if (graph.backMap!=null) {
1895 if (!graph.backMap.containsKey(e.dst))
1896 graph.backMap.put(e.dst, new MySet<Edge>());
1897 graph.backMap.get(e.dst).add(e);
1901 if (!graph.nodeMap.containsKey(nsrc)) {
1902 graph.nodeMap.put(nsrc, new MySet<Edge>());
1904 MySet<Edge> dstedges=graph.nodeMap.get(nsrc);
1905 MySet<Edge> diffedges=new MySet<Edge>();
1907 if (!dstedges.contains(e)) {
1908 //We have a new edge
1912 Edge origedge=dstedges.get(e);
1913 if (!origedge.subsumes(e)) {
1914 Edge mergededge=origedge.merge(e);
1915 diffedges.add(mergededge);
1916 dstedges.add(mergededge);
1920 //Done with edge set...
1921 if (diffedges.size()>0) {
1923 newdelta.baseheapedge.put(nsrc, diffedges);
1928 /* This function merges in the var edges. It updates delta to be
1931 void mergeVarEdges(Graph graph, Delta delta, Delta newdelta, BBlock block) {
1933 Set<TempDescriptor> livetemps=bblivetemps.get(block);
1935 for(Map.Entry<TempDescriptor, MySet<Edge>> varedge:delta.varedgeadd.entrySet()) {
1936 TempDescriptor tmpsrc=varedge.getKey();
1937 if (livetemps.contains(tmpsrc)) {
1938 MySet<Edge> edges=varedge.getValue();
1939 if (graph.backMap!=null) {
1941 if (!graph.backMap.containsKey(e.dst))
1942 graph.backMap.put(e.dst, new MySet<Edge>());
1943 graph.backMap.get(e.dst).add(e);
1947 if (!graph.varMap.containsKey(tmpsrc)) {
1948 graph.varMap.put(tmpsrc, new MySet<Edge>());
1950 MySet<Edge> dstedges=graph.varMap.get(tmpsrc);
1951 MySet<Edge> diffedges=new MySet<Edge>();
1953 if (!dstedges.contains(e)) {
1954 //We have a new edge
1958 Edge origedge=dstedges.get(e);
1959 if (!origedge.subsumes(e)) {
1960 Edge mergededge=origedge.merge(e);
1961 diffedges.add(mergededge);
1962 dstedges.add(mergededge);
1966 //Done with edge set...
1967 if (diffedges.size()>0) {
1969 newdelta.basevaredge.put(tmpsrc,diffedges);
1975 void mergeAges(Graph graph, Delta delta, Delta newDelta) {
1977 for(AllocNode node:delta.addNodeAges) {
1978 if (!graph.nodeAges.contains(node)) {
1979 graph.nodeAges.add(node);
1980 newDelta.baseNodeAges.add(node);
1983 for(Map.Entry<AllocNode, Boolean> oldentry:delta.addOldNodes.entrySet()) {
1984 AllocNode node=oldentry.getKey();
1985 boolean ispresent=oldentry.getValue().booleanValue();
1986 if (ispresent&&!graph.oldNodes.containsKey(node)) {
1987 graph.oldNodes.put(node, Boolean.TRUE);
1988 newDelta.baseOldNodes.put(node, Boolean.TRUE);