1 package Analysis.Pointer;
5 import Analysis.Pointer.BasicBlock.BBlock;
6 import Analysis.Pointer.AllocFactory.AllocNode;
9 HashMap<FlatMethod, BasicBlock> blockMap;
10 HashMap<BBlock, Graph> bbgraphMap;
11 HashMap<FlatNode, Graph> graphMap;
14 AllocFactory allocFactory;
15 LinkedList<Delta> toprocess;
16 TempDescriptor returntmp;
18 public Pointer(State state, TypeUtil typeUtil) {
20 this.blockMap=new HashMap<FlatMethod, BasicBlock>();
21 this.bbgraphMap=new HashMap<BBlock, Graph>();
22 this.graphMap=new HashMap<FlatNode, Graph>();
23 this.typeUtil=typeUtil;
24 this.allocFactory=new AllocFactory(state, typeUtil);
25 this.toprocess=new LinkedList<Delta>();
26 ClassDescriptor stringcd=typeUtil.getClass(TypeUtil.ObjectClass);
27 this.returntmp=new TempDescriptor("RETURNVAL", stringcd);
30 public BasicBlock getBBlock(FlatMethod fm) {
31 if (!blockMap.containsKey(fm))
32 blockMap.put(fm, BasicBlock.getBBlock(fm));
33 return blockMap.get(fm);
36 Delta buildInitialContext() {
37 MethodDescriptor md=typeUtil.getMain();
38 FlatMethod fm=state.getMethodFlat(md);
39 BasicBlock bb=getBBlock(fm);
40 BBlock start=bb.getStart();
41 Delta delta=new Delta(start, true);
42 HashSet<Edge> arrayset=new HashSet<Edge>();
43 HashSet<Edge> varset=new HashSet<Edge>();
44 arrayset.add(new Edge(allocFactory.StringArray, null, allocFactory.Strings));
45 varset.add(new Edge(fm.getParameter(0), allocFactory.StringArray));
46 delta.heapedgeadd.put(allocFactory.StringArray, arrayset);
47 delta.varedgeadd.put(fm.getParameter(0), varset);
51 public void doAnalysis() {
52 toprocess.add(buildInitialContext());
54 while(!toprocess.isEmpty()) {
55 Delta delta=toprocess.remove();
56 BBlock bblock=delta.getBlock();
57 Vector<FlatNode> nodes=bblock.nodes();
59 //Build base graph for entrance to this basic block
60 delta=applyInitDelta(delta, bblock);
61 Graph graph=bbgraphMap.get(bblock);
64 //Compute delta at exit of each node
65 for(int i=0; i<nodes.size();i++) {
66 FlatNode currNode=nodes.get(i);
67 if (!graphMap.containsKey(currNode)) {
68 graphMap.put(currNode, new Graph(graph));
70 nodeGraph=graphMap.get(currNode);
71 delta=processNode(currNode, delta, nodeGraph);
73 generateFinalDelta(bblock, delta, nodeGraph);
77 void generateFinalDelta(BBlock bblock, Delta delta, Graph graph) {
78 Delta newDelta=new Delta(null, false);
79 if (delta.getInit()) {
80 //First compute the set of temps
81 HashSet<TempDescriptor> tmpSet=new HashSet<TempDescriptor>();
82 tmpSet.addAll(graph.varMap.keySet());
83 tmpSet.addAll(graph.parent.varMap.keySet());
85 //Next build the temp map part of the delta
86 for(TempDescriptor tmp:tmpSet) {
87 HashSet<Edge> edgeSet=new HashSet<Edge>();
89 if (graph.varMap.containsKey(tmp))
90 edgeSet.addAll(graph.varMap.get(tmp));
92 edgeSet.addAll(graph.parent.varMap.get(tmp));
93 newDelta.varedgeadd.put(tmp, edgeSet);
96 //Next compute the set of src allocnodes
97 HashSet<AllocNode> nodeSet=new HashSet<AllocNode>();
98 nodeSet.addAll(graph.nodeMap.keySet());
99 nodeSet.addAll(graph.parent.nodeMap.keySet());
101 for(AllocNode node:nodeSet) {
102 HashSet<Edge> edgeSet=new HashSet<Edge>();
104 if (graph.nodeMap.containsKey(node))
105 edgeSet.addAll(graph.nodeMap.get(node));
107 edgeSet.addAll(graph.parent.nodeMap.get(node));
108 newDelta.heapedgeadd.put(node, edgeSet);
111 /* We can break the old delta...it is done being used */
112 /* First we will build variable edges */
113 HashSet<TempDescriptor> tmpSet=new HashSet<TempDescriptor>();
114 tmpSet.addAll(delta.basevaredge.keySet());
115 tmpSet.addAll(delta.varedgeadd.keySet());
116 for(TempDescriptor tmp:tmpSet) {
117 /* Start with the new incoming edges */
118 HashSet<Edge> newbaseedge=delta.basevaredge.get(tmp);
119 /* Remove the remove set */
120 newbaseedge.removeAll(delta.varedgeremove.get(tmp));
121 /* Add in the new set*/
122 newbaseedge.addAll(delta.varedgeadd.get(tmp));
123 /* Store the results */
124 newDelta.varedgeadd.put(tmp, newbaseedge);
127 /* Next we build heap edges */
128 HashSet<AllocNode> nodeSet=new HashSet<AllocNode>();
129 nodeSet.addAll(delta.baseheapedge.keySet());
130 nodeSet.addAll(delta.heapedgeadd.keySet());
131 nodeSet.addAll(delta.heapedgeremove.keySet());
132 for(AllocNode node:nodeSet) {
133 /* Start with the new incoming edges */
134 HashSet<Edge> newheapedge=(HashSet<Edge>) delta.baseheapedge.get(node).clone();
135 /* Remove the remove set */
136 newheapedge.removeAll(delta.heapedgeremove.get(node));
137 /* Add in the add set */
138 newheapedge.addAll(delta.heapedgeadd.get(node));
139 newDelta.heapedgeadd.put(node, newheapedge);
141 /* Also need to subtract off some edges */
142 HashSet<Edge> removeset=delta.heapedgeremove.get(node);
143 /* Remove the newly created edges..no need to propagate a diff for those */
144 removeset.removeAll(delta.baseheapedge.get(node));
145 newDelta.heapedgeremove.put(node, removeset);
148 /* Now we need to propagate newdelta */
149 if (!newDelta.heapedgeadd.isEmpty()||!newDelta.heapedgeremove.isEmpty()||!newDelta.varedgeadd.isEmpty()) {
150 /* We have a delta to propagate */
151 Vector<BBlock> blockvector=bblock.next();
152 for(int i=0;i<blockvector.size();i++) {
154 newDelta.setBlock(blockvector.get(i));
155 toprocess.add(newDelta);
157 toprocess.add(newDelta.diffBlock(blockvector.get(i)));
163 Delta processNode(FlatNode node, Delta delta, Graph newgraph) {
164 switch(node.kind()) {
166 return processNewNode((FlatNew)node, delta, newgraph);
167 case FKind.FlatFieldNode:
168 case FKind.FlatElementNode:
169 return processFieldElementNode(node, delta, newgraph);
170 case FKind.FlatCastNode:
171 case FKind.FlatOpNode:
172 case FKind.FlatReturnNode:
173 return processCopyNode(node, delta, newgraph);
174 case FKind.FlatSetFieldNode:
175 case FKind.FlatSetElementNode:
176 return processSetFieldElementNode(node, delta, newgraph);
177 case FKind.FlatMethod:
179 return processFlatNop(node, delta, newgraph);
181 case FKind.FlatSESEEnterNode:
182 case FKind.FlatSESEExitNode:
183 throw new Error("Unimplemented node:"+node);
185 throw new Error("Unrecognized node:"+node);
189 void applyDiffs(Graph graph, Delta delta) {
190 //Add hidden base edges
191 for(Map.Entry<AllocNode, HashSet<Edge>> e: delta.baseheapedge.entrySet()) {
192 AllocNode node=e.getKey();
193 HashSet<Edge> edges=e.getValue();
194 if (graph.nodeMap.containsKey(node)) {
195 HashSet<Edge> nodeEdges=graph.nodeMap.get(node);
196 nodeEdges.addAll(edges);
201 for(Map.Entry<AllocNode, HashSet<Edge>> e: delta.heapedgeremove.entrySet()) {
202 AllocNode node=e.getKey();
203 HashSet<Edge> edgestoremove=e.getValue();
204 if (graph.nodeMap.containsKey(node)) {
205 //Just apply diff to current map
206 graph.nodeMap.get(node).removeAll(edgestoremove);
208 //Generate diff from parent graph
209 HashSet<Edge> parentedges=graph.parent.nodeMap.get(node);
210 HashSet<Edge> newedgeset=Util.setSubtract(parentedges, edgestoremove);
211 graph.nodeMap.put(node, newedgeset);
216 for(Map.Entry<AllocNode, HashSet<Edge>> e: delta.heapedgeadd.entrySet()) {
217 AllocNode node=e.getKey();
218 HashSet<Edge> edgestoadd=e.getValue();
219 //If we have not done a subtract, then
220 if (!graph.nodeMap.containsKey(node)) {
221 //Copy the parent entry
222 graph.nodeMap.put(node, (HashSet<Edge>)graph.parent.nodeMap.get(node).clone());
224 graph.nodeMap.get(node).addAll(edgestoadd);
228 for(Map.Entry<TempDescriptor, HashSet<Edge>> e: delta.varedgeremove.entrySet()) {
229 TempDescriptor tmp=e.getKey();
230 HashSet<Edge> edgestoremove=e.getValue();
232 if (graph.varMap.containsKey(tmp)) {
233 //Just apply diff to current map
234 graph.varMap.get(tmp).removeAll(edgestoremove);
236 //Generate diff from parent graph
237 HashSet<Edge> parentedges=graph.parent.varMap.get(tmp);
238 HashSet<Edge> newedgeset=Util.setSubtract(parentedges, edgestoremove);
239 graph.varMap.put(tmp, newedgeset);
244 for(Map.Entry<TempDescriptor, HashSet<Edge>> e: delta.varedgeadd.entrySet()) {
245 TempDescriptor tmp=e.getKey();
246 HashSet<Edge> edgestoadd=e.getValue();
247 graph.varMap.put(tmp, (HashSet<Edge>) edgestoadd.clone());
251 Delta processSetFieldElementNode(FlatNode node, Delta delta, Graph graph) {
255 if (node.kind()==FKind.FlatSetElementNode) {
256 FlatSetElementNode fen=(FlatSetElementNode) node;
261 FlatSetFieldNode ffn=(FlatSetFieldNode) node;
266 if (delta.getInit()) {
267 HashSet<AllocNode> srcNodes=GraphManip.getNodes(graph, delta, src);
268 HashSet<AllocNode> dstNodes=GraphManip.getNodes(graph, delta, dst);
269 HashSet<Edge> edgesToAdd=GraphManip.genEdges(srcNodes, fd, dstNodes);
270 HashSet<Edge> edgesToRemove=null;
271 if (dstNodes.size()==1&&!dstNodes.iterator().next().isSummary()) {
272 /* Can do a strong update */
273 edgesToRemove=GraphManip.getEdges(graph, delta, dstNodes, fd);
276 updateHeapDelta(graph, delta, edgesToAdd, edgesToRemove);
277 applyDiffs(graph, delta);
279 /* First look at new sources */
280 HashSet<Edge> edgesToAdd=new HashSet<Edge>();
281 HashSet<AllocNode> newSrcNodes=GraphManip.getDiffNodes(delta, src);
282 HashSet<AllocNode> dstNodes=GraphManip.getDiffNodes(delta, dst);
283 edgesToAdd.addAll(GraphManip.genEdges(newSrcNodes, fd, dstNodes));
284 HashSet<AllocNode> newDstNodes=GraphManip.getDiffNodes(delta, dst);
285 HashSet<Edge> edgesToRemove=null;
286 if (newDstNodes.size()!=0) {
287 if (dstNodes.size()==1&&!dstNodes.iterator().next().isSummary()) {
288 /* Need to undo strong update */
289 if (graph.strongUpdateSet!=null) {
290 edgesToAdd.addAll(graph.strongUpdateSet);
291 graph.strongUpdateSet.clear();
293 } else if (dstNodes.size()==0&&newDstNodes.size()==1&&!newDstNodes.iterator().next().isSummary()&&graph.strongUpdateSet==null) {
294 edgesToRemove=GraphManip.getEdges(graph, delta, dstNodes, fd);
296 HashSet<AllocNode> srcNodes=GraphManip.getDiffNodes(delta, src);
297 edgesToAdd.addAll(GraphManip.genEdges(srcNodes, fd, newDstNodes));
300 updateHeapDelta(graph, delta, edgesToAdd, edgesToRemove);
301 applyDiffs(graph, delta);
306 Delta processCopyNode(FlatNode node, Delta delta, Graph graph) {
309 if (node.kind()==FKind.FlatOpNode) {
310 FlatOpNode fon=(FlatOpNode) node;
313 } else if (node.kind()==FKind.FlatReturnNode) {
314 FlatReturnNode frn=(FlatReturnNode)node;
315 src=frn.getReturnTemp();
318 FlatCastNode fcn=(FlatCastNode) node;
322 if (delta.getInit()) {
323 HashSet<AllocNode> srcnodes=GraphManip.getNodes(graph, delta, src);
324 HashSet<Edge> edgesToAdd=GraphManip.genEdges(src, srcnodes);
325 HashSet<Edge> edgesToRemove=GraphManip.getEdges(graph, delta, dst);
326 updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove);
327 applyDiffs(graph, delta);
329 /* First compute new src nodes */
330 HashSet<AllocNode> newSrcNodes=GraphManip.getDiffNodes(delta, src);
332 /* Compute the union, and then the set of edges */
333 HashSet<Edge> edgesToAdd=GraphManip.genEdges(src, newSrcNodes);
335 /* Compute set of edges to remove */
336 HashSet<Edge> edgesToRemove=GraphManip.getDiffEdges(delta, dst);
339 updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove);
340 applyDiffs(graph, delta);
345 Delta processFieldElementNode(FlatNode node, Delta delta, Graph graph) {
349 if (node.kind()==FKind.FlatElementNode) {
350 FlatElementNode fen=(FlatElementNode) node;
355 FlatFieldNode ffn=(FlatFieldNode) node;
360 if (delta.getInit()) {
361 HashSet<AllocNode> srcnodes=GraphManip.getNodes(graph, delta, src);
362 HashSet<AllocNode> fdnodes=GraphManip.getNodes(graph, delta, srcnodes, fd);
363 HashSet<Edge> edgesToAdd=GraphManip.genEdges(src, fdnodes);
364 HashSet<Edge> edgesToRemove=GraphManip.getEdges(graph, delta, dst);
365 updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove);
366 applyDiffs(graph, delta);
368 /* First compute new objects we read fields of */
369 HashSet<AllocNode> allsrcnodes=GraphManip.getNodes(graph, delta, src);
370 HashSet<AllocNode> difffdnodes=GraphManip.getDiffNodes(delta, allsrcnodes, fd);
371 /* Next compute new targets of fields */
372 HashSet<AllocNode> newsrcnodes=GraphManip.getDiffNodes(delta, src);
373 HashSet<AllocNode> newfdnodes=GraphManip.getNodes(graph, delta, newsrcnodes, fd);
374 /* Compute the union, and then the set of edges */
375 HashSet<AllocNode> newTargets=new HashSet<AllocNode>();
376 newTargets.addAll(newfdnodes);
377 newTargets.addAll(difffdnodes);
378 HashSet<Edge> edgesToAdd=GraphManip.genEdges(src, newTargets);
380 /* Compute set of edges to remove */
381 HashSet<Edge> edgesToRemove=GraphManip.getDiffEdges(delta, dst);
384 updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove);
385 applyDiffs(graph, delta);
390 static void updateVarDelta(Graph graph, Delta delta, TempDescriptor tmp, HashSet<Edge> edgestoAdd, HashSet<Edge> edgestoRemove) {
391 HashSet<Edge> edgeAdd=delta.varedgeadd.get(tmp);
392 HashSet<Edge> edgeRemove=delta.varedgeremove.get(tmp);
393 HashSet<Edge> existingEdges=graph.getEdges(tmp);
394 for(Edge e: edgestoRemove) {
395 //remove edge from delta
397 //if the edge is already in the graph, add an explicit remove to the delta
398 if (existingEdges.contains(e))
401 for(Edge e: edgestoAdd) {
402 //Remove the edge from the remove set
403 edgeRemove.remove(e);
404 //Explicitly add it to the add set unless it is already in the graph
405 if (!existingEdges.contains(e))
410 static void updateHeapDelta(Graph graph, Delta delta, HashSet<Edge> edgestoAdd, HashSet<Edge> edgestoRemove) {
411 for(Edge e: edgestoRemove) {
413 HashSet<Edge> edgeAdd=delta.heapedgeadd.get(src);
414 HashSet<Edge> existingEdges=graph.getEdges(src);
415 //remove edge from delta
417 //if the edge is already in the graph, add an explicit remove to the delta
418 if (existingEdges.contains(e)) {
419 HashSet<Edge> edgeRemove=delta.heapedgeremove.get(src);
423 for(Edge e: edgestoAdd) {
425 HashSet<Edge> edgeRemove=delta.heapedgeremove.get(src);
426 HashSet<Edge> existingEdges=graph.getEdges(src);
427 //Remove the edge from the remove set
428 edgeRemove.remove(e);
429 //Explicitly add it to the add set unless it is already in the graph
430 if (!existingEdges.contains(e)) {
431 HashSet<Edge> edgeAdd=delta.heapedgeadd.get(src);
437 Delta processFlatNop(FlatNode node, Delta delta, Graph graph) {
438 applyDiffs(graph, delta);
442 Delta processNewNode(FlatNew node, Delta delta, Graph graph) {
443 AllocNode summary=allocFactory.getAllocNode(node, true);
444 AllocNode single=allocFactory.getAllocNode(node, false);
445 TempDescriptor tmp=node.getDst();
447 if (delta.getInit()) {
449 Edge e=new Edge(tmp, single);
451 HashSet<Edge> newedges=new HashSet<Edge>();
453 //Add it into the diffs
454 delta.varedgeadd.put(tmp, newedges);
455 //Remove the old edges
456 delta.varedgeremove.put(tmp, graph.getEdges(tmp));
457 //Apply incoming diffs to graph
458 applyDiffs(graph, delta);
460 /* 1. Fix up the variable edge additions */
462 for(Iterator<Map.Entry<TempDescriptor, HashSet<Edge>>> entryIt=delta.varedgeadd.entrySet().iterator();entryIt.hasNext();) {
463 Map.Entry<TempDescriptor, HashSet<Edge>> entry=entryIt.next();
465 if (entry.getKey()==tmp) {
466 /* Check if this is the tmp we overwrite */
469 /* Otherwise, check if the target of the edge is changed... */
470 rewriteSet(entry.getValue(), graph.varMap.get(entry.getKey()), single, summary);
474 /* 2. Fix up the base variable edges */
476 for(Iterator<Map.Entry<TempDescriptor, HashSet<Edge>>> entryIt=delta.basevaredge.entrySet().iterator();entryIt.hasNext();) {
477 Map.Entry<TempDescriptor, HashSet<Edge>> entry=entryIt.next();
478 TempDescriptor entrytmp=entry.getKey();
480 /* Check is this is the tmp we overwrite, if so add to remove set */
481 Util.relationUpdate(delta.varedgeremove, tmp, null, entry.getValue());
483 /* Check if the target of the edge is changed */
484 HashSet<Edge> newset=(HashSet<Edge>)entry.getValue().clone();
485 HashSet<Edge> removeset=shrinkSet(newset, graph.varMap.get(entrytmp), single, summary);
486 Util.relationUpdate(delta.varedgeremove, entrytmp, newset, removeset);
487 Util.relationUpdate(delta.varedgeadd, entrytmp, null, newset);
492 /* 3. Fix up heap edge additions */
494 HashMap<AllocNode, HashSet<Edge>> addheapedge=new HashMap<AllocNode, HashSet<Edge>>();
495 for(Iterator<Map.Entry<AllocNode, HashSet<Edge>>> entryIt=delta.heapedgeadd.entrySet().iterator();entryIt.hasNext();) {
496 Map.Entry<AllocNode, HashSet<Edge>> entry=entryIt.next();
497 HashSet<Edge> edgeset=entry.getValue();
498 AllocNode allocnode=entry.getKey();
499 if (allocnode==single) {
501 rewriteSet(edgeset, graph.nodeMap.get(summary), single, summary);
502 addheapedge.put(summary, edgeset);
504 rewriteSet(edgeset, graph.nodeMap.get(allocnode), single, summary);
510 for(Map.Entry<AllocNode, HashSet<Edge>> entry:addheapedge.entrySet()) {
511 AllocNode allocnode=entry.getKey();
512 Util.relationUpdate(delta.heapedgeadd, allocnode, null, entry.getValue());
515 /* 4. Fix up the base heap edges */
517 for(Iterator<Map.Entry<AllocNode, HashSet<Edge>>> entryIt=delta.baseheapedge.entrySet().iterator();entryIt.hasNext();) {
518 Map.Entry<AllocNode, HashSet<Edge>> entry=entryIt.next();
519 HashSet<Edge> edgeset=entry.getValue();
520 AllocNode allocnode=entry.getKey();
521 if (allocnode==single) {
524 AllocNode addnode=(allocnode==single)?summary:allocnode;
526 HashSet<Edge> newset=(HashSet<Edge>) edgeset.clone();
527 HashSet<Edge> removeset=shrinkSet(newset, graph.nodeMap.get(addnode), single, summary);
528 Util.relationUpdate(delta.heapedgeadd, addnode, null, newset);
529 Util.relationUpdate(delta.heapedgeremove, allocnode, null, removeset);
532 //Apply incoming diffs to graph
533 applyDiffs(graph, delta);
538 void rewriteSet(HashSet<Edge> edgeset, HashSet<Edge> oldedgeset, AllocNode oldnode, AllocNode newnode) {
539 HashSet<Edge> newSet=null;
540 for(Iterator<Edge> edgeit=edgeset.iterator();edgeit.hasNext();) {
541 Edge e=edgeit.next();
542 if (e.dst==oldnode||e.src==oldnode) {
544 newSet=new HashSet<Edge>();
551 if (oldedgeset==null||!oldedgeset.contains(e))
556 edgeset.addAll(newSet);
559 /* Shrinks the incoming set to just include rewritten values.
560 * Returns a set of the original rewritten values */
562 HashSet<Edge> shrinkSet(HashSet<Edge> edgeset, HashSet<Edge> oldedgeset, AllocNode oldnode, AllocNode newnode) {
563 HashSet<Edge> newSet=null;
564 HashSet<Edge> removeSet=null;
565 for(Iterator<Edge> edgeit=edgeset.iterator();edgeit.hasNext();) {
566 Edge e=edgeit.next();
568 if (e.dst==oldnode||e.src==oldnode) {
570 newSet=new HashSet<Edge>();
571 removeSet=new HashSet<Edge>();
574 removeSet.add(e.copy());
579 if (oldedgeset==null||!oldedgeset.contains(e))
584 edgeset.addAll(newSet);
588 Delta applyInitDelta(Delta delta, BBlock block) {
589 //Apply delta to graph
590 boolean newGraph=false;
591 if (!bbgraphMap.containsKey(block)) {
592 bbgraphMap.put(block, new Graph(null));
596 Graph graph=bbgraphMap.get(block);
599 newdelta=new Delta(null, true);
600 //Add in heap edges and throw away original diff
601 graph.nodeMap.putAll(delta.heapedgeadd);
602 //Add in var edges and throw away original diff
603 graph.varMap.putAll(delta.varedgeadd);
604 //Record that this is initial set...
606 newdelta=new Delta(null, false);
607 //merge in heap edges and variables
608 mergeHeapEdges(graph, delta, newdelta);
609 mergeVarEdges(graph, delta, newdelta);
610 //Record that this is a diff
611 newdelta.setInit(false);
616 /* This function merges in the heap edges. It updates delta to be
619 void mergeHeapEdges(Graph graph, Delta delta, Delta newdelta) {
621 for(Map.Entry<AllocNode, HashSet<Edge>> heapedge:delta.heapedgeadd.entrySet()) {
622 AllocNode nsrc=heapedge.getKey();
623 HashSet<Edge> edges=heapedge.getValue();
624 if (!graph.nodeMap.containsKey(nsrc)) {
625 graph.nodeMap.put(nsrc, new HashSet<Edge>());
627 HashSet<Edge> dstedges=graph.nodeMap.get(nsrc);
628 HashSet<Edge> diffedges=new HashSet<Edge>();
630 if (!dstedges.contains(e)) {
636 //Done with edge set...
637 if (diffedges.size()>0) {
639 newdelta.baseheapedge.put(nsrc, diffedges);
644 /* This function merges in the var edges. It updates delta to be
647 void mergeVarEdges(Graph graph, Delta delta, Delta newdelta) {
649 for(Map.Entry<TempDescriptor, HashSet<Edge>> varedge:delta.varedgeadd.entrySet()) {
650 TempDescriptor tmpsrc=varedge.getKey();
651 HashSet<Edge> edges=varedge.getValue();
652 if (!graph.varMap.containsKey(tmpsrc)) {
653 graph.varMap.put(tmpsrc, new HashSet<Edge>());
655 HashSet<Edge> dstedges=graph.varMap.get(tmpsrc);
656 HashSet<Edge> diffedges=new HashSet<Edge>();
658 if (!dstedges.contains(e)) {
664 //Done with edge set...
665 if (diffedges.size()>=0) {
667 newdelta.basevaredge.put(tmpsrc,diffedges);