changes according to new forms of effect analysis
authoryeom <yeom>
Tue, 29 Jun 2010 23:45:49 +0000 (23:45 +0000)
committeryeom <yeom>
Tue, 29 Jun 2010 23:45:49 +0000 (23:45 +0000)
Robust/src/Analysis/Disjoint/EffectsAnalysis.java
Robust/src/Analysis/OoOJava/ConflictGraph.java
Robust/src/Analysis/OoOJava/ConflictNode.java
Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java

index 1ed85fa9eb946cbf653be9fa23af0665004e8df5..9ee62fb5579be0b3fd6914fb1b4471b45497db7b 100644 (file)
@@ -59,63 +59,6 @@ public class EffectsAnalysis {
     return taint2effects.entrySet().iterator();
   }
 
-  /*
-  public Hashtable<Taint, Set<Effect>> getSESEEffects(FlatSESEEnterNode sese){
-    
-    Hashtable<Taint, Set<Effect>> taint2Effects = new Hashtable<Taint, Set<Effect>>();
-    Iterator iter=iteratorTaintEffectPairs();
-    while (iter.hasNext()) {
-      Entry entry = (Entry) iter.next();
-      Taint taint = (Taint) entry.getKey();
-      Set<Effect> effects = (Set<Effect>) entry.getValue();
-      if (taint.getSESE().equals(sese)) {
-        Iterator<Effect> eIter = effects.iterator();
-        while (eIter.hasNext()) {
-          Effect effect = eIter.next();
-          if (taint.getSESE().equals(sese)) {
-            Set<Effect> effectSet = taint2Effects.get(taint);
-            if (effectSet == null) {
-              effectSet = new HashSet<Effect>();
-            }
-            effectSet.add(effect);
-            taint2Effects.put(taint, effectSet);
-          }
-        }
-      }
-    }
-    
-    return taint2Effects;
-    
-  }
-  */
-
-  public Hashtable<Taint, Set<Effect>> getStallSiteEffects(FlatNode fn, TempDescriptor td){
-    
-    Hashtable<Taint, Set<Effect>> taint2Effects = new Hashtable<Taint, Set<Effect>>();
-    Iterator iter=iteratorTaintEffectPairs();
-    while(iter.hasNext()){
-      Entry entry=(Entry)iter.next();
-      Taint taint=(Taint)entry.getKey();
-      Set<Effect> effects=(Set<Effect>)entry.getValue();
-      if(taint.getStallSite().equals(fn)){
-        Iterator<Effect> eIter=effects.iterator();        
-        while (eIter.hasNext()) {
-          Effect effect = eIter.next();
-          if( taint.getStallSite().equals(fn) && taint.getVar().equals(td) ){
-            Set<Effect> effectSet=taint2Effects.get(taint);
-            if(effectSet==null){
-              effectSet=new HashSet<Effect>();
-            }
-            effectSet.add(effect);
-            taint2Effects.put(taint, effectSet);
-          }
-        }
-      }
-    }
-    return taint2Effects; 
-  }
-
-
   protected void add(Taint t, Effect e) {
     if( t.getSESE() != null &&
         t.getSESE().getIsCallerSESEplaceholder() ) {
@@ -167,7 +110,6 @@ public class EffectsAnalysis {
       }
       effects.add(e);
       te.put(tNoPreds, effects);
-
       stallSite2te.put(stallSite, te);
     }    
   }
index 45b1cec6d33bdc9bd03074d3911151a521148b96..6f114385631c0ce99852cadcb938c6ba4828f771 100644 (file)
@@ -11,25 +11,43 @@ import java.util.Set;
 import java.util.Map.Entry;
 
 import Analysis.Disjoint.AllocSite;
+import Analysis.Disjoint.DisjointAnalysis;
 import Analysis.Disjoint.Effect;
 import Analysis.Disjoint.Taint;
