adds new option '-nostalltr' that turns off rcr traversers that only handle conflicts...
[IRC.git] / Robust / src / Analysis / OoOJava / ConflictGraph.java
index 0e8c9cf170dec4757146f2ead89448ac7ba8ec14..75304f40e3a98d8b148d51307a87033e9f90b282 100644 (file)
@@ -10,6 +10,7 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import java.util.Map.Entry;
+import IR.State;
 
 import Analysis.Disjoint.AllocSite;
 import Analysis.Disjoint.DisjointAnalysis;
@@ -32,9 +33,11 @@ public class ConflictGraph {
   public static final int NON_WRITE_CONFLICT = 0;
   public static final int FINE_GRAIN_EDGE = 1;
   public static final int COARSE_GRAIN_EDGE = 2;
-  public static final int CONFLICT = 3;
+  State state;
 
-  public ConflictGraph() {
+  public ConflictGraph(State state) {
+    this.state=state;
     id2cn = new Hashtable<String, ConflictNode>();
     sese2te = new Hashtable<FlatNode, Hashtable<Taint, Set<Effect>>>();
   }
@@ -109,7 +112,7 @@ public class ConflictGraph {
     TempDescriptor invar = t.getVar();
     AllocSite as = t.getAllocSite();
 
-    String id = invar + "_sese" + sese.getIdentifier();
+    String id = invar + "_sese" + sese.getPrettyIdentifier();
     ConflictNode node = id2cn.get(id);
     if (node == null) {
       node = new ConflictNode(id, ConflictNode.INVAR, t.getVar(), t.getSESE());
@@ -318,7 +321,16 @@ public class ConflictGraph {
                   conflictType = updateConflictType(conflictType, ConflictGraph.COARSE_GRAIN_EDGE);
                 }
               } else {
-                return ConflictGraph.CONFLICT;
+                if (state.RCR) {
+                  // need coarse effects for RCR from just one pass
+                  addCoarseEffect(nodeA, asA, strongUpdateA);
+                  if (!nodeA.equals(nodeB)) {
+                    addCoarseEffect(nodeB, asB, effectB);
+                  }
+                  conflictType=ConflictGraph.COARSE_GRAIN_EDGE;
+                } else {
+                  return ConflictGraph.COARSE_GRAIN_EDGE;
+                }
               }
 
             }
@@ -353,7 +365,7 @@ public class ConflictGraph {
                   conflictType = updateConflictType(conflictType, ConflictGraph.COARSE_GRAIN_EDGE);
                 }
               } else {
-                return ConflictGraph.CONFLICT;
+                return ConflictGraph.COARSE_GRAIN_EDGE;
               }
             }
 
@@ -422,7 +434,16 @@ public class ConflictGraph {
                   }
                 }
               } else {
-                return ConflictGraph.CONFLICT;
+                if (state.RCR) {
+                  // need coarse effects for RCR from just one pass
+                  addCoarseEffect(nodeA, asA, effectA);
+                  if (!nodeA.equals(nodeB)) {
+                    addCoarseEffect(nodeB, asB, effectB);
+                  }
+                  conflictType=ConflictGraph.COARSE_GRAIN_EDGE;
+                } else {
+                  return ConflictGraph.COARSE_GRAIN_EDGE;
+                }
               }
             }
           }
@@ -537,9 +558,9 @@ public class ConflictGraph {
                 WaitingElement newElement = new WaitingElement();
                 newElement.setQueueID(seseLock.getID());
                 newElement.setStatus(seseLock.getNodeType(node));
+                newElement.setTempDesc(node.getVar());
                 if (isFineElement(newElement.getStatus())) {
-                  newElement.setDynID(node.getVar().toString());
-                  newElement.setTempDesc(node.getVar());
+                  newElement.setDynID(node.getVar().toString());                  
                 }
                 if (!waitingElementSet.contains(newElement)) {
                   waitingElementSet.add(newElement);
@@ -556,8 +577,7 @@ public class ConflictGraph {
 
     // handle the case that multiple enqueues by an SESE for different live-in
     // into the same queue
-    return refineQueue(waitingElementSet);
-    // return waitingElementSet;
+     return refineQueue(waitingElementSet);  
 
   }
 
@@ -576,7 +596,7 @@ public class ConflictGraph {
       set.add(waitingElement);
       map.put(new Integer(waitingElement.getQueueID()), set);
     }
-
+    
     Set<Integer> keySet = map.keySet();
     for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
       Integer queueID = (Integer) iterator.next();
@@ -614,12 +634,23 @@ public class ConflictGraph {
           SCCelement = waitingElement;
         }
       }
-
       if (SCCelement != null) {
         // if there is at lease one SCC element, just enqueue SCC and
         // ignore others.
+        if(state.RCR){
+          // for rcr, we need to label all of coarse tempdescriptors
+          // here assume that all waiting elements are coarse
+          for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) {
+            WaitingElement waitingElement = (WaitingElement) iterator.next();
+            SCCelement.addTempDesc(waitingElement.getTempDesc());
+            if(waitingElement!=SCCelement){
+              waitingElement.setBogus(true);
+              refinedSet.add(waitingElement);
+            }
+          }
+        }
         refinedSet.add(SCCelement);
-      } else if (numCoarse == 1 && (numRead + numWrite + numCoarse == total)) {
+      } else if (numCoarse == 1 && (numRead + numWrite  == total)) {
         // if one is a coarse, the othere are reads/write, enqueue SCC.
         WaitingElement we = new WaitingElement();
         we.setQueueID(queueID);
@@ -627,6 +658,17 @@ public class ConflictGraph {
         refinedSet.add(we);
       } else if (numCoarse == total) {
         // if there are multiple coarses, enqueue just one coarse.
+        if(state.RCR){
+          // for rcr, we need to label all of coarse tempdescriptors
+          for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) {
+            WaitingElement waitingElement = (WaitingElement) iterator.next();
+            if(waitingElement!=coarseElement){
+              coarseElement.addTempDesc(waitingElement.getTempDesc());
+              waitingElement.setBogus(true);
+              refinedSet.add(waitingElement);
+            }
+          }
+        }
         refinedSet.add(coarseElement);
       } else if (numWrite == total || (numRead + numWrite) == total) {
         // code generator is going to handle the case for multiple writes &
@@ -667,8 +709,8 @@ public class ConflictGraph {
               newElement.setStatus(seseLock.getNodeType(node));
               if (isFineElement(newElement.getStatus())) {
                 newElement.setDynID(node.getVar().toString());
-                newElement.setTempDesc(node.getVar());
               }
+              newElement.setTempDesc(node.getVar());
               waitingElementSet.add(newElement);
             }
           }
@@ -682,8 +724,8 @@ public class ConflictGraph {
     return waitingElementSet;
   }
 
-  public Hashtable<Taint, Set<Effect>> getConflictEffectSet(FlatSESEEnterNode fsen) {
-    return sese2te.get(fsen);
+  public Hashtable<Taint, Set<Effect>> getConflictEffectSet(FlatNode fn) {
+    return sese2te.get(fn);
   }
 
   public void writeGraph(String graphName, boolean filter) throws java.io.IOException {
@@ -760,5 +802,9 @@ public class ConflictGraph {
     bw.close();
 
   }
+  
+  public Hashtable<String, ConflictNode> getId2cn() {
+    return id2cn;
+  }
 
 }