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, BuildStateMachines bsm) {
43 this(state, typeUtil);
44 this.callGraph=callGraph;
46 this.taskAnalysis=taskAnalysis;
47 this.effectsAnalysis=new EffectsAnalysis();
48 effectsAnalysis.state=state;
49 effectsAnalysis.buildStateMachines=bsm;
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)) {
250 if (graph.oldNodes.get(node).booleanValue())
251 newDelta.addOldNodes.put(node, Boolean.TRUE);
252 } else if (graph.parent.oldNodes.containsKey(node)) {
253 //parent graphs only contain true...no need to check
254 newDelta.addOldNodes.put(node, Boolean.TRUE);
258 newDelta.addNodeAges.addAll(graph.nodeAges);
259 newDelta.addNodeAges.addAll(graph.parent.nodeAges);
262 /* This function build the delta for the exit of a basic block. */
264 void generateFinalDelta(BBlock bblock, Delta delta, Graph graph) {
265 Delta newDelta=new Delta(null, false);
266 if (delta.getInit()) {
267 buildInitDelta(graph, newDelta);
269 /* We can break the old delta...it is done being used */
270 /* First we will build variable edges */
271 HashSet<TempDescriptor> tmpSet=new HashSet<TempDescriptor>();
272 tmpSet.addAll(delta.basevaredge.keySet());
273 tmpSet.addAll(delta.varedgeadd.keySet());
274 for(TempDescriptor tmp:tmpSet) {
275 /* Start with the new incoming edges */
276 MySet<Edge> newbaseedge=delta.basevaredge.get(tmp);
277 /* Remove the remove set */
278 if (newbaseedge==null)
279 newbaseedge=new MySet<Edge>();
280 newbaseedge.removeAll(delta.varedgeremove.get(tmp));
281 /* Add in the new set*/
282 newbaseedge.addAll(delta.varedgeadd.get(tmp));
283 /* Store the results */
284 newDelta.varedgeadd.put(tmp, newbaseedge);
286 delta.basevaredge.clear();
288 /* Next we build heap edges */
289 HashSet<AllocNode> nodeSet=new HashSet<AllocNode>();
290 nodeSet.addAll(delta.baseheapedge.keySet());
291 nodeSet.addAll(delta.heapedgeadd.keySet());
292 nodeSet.addAll(delta.heapedgeremove.keySet());
293 for(AllocNode node:nodeSet) {
294 /* Start with the new incoming edges */
295 MySet<Edge> newheapedge=new MySet<Edge>(delta.baseheapedge.get(node));
296 /* Remove the remove set */
297 MySet<Edge> removeset=delta.heapedgeremove.get(node);
300 newheapedge.removeAll(removeset);
302 /* Add in the add set */
303 MySet<Edge> settoadd=delta.heapedgeadd.get(node);
305 newheapedge.addAll(settoadd);
306 newDelta.heapedgeadd.put(node, newheapedge);
308 /* Remove the newly created edges..no need to propagate a diff for those */
309 if (removeset!=null) {
310 removeset.removeAll(delta.baseheapedge.get(node));
311 newDelta.heapedgeremove.put(node, removeset);
315 /* Compute new ages */
316 newDelta.addNodeAges.addAll(delta.baseNodeAges);
317 newDelta.addNodeAges.addAll(delta.addNodeAges);
318 HashSet<AllocNode> oldNodes=new HashSet<AllocNode>();
320 /* Compute whether old nodes survive */
321 oldNodes.addAll(delta.baseOldNodes.keySet());
322 oldNodes.addAll(delta.addOldNodes.keySet());
323 for(AllocNode node:oldNodes) {
324 if (delta.addOldNodes.containsKey(node)) {
325 if (delta.addOldNodes.get(node).booleanValue()) {
326 newDelta.addOldNodes.put(node, Boolean.TRUE);
329 if (delta.baseOldNodes.get(node).booleanValue()) {
330 newDelta.addOldNodes.put(node, Boolean.TRUE);
336 /* Now we need to propagate newdelta */
337 if (!newDelta.heapedgeadd.isEmpty()||!newDelta.heapedgeremove.isEmpty()||!newDelta.varedgeadd.isEmpty()||!newDelta.addNodeAges.isEmpty()||!newDelta.addOldNodes.isEmpty()) {
338 /* We have a delta to propagate */
339 if (returnMap.containsKey(bblock)) {
343 for(PPoint caller:returnMap.get(bblock)) {
344 //System.out.println("Sending Return BBlock to "+caller.getBBlock().nodes.get(caller.getIndex()).toString().replace(' ','_'));
347 newDelta.setBlock(caller);
348 toprocess.add(newDelta);
351 Delta d=newDelta.diffBlock(caller);
357 Vector<BBlock> blockvector=bblock.next();
358 for(int i=0;i<blockvector.size();i++) {
359 //System.out.println("Sending BBlock to "+blockvector.get(i).nodes.get(0).toString().replace(' ','_'));
362 newDelta.setBlock(new PPoint(blockvector.get(i)));
363 toprocess.add(newDelta);
365 Delta d=newDelta.diffBlock(new PPoint(blockvector.get(i)));
371 //System.out.println("EMPTY DELTA");
372 //System.out.println("delta");
374 //System.out.println("newDelta");
379 boolean isNEEDED(FlatNode node) {
380 switch(node.kind()) {
381 case FKind.FlatSetFieldNode: {
382 FlatSetFieldNode n=(FlatSetFieldNode)node;
383 return n.getSrc().getType().isPtr();
385 case FKind.FlatSetElementNode: {
386 FlatSetElementNode n=(FlatSetElementNode)node;
387 return n.getSrc().getType().isPtr();
389 case FKind.FlatFieldNode: {
390 FlatFieldNode n=(FlatFieldNode)node;
391 return n.getDst().getType().isPtr();
393 case FKind.FlatElementNode: {
394 FlatElementNode n=(FlatElementNode)node;
395 return n.getDst().getType().isPtr();
401 Delta processNode(BBlock bblock, int index, FlatNode node, Delta delta, Graph newgraph) {
402 switch(node.kind()) {
404 return processNewNode((FlatNew)node, delta, newgraph);
405 case FKind.FlatFieldNode:
406 case FKind.FlatElementNode:
407 return processFieldElementNode(node, delta, newgraph);
408 case FKind.FlatCastNode:
409 case FKind.FlatOpNode:
410 case FKind.FlatReturnNode:
411 return processCopyNode(node, delta, newgraph);
412 case FKind.FlatSetFieldNode:
413 case FKind.FlatSetElementNode:
414 return processSetFieldElementNode(node, delta, newgraph);
415 case FKind.FlatSESEEnterNode:
416 return processSESEEnterNode((FlatSESEEnterNode) node, delta, newgraph);
417 case FKind.FlatSESEExitNode:
418 return processSESEExitNode((FlatSESEExitNode) node, delta, newgraph);
419 case FKind.FlatMethod:
421 case FKind.FlatBackEdge:
422 case FKind.FlatGenReachNode:
423 return processFlatNop(node, delta, newgraph);
425 return processFlatCall(bblock, index, (FlatCall) node, delta, newgraph);
427 throw new Error("Unrecognized node:"+node);
431 Delta processSESEEnterNode(FlatSESEEnterNode sese, Delta delta, Graph graph) {
433 return processFlatNop(sese, delta, graph);
434 if (delta.getInit()) {
435 removeInitTaints(null, delta, graph);
436 for (TempDescriptor tmp:sese.getInVarSet()) {
437 Taint taint=Taint.factory(sese, null, tmp, AllocFactory.dummySite, null, ReachGraph.predsEmpty);
438 MySet<Edge> edges=GraphManip.getEdges(graph, delta, tmp);
440 Edge newe=e.addTaint(taint);
441 delta.addVarEdge(newe);
445 removeDiffTaints(null, delta);
446 for (TempDescriptor tmp:sese.getInVarSet()) {
447 Taint taint=Taint.factory(sese, null, tmp, AllocFactory.dummySite, null, ReachGraph.predsEmpty);
448 MySet<Edge> edges=GraphManip.getDiffEdges(delta, tmp);
450 Edge newe=e.addTaint(taint);
451 delta.addVarEdge(newe);
457 applyDiffs(graph, delta);
461 private boolean isRecursive(FlatSESEEnterNode sese) {
462 MethodDescriptor md=sese.getmdEnclosing();
463 boolean isrecursive=callGraph.getCalleeSet(md).contains(md);
467 Delta processSESEExitNode(FlatSESEExitNode seseexit, Delta delta, Graph graph) {
469 return processFlatNop(seseexit, delta, graph);
470 FlatSESEEnterNode sese=seseexit.getFlatEnter();
471 //Strip Taints from this SESE
472 if (delta.getInit()) {
473 removeInitTaints(isRecursive(sese)?null:sese, delta, graph);
475 removeDiffTaints(isRecursive(sese)?null:sese, delta);
477 applyDiffs(graph, delta);
481 void removeDiffTaints(FlatSESEEnterNode sese, Delta delta) {
482 //Start with variable edges
484 MySet<Edge> edgestoadd=new MySet<Edge>();
485 MySet<Edge> edgestoremove=new MySet<Edge>();
487 //Process base diff edges
488 processEdgeMap(sese, delta.basevaredge, null, delta.varedgeremove, edgestoremove, edgestoadd);
489 //Process delta edges
490 processEdgeMap(sese, delta.varedgeadd, null, null, edgestoremove, edgestoadd);
491 for(Edge e:edgestoremove) {
492 delta.removeVarEdge(e);
494 for(Edge e:edgestoadd) {
501 MySet<Edge> edgestoadd=new MySet<Edge>();
502 MySet<Edge> edgestoremove=new MySet<Edge>();
504 //Process base diff edges
505 processEdgeMap(sese, delta.baseheapedge, null, delta.heapedgeremove, edgestoremove, edgestoadd);
506 //Process delta edges
507 processEdgeMap(sese, delta.heapedgeadd, null, null, edgestoremove, edgestoadd);
508 for(Edge e:edgestoremove) {
509 delta.removeHeapEdge(e);
511 for(Edge e:edgestoadd) {
512 delta.addHeapEdge(e);
517 void removeInitTaints(FlatSESEEnterNode sese, Delta delta, Graph graph) {
518 //Start with variable edges
520 MySet<Edge> edgestoadd=new MySet<Edge>();
521 MySet<Edge> edgestoremove=new MySet<Edge>();
523 //Process parent edges
524 processEdgeMap(sese, graph.parent.varMap, graph.varMap, delta.varedgeremove, edgestoremove, edgestoadd);
525 //Process graph edges
526 processEdgeMap(sese, graph.varMap, null, delta.varedgeremove, edgestoremove, edgestoadd);
527 //Process delta edges
528 processEdgeMap(sese, delta.varedgeadd, null, null, edgestoremove, edgestoadd);
529 for(Edge e:edgestoremove) {
530 delta.removeVarEdge(e);
532 for(Edge e:edgestoadd) {
539 MySet<Edge> edgestoadd=new MySet<Edge>();
540 MySet<Edge> edgestoremove=new MySet<Edge>();
542 //Process parent edges
543 processEdgeMap(sese, graph.parent.nodeMap, graph.nodeMap, delta.heapedgeremove, edgestoremove, edgestoadd);
544 //Process graph edges
545 processEdgeMap(sese, graph.nodeMap, null, delta.heapedgeremove, edgestoremove, edgestoadd);
546 //Process delta edges
547 processEdgeMap(sese, delta.heapedgeadd, null, null, edgestoremove, edgestoadd);
548 for(Edge e:edgestoremove) {
549 delta.removeHeapEdge(e);
551 for(Edge e:edgestoadd) {
552 delta.addHeapEdge(e);
557 void processEdgeMap(FlatSESEEnterNode sese, HashMap<?, MySet<Edge>> edgemap, HashMap<?, MySet<Edge>> childmap, HashMap<?, MySet<Edge>> removemap, MySet<Edge> edgestoremove, MySet<Edge> edgestoadd) {
558 for(Map.Entry<?, MySet<Edge>> entry:edgemap.entrySet()) {
559 //If the parent map exists and overrides this entry, skip it
560 if (childmap!=null&&childmap.containsKey(entry.getKey()))
562 for(Edge e:entry.getValue()) {
563 //check whether this edge has been removed
564 if (removemap!=null&&removemap.containsKey(entry.getKey())&&
565 removemap.get(entry.getKey()).contains(e))
568 TaintSet ts=e.getTaints();
570 //update non-null taint set
572 newts=Canonical.removeInContextTaintsNP(ts, sese);
574 edgestoremove.add(e);
575 edgestoadd.add(e.changeTaintSet(newts));
581 /* This function compute the edges for the this variable for a
582 * callee if it exists. */
584 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) {
585 //Handle the this temp
587 MySet<Edge> edges=(oldnodeset!=null)?GraphManip.getDiffEdges(delta, tmpthis):GraphManip.getEdges(graph, delta, tmpthis);
588 newDelta.varedgeadd.put(tmpthis, (MySet<Edge>) edges.clone());
589 edgeset.addAll(edges);
591 AllocNode dstnode=e.dst;
592 if (!nodeset.contains(dstnode)&&(oldnodeset==null||!oldnodeset.contains(dstnode))) {
593 TypeDescriptor type=dstnode.getType();
594 if (!type.isArray()) {
595 targetSet.add(type.getClassDesc());
597 //arrays don't have code
598 targetSet.add(typeUtil.getClass(TypeUtil.ObjectClass));
600 nodeset.add(dstnode);
601 tovisit.add(dstnode);
607 /* This function compute the edges for a call's parameters. */
609 void processParams(Graph graph, Delta delta, Delta newDelta, HashSet<AllocNode> nodeset, Stack<AllocNode> tovisit, MySet<Edge> edgeset, FlatCall fcall, boolean diff) {
610 //Go through each temp
611 for(int i=0;i<fcall.numArgs();i++) {
612 TempDescriptor tmp=fcall.getArg(i);
613 MySet<Edge> edges=diff?GraphManip.getDiffEdges(delta, tmp):GraphManip.getEdges(graph, delta, tmp);
614 newDelta.varedgeadd.put(tmp, (MySet<Edge>) edges.clone());
615 edgeset.addAll(edges);
617 if (!nodeset.contains(e.dst)) {
625 /* This function computes the reachable nodes for a callee. */
627 void computeReachableNodes(Graph graph, Delta delta, Delta newDelta, HashSet<AllocNode> nodeset, Stack<AllocNode> tovisit, MySet<Edge> edgeset, HashSet<AllocNode> oldnodeset) {
628 while(!tovisit.isEmpty()) {
629 AllocNode node=tovisit.pop();
630 MySet<Edge> edges=GraphManip.getEdges(graph, delta, node);
631 if (!edges.isEmpty()) {
632 newDelta.heapedgeadd.put(node, Edge.makeOld(edges));
633 edgeset.addAll(edges);
635 if (!nodeset.contains(e.dst)&&(oldnodeset==null||!oldnodeset.contains(e.dst))) {
644 HashSet<MethodDescriptor> computeTargets(FlatCall fcall, Delta newDelta) {
645 TempDescriptor tmpthis=fcall.getThis();
646 MethodDescriptor md=fcall.getMethod();
647 HashSet<MethodDescriptor> targets=new HashSet<MethodDescriptor>();
648 if (md.isStatic()||fcall.getSuper()) {
652 for(Edge e:newDelta.varedgeadd.get(tmpthis)) {
653 AllocNode node=e.dst;
654 ClassDescriptor cd=node.getType().getClassDesc();
655 //Figure out exact method called and add to set
656 MethodDescriptor calledmd=cd.getCalledMethod(md);
657 targets.add(calledmd);
663 void fixMapping(FlatCall fcall, HashSet<MethodDescriptor> targets, MySet<Edge> oldedgeset, Delta newDelta, BBlock callblock, int callindex) {
664 Delta basedelta=null;
665 TempDescriptor tmpthis=fcall.getThis();
667 for(MethodDescriptor calledmd:targets) {
668 FlatMethod fm=state.getMethodFlat(calledmd);
669 boolean newmethod=false;
672 HashMap<TempDescriptor, TempDescriptor> tmpMap=new HashMap<TempDescriptor, TempDescriptor>();
675 tmpMap.put(tmpthis, fm.getParameter(offset++));
677 for(int i=0;i<fcall.numArgs();i++) {
678 TempDescriptor tmp=fcall.getArg(i);
679 tmpMap.put(tmp,fm.getParameter(i+offset));
682 //Get basicblock for the method
683 BasicBlock block=getBBlock(fm);
686 if (!callMap.containsKey(fcall)) {
687 callMap.put(fcall, new HashSet<BBlock>());
690 Delta returnDelta=null;
691 if (!callMap.get(fcall).contains(block.getStart())) {
692 callMap.get(fcall).add(block.getStart());
696 if (!returnMap.containsKey(block.getExit())) {
697 returnMap.put(block.getExit(), new HashSet<PPoint>());
699 returnMap.get(block.getExit()).add(new PPoint(callblock, callindex));
701 if (bbgraphMap.containsKey(block.getExit())) {
702 //Need to push existing results to current node
703 if (returnDelta==null) {
704 returnDelta=new Delta(null, false);
705 Vector<FlatNode> exitblocknodes=block.getExit().nodes();
706 FlatExit fexit=(FlatExit)exitblocknodes.get(exitblocknodes.size()-1);
707 buildInitDelta(graphMap.get(fexit), returnDelta);
708 if (!returnDelta.heapedgeadd.isEmpty()||!returnDelta.heapedgeremove.isEmpty()||!returnDelta.varedgeadd.isEmpty()) {
709 returnDelta.setBlock(new PPoint(callblock, callindex));
710 toprocess.add(returnDelta);
713 if (!returnDelta.heapedgeadd.isEmpty()||!returnDelta.heapedgeremove.isEmpty()||!returnDelta.varedgeadd.isEmpty()) {
714 toprocess.add(returnDelta.diffBlock(new PPoint(callblock, callindex)));
720 if (oldedgeset==null) {
721 //First build of this graph
722 //Build and enqueue delta...safe to just use existing delta
723 Delta d=newDelta.changeParams(tmpMap, new PPoint(block.getStart()));
724 //System.out.println("AProcessing "+block.getStart().nodes.get(0).toString().replace(' ','_'));
727 } else if (newmethod) {
728 if (basedelta==null) {
729 basedelta=newDelta.buildBase(oldedgeset);
731 //Build and enqueue delta
732 Delta d=basedelta.changeParams(tmpMap, new PPoint(block.getStart()));
733 //System.out.println("BProcessing "+block.getStart().nodes.get(0).toString().replace(' ','_'));
737 //Build and enqueue delta
738 Delta d=newDelta.changeParams(tmpMap, new PPoint(block.getStart()));
739 //System.out.println("CProcessing "+block.getStart().nodes.get(0).toString().replace(' ','_'));
747 /* This function computes all edges that start outside of the callee
748 * context and go into the callee context */
750 void computeExternalEdges(Graph graph, Delta delta, HashSet<AllocNode> nodeset, HashSet<AllocNode> deltaset, MySet<Edge> externaledgeset) {
751 //Do heap edges first
752 HashSet<AllocNode> externalnodes=new HashSet<AllocNode>();
753 externalnodes.addAll(delta.baseheapedge.keySet());
754 externalnodes.addAll(delta.heapedgeadd.keySet());
755 externalnodes.addAll(delta.heapedgeremove.keySet());
756 //remove allinternal nodes
757 externalnodes.removeAll(nodeset);
758 for(AllocNode extNode:externalnodes) {
759 //Compute set of edges from given node
760 MySet<Edge> edges=new MySet<Edge>(delta.baseheapedge.get(extNode));
761 edges.removeAll(delta.heapedgeremove.get(extNode));
762 edges.addAll(delta.heapedgeadd.get(extNode));
765 if (nodeset.contains(e.dst))
766 externaledgeset.add(e);
771 HashSet<TempDescriptor> temps=new HashSet<TempDescriptor>();
772 temps.addAll(delta.basevaredge.keySet());
773 temps.addAll(delta.varedgeadd.keySet());
774 temps.addAll(delta.varedgeremove.keySet());
775 //remove allinternal nodes
776 temps.removeAll(nodeset);
778 for(TempDescriptor tmp:temps) {
779 //Compute set of edges from given node
780 MySet<Edge> edges=new MySet<Edge>(delta.basevaredge.get(tmp));
782 edges.removeAll(delta.varedgeremove.get(tmp));
783 edges.addAll(delta.varedgeadd.get(tmp));
786 if (nodeset.contains(e.dst))
787 externaledgeset.add(e);
792 /* This function removes the caller reachable edges from the
795 void removeEdges(Graph graph, Delta delta, HashSet<AllocNode> nodeset, MySet<Edge> edgeset, MySet<Edge> externaledgeset) {
796 //Want to remove the set of internal edges
797 for(Edge e:edgeset) {
798 if (e.src!=null&&!graph.callerEdges.contains(e)) {
799 delta.removeHeapEdge(e);
803 //Want to remove the set of external edges
804 for(Edge e:externaledgeset) {
805 //want to remove the set of internal edges
806 if (!graph.callerEdges.contains(e))
811 Delta processFlatCall(BBlock callblock, int callindex, FlatCall fcall, Delta delta, Graph graph) {
812 Delta newDelta=new Delta(null, false);
814 if (delta.getInit()) {
815 MySet<Edge> edgeset=new MySet<Edge>();
816 MySet<Edge> externaledgeset=new MySet<Edge>();
817 HashSet<AllocNode> nodeset=new HashSet<AllocNode>();
818 HashSet<ClassDescriptor> targetSet=new HashSet<ClassDescriptor>();
819 Stack<AllocNode> tovisit=new Stack<AllocNode>();
820 TempDescriptor tmpthis=fcall.getThis();
821 graph.callerEdges=new MySet<Edge>();
823 //Handle the this temp
824 processThisTargets(targetSet, graph, delta, newDelta, nodeset, tovisit, edgeset, tmpthis, null);
826 //Go through each temp
827 processParams(graph, delta, newDelta, nodeset, tovisit, edgeset, fcall, false);
829 //Traverse all reachable nodes
830 computeReachableNodes(graph, delta, newDelta, nodeset, tovisit, edgeset, null);
832 //Compute call targets
833 HashSet<MethodDescriptor> newtargets=computeTargets(fcall, newDelta);
836 fixMapping(fcall, newtargets, null, newDelta, callblock, callindex);
838 //Compute edges into region to splice out
839 computeExternalEdges(graph, delta, nodeset, null, externaledgeset);
841 //Splice out internal edges
842 removeEdges(graph, delta, nodeset, edgeset, externaledgeset);
844 //store data structures
845 graph.externalEdgeSet=externaledgeset;
846 graph.reachNode=nodeset;
847 graph.reachEdge=edgeset;
849 graph.callTargets=newtargets;
850 graph.callNodeAges=new HashSet<AllocNode>();
851 graph.callOldNodes=new HashSet<AllocNode>();
852 graph.callNewEdges=new HashMap<AllocNode, MySet<Edge>>();
853 graph.callOldEdges=new HashMap<Edge,MySet<Edge>>();
855 //Apply diffs to graph
856 applyDiffs(graph, delta, true);
858 MySet<Edge> edgeset=new MySet<Edge>();
859 MySet<Edge> externaledgeset=new MySet<Edge>();
860 HashSet<AllocNode> nodeset=new HashSet<AllocNode>();
861 MySet<Edge> oldedgeset=graph.reachEdge;
862 HashSet<AllocNode> oldnodeset=graph.reachNode;
864 HashSet<ClassDescriptor> targetSet=new HashSet<ClassDescriptor>();
865 Stack<AllocNode> tovisit=new Stack<AllocNode>();
866 TempDescriptor tmpthis=fcall.getThis();
867 //Fix up delta to get rid of unnecessary heap edge removals
868 for(Map.Entry<AllocNode, MySet<Edge>> entry:delta.heapedgeremove.entrySet()) {
869 for(Iterator<Edge> eit=entry.getValue().iterator();eit.hasNext();) {
871 if (graph.callerEdges.contains(e))
876 //Fix up delta to get rid of unnecessary var edge removals
877 for(Map.Entry<TempDescriptor, MySet<Edge>> entry:delta.varedgeremove.entrySet()) {
878 for(Iterator<Edge> eit=entry.getValue().iterator();eit.hasNext();) {
880 if (graph.callerEdges.contains(e))
885 //Handle the this temp
886 processThisTargets(targetSet, graph, delta, newDelta, nodeset, tovisit, edgeset, tmpthis, oldnodeset);
888 //Go through each temp
889 processParams(graph, delta, newDelta, nodeset, tovisit, edgeset, fcall, true);
890 //Go through each new heap edge that starts from old node
891 MySet<Edge> newedges=GraphManip.getDiffEdges(delta, oldnodeset);
892 edgeset.addAll(newedges);
893 for(Edge e:newedges) {
894 //Add new edges that start from old node to newDelta
896 if (!newDelta.heapedgeadd.containsKey(src)) {
897 newDelta.heapedgeadd.put(src, new MySet<Edge>());
899 newDelta.heapedgeadd.get(src).add(e.makeOld());
900 if (!nodeset.contains(e.dst)&&!oldnodeset.contains(e.dst)) {
906 //Traverse all reachable nodes
907 computeReachableNodes(graph, delta, newDelta, nodeset, tovisit, edgeset, oldnodeset);
908 //Compute call targets
909 HashSet<MethodDescriptor> newtargets=computeTargets(fcall, newDelta);
910 graph.callTargets.addAll(newtargets);
912 //add in new nodeset and edgeset
913 oldnodeset.addAll(nodeset);
914 oldedgeset.addAll(edgeset);
916 fixMapping(fcall, graph.callTargets, oldedgeset, newDelta, callblock, callindex);
917 //Compute edges into region to splice out
918 computeExternalEdges(graph, delta, oldnodeset, nodeset, externaledgeset);
920 //Splice out internal edges
921 removeEdges(graph, delta, nodeset, edgeset, externaledgeset);
923 //Add external edges back in
924 processCallExternal(graph, delta, externaledgeset);
926 //Move new edges that should be summarized
927 processSummarization(graph, delta);
929 Set<FlatSESEEnterNode> seseCallers=OoOJava?taskAnalysis.getTransitiveExecutingRBlocks(fcall):null;
930 //Check if the new nodes allow us to insert a new edge
931 for(AllocNode node:nodeset) {
932 if (graph.callNewEdges.containsKey(node)) {
933 for(Iterator<Edge> eit=graph.callNewEdges.get(node).iterator();eit.hasNext();) {
935 if ((graph.callNodeAges.contains(e.src)||graph.reachNode.contains(e.src))&&
936 (graph.callNodeAges.contains(e.dst)||graph.reachNode.contains(e.dst))) {
937 Edge edgetoadd=e.copy();//we need our own copy to modify below
939 if (seseCallers!=null)
940 edgetoadd.taintModify(seseCallers);
941 mergeCallEdge(graph, delta, edgetoadd);
947 for(Edge e:edgeset) {
948 //See if these edges would allow an old edge to be added
949 if (graph.callOldEdges.containsKey(e)) {
950 for(Edge adde:graph.callOldEdges.get(e)) {
951 Edge ecopy=adde.copy();
952 ecopy.statuspredicate=e.statuspredicate;
953 mergeCallEdge(graph, delta, ecopy);
958 //Add in new external edges
959 graph.externalEdgeSet.addAll(externaledgeset);
960 //Apply diffs to graph
961 applyDiffs(graph, delta);
966 void processSummarization(Graph graph, Delta delta) {
967 processSumHeapEdgeSet(delta.heapedgeadd, delta, graph);
968 processSumHeapEdgeSet(delta.baseheapedge, delta, graph);
969 processSumVarEdgeSet(delta.varedgeadd, delta, graph);
970 processSumVarEdgeSet(delta.basevaredge, delta, graph);
973 void processSumVarEdgeSet(HashMap<TempDescriptor, MySet<Edge>> map, Delta delta, Graph graph) {
974 MySet<Edge> edgestoadd=new MySet<Edge>();
975 MySet<Edge> edgestoremove=new MySet<Edge>();
976 for(Iterator<Map.Entry<TempDescriptor, MySet<Edge>>> eit=map.entrySet().iterator();eit.hasNext();) {
977 Map.Entry<TempDescriptor, MySet<Edge>> entry=eit.next();
978 MySet<Edge> edgeset=entry.getValue();
980 for(Edge e:edgeset) {
982 boolean rewrite=false;
983 if (copy.dst!=null&&graph.callNodeAges.contains(copy.dst)) {
984 copy.dst=allocFactory.getAllocNode(copy.dst, true);
988 edgestoremove.add(e);
989 edgestoadd.add(copy);
993 for(Edge e:edgestoremove) {
994 if (!graph.callerEdges.contains(e))
995 delta.removeVarEdge(e);
997 for(Edge e:edgestoadd) {
1002 public Alloc getAllocationSiteFromFlatNew(FlatNew node) {
1003 return allocFactory.getAllocNode(node, false).getAllocSite();
1006 void processSumHeapEdgeSet(HashMap<AllocNode, MySet<Edge>> map, Delta delta, Graph graph) {
1007 MySet<Edge> edgestoadd=new MySet<Edge>();
1008 MySet<Edge> edgestoremove=new MySet<Edge>();
1009 for(Iterator<Map.Entry<AllocNode, MySet<Edge>>> eit=map.entrySet().iterator();eit.hasNext();) {
1010 Map.Entry<AllocNode, MySet<Edge>> entry=eit.next();
1011 AllocNode node=entry.getKey();
1012 MySet<Edge> edgeset=entry.getValue();
1014 for(Edge e:edgeset) {
1016 boolean rewrite=false;
1017 if (copy.src!=null&&graph.callNodeAges.contains(copy.src)) {
1018 copy.src=allocFactory.getAllocNode(copy.src, true);
1021 if (copy.dst!=null&&graph.callNodeAges.contains(copy.dst)) {
1022 copy.dst=allocFactory.getAllocNode(copy.dst, true);
1026 edgestoremove.add(e);
1027 edgestoadd.add(copy);
1031 for(Edge e:edgestoremove) {
1032 if (!graph.callerEdges.contains(e))
1033 delta.removeHeapEdge(e);
1035 for(Edge e:edgestoadd) {
1036 delta.addHeapEdge(e);
1040 //Handle external edges
1041 void processCallExternal(Graph graph, Delta newDelta, MySet<Edge> externalEdgeSet) {
1042 //Add external edges in
1043 for(Edge e:externalEdgeSet) {
1044 //First did we age the source
1045 Edge newedge=e.copy();
1046 if (newedge.src!=null&&!e.src.isSummary()&&graph.callNodeAges.contains(e.src)) {
1047 AllocNode summaryNode=allocFactory.getAllocNode(newedge.src, true);
1048 newedge.src=summaryNode;
1051 if (graph.callNodeAges.contains(e.dst)&&!e.dst.isSummary()) {
1052 if (graph.callOldNodes.contains(e.dst)) {
1054 Edge copy=newedge.copy();
1055 mergeEdge(graph, newDelta, copy);
1057 //Now add summarized node
1058 newedge.dst=allocFactory.getAllocNode(newedge.dst, true);
1059 mergeCallEdge(graph, newDelta, newedge);
1061 //Add edge to single node
1062 mergeEdge(graph, newDelta, newedge);
1067 /* This function applies callee deltas to the caller heap. */
1069 Delta applyCallDelta(Delta delta, BBlock bblock) {
1070 Delta newDelta=new Delta(null, false);
1071 Vector<FlatNode> nodes=bblock.nodes();
1072 PPoint ppoint=delta.getBlock();
1073 FlatCall fcall=(FlatCall)nodes.get(ppoint.getIndex());
1074 Graph graph=graphMap.get(fcall);
1075 Graph oldgraph=(ppoint.getIndex()==0)?
1076 bbgraphMap.get(bblock):
1077 graphMap.get(nodes.get(ppoint.getIndex()-1));
1078 Set<FlatSESEEnterNode> seseCallers=OoOJava?taskAnalysis.getTransitiveExecutingRBlocks(fcall):null;
1080 //Age outside nodes if necessary
1081 for(Iterator<AllocNode> nodeit=delta.addNodeAges.iterator();nodeit.hasNext();) {
1082 AllocNode node=nodeit.next();
1083 if (!graph.callNodeAges.contains(node)) {
1084 graph.callNodeAges.add(node);
1085 newDelta.addNodeAges.add(node);
1087 if (!graph.reachNode.contains(node)&&!node.isSummary()) {
1088 /* Need to age node in existing graph*/
1089 summarizeInGraph(graph, newDelta, node);
1091 if (graph.callNewEdges.containsKey(node)) {
1092 for(Iterator<Edge> eit=graph.callNewEdges.get(node).iterator();eit.hasNext();) {
1094 if ((graph.callNodeAges.contains(e.src)||graph.reachNode.contains(e.src))&&
1095 (graph.callNodeAges.contains(e.dst)||graph.reachNode.contains(e.dst))) {
1096 Edge edgetoadd=e.copy();//we need our own copy to modify below
1098 if (seseCallers!=null)
1099 edgetoadd.taintModify(seseCallers);
1100 mergeCallEdge(graph, newDelta, edgetoadd);
1107 for(Map.Entry<AllocNode, MySet<Edge>> entry:delta.heapedgeadd.entrySet()) {
1108 for(Edge e:entry.getValue()) {
1109 boolean addedge=false;
1110 Edge edgetoadd=null;
1111 if (e.statuspredicate==Edge.NEW) {
1112 if ((graph.callNodeAges.contains(e.src)||graph.reachNode.contains(e.src))&&
1113 (graph.callNodeAges.contains(e.dst)||graph.reachNode.contains(e.dst))) {
1114 edgetoadd=e.copy();//we need our own copy to modify below
1116 graph.addCallEdge(e);
1119 Edge[] edgeArray=e.makeStatus(allocFactory);
1121 int statuspredicate=0;
1122 for(int i=0;i<edgeArray.length;i++) {
1123 Edge origEdgeKey=edgeArray[i];
1124 if (graph.reachEdge.contains(origEdgeKey)) {
1125 Edge origEdge=graph.reachEdge.get(origEdgeKey);
1126 //copy the predicate
1127 statuspredicate=statuspredicate|origEdge.statuspredicate;
1129 if (!graph.callOldEdges.containsKey(origEdgeKey)) {
1130 graph.callOldEdges.put(origEdgeKey, new MySet<Edge>());
1132 if (graph.callOldEdges.get(origEdgeKey).contains(e)) {
1133 Edge olde=graph.callOldEdges.get(origEdgeKey).get(e);
1134 graph.callOldEdges.get(origEdgeKey).add(olde.merge(e));
1136 graph.callOldEdges.get(origEdgeKey).add(e);
1139 if (statuspredicate!=0) {
1141 newe.statuspredicate=statuspredicate;
1145 if (seseCallers!=null&&edgetoadd!=null)
1146 edgetoadd.taintModify(seseCallers);
1147 mergeCallEdge(graph, newDelta, edgetoadd);
1151 processCallExternal(graph, newDelta, graph.externalEdgeSet);
1153 //Add edge for return value
1154 if (fcall.getReturnTemp()!=null) {
1155 MySet<Edge> returnedge=delta.varedgeadd.get(returntmp);
1156 if (returnedge!=null)
1157 for(Edge e:returnedge) {
1158 Edge newedge=e.copy();
1159 newedge.srcvar=fcall.getReturnTemp();
1160 if (seseCallers!=null)
1161 newedge.taintModify(seseCallers);
1162 if (graph.getEdges(fcall.getReturnTemp())==null||!graph.getEdges(fcall.getReturnTemp()).contains(newedge))
1163 newDelta.addEdge(newedge);
1166 applyDiffs(graph, newDelta);
1170 public void mergeEdge(Graph graph, Delta newDelta, Edge edgetoadd) {
1171 if (edgetoadd!=null) {
1172 Edge match=graph.getMatch(edgetoadd);
1174 if (match==null||!match.subsumes(edgetoadd)) {
1175 Edge mergededge=edgetoadd.merge(match);
1176 newDelta.addEdge(mergededge);
1181 /* This is a call produced edge...need to remember this */
1183 public void mergeCallEdge(Graph graph, Delta newDelta, Edge edgetoadd) {
1184 if (edgetoadd!=null) {
1185 newDelta.addEdgeClear(edgetoadd);
1187 Edge match=graph.getMatch(edgetoadd);
1189 if (match==null||!match.subsumes(edgetoadd)) {
1190 Edge mergededge=edgetoadd.merge(match);
1191 newDelta.addEdge(mergededge);
1192 graph.callerEdges.add(mergededge);
1198 /* Summarizes out of context nodes in graph */
1199 void summarizeInGraph(Graph graph, Delta newDelta, AllocNode singleNode) {
1200 AllocNode summaryNode=allocFactory.getAllocNode(singleNode, true);
1202 //Handle outgoing heap edges
1203 MySet<Edge> edgeset=graph.getEdges(singleNode);
1205 for(Edge e:edgeset) {
1206 Edge rewrite=e.rewrite(singleNode, summaryNode);
1208 newDelta.removeHeapEdge(e);
1209 mergeCallEdge(graph, newDelta, rewrite);
1212 //Handle incoming edges
1213 MySet<Edge> backedges=graph.getBackEdges(singleNode);
1214 for(Edge e:backedges) {
1215 if (e.dst==singleNode) {
1216 //Need to get original edge so that predicate will be correct
1217 Edge match=graph.getMatch(e);
1219 Edge rewrite=match.rewrite(singleNode, summaryNode);
1220 newDelta.removeEdge(match);
1221 mergeCallEdge(graph, newDelta, rewrite);
1227 void applyDiffs(Graph graph, Delta delta) {
1228 applyDiffs(graph, delta, false);
1231 void applyDiffs(Graph graph, Delta delta, boolean genbackwards) {
1232 //build backwards map if requested
1233 if (genbackwards&&graph.backMap==null) {
1234 graph.backMap=new HashMap<AllocNode, MySet<Edge>>();
1235 if (graph.parent.backMap==null) {
1236 graph.parent.backMap=new HashMap<AllocNode, MySet<Edge>>();
1237 for(Map.Entry<AllocNode, MySet<Edge>> entry:graph.nodeMap.entrySet()) {
1238 for(Edge e:entry.getValue()) {
1239 if (!graph.parent.backMap.containsKey(e.dst))
1240 graph.parent.backMap.put(e.dst, new MySet<Edge>());
1241 graph.parent.backMap.get(e.dst).add(e);
1244 for(Map.Entry<TempDescriptor, MySet<Edge>> entry:graph.varMap.entrySet()) {
1245 for(Edge e:entry.getValue()) {
1246 if (!graph.parent.backMap.containsKey(e.dst))
1247 graph.parent.backMap.put(e.dst, new MySet<Edge>());
1248 graph.parent.backMap.get(e.dst).add(e);
1254 //Add hidden base edges
1255 for(Map.Entry<AllocNode, MySet<Edge>> e: delta.baseheapedge.entrySet()) {
1256 AllocNode node=e.getKey();
1257 MySet<Edge> edges=e.getValue();
1258 if (graph.nodeMap.containsKey(node)) {
1259 MySet<Edge> nodeEdges=graph.nodeMap.get(node);
1260 nodeEdges.addAll(edges);
1265 for(Map.Entry<AllocNode, MySet<Edge>> e: delta.heapedgeremove.entrySet()) {
1266 AllocNode node=e.getKey();
1267 MySet<Edge> edgestoremove=e.getValue();
1268 if (graph.nodeMap.containsKey(node)) {
1269 //Just apply diff to current map
1270 graph.nodeMap.get(node).removeAll(edgestoremove);
1272 //Generate diff from parent graph
1273 MySet<Edge> parentedges=graph.parent.nodeMap.get(node);
1274 if (parentedges!=null) {
1275 MySet<Edge> newedgeset=Util.setSubtract(parentedges, edgestoremove);
1276 graph.nodeMap.put(node, newedgeset);
1282 for(Map.Entry<AllocNode, MySet<Edge>> e: delta.heapedgeadd.entrySet()) {
1283 AllocNode node=e.getKey();
1284 MySet<Edge> edgestoadd=e.getValue();
1285 //If we have not done a subtract, then
1286 if (!graph.nodeMap.containsKey(node)) {
1287 //Copy the parent entry
1288 if (graph.parent.nodeMap.containsKey(node))
1289 graph.nodeMap.put(node, (MySet<Edge>)graph.parent.nodeMap.get(node).clone());
1291 graph.nodeMap.put(node, new MySet<Edge>());
1293 Edge.mergeEdgesInto(graph.nodeMap.get(node),edgestoadd);
1295 for(Edge eadd:edgestoadd) {
1296 if (!graph.backMap.containsKey(eadd.dst))
1297 graph.backMap.put(eadd.dst, new MySet<Edge>());
1298 graph.backMap.get(eadd.dst).add(eadd);
1304 for(Map.Entry<TempDescriptor, MySet<Edge>> e: delta.varedgeremove.entrySet()) {
1305 TempDescriptor tmp=e.getKey();
1306 MySet<Edge> edgestoremove=e.getValue();
1308 if (graph.varMap.containsKey(tmp)) {
1309 //Just apply diff to current map
1310 graph.varMap.get(tmp).removeAll(edgestoremove);
1311 } else if (graph.parent.varMap.containsKey(tmp)) {
1312 //Generate diff from parent graph
1313 MySet<Edge> parentedges=graph.parent.varMap.get(tmp);
1314 MySet<Edge> newedgeset=Util.setSubtract(parentedges, edgestoremove);
1315 graph.varMap.put(tmp, newedgeset);
1320 for(Map.Entry<TempDescriptor, MySet<Edge>> e: delta.varedgeadd.entrySet()) {
1321 TempDescriptor tmp=e.getKey();
1322 MySet<Edge> edgestoadd=e.getValue();
1323 if (graph.varMap.containsKey(tmp)) {
1324 Edge.mergeEdgesInto(graph.varMap.get(tmp), edgestoadd);
1326 graph.varMap.put(tmp, (MySet<Edge>) edgestoadd.clone());
1328 for(Edge eadd:edgestoadd) {
1329 if (!graph.backMap.containsKey(eadd.dst))
1330 graph.backMap.put(eadd.dst, new MySet<Edge>());
1331 graph.backMap.get(eadd.dst).add(eadd);
1336 //Add node additions
1337 for(AllocNode node:delta.addNodeAges) {
1338 graph.nodeAges.add(node);
1341 for(Map.Entry<AllocNode, Boolean> nodeentry:delta.addOldNodes.entrySet()) {
1342 AllocNode node=nodeentry.getKey();
1343 Boolean ispresent=nodeentry.getValue();
1344 graph.oldNodes.put(node, ispresent);
1347 Delta processSetFieldElementNode(FlatNode node, Delta delta, Graph graph) {
1351 if (node.kind()==FKind.FlatSetElementNode) {
1352 FlatSetElementNode fen=(FlatSetElementNode) node;
1357 FlatSetFieldNode ffn=(FlatSetFieldNode) node;
1363 if (delta.getInit()) {
1364 MySet<Edge> dstEdges=GraphManip.getEdges(graph, delta, dst);
1366 if (OoOJava&&!accessible.isAccessible(node, dst)) {
1367 Taint dstStallTaint=Taint.factory(node, dst, AllocFactory.dummySite, null, ReachGraph.predsEmpty);
1368 dstEdges=Edge.taintAll(dstEdges, dstStallTaint);
1369 updateVarDelta(graph, delta, dst, dstEdges, null);
1372 effectsAnalysis.analyzeFlatSetFieldNode(dstEdges, fd, node);
1375 //Do nothing for non pointers
1376 if (!src.getType().isPtr()) {
1380 MySet<Edge> srcEdges=GraphManip.getEdges(graph, delta, src);
1381 if (OoOJava&&!accessible.isAccessible(node, src)) {
1382 Taint srcStallTaint=Taint.factory(node, src, AllocFactory.dummySite, null, ReachGraph.predsEmpty);
1383 srcEdges=Edge.taintAll(srcEdges, srcStallTaint);
1384 updateVarDelta(graph, delta, src, srcEdges, null);
1387 MySet<Edge> edgesToAdd=GraphManip.genEdges(dstEdges, fd, srcEdges);
1388 MySet<Edge> edgesToRemove=null;
1389 if (dstEdges.size()==1&&!dstEdges.iterator().next().dst.isSummary()&&fd!=null) {
1390 /* Can do a strong update */
1391 edgesToRemove=GraphManip.getEdges(graph, delta, dstEdges, fd);
1392 graph.strongUpdateSet=edgesToRemove;
1394 graph.strongUpdateSet=new MySet<Edge>();
1397 updateHeapDelta(graph, delta, edgesToAdd, edgesToRemove);
1398 applyDiffs(graph, delta);
1400 MySet<Edge> newDstEdges=GraphManip.getDiffEdges(delta, dst);
1402 if (OoOJava&&!accessible.isAccessible(node, dst)) {
1403 Taint dstStallTaint=Taint.factory(node, dst, AllocFactory.dummySite, null, ReachGraph.predsEmpty);
1404 newDstEdges=Edge.taintAll(newDstEdges, dstStallTaint);
1405 updateVarDelta(graph, delta, dst, newDstEdges, null);
1409 effectsAnalysis.analyzeFlatSetFieldNode(newDstEdges, fd, node);
1412 if (!src.getType().isPtr()) {
1416 /* Next look at new sources */
1418 MySet<Edge> edgesToAdd=new MySet<Edge>();
1419 MySet<Edge> newSrcEdges=GraphManip.getDiffEdges(delta, src);
1420 MySet<Edge> srcEdges=GraphManip.getEdges(graph, delta, src);
1421 HashSet<AllocNode> dstNodes=GraphManip.getNodes(graph, delta, dst);
1423 if (OoOJava&&!accessible.isAccessible(node, src)) {
1424 Taint srcStallTaint=Taint.factory(node, src, AllocFactory.dummySite, null, ReachGraph.predsEmpty);
1425 newSrcEdges=Edge.taintAll(newSrcEdges, srcStallTaint);
1426 updateVarDelta(graph, delta, src, newSrcEdges, null);
1429 MySet<Edge> edgesToRemove=null;
1430 if (newDstEdges.size()!=0) {
1431 if (dstNodes.size()>1&&!dstNodes.iterator().next().isSummary()&&fd!=null) {
1432 /* Need to undo strong update */
1433 if (graph.strongUpdateSet!=null) {
1434 edgesToAdd.addAll(graph.strongUpdateSet);
1435 graph.strongUpdateSet=null; //Prevent future strong updates
1437 } else if (dstNodes.size()==1&&newDstEdges.size()==1&&!newDstEdges.iterator().next().dst.isSummary()&&graph.strongUpdateSet!=null&&fd!=null) {
1438 edgesToRemove=GraphManip.getEdges(graph, delta, dstNodes, fd);
1439 graph.strongUpdateSet.addAll(edgesToRemove);
1441 Edge.mergeEdgesInto(edgesToAdd, GraphManip.genEdges(newDstEdges, fd, srcEdges));
1445 if (graph.strongUpdateSet!=null&&fd!=null) {
1446 MySet<Edge> otherEdgesToRemove=GraphManip.getDiffEdges(delta, dstNodes, fd);
1447 if (edgesToRemove!=null)
1448 edgesToRemove.addAll(otherEdgesToRemove);
1450 edgesToRemove=otherEdgesToRemove;
1451 graph.strongUpdateSet.addAll(otherEdgesToRemove);
1454 //Next look at new destinations
1455 Edge.mergeEdgesInto(edgesToAdd, GraphManip.genEdges(dstNodes, fd, newSrcEdges));
1458 updateHeapDelta(graph, delta, edgesToAdd, edgesToRemove);
1459 applyDiffs(graph, delta);
1464 Delta processCopyNode(FlatNode node, Delta delta, Graph graph) {
1467 if (node.kind()==FKind.FlatOpNode) {
1468 FlatOpNode fon=(FlatOpNode) node;
1471 } else if (node.kind()==FKind.FlatReturnNode) {
1472 FlatReturnNode frn=(FlatReturnNode)node;
1473 src=frn.getReturnTemp();
1475 if (src==null||!src.getType().isPtr()) {
1477 applyDiffs(graph, delta);
1481 FlatCastNode fcn=(FlatCastNode) node;
1485 if (delta.getInit()) {
1486 MySet<Edge> srcedges=GraphManip.getEdges(graph, delta, src);
1487 MySet<Edge> edgesToAdd=GraphManip.genEdges(dst, srcedges);
1488 MySet<Edge> edgesToRemove=GraphManip.getEdges(graph, delta, dst);
1489 updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove);
1490 applyDiffs(graph, delta);
1492 /* First compute new src nodes */
1493 MySet<Edge> newSrcEdges=GraphManip.getDiffEdges(delta, src);
1495 /* Compute the union, and then the set of edges */
1496 MySet<Edge> edgesToAdd=GraphManip.genEdges(dst, newSrcEdges);
1498 /* Compute set of edges to remove */
1499 MySet<Edge> edgesToRemove=GraphManip.getDiffEdges(delta, dst);
1502 updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove);
1503 applyDiffs(graph, delta);
1508 Delta processFieldElementNode(FlatNode node, Delta delta, Graph graph) {
1512 TaintSet taint=null;
1514 if (node.kind()==FKind.FlatElementNode) {
1515 FlatElementNode fen=(FlatElementNode) node;
1520 FlatFieldNode ffn=(FlatFieldNode) node;
1525 if (OoOJava&&!accessible.isAccessible(node, src)) {
1526 taint=TaintSet.factory(Taint.factory(node, src, AllocFactory.dummySite, null, ReachGraph.predsEmpty));
1529 //Do nothing for non pointers
1530 if (delta.getInit()) {
1531 MySet<Edge> srcedges=GraphManip.getEdges(graph, delta, src);
1534 srcedges=Edge.taintAll(srcedges, taint);
1535 updateVarDelta(graph, delta, src, srcedges, null);
1537 effectsAnalysis.analyzeFlatFieldNode(srcedges, fd, node);
1539 if (!dst.getType().isPtr())
1542 MySet<Edge> edgesToAdd=GraphManip.dereference(graph, delta, dst, srcedges, fd, node);
1543 MySet<Edge> edgesToRemove=GraphManip.getEdges(graph, delta, dst);
1545 updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove);
1546 applyDiffs(graph, delta);
1548 MySet<Edge> newsrcedges=GraphManip.getDiffEdges(delta, src);
1551 newsrcedges=Edge.taintAll(newsrcedges, taint);
1552 updateVarDelta(graph, delta, src, newsrcedges, null);
1554 effectsAnalysis.analyzeFlatFieldNode(newsrcedges, fd, node);
1556 if (!dst.getType().isPtr())
1559 /* First compute new objects we read fields of */
1560 MySet<Edge> allsrcedges=GraphManip.getEdges(graph, delta, src);
1561 MySet<Edge> edgesToAdd=GraphManip.diffDereference(delta, dst, allsrcedges, fd, node);
1562 /* Next compute new targets of fields */
1563 MySet<Edge> newfdedges=GraphManip.dereference(graph, delta, dst, newsrcedges, fd, node);
1565 /* Compute the union, and then the set of edges */
1566 Edge.mergeEdgesInto(edgesToAdd, newfdedges);
1568 /* Compute set of edges to remove */
1569 MySet<Edge> edgesToRemove=GraphManip.getDiffEdges(delta, dst);
1573 updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove);
1574 applyDiffs(graph, delta);
1580 void updateVarDelta(Graph graph, Delta delta, TempDescriptor tmp, MySet<Edge> edgestoAdd, MySet<Edge> edgestoRemove) {
1581 MySet<Edge> edgeAdd=delta.varedgeadd.get(tmp);
1582 MySet<Edge> edgeRemove=delta.varedgeremove.get(tmp);
1583 MySet<Edge> existingEdges=graph.getEdges(tmp);
1584 if (edgestoRemove!=null)
1585 for(Edge e: edgestoRemove) {
1586 //remove edge from delta
1589 //if the edge is already in the graph, add an explicit remove to the delta
1590 if (existingEdges.contains(e))
1591 delta.removeVarEdge(e);
1593 for(Edge e: edgestoAdd) {
1594 //Remove the edge from the remove set
1595 if (edgeRemove!=null)
1596 edgeRemove.remove(e);
1597 //Explicitly add it to the add set unless it is already in the graph
1598 if (typeUtil.isSuperorType(tmp.getType(), e.dst.getType())) {
1599 if (!existingEdges.contains(e)) {
1600 delta.addVarEdge(e);
1602 //See if the old edge subsumes the new one
1603 Edge olde=existingEdges.get(e);
1604 if (!olde.subsumes(e)) {
1605 delta.addVarEdge(olde.merge(e));
1612 void updateHeapDelta(Graph graph, Delta delta, MySet<Edge> edgestoAdd, MySet<Edge> edgestoRemove) {
1613 if (edgestoRemove!=null)
1614 for(Edge e: edgestoRemove) {
1615 AllocNode src=e.src;
1616 MySet<Edge> edgeAdd=delta.heapedgeadd.get(src);
1617 MySet<Edge> existingEdges=graph.getEdges(src);
1618 //remove edge from delta
1621 //if the edge is already in the graph, add an explicit remove to the delta
1622 if (existingEdges.contains(e)) {
1623 delta.removeHeapEdge(e);
1626 if (edgestoAdd!=null)
1627 for(Edge e: edgestoAdd) {
1628 AllocNode src=e.src;
1629 MySet<Edge> edgeRemove=delta.heapedgeremove.get(src);
1630 MySet<Edge> existingEdges=graph.getEdges(src);
1631 //Remove the edge from the remove set
1632 if (edgeRemove!=null)
1633 edgeRemove.remove(e);
1634 //Explicitly add it to the add set unless it is already in the graph
1635 if (!existingEdges.contains(e)) {
1636 delta.addHeapEdge(e);
1638 //See if the old edge subsumes the new one
1639 Edge olde=existingEdges.get(e);
1640 if (!olde.subsumes(e)) {
1641 delta.addHeapEdge(olde.merge(e));
1647 Delta processFlatNop(FlatNode node, Delta delta, Graph graph) {
1648 applyDiffs(graph, delta);
1652 Delta processNewNode(FlatNew node, Delta delta, Graph graph) {
1653 AllocNode summary=allocFactory.getAllocNode(node, true);
1654 AllocNode single=allocFactory.getAllocNode(node, false);
1655 TempDescriptor tmp=node.getDst();
1657 if (delta.getInit()) {
1658 /* We don't have to deal with summarization here... The
1659 * intuition is that this is the only place where we generate
1660 * nodes for this allocation site and this is the first time
1661 * we've analyzed this site */
1664 Edge e=new Edge(tmp, single);
1665 //Build new Edge set
1666 MySet<Edge> newedges=new MySet<Edge>();
1668 //Add it into the diffs
1669 delta.varedgeadd.put(tmp, newedges);
1670 //Remove the old edges
1671 MySet<Edge> oldedges=graph.getEdges(tmp);
1672 if (!oldedges.isEmpty())
1673 delta.varedgeremove.put(tmp, (MySet<Edge>) oldedges);
1674 //Apply incoming diffs to graph
1675 applyDiffs(graph, delta);
1676 //Note that we create a single node
1677 delta.addNodeAges.add(single);
1679 if (delta.addOldNodes.containsKey(single)||delta.baseOldNodes.containsKey(single)) {
1680 delta.addOldNodes.put(single, Boolean.FALSE);
1683 /* 1. Fix up the variable edge additions */
1685 for(Iterator<Map.Entry<TempDescriptor, MySet<Edge>>> entryIt=delta.varedgeadd.entrySet().iterator();entryIt.hasNext();) {
1686 Map.Entry<TempDescriptor, MySet<Edge>> entry=entryIt.next();
1688 if (entry.getKey()==tmp) {
1689 /* Check if this is the tmp we overwrite */
1692 /* Otherwise, check if the target of the edge is changed... */
1693 summarizeSet(entry.getValue(), graph.varMap.get(entry.getKey()), single, summary);
1697 /* 2. Fix up the base variable edges */
1699 for(Iterator<Map.Entry<TempDescriptor, MySet<Edge>>> entryIt=delta.basevaredge.entrySet().iterator();entryIt.hasNext();) {
1700 Map.Entry<TempDescriptor, MySet<Edge>> entry=entryIt.next();
1701 TempDescriptor entrytmp=entry.getKey();
1702 if (entrytmp==tmp) {
1703 /* Check is this is the tmp we overwrite, if so add to remove set */
1704 Util.relationUpdate(delta.varedgeremove, tmp, null, entry.getValue());
1706 /* Check if the target of the edge is changed */
1707 MySet<Edge> newset=(MySet<Edge>)entry.getValue().clone();
1708 MySet<Edge> removeset=shrinkSet(newset, graph.varMap.get(entrytmp), single, summary);
1709 Util.relationUpdate(delta.varedgeremove, entrytmp, newset, removeset);
1710 Util.relationUpdate(delta.varedgeadd, entrytmp, null, newset);
1715 /* 3. Fix up heap edge additions */
1717 HashMap<AllocNode, MySet<Edge>> addheapedge=new HashMap<AllocNode, MySet<Edge>>();
1718 for(Iterator<Map.Entry<AllocNode, MySet<Edge>>> entryIt=delta.heapedgeadd.entrySet().iterator();entryIt.hasNext();) {
1719 Map.Entry<AllocNode, MySet<Edge>> entry=entryIt.next();
1720 MySet<Edge> edgeset=entry.getValue();
1721 AllocNode allocnode=entry.getKey();
1722 if (allocnode==single) {
1724 summarizeSet(edgeset, graph.nodeMap.get(summary), single, summary);
1725 addheapedge.put(summary, edgeset);
1727 summarizeSet(edgeset, graph.nodeMap.get(allocnode), single, summary);
1731 /* Merge in diffs */
1733 for(Map.Entry<AllocNode, MySet<Edge>> entry:addheapedge.entrySet()) {
1734 AllocNode allocnode=entry.getKey();
1735 Util.relationUpdate(delta.heapedgeadd, allocnode, null, entry.getValue());
1738 /* 4. Fix up the base heap edges */
1740 for(Iterator<Map.Entry<AllocNode, MySet<Edge>>> entryIt=delta.baseheapedge.entrySet().iterator();entryIt.hasNext();) {
1741 Map.Entry<AllocNode, MySet<Edge>> entry=entryIt.next();
1742 MySet<Edge> edgeset=entry.getValue();
1743 AllocNode allocnode=entry.getKey();
1744 if (allocnode==single) {
1747 AllocNode addnode=(allocnode==single)?summary:allocnode;
1749 MySet<Edge> newset=(MySet<Edge>) edgeset.clone();
1750 MySet<Edge> removeset=shrinkSet(newset, graph.nodeMap.get(addnode), single, summary);
1751 Util.relationUpdate(delta.heapedgeadd, addnode, null, newset);
1752 Util.relationUpdate(delta.heapedgeremove, allocnode, null, removeset);
1755 /* Update Node Ages...If the base or addNodeAges set contains a
1756 * single node, it now should also contain a summary node... No
1757 * need to generate a single node as that has already been
1759 if (delta.baseNodeAges.contains(single)||delta.addNodeAges.contains(single)) {
1760 delta.addNodeAges.add(summary);
1763 //Kill the old node if someone tries to add it
1764 if (delta.addOldNodes.containsKey(single)||delta.baseOldNodes.containsKey(single)) {
1765 delta.addOldNodes.put(single, Boolean.FALSE);
1769 //Apply incoming diffs to graph
1770 applyDiffs(graph, delta);
1775 /* This function builds a new edge set where oldnode is summarized into new node */
1777 void summarizeSet(MySet<Edge> edgeset, MySet<Edge> oldedgeset, AllocNode oldnode, AllocNode sumnode) {
1778 MySet<Edge> newSet=null;
1779 for(Iterator<Edge> edgeit=edgeset.iterator();edgeit.hasNext();) {
1780 Edge e=edgeit.next();
1781 if (e.dst==oldnode||e.src==oldnode) {
1783 newSet=new MySet<Edge>();
1788 if (e.dst==oldnode) {
1791 if (e.src==oldnode) {
1794 if (oldedgeset==null||!oldedgeset.contains(e))
1799 edgeset.addAll(newSet);
1802 /* Shrinks the incoming set to just include rewritten values.
1803 * Returns a set of the original rewritten values */
1805 MySet<Edge> shrinkSet(MySet<Edge> edgeset, MySet<Edge> oldedgeset, AllocNode oldnode, AllocNode newnode) {
1806 MySet<Edge> newSet=null;
1807 MySet<Edge> removeSet=null;
1808 for(Iterator<Edge> edgeit=edgeset.iterator();edgeit.hasNext();) {
1809 Edge e=edgeit.next();
1811 if (e.dst==oldnode||e.src==oldnode) {
1813 newSet=new MySet<Edge>();
1814 removeSet=new MySet<Edge>();
1823 if (oldedgeset==null||!oldedgeset.contains(e))
1828 edgeset.addAll(newSet);
1832 /* This function returns a completely new Delta... It is safe to
1835 Delta applyInitDelta(Delta delta, BBlock block) {
1836 //Apply delta to graph
1837 boolean newGraph=false;
1838 if (!bbgraphMap.containsKey(block)) {
1839 bbgraphMap.put(block, new Graph(null));
1842 Graph graph=bbgraphMap.get(block);
1845 Delta newdelta=new Delta(null, true);
1846 //Add in heap edges and throw away original diff
1848 for(Map.Entry<AllocNode, MySet<Edge>> entry:delta.heapedgeadd.entrySet()) {
1849 graph.nodeMap.put(entry.getKey(), new MySet<Edge>(entry.getValue()));
1851 //Add in var edges and throw away original diff
1852 Set<TempDescriptor> livetemps=bblivetemps.get(block);
1854 for(Map.Entry<TempDescriptor, MySet<Edge>> entry:delta.varedgeadd.entrySet()) {
1855 if (livetemps.contains(entry.getKey()))
1856 graph.varMap.put(entry.getKey(), new MySet<Edge>(entry.getValue()));
1858 //Record that this is initial set...
1859 graph.nodeAges.addAll(delta.addNodeAges);
1861 for(Map.Entry<AllocNode, Boolean> oldentry:delta.addOldNodes.entrySet()) {
1862 if (oldentry.getValue().booleanValue()) {
1863 graph.oldNodes.put(oldentry.getKey(), Boolean.TRUE);
1868 Delta newdelta=new Delta(null, false);
1869 //merge in heap edges and variables
1870 mergeHeapEdges(graph, delta, newdelta);
1871 mergeVarEdges(graph, delta, newdelta, block);
1872 mergeAges(graph, delta, newdelta);
1877 /* This function merges in the heap edges. It updates delta to be
1880 void mergeHeapEdges(Graph graph, Delta delta, Delta newdelta) {
1882 for(Map.Entry<AllocNode, MySet<Edge>> heapedge:delta.heapedgeadd.entrySet()) {
1883 AllocNode nsrc=heapedge.getKey();
1884 MySet<Edge> edges=heapedge.getValue();
1886 if (graph.backMap!=null) {
1888 if (!graph.backMap.containsKey(e.dst))
1889 graph.backMap.put(e.dst, new MySet<Edge>());
1890 graph.backMap.get(e.dst).add(e);
1894 if (!graph.nodeMap.containsKey(nsrc)) {
1895 graph.nodeMap.put(nsrc, new MySet<Edge>());
1897 MySet<Edge> dstedges=graph.nodeMap.get(nsrc);
1898 MySet<Edge> diffedges=new MySet<Edge>();
1900 if (!dstedges.contains(e)) {
1901 //We have a new edge
1905 Edge origedge=dstedges.get(e);
1906 if (!origedge.subsumes(e)) {
1907 Edge mergededge=origedge.merge(e);
1908 diffedges.add(mergededge);
1909 dstedges.add(mergededge);
1913 //Done with edge set...
1914 if (diffedges.size()>0) {
1916 newdelta.baseheapedge.put(nsrc, diffedges);
1921 /* This function merges in the var edges. It updates delta to be
1924 void mergeVarEdges(Graph graph, Delta delta, Delta newdelta, BBlock block) {
1926 Set<TempDescriptor> livetemps=bblivetemps.get(block);
1928 for(Map.Entry<TempDescriptor, MySet<Edge>> varedge:delta.varedgeadd.entrySet()) {
1929 TempDescriptor tmpsrc=varedge.getKey();
1930 if (livetemps.contains(tmpsrc)) {
1931 MySet<Edge> edges=varedge.getValue();
1932 if (graph.backMap!=null) {
1934 if (!graph.backMap.containsKey(e.dst))
1935 graph.backMap.put(e.dst, new MySet<Edge>());
1936 graph.backMap.get(e.dst).add(e);
1940 if (!graph.varMap.containsKey(tmpsrc)) {
1941 graph.varMap.put(tmpsrc, new MySet<Edge>());
1943 MySet<Edge> dstedges=graph.varMap.get(tmpsrc);
1944 MySet<Edge> diffedges=new MySet<Edge>();
1946 if (!dstedges.contains(e)) {
1947 //We have a new edge
1951 Edge origedge=dstedges.get(e);
1952 if (!origedge.subsumes(e)) {
1953 Edge mergededge=origedge.merge(e);
1954 diffedges.add(mergededge);
1955 dstedges.add(mergededge);
1959 //Done with edge set...
1960 if (diffedges.size()>0) {
1962 newdelta.basevaredge.put(tmpsrc,diffedges);
1968 void mergeAges(Graph graph, Delta delta, Delta newDelta) {
1970 for(AllocNode node:delta.addNodeAges) {
1971 if (!graph.nodeAges.contains(node)) {
1972 graph.nodeAges.add(node);
1973 newDelta.baseNodeAges.add(node);
1976 for(Map.Entry<AllocNode, Boolean> oldentry:delta.addOldNodes.entrySet()) {
1977 AllocNode node=oldentry.getKey();
1978 boolean ispresent=oldentry.getValue().booleanValue();
1979 if (ispresent&&!graph.oldNodes.containsKey(node)) {
1980 graph.oldNodes.put(node, Boolean.TRUE);
1981 newDelta.baseOldNodes.put(node, Boolean.TRUE);