+import IR.Flat.FlatMethod;
+import IR.Flat.FlatNew;
 import IR.Flat.FlatNode;
 import IR.Flat.FlatSESEEnterNode;
 import IR.Flat.TempDescriptor;
 
 public class ConflictGraph {
 
-  public Hashtable<String, ConflictNode> id2cn;
+  protected Hashtable<String, ConflictNode> id2cn;
+
+  protected DisjointAnalysis da;
+  protected FlatMethod fmEnclosing;
 
   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;
 
   public ConflictGraph() {
     id2cn = new Hashtable<String, ConflictNode>();
   }
-  
+
+  public void setDisJointAnalysis(DisjointAnalysis da) {
+    this.da = da;
+  }
+
+  public void setFMEnclosing(FlatMethod fmEnclosing) {
+    this.fmEnclosing = fmEnclosing;
+  }
+
   public void addLiveIn(Hashtable<Taint, Set<Effect>> taint2Effects) {
+    if (taint2Effects == null) {
+      return;
+    }
     Iterator entryIter = taint2Effects.entrySet().iterator();
     while (entryIter.hasNext()) {
       Entry entry = (Entry) entryIter.next();
@@ -45,7 +63,10 @@ public class ConflictGraph {
     }
   }
 
-  public void addStallSite(Hashtable<Taint, Set<Effect>> taint2Effects) {
+  public void addStallSite(Hashtable<Taint, Set<Effect>> taint2Effects, TempDescriptor var) {
+    if (taint2Effects == null) {
+      return;
+    }
     Iterator entryIter = taint2Effects.entrySet().iterator();
     while (entryIter.hasNext()) {
       Entry entry = (Entry) entryIter.next();
@@ -55,7 +76,9 @@ public class ConflictGraph {
         Iterator<Effect> effectIter = effectSet.iterator();
         while (effectIter.hasNext()) {
           Effect effect = (Effect) effectIter.next();
-          addStallSiteEffect(taint, effect);
+          if (taint.getVar().equals(var)) {
+            addStallSiteEffect(taint, effect);
+          }
         }
       }
     }
@@ -66,21 +89,14 @@ public class ConflictGraph {
     TempDescriptor var = t.getVar();
     AllocSite as = t.getAllocSite();
 
-    String id = var + "_" + fn;
+    String id = var + "_fn" + fn.hashCode();
     ConflictNode node = id2cn.get(id);
     if (node == null) {
-      node = new ConflictNode(id, ConflictNode.INVAR);
-    }
-
-    if (!id2cn.containsKey(id)) {
-
-    } else {
-      node = id2cn.get(id);
+      node = new ConflictNode(id, ConflictNode.STALLSITE);
     }
     node.addEffect(as, e);
 
     id2cn.put(id, node);
-
   }
 
   public void addLiveInNodeEffect(Taint t, Effect e) {
@@ -88,18 +104,11 @@ public class ConflictGraph {
     TempDescriptor invar = t.getVar();
     AllocSite as = t.getAllocSite();
 
-    String id = invar + "_" + sese.getIdentifier();
-
+    String id = invar + "_sese" + sese.getIdentifier();
     ConflictNode node = id2cn.get(id);
     if (node == null) {
       node = new ConflictNode(id, ConflictNode.INVAR);
     }
-
-    if (!id2cn.containsKey(id)) {
-
-    } else {
-      node = id2cn.get(id);
-    }
     node.addEffect(as, e);
 
     id2cn.put(id, node);
@@ -139,7 +148,7 @@ public class ConflictGraph {
 
   }
 
-  public void analyzeConflicts() {
+  public void analyzeConflicts(Set<FlatNew> sitesToFlag, boolean useReachInfo) {
 
     Set<String> keySet = id2cn.keySet();
     Set<String> analyzedIDSet = new HashSet<String>();
@@ -147,20 +156,24 @@ public class ConflictGraph {
     for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
       String nodeID = (String) iterator.next();
       ConflictNode node = id2cn.get(nodeID);
-      analyzePossibleConflicts(analyzedIDSet, node);
+      analyzePossibleConflicts(analyzedIDSet, node, sitesToFlag, useReachInfo);
     }
 
   }
 
-  private void analyzePossibleConflicts(Set<String> analyzedIDSet, ConflictNode currentNode) {
+  private void analyzePossibleConflicts(Set<String> analyzedIDSet, ConflictNode currentNode,
+      Set<FlatNew> sitesToFlag, boolean useReachInfo) {
     // compare with all nodes
     // examine the case where self-edge exists
 
     int conflictType;
     if (currentNode.isInVarNode()) {
-      conflictType = calculateConflictType(currentNode);
+      conflictType = calculateConflictType(currentNode, useReachInfo);
       if (conflictType > ConflictGraph.NON_WRITE_CONFLICT) {
         addConflictEdge(conflictType, currentNode, currentNode);
+        if (sitesToFlag != null) {
+          sitesToFlag.addAll(currentNode.getFlatNewSet());
+        }
       }
     }
 
@@ -175,27 +188,22 @@ public class ConflictGraph {
           && !(analyzedIDSet.contains(currentNode.getID() + entryNodeID) || analyzedIDSet
               .contains(entryNodeID + currentNode.getID()))) {
 
-        if (currentNode.isStallSiteNode() && entryNode.isInVarNode()) {
-          /*
-           * int conflictType = calculateConflictType((StallSiteNode)
-           * currentNode, (LiveInNode) entryNode); if (conflictType > 0) {
-           * addConflictEdge(conflictType, currentNode, entryNode); }
-           * 
-           * analyzedIDSet.add(currentNode.getID() + entryNodeID);
-           */
-        } else if (currentNode.isInVarNode() && entryNode.isInVarNode()) {
-          conflictType = calculateConflictType(currentNode, entryNode);
-          if (conflictType > ConflictGraph.NON_WRITE_CONFLICT) {
-            addConflictEdge(conflictType, currentNode, entryNode);
+        conflictType = calculateConflictType(currentNode, entryNode, useReachInfo);
+        if (conflictType > ConflictGraph.NON_WRITE_CONFLICT) {
+          addConflictEdge(conflictType, currentNode, entryNode);
+          if (sitesToFlag != null) {
+            sitesToFlag.addAll(currentNode.getFlatNewSet());
+            sitesToFlag.addAll(entryNode.getFlatNewSet());
           }
-          analyzedIDSet.add(currentNode.getID() + entryNodeID);
         }
+        analyzedIDSet.add(currentNode.getID() + entryNodeID);
+
       }
     }
 
   }
 
-  private int calculateConflictType(ConflictNode node) {
+  private int calculateConflictType(ConflictNode node, boolean useReachInfo) {
 
     int conflictType = ConflictGraph.NON_WRITE_CONFLICT;
     Hashtable<AllocSite, Set<Effect>> alloc2readEffects = node.getReadEffectSet();
@@ -204,16 +212,16 @@ public class ConflictGraph {
 
     conflictType =
         updateConflictType(conflictType, determineConflictType(alloc2writeEffects,
-            alloc2writeEffects));
+            alloc2writeEffects, useReachInfo));
 
     conflictType =
         updateConflictType(conflictType, hasStrongUpdateConflicts(alloc2SUEffects,
-            alloc2readEffects, alloc2writeEffects));
+            alloc2readEffects, alloc2writeEffects, useReachInfo));
 
     return conflictType;
   }
 
-  private int calculateConflictType(ConflictNode nodeA, ConflictNode nodeB) {
+  private int calculateConflictType(ConflictNode nodeA, ConflictNode nodeB, boolean useReachInfo) {
 
     int conflictType = ConflictGraph.NON_WRITE_CONFLICT;
 
@@ -227,13 +235,15 @@ public class ConflictGraph {
     // if node A has write effects on reading/writing regions of node B
     conflictType =
         updateConflictType(conflictType, determineConflictType(alloc2writeEffectsA,
-            alloc2readEffectsB));
+            alloc2readEffectsB, useReachInfo));
     conflictType =
         updateConflictType(conflictType, determineConflictType(alloc2writeEffectsA,
-            alloc2writeEffectsB));
+            alloc2writeEffectsB, useReachInfo));
 
     // if node B has write effects on reading regions of node A
-    determineConflictType(alloc2writeEffectsB, alloc2readEffectsA);
+    conflictType =
+        updateConflictType(conflictType, determineConflictType(alloc2writeEffectsB,
+            alloc2readEffectsA, useReachInfo));
 
     // strong udpate effects conflict with all effects
     // on objects that are reachable from the same heap roots
@@ -241,21 +251,22 @@ public class ConflictGraph {
     if (!alloc2SUEffectsA.isEmpty()) {
       conflictType =
           updateConflictType(conflictType, hasStrongUpdateConflicts(alloc2SUEffectsA,
-              alloc2readEffectsB, alloc2writeEffectsB));
+              alloc2readEffectsB, alloc2writeEffectsB, useReachInfo));
     }
 
     // if node B has SU on regions of node A
     if (!alloc2SUEffectsB.isEmpty()) {
       conflictType =
           updateConflictType(conflictType, hasStrongUpdateConflicts(alloc2SUEffectsB,
-              alloc2readEffectsA, alloc2writeEffectsA));
+              alloc2readEffectsA, alloc2writeEffectsA, useReachInfo));
     }
 
     return conflictType;
   }
 
   private int hasStrongUpdateConflicts(Hashtable<AllocSite, Set<Effect>> SUEffectsTableA,
-      Hashtable<AllocSite, Set<Effect>> readTableB, Hashtable<AllocSite, Set<Effect>> writeTableB) {
+      Hashtable<AllocSite, Set<Effect>> readTableB, Hashtable<AllocSite, Set<Effect>> writeTableB,
+      boolean useReachInfo) {
 
     int conflictType = ConflictGraph.NON_WRITE_CONFLICT;
 
@@ -278,13 +289,17 @@ public class ConflictGraph {
 
             if (strongUpdateA.getAffectedAllocSite().equals(effectB.getAffectedAllocSite())
                 && strongUpdateA.getField().equals(effectB.getField())) {
-              // possible conflict
-              // check affected allocation site can be reached from both heap
-              // roots
-              // if(og.isReachable(asA, asB,
-              // strongUpdateA.getAffectedAllocSite()){
-              // return ConflictGraph.COARSE_GRAIN_EDGE;
-              // }
+              if (useReachInfo) {
+                FlatNew fnRoot1 = asA.getFlatNew();
+                FlatNew fnRoot2 = asB.getFlatNew();
+                FlatNew fnTarget = strongUpdateA.getAffectedAllocSite().getFlatNew();
+                if (da.mayBothReachTarget(fmEnclosing, fnRoot1, fnRoot2, fnTarget)) {
+                  conflictType = updateConflictType(conflictType, ConflictGraph.COARSE_GRAIN_EDGE);
+                }
+              } else {
+                return ConflictGraph.CONFLICT;
+              }
+
             }
 
           }
@@ -304,13 +319,13 @@ public class ConflictGraph {
 
             if (strongUpdateA.getAffectedAllocSite().equals(effectB.getAffectedAllocSite())
                 && strongUpdateA.getField().equals(effectB.getField())) {
-              // possible conflict
-              // check affected allocation site can be reached from both heap
-              // roots
-              // if(og.isReachable(asA, asB,
-              // strongUpdateA.getAffectedAllocSite()){
-              // return ConflictGraph.COARSE_GRAIN_EDGE;
-              // }
+
+              FlatNew fnRoot1 = asA.getFlatNew();
+              FlatNew fnRoot2 = asB.getFlatNew();
+              FlatNew fnTarget = strongUpdateA.getAffectedAllocSite().getFlatNew();
+              if (da.mayBothReachTarget(fmEnclosing, fnRoot1, fnRoot2, fnTarget)) {
+                conflictType = updateConflictType(conflictType, ConflictGraph.COARSE_GRAIN_EDGE);
+              }
             }
 
           }
@@ -324,7 +339,7 @@ public class ConflictGraph {
   }
 
   private int determineConflictType(Hashtable<AllocSite, Set<Effect>> nodeAtable,
-      Hashtable<AllocSite, Set<Effect>> nodeBtable) {
+      Hashtable<AllocSite, Set<Effect>> nodeBtable, boolean useReachInfo) {
 
     int conflictType = ConflictGraph.NON_WRITE_CONFLICT;
 
@@ -337,8 +352,8 @@ public class ConflictGraph {
       Iterator effectItrB = nodeBtable.entrySet().iterator();
       while (effectItrB.hasNext()) {
         Map.Entry meB = (Map.Entry) effectItrB.next();
-        AllocSite asB = (AllocSite) meA.getKey();
-        Set<Effect> esB = (Set<Effect>) meA.getValue();
+        AllocSite asB = (AllocSite) meB.getKey();
+        Set<Effect> esB = (Set<Effect>) meB.getValue();
 
         for (Iterator iterator = esA.iterator(); iterator.hasNext();) {
           Effect effectA = (Effect) iterator.next();
@@ -347,16 +362,29 @@ public class ConflictGraph {
 
             if (effectA.getAffectedAllocSite().equals(effectB.getAffectedAllocSite())
                 && effectA.getField().equals(effectB.getField())) {
-              // possible conflict
-              /*
-               * if(og.isReachable(asA, asB, effectA.getAffectedAllocSite())){
-               * //affected allocation site can be reached from both heap roots
-               * if(isFineGrainConflict()){
-               * conflictType=updateConflictType(conflictType
-               * ,ConflictGraph.FINE_GRAIN_EDGE); }else{
-               * conflictType=updateConflictType
-               * (conflictType,ConflictGraph.COARSE_GRAIN_EDGE); } }
-               */
+
+              if (useReachInfo) {
+                FlatNew fnRoot1 = asA.getFlatNew();
+                FlatNew fnRoot2 = asB.getFlatNew();
+                FlatNew fnTarget = effectA.getAffectedAllocSite().getFlatNew();
+                if (da.mayBothReachTarget(fmEnclosing, fnRoot1, fnRoot2, fnTarget)) {
+                  if (fnRoot1.equals(fnRoot2)) {
+                    if (!da.mayManyReachTarget(fmEnclosing, fnRoot1, fnTarget)) {
+                      // fine-grained conflict case
+                      conflictType =
+                          updateConflictType(conflictType, ConflictGraph.FINE_GRAIN_EDGE);
+                    } else {
+                      conflictType =
+                          updateConflictType(conflictType, ConflictGraph.COARSE_GRAIN_EDGE);
+                    }
+                  } else {
+                    conflictType =
+                        updateConflictType(conflictType, ConflictGraph.COARSE_GRAIN_EDGE);
+                  }
+                }
+              } else {
+                return ConflictGraph.CONFLICT;
+              }
             }
           }
         }
@@ -374,6 +402,14 @@ public class ConflictGraph {
     }
   }
 
+  public void clearAllConflictEdge() {
+    Collection<ConflictNode> nodes = id2cn.values();
+    for (Iterator iterator = nodes.iterator(); iterator.hasNext();) {
+      ConflictNode conflictNode = (ConflictNode) iterator.next();
+      conflictNode.getEdgeSet().clear();
+    }
+  }
+
   public HashSet<ConflictEdge> getEdgeSet() {
 
     HashSet<ConflictEdge> returnSet = new HashSet<ConflictEdge>();
index 3df327e6e445550359c8181c1f21a44755c763ea..51908e43157fb9b2c56ac3966cfdd2ada9f62a10 100644 (file)
@@ -2,14 +2,17 @@ package Analysis.OoOJava;
 
 import java.util.HashSet;
 import java.util.Hashtable;
+import java.util.Iterator;
 import java.util.Set;
 
 import Analysis.Disjoint.AllocSite;
 import Analysis.Disjoint.Effect;
+import IR.Flat.FlatNew;
 
 public class ConflictNode {
 
   protected HashSet<ConflictEdge> edgeSet;
+  protected HashSet<AllocSite> allocSet;
 
   protected Hashtable<AllocSite, Set<Effect>> alloc2readEffectSet;
   protected Hashtable<AllocSite, Set<Effect>> alloc2writeEffectSet;
@@ -32,6 +35,9 @@ public class ConflictNode {
 
   public ConflictNode(String id, int nodeType) {
     edgeSet = new HashSet<ConflictEdge>();
+    // redundant views of access root's 
+    // allocation sites for efficient retrieval
+    allocSet = new HashSet<AllocSite>();
 
     alloc2readEffectSet = new Hashtable<AllocSite, Set<Effect>>();
     alloc2writeEffectSet = new Hashtable<AllocSite, Set<Effect>>();
@@ -52,6 +58,7 @@ public class ConflictNode {
   }
 
   public void addReadEffect(AllocSite as, Effect e) {
+    allocSet.add(as);    
     Set<Effect> effectSet = alloc2readEffectSet.get(as);
     if (effectSet == null) {
       effectSet = new HashSet<Effect>();
@@ -62,6 +69,7 @@ public class ConflictNode {
   }
 
   public void addWriteEffect(AllocSite as, Effect e) {
+    allocSet.add(as);    
     Set<Effect> effectSet = alloc2writeEffectSet.get(as);
     if (effectSet == null) {
       effectSet = new HashSet<Effect>();
@@ -72,6 +80,7 @@ public class ConflictNode {
   }
 
   public void addStrongUpdateEffect(AllocSite as, Effect e) {
+    allocSet.add(as);    
     Set<Effect> effectSet = alloc2strongUpdateEffectSet.get(as);
     if (effectSet == null) {
       effectSet = new HashSet<Effect>();
@@ -103,6 +112,16 @@ public class ConflictNode {
   public boolean isStallSiteNode() {
     return !isInVarNode();
   }
+  
+  public Set<FlatNew> getFlatNewSet(){
+    Set<FlatNew> fnSet=new HashSet<FlatNew>();
+    for (Iterator iterator = allocSet.iterator(); iterator.hasNext();) {
+      AllocSite as = (AllocSite) iterator.next();
+      FlatNew fn=as.getFlatNew();
+      fnSet.add(fn);
+    }
+    return fnSet;
+  }
 
   public Set<ConflictEdge> getEdgeSet() {
     return edgeSet;
@@ -140,7 +159,7 @@ public class ConflictNode {
 
   }
 
-  public String toString() {
+  public String toStringAllEffects() {
 
     String str = "";
 
@@ -158,5 +177,5 @@ public class ConflictNode {
 
     return str;
   }
-
+  
 }
index 0c7707d362a72e5330bbd4c8b23a08247c22b7e6..d8ec7134528509b7901a45aa20ab247c57b90c4d 100644 (file)
@@ -180,15 +180,12 @@ public class OoOJavaAnalysis {
 
     // 7th pass,  make conflict graph
     // conflict graph is maintained by each parent sese,
-    // and while making the graph identify set of FlatNew
-    // that next disjoint reach. analysis should flag
-    Set<FlatNew> sitesToFlag = new HashSet<FlatNew>();
-    
-    methItr = descriptorsToAnalyze.iterator();
-    while (methItr.hasNext()) {
-      Descriptor d = methItr.next();
+    Iterator descItr=disjointAnalysisTaints.getDescriptorsToAnalyze().iterator();
+    while (descItr.hasNext()) {
+      Descriptor d = (Descriptor)descItr.next();
       FlatMethod fm = state.getMethodFlat(d);
-      makeConflictGraph(fm, sitesToFlag);
+      if(fm != null)
+        makeConflictGraph(fm);
     }
 
     // debug routine 
@@ -197,16 +194,22 @@ public class OoOJavaAnalysis {
       Entry e = (Entry) iter.next();
       FlatNode fn = (FlatNode) e.getKey();
       ConflictGraph conflictGraph = (ConflictGraph) e.getValue();
+      System.out.println("---------------------------------------");
       System.out.println("CONFLICT GRAPH for " + fn);
       Set<String> keySet = conflictGraph.id2cn.keySet();
       for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
         String key = (String) iterator.next();
         ConflictNode node = conflictGraph.id2cn.get(key);
-        System.out.println("key=" + key + " --\n" + node.toString());
+        System.out.println("key=" + key + " \n" + node.toStringAllEffects());
       }
     }
     
-    // 8th pass, ask disjoint analysis to compute reachability
+    // 8th pass, calculate all possible conflicts without using reachability info
+    // and identify set of FlatNew that next disjoint reach. analysis should flag
+    Set<FlatNew> sitesToFlag = new HashSet<FlatNew>();
+    calculateConflicts(sitesToFlag,false);    
+    
+    // 9th pass, ask disjoint analysis to compute reachability
     // for objects that may cause heap conflicts so the most
     // efficient method to deal with conflict can be computed
     // later
@@ -221,11 +224,11 @@ public class OoOJavaAnalysis {
                            null  // don't do effects analysis again!
                            );
 
-    // 9th pass, calculate conflicts
-    //calculateConflicts();
+    // 10th pass, calculate conflicts with reachability info
+    calculateConflicts(null, true);
     
     /*
-    // #th pass, compiling locks
+    // 11th pass, compiling locks
     synthesizeLocks();
 
     // #th pass, writing conflict graph
@@ -669,7 +672,7 @@ public class OoOJavaAnalysis {
     } // end switch
   }
 
-  private void makeConflictGraph(FlatMethod fm, Set<FlatNew> sitesToFlag) {
+  private void makeConflictGraph(FlatMethod fm) {
 
     Set<FlatNode> flatNodesToVisit = new HashSet<FlatNode>();
     flatNodesToVisit.add(fm);
@@ -691,7 +694,7 @@ public class OoOJavaAnalysis {
           conflictGraph = new ConflictGraph();
         }
 
-        conflictGraph_nodeAction(fn, seseStack.peek(), sitesToFlag);
+        conflictGraph_nodeAction(fn, seseStack.peek());
       }
 
       // schedule forward nodes for analysis
@@ -707,74 +710,99 @@ public class OoOJavaAnalysis {
   }
  
 
-  private void conflictGraph_nodeAction(FlatNode fn, FlatSESEEnterNode currentSESE, Set<FlatNew> sitesToFlag) {
+  private void conflictGraph_nodeAction(FlatNode fn, FlatSESEEnterNode currentSESE) {
 
+    ConflictGraph conflictGraph;
     EffectsAnalysis effectsAnalysis = disjointAnalysisTaints.getEffectsAnalysis();
-    ConflictGraph conflictGraph = sese2conflictGraph.get(currentSESE.getParent());
-    if (conflictGraph == null) {
-      conflictGraph = new ConflictGraph();
-    }
-    
+
     switch (fn.kind()) {
 
     case FKind.FlatSESEEnterNode: {
 
+      if (currentSESE.getParent() == null) {
+        return;
+      }
+      conflictGraph = sese2conflictGraph.get(currentSESE.getParent());
+      if (conflictGraph == null) {
+        conflictGraph = new ConflictGraph();
+      }
+
       FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn;
 
       if (!fsen.getIsCallerSESEplaceholder() && currentSESE.getParent() != null) {
         // collects effects set of invar set and generates invar node
-        Hashtable<Taint, Set<Effect>> taint2Effects=effectsAnalysis.get(currentSESE);
+        Hashtable<Taint, Set<Effect>> taint2Effects = effectsAnalysis.get(currentSESE);
         conflictGraph.addLiveIn(taint2Effects);
       }
+
+      if (conflictGraph.id2cn.size() > 0) {
+        sese2conflictGraph.put(currentSESE.getParent(), conflictGraph);
+      }
+
     }
       break;
-      
-    case FKind.FlatFieldNode:  
+
+    case FKind.FlatFieldNode:
     case FKind.FlatElementNode: {
-      
+
+      conflictGraph = sese2conflictGraph.get(currentSESE);
+      if (conflictGraph == null) {
+        conflictGraph = new ConflictGraph();
+      }
+
       FlatFieldNode ffn = (FlatFieldNode) fn;
       TempDescriptor rhs = ffn.getSrc();
-      
-      // add stall site      
-      //Hashtable<Taint, Set<Effect>> taint2Effects=effectsAnalysis.get(fn, rhs);
-      //conflictGraph.addStallSite(taint2Effects);
-      
-    }    
+
+      // add stall site
+      Hashtable<Taint, Set<Effect>> taint2Effects = effectsAnalysis.get(fn);
+      conflictGraph.addStallSite(taint2Effects, rhs);
+
+      if (conflictGraph.id2cn.size() > 0) {
+        sese2conflictGraph.put(currentSESE, conflictGraph);
+      }
+    }
       break;
-      
-    case FKind.FlatSetFieldNode: 
+
+    case FKind.FlatSetFieldNode:
     case FKind.FlatSetElementNode: {
-      
+
+      conflictGraph = sese2conflictGraph.get(currentSESE);
+      if (conflictGraph == null) {
+        conflictGraph = new ConflictGraph();
+      }
+
       FlatSetFieldNode fsfn = (FlatSetFieldNode) fn;
       TempDescriptor lhs = fsfn.getDst();
       TempDescriptor rhs = fsfn.getSrc();
-      
+
       // collects effects of stall site and generates stall site node
-      //Hashtable<Taint, Set<Effect>> taint2Effects=effectsAnalysis.get(fn, rhs);
-      //conflictGraph.addStallSite(taint2Effects);
-      
-      //taint2Effects=effectsAnalysis.get(fn, lhs);
-      //conflictGraph.addStallSite(taint2Effects);
-      
-    }    
+      Hashtable<Taint, Set<Effect>> taint2Effects = effectsAnalysis.get(fn);
+      conflictGraph.addStallSite(taint2Effects, rhs);
+      conflictGraph.addStallSite(taint2Effects, lhs);
+
+      if (conflictGraph.id2cn.size() > 0) {
+        sese2conflictGraph.put(currentSESE, conflictGraph);
+      }
+    }
       break;
     }
 
-    if (conflictGraph.id2cn.size() > 0) {
-      sese2conflictGraph.put(currentSESE.getParent(), conflictGraph);
-    }
-    
   }
-  
-  private void calculateConflicts() {
+
+  private void calculateConflicts(Set<FlatNew> sitesToFlag, boolean useReachInfo) {
     // decide fine-grain edge or coarse-grain edge among all vertexes by
     // pair-wise comparison
-
     Iterator<FlatNode> seseIter = sese2conflictGraph.keySet().iterator();
     while (seseIter.hasNext()) {
-      FlatNode sese = seseIter.next();
+      FlatSESEEnterNode sese = (FlatSESEEnterNode) seseIter.next();
       ConflictGraph conflictGraph = sese2conflictGraph.get(sese);
-      conflictGraph.analyzeConflicts();
+      if (useReachInfo) {
+        // clear current conflict before recalculating with reachability info
+        conflictGraph.clearAllConflictEdge(); 
+        conflictGraph.setDisJointAnalysis(disjointAnalysisReach);
+        conflictGraph.setFMEnclosing(sese.getfmEnclosing());
+      }
+      conflictGraph.analyzeConflicts(sitesToFlag, useReachInfo);
       sese2conflictGraph.put(sese, conflictGraph);
     }
   }