1 package Analysis.OoOJava;
3 import java.io.BufferedWriter;
4 import java.io.FileWriter;
5 import java.util.Collection;
6 import java.util.HashMap;
7 import java.util.HashSet;
8 import java.util.Hashtable;
9 import java.util.Iterator;
12 import java.util.Map.Entry;
15 import Analysis.Disjoint.AllocSite;
16 import Analysis.Disjoint.DisjointAnalysis;
17 import Analysis.Disjoint.Effect;
18 import Analysis.Disjoint.Taint;
19 import IR.Flat.FlatMethod;
20 import IR.Flat.FlatNew;
21 import IR.Flat.FlatNode;
22 import IR.Flat.FlatSESEEnterNode;
23 import IR.Flat.TempDescriptor;
25 public class ConflictGraph {
27 protected Hashtable<String, ConflictNode> id2cn;
28 protected Hashtable<FlatNode, Hashtable<Taint, Set<Effect>>> sese2te;
30 protected DisjointAnalysis da;
31 protected FlatMethod fmEnclosing;
33 public static final int NON_WRITE_CONFLICT = 0;
34 public static final int FINE_GRAIN_EDGE = 1;
35 public static final int COARSE_GRAIN_EDGE = 2;
39 public ConflictGraph(State state) {
41 id2cn = new Hashtable<String, ConflictNode>();
42 sese2te = new Hashtable<FlatNode, Hashtable<Taint, Set<Effect>>>();
45 public void setDisJointAnalysis(DisjointAnalysis da) {
49 public void setFMEnclosing(FlatMethod fmEnclosing) {
50 this.fmEnclosing = fmEnclosing;
53 public void addLiveIn(Hashtable<Taint, Set<Effect>> taint2Effects) {
54 if (taint2Effects == null) {
57 Iterator entryIter = taint2Effects.entrySet().iterator();
58 while (entryIter.hasNext()) {
59 Entry entry = (Entry) entryIter.next();
60 Taint taint = (Taint) entry.getKey();
61 Set<Effect> effectSet = (Set<Effect>) entry.getValue();
62 if (!effectSet.isEmpty()) {
63 Iterator<Effect> effectIter = effectSet.iterator();
64 while (effectIter.hasNext()) {
65 Effect effect = (Effect) effectIter.next();
66 addLiveInNodeEffect(taint, effect);
72 public void addStallSite(Hashtable<Taint, Set<Effect>> taint2Effects, TempDescriptor var) {
73 if (taint2Effects == null) {
76 Iterator entryIter = taint2Effects.entrySet().iterator();
77 while (entryIter.hasNext()) {
78 Entry entry = (Entry) entryIter.next();
79 Taint taint = (Taint) entry.getKey();
80 Set<Effect> effectSet = (Set<Effect>) entry.getValue();
81 if (!effectSet.isEmpty()) {
82 Iterator<Effect> effectIter = effectSet.iterator();
83 while (effectIter.hasNext()) {
84 Effect effect = (Effect) effectIter.next();
85 if (taint.getVar().equals(var)) {
86 addStallSiteEffect(taint, effect);
93 public void addStallSiteEffect(Taint t, Effect e) {
94 FlatNode fn = t.getStallSite();
95 TempDescriptor var = t.getVar();
96 AllocSite as = t.getAllocSite();
98 String id = var + "_fn" + fn.hashCode();
99 ConflictNode node = id2cn.get(id);
101 node = new ConflictNode(id, ConflictNode.STALLSITE, t.getVar(), t.getStallSite());
103 node.addEffect(as, e);
109 public void addLiveInNodeEffect(Taint t, Effect e) {
111 FlatSESEEnterNode sese = t.getSESE();
112 TempDescriptor invar = t.getVar();
113 AllocSite as = t.getAllocSite();
115 String id = invar + "_sese" + sese.getPrettyIdentifier();
116 ConflictNode node = id2cn.get(id);
118 node = new ConflictNode(id, ConflictNode.INVAR, t.getVar(), t.getSESE());
120 node.addEffect(as, e);
126 public void addConflictEdge(int type, ConflictNode nodeU, ConflictNode nodeV) {
128 // if there are two edges between the same node pair, coarse has a
130 Set<ConflictEdge> set = nodeU.getEdgeSet();
131 ConflictEdge toBeRemoved = null;
132 for (Iterator iterator = set.iterator(); iterator.hasNext();) {
133 ConflictEdge conflictEdge = (ConflictEdge) iterator.next();
135 if ((conflictEdge.getVertexU().equals(nodeU) && conflictEdge.getVertexV().equals(nodeV))
136 || (conflictEdge.getVertexU().equals(nodeV) && conflictEdge.getVertexV().equals(nodeU))) {
137 if (conflictEdge.getType() == ConflictGraph.FINE_GRAIN_EDGE
138 && type == ConflictGraph.COARSE_GRAIN_EDGE) {
139 toBeRemoved = conflictEdge;
141 } else if (conflictEdge.getType() == ConflictGraph.COARSE_GRAIN_EDGE
142 && type == ConflictGraph.FINE_GRAIN_EDGE) {
149 if (toBeRemoved != null) {
150 nodeU.getEdgeSet().remove(toBeRemoved);
151 nodeV.getEdgeSet().remove(toBeRemoved);
154 ConflictEdge newEdge = new ConflictEdge(nodeU, nodeV, type);
155 nodeU.addEdge(newEdge);
156 nodeV.addEdge(newEdge);
160 public void analyzeConflicts(Set<FlatNew> sitesToFlag, boolean useReachInfo) {
162 Set<String> keySet = id2cn.keySet();
163 Set<String> analyzedIDSet = new HashSet<String>();
165 for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
166 String nodeID = (String) iterator.next();
167 ConflictNode node = id2cn.get(nodeID);
168 analyzePossibleConflicts(analyzedIDSet, node, sitesToFlag, useReachInfo);
173 private void analyzePossibleConflicts(Set<String> analyzedIDSet, ConflictNode currentNode,
174 Set<FlatNew> sitesToFlag, boolean useReachInfo) {
175 // compare with all nodes
176 // examine the case where self-edge exists
179 if (currentNode.isInVarNode()) {
180 conflictType = calculateConflictType(currentNode, useReachInfo);
181 if (conflictType > ConflictGraph.NON_WRITE_CONFLICT) {
182 addConflictEdge(conflictType, currentNode, currentNode);
183 if (sitesToFlag != null) {
184 sitesToFlag.addAll(currentNode.getFlatNewSet());
189 Set<Entry<String, ConflictNode>> set = id2cn.entrySet();
190 for (Iterator iterator = set.iterator(); iterator.hasNext();) {
191 Entry<String, ConflictNode> entry = (Entry<String, ConflictNode>) iterator.next();
193 String entryNodeID = entry.getKey();
194 ConflictNode entryNode = entry.getValue();
196 if (currentNode.isStallSiteNode() && entryNode.isStallSiteNode()) {
200 if ((currentNode.isInVarNode() && entryNode.isInVarNode())
201 && (currentNode.getSESEIdentifier() == entryNode.getSESEIdentifier())
202 && (currentNode.getVar().equals(entryNode.getVar()))) {
206 if ((!currentNode.getID().equals(entryNodeID))
207 && !(analyzedIDSet.contains(currentNode.getID() + entryNodeID) || analyzedIDSet
208 .contains(entryNodeID + currentNode.getID()))) {
210 conflictType = calculateConflictType(currentNode, entryNode, useReachInfo);
211 if (conflictType > ConflictGraph.NON_WRITE_CONFLICT) {
212 addConflictEdge(conflictType, currentNode, entryNode);
213 if (sitesToFlag != null) {
214 sitesToFlag.addAll(currentNode.getFlatNewSet());
215 sitesToFlag.addAll(entryNode.getFlatNewSet());
218 analyzedIDSet.add(currentNode.getID() + entryNodeID);
225 private int calculateConflictType(ConflictNode node, boolean useReachInfo) {
227 int conflictType = ConflictGraph.NON_WRITE_CONFLICT;
228 Hashtable<AllocSite, Set<Effect>> alloc2readEffects = node.getReadEffectSet();
229 Hashtable<AllocSite, Set<Effect>> alloc2writeEffects = node.getWriteEffectSet();
230 Hashtable<AllocSite, Set<Effect>> alloc2SUEffects = node.getStrongUpdateEffectSet();
233 updateConflictType(conflictType, determineConflictType(node, alloc2writeEffects, node,
234 alloc2writeEffects, useReachInfo));
237 updateConflictType(conflictType, hasStrongUpdateConflicts(node, alloc2SUEffects, node,
238 alloc2readEffects, alloc2writeEffects, useReachInfo));
243 private int calculateConflictType(ConflictNode nodeA, ConflictNode nodeB, boolean useReachInfo) {
245 int conflictType = ConflictGraph.NON_WRITE_CONFLICT;
247 Hashtable<AllocSite, Set<Effect>> alloc2readEffectsA = nodeA.getReadEffectSet();
248 Hashtable<AllocSite, Set<Effect>> alloc2writeEffectsA = nodeA.getWriteEffectSet();
249 Hashtable<AllocSite, Set<Effect>> alloc2SUEffectsA = nodeA.getStrongUpdateEffectSet();
250 Hashtable<AllocSite, Set<Effect>> alloc2readEffectsB = nodeB.getReadEffectSet();
251 Hashtable<AllocSite, Set<Effect>> alloc2writeEffectsB = nodeB.getWriteEffectSet();
252 Hashtable<AllocSite, Set<Effect>> alloc2SUEffectsB = nodeB.getStrongUpdateEffectSet();
254 // if node A has write effects on reading/writing regions of node B
256 updateConflictType(conflictType, determineConflictType(nodeA, alloc2writeEffectsA, nodeB,
257 alloc2readEffectsB, useReachInfo));
259 updateConflictType(conflictType, determineConflictType(nodeA, alloc2writeEffectsA, nodeB,
260 alloc2writeEffectsB, useReachInfo));
262 // if node B has write effects on reading regions of node A
264 updateConflictType(conflictType, determineConflictType(nodeB, alloc2writeEffectsB, nodeA,
265 alloc2readEffectsA, useReachInfo));
267 // strong udpate effects conflict with all effects
268 // on objects that are reachable from the same heap roots
269 // if node A has SU on regions of node B
270 if (!alloc2SUEffectsA.isEmpty()) {
272 updateConflictType(conflictType, hasStrongUpdateConflicts(nodeA, alloc2SUEffectsA, nodeB,
273 alloc2readEffectsB, alloc2writeEffectsB, useReachInfo));
276 // if node B has SU on regions of node A
277 if (!alloc2SUEffectsB.isEmpty()) {
279 updateConflictType(conflictType, hasStrongUpdateConflicts(nodeB, alloc2SUEffectsB, nodeA,
280 alloc2readEffectsA, alloc2writeEffectsA, useReachInfo));
286 private int hasStrongUpdateConflicts(ConflictNode nodeA,
287 Hashtable<AllocSite, Set<Effect>> SUEffectsTableA, ConflictNode nodeB,
288 Hashtable<AllocSite, Set<Effect>> readTableB, Hashtable<AllocSite, Set<Effect>> writeTableB,
289 boolean useReachInfo) {
291 int conflictType = ConflictGraph.NON_WRITE_CONFLICT;
293 Iterator effectItrA = SUEffectsTableA.entrySet().iterator();
294 while (effectItrA.hasNext()) {
295 Map.Entry meA = (Map.Entry) effectItrA.next();
296 AllocSite asA = (AllocSite) meA.getKey();
297 Set<Effect> strongUpdateSetA = (Set<Effect>) meA.getValue();
299 Iterator effectItrB = readTableB.entrySet().iterator();
300 while (effectItrB.hasNext()) {
301 Map.Entry meB = (Map.Entry) effectItrB.next();
302 AllocSite asB = (AllocSite) meB.getKey();
303 Set<Effect> esB = (Set<Effect>) meB.getValue();
305 for (Iterator iterator = strongUpdateSetA.iterator(); iterator.hasNext();) {
306 Effect strongUpdateA = (Effect) iterator.next();
307 for (Iterator iterator2 = esB.iterator(); iterator2.hasNext();) {
308 Effect effectB = (Effect) iterator2.next();
310 if (strongUpdateA.getAffectedAllocSite().equals(effectB.getAffectedAllocSite())
311 && strongUpdateA.getField().equals(effectB.getField())) {
313 FlatNew fnRoot1 = asA.getFlatNew();
314 FlatNew fnRoot2 = asB.getFlatNew();
315 FlatNew fnTarget = strongUpdateA.getAffectedAllocSite().getFlatNew();
316 if (da.mayBothReachTarget(fmEnclosing, fnRoot1, fnRoot2, fnTarget)) {
317 addCoarseEffect(nodeA, asA, strongUpdateA);
318 if (!nodeA.equals(nodeB)) {
319 addCoarseEffect(nodeB, asB, effectB);
321 conflictType = updateConflictType(conflictType, ConflictGraph.COARSE_GRAIN_EDGE);
324 return ConflictGraph.COARSE_GRAIN_EDGE;
333 effectItrB = writeTableB.entrySet().iterator();
334 while (effectItrB.hasNext()) {
335 Map.Entry meB = (Map.Entry) effectItrB.next();
336 AllocSite asB = (AllocSite) meB.getKey();
337 Set<Effect> esB = (Set<Effect>) meB.getValue();
339 for (Iterator iterator = strongUpdateSetA.iterator(); iterator.hasNext();) {
340 Effect strongUpdateA = (Effect) iterator.next();
341 for (Iterator iterator2 = esB.iterator(); iterator2.hasNext();) {
342 Effect effectB = (Effect) iterator2.next();
344 if (strongUpdateA.getAffectedAllocSite().equals(effectB.getAffectedAllocSite())
345 && strongUpdateA.getField().equals(effectB.getField())) {
348 FlatNew fnRoot1 = asA.getFlatNew();
349 FlatNew fnRoot2 = asB.getFlatNew();
350 FlatNew fnTarget = strongUpdateA.getAffectedAllocSite().getFlatNew();
351 if (da.mayBothReachTarget(fmEnclosing, fnRoot1, fnRoot2, fnTarget)) {
352 addCoarseEffect(nodeA, asA, strongUpdateA);
353 if (!nodeA.equals(nodeB)) {
354 addCoarseEffect(nodeB, asB, effectB);
356 conflictType = updateConflictType(conflictType, ConflictGraph.COARSE_GRAIN_EDGE);
359 return ConflictGraph.COARSE_GRAIN_EDGE;
373 private int determineConflictType(ConflictNode nodeA,
374 Hashtable<AllocSite, Set<Effect>> nodeAtable, ConflictNode nodeB,
375 Hashtable<AllocSite, Set<Effect>> nodeBtable, boolean useReachInfo) {
377 int conflictType = ConflictGraph.NON_WRITE_CONFLICT;
379 Iterator effectItrA = nodeAtable.entrySet().iterator();
380 while (effectItrA.hasNext()) {
381 Map.Entry meA = (Map.Entry) effectItrA.next();
382 AllocSite asA = (AllocSite) meA.getKey();
383 Set<Effect> esA = (Set<Effect>) meA.getValue();
385 Iterator effectItrB = nodeBtable.entrySet().iterator();
386 while (effectItrB.hasNext()) {
387 Map.Entry meB = (Map.Entry) effectItrB.next();
388 AllocSite asB = (AllocSite) meB.getKey();
389 Set<Effect> esB = (Set<Effect>) meB.getValue();
391 for (Iterator iterator = esA.iterator(); iterator.hasNext();) {
392 Effect effectA = (Effect) iterator.next();
393 for (Iterator iterator2 = esB.iterator(); iterator2.hasNext();) {
394 Effect effectB = (Effect) iterator2.next();
396 if (effectA.getAffectedAllocSite().equals(effectB.getAffectedAllocSite())
397 && effectA.getField().equals(effectB.getField())) {
400 FlatNew fnRoot1 = asA.getFlatNew();
401 FlatNew fnRoot2 = asB.getFlatNew();
402 FlatNew fnTarget = effectA.getAffectedAllocSite().getFlatNew();
403 if (fnRoot1.equals(fnRoot2)) {
404 if (!da.mayManyReachTarget(fmEnclosing, fnRoot1, fnTarget)) {
405 // fine-grained conflict case
406 conflictType = updateConflictType(conflictType, ConflictGraph.FINE_GRAIN_EDGE);
408 // coarse-grained conflict case
409 addCoarseEffect(nodeA, asA, effectA);
410 if (!nodeA.equals(nodeB)) {
411 addCoarseEffect(nodeB, asB, effectB);
414 updateConflictType(conflictType, ConflictGraph.COARSE_GRAIN_EDGE);
417 if (da.mayBothReachTarget(fmEnclosing, fnRoot1, fnRoot2, fnTarget)) {
418 addCoarseEffect(nodeA, asA, effectA);
419 if (!nodeA.equals(nodeB)) {
420 addCoarseEffect(nodeB, asB, effectB);
423 updateConflictType(conflictType, ConflictGraph.COARSE_GRAIN_EDGE);
429 //need coarse effects for RCR from just one pass
430 addCoarseEffect(nodeA, asA, effectA);
431 if (!nodeA.equals(nodeB)) {
432 addCoarseEffect(nodeB, asB, effectB);
435 return ConflictGraph.COARSE_GRAIN_EDGE;
446 private void addCoarseEffect(ConflictNode node, AllocSite as, Effect e) {
447 Taint t = node.getTaint(as);
448 addEffectSetByTaint(t, e);
451 private void addEffectSetByTaint(Taint t, Effect e) {
453 FlatNode node=t.getSESE();
456 node=t.getStallSite();
459 Hashtable<Taint, Set<Effect>> taint2Conflicts = sese2te.get(node);
460 if (taint2Conflicts == null) {
461 taint2Conflicts = new Hashtable<Taint, Set<Effect>>();
464 Set<Effect> effectSet = taint2Conflicts.get(t);
465 if (effectSet == null) {
466 effectSet = new HashSet<Effect>();
469 taint2Conflicts.put(t, effectSet);
471 sese2te.put(node, taint2Conflicts);
475 private int updateConflictType(int current, int newType) {
476 if (newType > current) {
483 public void clearAllConflictEdge() {
484 Collection<ConflictNode> nodes = id2cn.values();
485 for (Iterator iterator = nodes.iterator(); iterator.hasNext();) {
486 ConflictNode conflictNode = (ConflictNode) iterator.next();
487 conflictNode.getEdgeSet().clear();
491 public HashSet<ConflictEdge> getEdgeSet() {
493 HashSet<ConflictEdge> returnSet = new HashSet<ConflictEdge>();
495 Collection<ConflictNode> nodes = id2cn.values();
496 for (Iterator iterator = nodes.iterator(); iterator.hasNext();) {
497 ConflictNode conflictNode = (ConflictNode) iterator.next();
498 returnSet.addAll(conflictNode.getEdgeSet());
504 public boolean hasConflictEdge() {
506 Set<String> keySet = id2cn.keySet();
507 for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
508 String key = (String) iterator.next();
509 ConflictNode node = id2cn.get(key);
510 if (node.getEdgeSet().size() > 0) {
517 public boolean isFineElement(int type) {
518 if (type == ConflictNode.FINE_READ || type == ConflictNode.FINE_WRITE
519 || type == ConflictNode.PARENT_READ || type == ConflictNode.PARENT_WRITE) {
526 public SESEWaitingQueue getWaitingElementSetBySESEID(int seseID, Set<SESELock> seseLockSet) {
528 HashSet<WaitingElement> waitingElementSet = new HashSet<WaitingElement>();
530 Iterator iter = id2cn.entrySet().iterator();
531 while (iter.hasNext()) {
532 Entry entry = (Entry) iter.next();
533 String conflictNodeID = (String) entry.getKey();
534 ConflictNode node = (ConflictNode) entry.getValue();
536 if (node.isInVarNode()) {
537 if (node.getSESEIdentifier() == seseID) {
539 Set<ConflictEdge> edgeSet = node.getEdgeSet();
540 for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) {
541 ConflictEdge conflictEdge = (ConflictEdge) iterator.next();
543 for (Iterator<SESELock> seseLockIter = seseLockSet.iterator(); seseLockIter.hasNext();) {
544 SESELock seseLock = seseLockIter.next();
545 if (seseLock.containsConflictNode(node)
546 && seseLock.containsConflictEdge(conflictEdge)) {
547 WaitingElement newElement = new WaitingElement();
548 newElement.setQueueID(seseLock.getID());
549 newElement.setStatus(seseLock.getNodeType(node));
550 newElement.setTempDesc(node.getVar());
551 if (isFineElement(newElement.getStatus())) {
552 newElement.setDynID(node.getVar().toString());
554 if (!waitingElementSet.contains(newElement)) {
555 waitingElementSet.add(newElement);
567 // handle the case that multiple enqueues by an SESE for different live-in
568 // into the same queue
569 return refineQueue(waitingElementSet);
573 public SESEWaitingQueue refineQueue(Set<WaitingElement> waitingElementSet) {
575 Set<WaitingElement> refinedSet = new HashSet<WaitingElement>();
576 HashMap<Integer, Set<WaitingElement>> map = new HashMap<Integer, Set<WaitingElement>>();
577 SESEWaitingQueue seseDS = new SESEWaitingQueue();
579 for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) {
580 WaitingElement waitingElement = (WaitingElement) iterator.next();
581 Set<WaitingElement> set = map.get(new Integer(waitingElement.getQueueID()));
583 set = new HashSet<WaitingElement>();
585 set.add(waitingElement);
586 map.put(new Integer(waitingElement.getQueueID()), set);
589 Set<Integer> keySet = map.keySet();
590 for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
591 Integer queueID = (Integer) iterator.next();
592 Set<WaitingElement> queueWEset = map.get(queueID);
593 refineQueue(queueID.intValue(), queueWEset, seseDS);
599 private void refineQueue(int queueID, Set<WaitingElement> waitingElementSet,
600 SESEWaitingQueue seseDS) {
602 if (waitingElementSet.size() > 1) {
603 // only consider there is more than one element submitted by same SESE
604 Set<WaitingElement> refinedSet = new HashSet<WaitingElement>();
609 int total = waitingElementSet.size();
610 WaitingElement SCCelement = null;
611 WaitingElement coarseElement = null;
613 for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) {
614 WaitingElement waitingElement = (WaitingElement) iterator.next();
615 if (waitingElement.getStatus() == ConflictNode.FINE_READ) {
617 } else if (waitingElement.getStatus() == ConflictNode.FINE_WRITE) {
619 } else if (waitingElement.getStatus() == ConflictNode.COARSE) {
621 coarseElement = waitingElement;
622 } else if (waitingElement.getStatus() == ConflictNode.SCC) {
623 SCCelement = waitingElement;
627 if (SCCelement != null) {
628 // if there is at lease one SCC element, just enqueue SCC and
631 // for rcr, we need to label all of coarse tempdescriptors
632 // here assume that all waiting elements are coarse
633 for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) {
634 WaitingElement waitingElement = (WaitingElement) iterator.next();
635 SCCelement.addTempDesc(waitingElement.getTempDesc());
638 refinedSet.add(SCCelement);
639 } else if (numCoarse == 1 && (numRead + numWrite + numCoarse == total)) {
640 // if one is a coarse, the othere are reads/write, enqueue SCC.
641 WaitingElement we = new WaitingElement();
642 we.setQueueID(queueID);
643 we.setStatus(ConflictNode.SCC);
645 } else if (numCoarse == total) {
646 // if there are multiple coarses, enqueue just one coarse.
648 // for rcr, we need to label all of coarse tempdescriptors
649 for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) {
650 WaitingElement waitingElement = (WaitingElement) iterator.next();
651 coarseElement.addTempDesc(waitingElement.getTempDesc());
654 refinedSet.add(coarseElement);
655 } else if (numWrite == total || (numRead + numWrite) == total) {
656 // code generator is going to handle the case for multiple writes &
658 seseDS.setType(queueID, SESEWaitingQueue.EXCEPTION);
659 refinedSet.addAll(waitingElementSet);
661 // otherwise, enqueue everything.
662 refinedSet.addAll(waitingElementSet);
664 seseDS.setWaitingElementSet(queueID, refinedSet);
666 seseDS.setWaitingElementSet(queueID, waitingElementSet);
671 public Set<WaitingElement> getStallSiteWaitingElementSet(FlatNode stallSite,
672 Set<SESELock> seseLockSet) {
674 HashSet<WaitingElement> waitingElementSet = new HashSet<WaitingElement>();
675 Iterator iter = id2cn.entrySet().iterator();
676 while (iter.hasNext()) {
677 Entry entry = (Entry) iter.next();
678 String conflictNodeID = (String) entry.getKey();
679 ConflictNode node = (ConflictNode) entry.getValue();
681 if (node.isStallSiteNode() && node.getStallSiteFlatNode().equals(stallSite)) {
682 Set<ConflictEdge> edgeSet = node.getEdgeSet();
683 for (Iterator iter2 = edgeSet.iterator(); iter2.hasNext();) {
684 ConflictEdge conflictEdge = (ConflictEdge) iter2.next();
686 for (Iterator<SESELock> seseLockIter = seseLockSet.iterator(); seseLockIter.hasNext();) {
687 SESELock seseLock = seseLockIter.next();
688 if (seseLock.containsConflictNode(node) && seseLock.containsConflictEdge(conflictEdge)) {
689 WaitingElement newElement = new WaitingElement();
690 newElement.setQueueID(seseLock.getID());
691 newElement.setStatus(seseLock.getNodeType(node));
692 if (isFineElement(newElement.getStatus())) {
693 newElement.setDynID(node.getVar().toString());
695 newElement.setTempDesc(node.getVar());
696 waitingElementSet.add(newElement);
706 return waitingElementSet;
709 public Hashtable<Taint, Set<Effect>> getConflictEffectSet(FlatNode fn) {
710 return sese2te.get(fn);
713 public void writeGraph(String graphName, boolean filter) throws java.io.IOException {
715 graphName = graphName.replaceAll("[\\W]", "");
717 BufferedWriter bw = new BufferedWriter(new FileWriter(graphName + ".dot"));
718 bw.write("graph " + graphName + " {\n");
720 // then visit every heap region node
721 Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
722 Iterator<Entry<String, ConflictNode>> i = s.iterator();
724 HashSet<ConflictEdge> addedSet = new HashSet<ConflictEdge>();
726 while (i.hasNext()) {
727 Entry<String, ConflictNode> entry = i.next();
728 ConflictNode node = entry.getValue();
731 if (node.getID().startsWith("___dst") || node.getID().startsWith("___srctmp")
732 || node.getID().startsWith("___neverused") || node.getID().startsWith("___temp")) {
737 if (node.getEdgeSet().isEmpty()) {
743 String attributes = "[";
745 attributes += "label=\"" + node.getID() + "\\n";
747 if (node.isStallSiteNode()) {
748 attributes += "STALL SITE" + "\\n" + "\"]";
750 attributes += "LIVE-IN" + "\\n" + "\"]";
752 bw.write(entry.getKey() + attributes + ";\n");
754 Set<ConflictEdge> edgeSet = node.getEdgeSet();
755 for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) {
756 ConflictEdge conflictEdge = (ConflictEdge) iterator.next();
758 ConflictNode u = conflictEdge.getVertexU();
759 ConflictNode v = conflictEdge.getVertexV();
762 String uID = u.getID();
763 String vID = v.getID();
764 if (uID.startsWith("___dst") || uID.startsWith("___srctmp")
765 || uID.startsWith("___neverused") || uID.startsWith("___temp")
766 || vID.startsWith("___dst") || vID.startsWith("___srctmp")
767 || vID.startsWith("___neverused") || vID.startsWith("___temp")) {
772 if (!addedSet.contains(conflictEdge)) {
773 bw.write("" + u.getID() + "--" + v.getID() + "[label=" + conflictEdge.toGraphEdgeString()
775 addedSet.add(conflictEdge);
781 bw.write(" graphTitle[label=\"" + graphName + "\",shape=box];\n");