missing files
[IRC.git] / Robust / src / Analysis / Locality / DiscoverConflicts.java
index ac58bf469f0e034d70460df67c8001052860d140..7baa47e9522857e97e6aefb6ed5a90dba1c6927c 100644 (file)
@@ -23,6 +23,8 @@ public class DiscoverConflicts {
   Hashtable<LocalityBinding, Set<TempFlatPair>> transreadmap;
   Hashtable<LocalityBinding, Set<FlatNode>> twritemap;
   Hashtable<LocalityBinding, Set<TempFlatPair>> writemap;
+  Hashtable<LocalityBinding, Set<FlatNode>> getmap;
+
   Hashtable<LocalityBinding, Set<FlatNode>> srcmap;
   Hashtable<LocalityBinding, Set<FlatNode>> leftsrcmap;
   Hashtable<LocalityBinding, Set<FlatNode>> rightsrcmap;
@@ -49,6 +51,7 @@ public class DiscoverConflicts {
       twritemap=new Hashtable<LocalityBinding, Set<FlatNode>>();
       writemap=new Hashtable<LocalityBinding, Set<TempFlatPair>>();
     }
+    getmap=new Hashtable<LocalityBinding, Set<FlatNode>>();
     this.gft=gft;
   }
 
@@ -71,6 +74,7 @@ public class DiscoverConflicts {
       twritemap=new Hashtable<LocalityBinding, Set<FlatNode>>();
       writemap=new Hashtable<LocalityBinding, Set<TempFlatPair>>();
     }
+    getmap=new Hashtable<LocalityBinding, Set<FlatNode>>();
     this.gft=gft;
   }
 
@@ -95,13 +99,12 @@ public class DiscoverConflicts {
     for(Iterator<LocalityBinding> lb=localityset.iterator();lb.hasNext();) {
       LocalityBinding l=lb.next();
       analyzeLocality(l);
-      setNeedReadTrans(l);
     }
   }
 
   //Change flatnode/temp pairs to just flatnodes that need transactional reads
 
-  public void setNeedReadTrans(LocalityBinding lb) {
+  private void setNeedReadTrans(LocalityBinding lb) {
     HashSet<FlatNode> set=new HashSet<FlatNode>();
     for(Iterator<TempFlatPair> it=transreadmap.get(lb).iterator();it.hasNext();) {
       TempFlatPair tfp=it.next();
@@ -118,6 +121,38 @@ public class DiscoverConflicts {
       twritemap.put(lb, set);
     }
   }
+  
+  private void computeneedsarrayget(LocalityBinding lb, Hashtable<FlatNode, Hashtable<TempDescriptor, Set<TempFlatPair>>> fnmap) {
+    //    Set<FlatNode> gwriteset=(state.READSET&&gft!=null)?twritemap.get(lb):treadmap.get(lb);
+    if (state.READSET&&gft!=null) {
+      if (twritemap.get(lb).size()==0) {
+       getmap.put(lb, new HashSet<FlatNode>());
+        return;
+      }
+    }
+
+    Set<FlatNode> gwriteset=treadmap.get(lb);
+    FlatMethod fm=state.getMethodFlat(lb.getMethod());
+    HashSet<FlatNode> needsget=new HashSet<FlatNode>();
+    for(Iterator<FlatNode> fnit=fm.getNodeSet().iterator();fnit.hasNext();) {
+      FlatNode fn=fnit.next();
+      Hashtable<FlatNode, Integer> atomictable=locality.getAtomic(lb);
+      if (atomictable.get(fn).intValue()>0&&fn.kind()==FKind.FlatElementNode) {
+       FlatElementNode fen=(FlatElementNode)fn;
+       Set<TempFlatPair> tfpset=fnmap.get(fen).get(fen.getSrc());
+       if (tfpset!=null) {
+         for(Iterator<TempFlatPair> tfpit=tfpset.iterator();tfpit.hasNext();) {
+           TempFlatPair tfp=tfpit.next();
+           if (gwriteset.contains(tfp.f)) {
+             needsget.add(fen);
+             break;
+           }
+         }
+       }
+      }
+    }
+    getmap.put(lb, needsget);
+  }
 
   //We have a set of things we write to, figure out what things this
   //could effect.
@@ -168,6 +203,12 @@ public class DiscoverConflicts {
     return treadmap.get(lb).contains(fn);
   }
 
+  public boolean getNeedGet(LocalityBinding lb, FlatNode fn) {
+    if (gft!=null)
+      return getmap.get(lb).contains(fn);
+    else throw new Error();
+  }
+
   public boolean getNeedWriteTrans(LocalityBinding lb, FlatNode fn) {
     if (gft!=null)
       return twritemap.get(lb).contains(fn);
@@ -193,7 +234,7 @@ public class DiscoverConflicts {
     if (gft!=null) {
       writemap.put(lb, writeset);
     }
-    
+
     HashSet<FlatNode> srctrans=new HashSet<FlatNode>();
     HashSet<FlatNode> leftsrctrans=new HashSet<FlatNode>();
     HashSet<FlatNode> rightsrctrans=new HashSet<FlatNode>();
@@ -209,7 +250,6 @@ public class DiscoverConflicts {
       if (atomictable.get(fn).intValue()>0) {
        Hashtable<TempDescriptor, Set<TempFlatPair>> tmap=fnmap.get(fn);
        switch(fn.kind()) {
-
          //We might need to translate arguments to pointer comparison
          
        case FKind.FlatOpNode: { 
@@ -315,6 +355,9 @@ public class DiscoverConflicts {
        }
       }
     }
+    //Update results
+    setNeedReadTrans(lb);
+    computeneedsarrayget(lb, fnmap);
   }
 
   public boolean outofscope(TempFlatPair tfp) {
@@ -435,7 +478,7 @@ public class DiscoverConflicts {
            //this could cause conflict...figure out conflict set
            Set<TempFlatPair> tfpset=tmap.get(fen.getSrc());
            if (tfpset!=null)
-             writeset.addAll(tfpset);
+             tfset.addAll(tfpset);
          }
          break;
        }
@@ -451,7 +494,7 @@ public class DiscoverConflicts {
            //this could cause conflict...figure out conflict set
            Set<TempFlatPair> tfpset=tmap.get(ffn.getSrc());
            if (tfpset!=null)
-             writeset.addAll(tfpset);
+             tfset.addAll(tfpset);
          }
          break;
        }
@@ -757,18 +800,21 @@ public class DiscoverConflicts {
 }
 
 class TempFlatPair {
-    FlatNode f;
-    TempDescriptor t;
-    TempFlatPair(TempDescriptor t, FlatNode f) {
-       this.t=t;
-       this.f=f;
-    }
-
-    public int hashCode() {
-       return f.hashCode()^t.hashCode();
-    }
-    public boolean equals(Object o) {
-       TempFlatPair tf=(TempFlatPair)o;
-       return t.equals(tf.t)&&f.equals(tf.f);
-    }
+  FlatNode f;
+  TempDescriptor t;
+  TempFlatPair(TempDescriptor t, FlatNode f) {
+    this.t=t;
+    this.f=f;
+  }
+  
+  public int hashCode() {
+    return f.hashCode()^t.hashCode();
+  }
+  public boolean equals(Object o) {
+    TempFlatPair tf=(TempFlatPair)o;
+    return t.equals(tf.t)&&f.equals(tf.f);
+  }
+  public String toString() {
+    return f.toString()+" "+t.toString();
+  }
 }