it passes the definite clearance analysis.
[IRC.git] / Robust / src / Analysis / Locality / DCWrapper.java
index 508b44a605cc0a27dc59328a6d1e176b9b7255c4..3e0f692a67f41a597ff8b383f69807e0405dee25 100644 (file)
@@ -31,24 +31,25 @@ public class DCWrapper {
     this.typeanalysis=typeanalysis;
     this.gft=gft;
     Set<LocalityBinding> localityset=locality.getLocalityBindings();
-    for(Iterator<LocalityBinding> lbit=localityset.iterator();lbit.hasNext();) {
+    for(Iterator<LocalityBinding> lbit=localityset.iterator(); lbit.hasNext(); ) {
       processlb(lbit.next());
     }
   }
-  
+
   Hashtable<LocalityBinding, Set<FlatNode>> transmap=new Hashtable<LocalityBinding, Set<FlatNode>>();
   Hashtable<LocalityBinding, Set<FlatNode>> recordmap=new Hashtable<LocalityBinding, Set<FlatNode>>();
   Hashtable<LocalityBinding, Set<FlatNode>> othermap=new Hashtable<LocalityBinding, Set<FlatNode>>();
   Hashtable<LocalityBinding, Set<FlatNode>> notreadymap=new Hashtable<LocalityBinding, Set<FlatNode>>();
   Hashtable<LocalityBinding, HashSet<FlatNode>> cannotdelaymap=new Hashtable<LocalityBinding, HashSet<FlatNode>>();
   Hashtable<LocalityBinding, Set<FlatNode>> derefmap=new Hashtable<LocalityBinding, Set<FlatNode>>();
-  
+  Hashtable<LocalityBinding, Set<FlatNode>> convmap=new Hashtable<LocalityBinding, Set<FlatNode>>();
+
   public DiscoverConflicts getConflicts() {
     DiscoverConflicts dc=new DiscoverConflicts(locality, state, typeanalysis, cannotdelaymap, false, false, state.READSET?gft:null);
     dc.doAnalysis();
     return dc;
   }
-  
+
   public Hashtable<LocalityBinding, HashSet<FlatNode>> getCannotDelayMap() {
     return cannotdelaymap;
   }
@@ -95,15 +96,21 @@ public class DCWrapper {
     return othermap.get(lb);
   }
 
+  public Set<FlatNode> getConv(LocalityBinding lb) {
+    return convmap.get(lb);
+  }
+
   public Set<FlatNode> livecode(LocalityBinding lb) {
     return recordmap.get(lb);
   }
 
   private void processlb(LocalityBinding lb) {
     transmap.put(lb, new HashSet<FlatNode>());
+    Set<FlatNode> convset=new HashSet<FlatNode>();
+    convmap.put(lb, convset);
     if (lb.isAtomic()||!lb.getHasAtomic())
       return;
-    
+
     Set<FlatNode> recordset=delaycomp.livecode(lb);
     Set<FlatNode> cannotdelay=delaycomp.getCannotDelay(lb);
     Set<FlatNode> otherset=delaycomp.getOther(lb);
@@ -119,43 +126,46 @@ public class DCWrapper {
     Set<FlatNode> nnotready=new HashSet<FlatNode>();
     Set<FlatNode> nderef=new HashSet<FlatNode>();
 
+
     recordmap.put(lb, nrecordset);
     cannotdelaymap.put(lb, ncannotdelay);
     notreadymap.put(lb, nnotready);
     othermap.put(lb, notherset);
     derefmap.put(lb, nderef);
 
+
     FlatMethod fm=state.getMethodFlat(lb.getMethod());
-    for(Iterator<FlatNode> fnit=fm.getNodeSet().iterator();fnit.hasNext();) {
+    for(Iterator<FlatNode> fnit=fm.getNodeSet().iterator(); fnit.hasNext(); ) {
       FlatNode fn=fnit.next();
       if (fn.kind()==FKind.FlatAtomicEnterNode&&
-         locality.getAtomic(lb).get(fn.getPrev(0)).intValue()==0) {
-       Set<FlatNode> transSet=computeTrans(lb, fn);
-       Set<FlatNode> tCheckSet=intersect(checkset, transSet);
-       Set<FlatNode> tRecordSet=intersect(recordset, transSet);
-       Set<FlatNode> tOtherSet=intersect(otherset, transSet);
-       Set<FlatNode> tNotReadySet=intersect(notreadyset, transSet);
-       HashSet<FlatNode> tCannotDelay=intersect(cannotdelay, transSet);
-       Set<FlatNode> tderef=(state.STMARRAY&&!state.DUALVIEW)?intersect(derefset, transSet):null;
-       
-       if (checkSet(fn, tCheckSet, tRecordSet, lb)) {
-         //We will convert this one
-         nrecordset.addAll(tRecordSet);
-         notherset.addAll(tOtherSet);
-         nnotready.addAll(tNotReadySet);
-         ncannotdelay.addAll(tCannotDelay);
-         if (state.STMARRAY&&!state.DUALVIEW)
-           nderef.addAll(tderef);
-         transmap.get(lb).add(fn);
-       } else {
-         ncannotdelay.addAll(transSet);
-       }
-       if (!lwmap.containsKey(lb))
-         lwmap.put(lb, new HashSet<FlatNode>());
-       lwmap.get(lb).add(fn);
+          locality.getAtomic(lb).get(fn.getPrev(0)).intValue()==0) {
+        Set<FlatNode> transSet=computeTrans(lb, fn);
+        Set<FlatNode> tCheckSet=intersect(checkset, transSet);
+        Set<FlatNode> tRecordSet=intersect(recordset, transSet);
+        Set<FlatNode> tOtherSet=intersect(otherset, transSet);
+        Set<FlatNode> tNotReadySet=intersect(notreadyset, transSet);
+        HashSet<FlatNode> tCannotDelay=intersect(cannotdelay, transSet);
+        Set<FlatNode> tderef=(state.STMARRAY&&!state.DUALVIEW)?intersect(derefset, transSet):null;
+
+        if (checkSet(fn, tCheckSet, tRecordSet, lb)) {
+          //We will convert this one
+          nrecordset.addAll(tRecordSet);
+          notherset.addAll(tOtherSet);
+          nnotready.addAll(tNotReadySet);
+          ncannotdelay.addAll(tCannotDelay);
+          if (state.STMARRAY&&!state.DUALVIEW)
+            nderef.addAll(tderef);
+          transmap.get(lb).add(fn);
+          convset.addAll(transSet);
+        } else {
+          ncannotdelay.addAll(transSet);
+        }
+        if (!lwmap.containsKey(lb))
+          lwmap.put(lb, new HashSet<FlatNode>());
+        lwmap.get(lb).add(fn);
       } else {
-       if (locality.getAtomic(lb).get(fn).intValue()==0)
-         ncannotdelay.add(fn);
+        if (locality.getAtomic(lb).get(fn).intValue()==0)
+          ncannotdelay.add(fn);
       }
     }
   }
@@ -175,15 +185,19 @@ public class DCWrapper {
     if (!optmap.containsKey(lb)) {
       optmap.put(lb, new HashSet<FlatNode>());
     }
+
+    if (state.HYBRID&&recordset.size()>6)
+      return false;
+
     DiscoverConflicts dc=delaycomp.getConflicts();
-    for(Iterator<FlatNode> fnit=checkset.iterator();fnit.hasNext();) {
+    for(Iterator<FlatNode> fnit=checkset.iterator(); fnit.hasNext(); ) {
       FlatNode fn=fnit.next();
       //needs transread
       if (!state.READSET&&dc.getNeedTrans(lb, fn)||state.READSET&&dc.getNeedWriteTrans(lb, fn)||fn.kind()==FKind.FlatCall) {
-       System.out.println("False because"+fn);
-       if (!state.HYBRID)
-         return true;
-       return false;
+        System.out.println("False because"+fn);
+        if (!state.HYBRID)
+          return true;
+        return false;
       }
     }
     optmap.get(lb).add(faen);
@@ -199,10 +213,10 @@ public class DCWrapper {
       toProcess.remove(fn);
       transSet.add(fn);
       if (locality.getAtomic(lb).get(fn).intValue()==0)
-       continue;
-      for(int i=0;i<fn.numNext();i++) {
-       if (!transSet.contains(fn.getNext(i)))
-         toProcess.add(fn.getNext(i));
+        continue;
+      for(int i=0; i<fn.numNext(); i++) {
+        if (!transSet.contains(fn.getNext(i)))
+          toProcess.add(fn.getNext(i));
       }
     }
     return transSet;