lots of bug fixes
authorbdemsky <bdemsky>
Fri, 26 Jun 2009 19:39:08 +0000 (19:39 +0000)
committerbdemsky <bdemsky>
Fri, 26 Jun 2009 19:39:08 +0000 (19:39 +0000)
Robust/src/Analysis/Liveness.java
Robust/src/Analysis/Locality/DelayComputation.java
Robust/src/Analysis/ReachingDefs.java
Robust/src/IR/Flat/FlatGlobalConvNode.java
Robust/src/IR/Flat/FlatMethod.java
Robust/src/IR/Flat/FlatNode.java
Robust/src/IR/Flat/TempDescriptor.java
Robust/src/Runtime/STM/stmlookup.c

index 6fe3a671839072246c222ed932d04fce3d2a029c..5e9c7d999e14c37912160f0c1d94497b8ccda17d 100644 (file)
@@ -9,7 +9,7 @@ import java.util.Hashtable;
 
 public class Liveness {
   /* This methods takes in a FlatMethod and returns a map from a
-   * FlatNode to the set of live temps for that FlatNode.*/
+   * FlatNode to the set of temps that are live into the FlatNode.*/
 
   public static Hashtable<FlatNode, Set<TempDescriptor>> computeLiveTemps(FlatMethod fm) {
     Hashtable<FlatNode, Set<TempDescriptor>> nodetotemps=new Hashtable<FlatNode, Set<TempDescriptor>>();
index 5e0ffd1db29d354ab3bdfa92addecd948cb65a5b..93b0489be013395dc05cd8d7b7cc086b4f3f9d40 100644 (file)
@@ -102,7 +102,8 @@ public class DelayComputation {
     secondpart.retainAll(atomicnodes);
 
     Set<TempDescriptor> liveinto=new HashSet<TempDescriptor>();
-    Hashtable<FlatNode, Hashtable<TempDescriptor, Set<FlatNode>>> reachingdefs=ReachingDefs.computeReachingDefs(fm);
+    
+    Hashtable<FlatNode, Hashtable<TempDescriptor, Set<FlatNode>>> reachingdefs=ReachingDefs.computeReachingDefs(fm, Liveness.computeLiveTemps(fm));
     
     for(Iterator<FlatNode> fnit=secondpart.iterator();fnit.hasNext();) {
       FlatNode fn=fnit.next();
@@ -131,8 +132,8 @@ public class DelayComputation {
     FlatMethod fm=state.getMethodFlat(md);
     Set<FlatNode> exits=faen.getExits();
     Hashtable<FlatNode, Set<TempDescriptor>> livemap=Liveness.computeLiveTemps(fm);
-    Hashtable<FlatNode, Hashtable<TempDescriptor, Set<FlatNode>>> reachingdefs=ReachingDefs.computeReachingDefs(fm);
-    
+    Hashtable<FlatNode, Hashtable<TempDescriptor, Set<FlatNode>>> reachingdefs=ReachingDefs.computeReachingDefs(fm, Liveness.computeLiveTemps(fm));    
+
     Set<FlatNode> atomicnodes=faen.getReachableSet(faen.getExits());
 
     Set<FlatNode> secondpart=new HashSet<FlatNode>(getNotReady(lb));
@@ -176,7 +177,7 @@ public class DelayComputation {
     FlatMethod fm=state.getMethodFlat(md);
     Set<FlatNode> exits=faen.getExits();
     Hashtable<FlatNode, Set<TempDescriptor>> livemap=Liveness.computeLiveTemps(fm);
-    Hashtable<FlatNode, Hashtable<TempDescriptor, Set<FlatNode>>> reachingdefs=ReachingDefs.computeReachingDefs(fm);
+    Hashtable<FlatNode, Hashtable<TempDescriptor, Set<FlatNode>>> reachingdefs=ReachingDefs.computeReachingDefs(fm, livemap);
     
     Set<FlatNode> atomicnodes=faen.getReachableSet(faen.getExits());
 
@@ -195,6 +196,10 @@ public class DelayComputation {
       for(Iterator<TempDescriptor> tmpit=tempset.iterator();tmpit.hasNext();) {
        TempDescriptor tmp=tmpit.next();
        Set<FlatNode> fnset=reachmap.get(tmp);
+       if (fnset==null) {
+         System.out.println("null temp set for"+fn+" tmp="+tmp);
+         System.out.println(fm.printMethod());
+       }
        for(Iterator<FlatNode> fnit2=fnset.iterator();fnit2.hasNext();) {
          FlatNode fn2=fnit2.next();
          if (secondpart.contains(fn2)) {
index 56095d08aa5424250e6df675fbf73117d9db6fce..411017a7164c03c2cb0159b53ba25b56044df9fc 100644 (file)
@@ -10,7 +10,7 @@ public class ReachingDefs {
   /* This methods takes in a FlatMethod and returns a map from a
    * FlatNode to the set of live temps for that FlatNode.*/
 
-  public static Hashtable<FlatNode, Hashtable<TempDescriptor, Set<FlatNode>>> computeReachingDefs(FlatMethod fm) {
+  public static Hashtable<FlatNode, Hashtable<TempDescriptor, Set<FlatNode>>> computeReachingDefs(FlatMethod fm, Hashtable<FlatNode, Set<TempDescriptor>> livemap) {
     Hashtable<FlatNode, Hashtable<TempDescriptor, Set<FlatNode>>> nodetotemps=new Hashtable<FlatNode, Hashtable<TempDescriptor,Set<FlatNode>>>();
     
     Set<FlatNode> toprocess=fm.getNodeSet();
@@ -21,12 +21,16 @@ public class ReachingDefs {
       
       Hashtable<TempDescriptor, Set<FlatNode>> tempset=new Hashtable<TempDescriptor, Set<FlatNode>>();
 
+      Set<TempDescriptor> livetempset=livemap.get(fn);
+
       for(int i=0; i<fn.numPrev(); i++) {
        FlatNode fnprev=fn.getPrev(i);
        if (nodetotemps.containsKey(fnprev)) {
          Hashtable<TempDescriptor,Set<FlatNode>> prevtable=nodetotemps.get(fnprev);
          for(Iterator<TempDescriptor> tmpit=prevtable.keySet().iterator();tmpit.hasNext();) {
            TempDescriptor tmp=tmpit.next();
+           if (!livetempset.contains(tmp))
+             continue;
            if (!tempset.containsKey(tmp))
              tempset.put(tmp, new HashSet<FlatNode>());
            tempset.get(tmp).addAll(prevtable.get(tmp));
index f03815c89d35a36bb042bb533c1f8156ad3c6b25..3076a2e5a98a824a9b1751cd97652d79ea28602d 100644 (file)
@@ -64,6 +64,9 @@ public class FlatGlobalConvNode extends FlatNode {
   }
 
   public TempDescriptor [] readsTemps() {
-    return new TempDescriptor[] {src};
+    if (!makePtr&&!convert)
+      return new TempDescriptor[0];
+    else
+      return new TempDescriptor[] {src};
   }
 }
index 6fdc29bbc65062e13f435bd65cfbecd1c1a86c00..96a83adeabda21102d3966988be1b1312c466ced 100644 (file)
@@ -94,6 +94,22 @@ public class FlatMethod extends FlatNode {
     return flatExit;
   }
 
+  public void check() {
+    Set<FlatNode> set=getNodeSet();
+    for(Iterator<FlatNode> setit=set.iterator();setit.hasNext();) {
+      FlatNode fn=setit.next();
+      for(int i=0;i<fn.numPrev();i++) {
+       FlatNode fnprev=fn.getPrev(i);
+       if (!set.contains(fnprev)) {
+         System.out.println(fn+" has unreachable parent:"+i+"  "+fnprev);
+         System.out.println(printMethod());
+         throw new Error();
+
+       }
+      }
+    }
+  }
+
   /** This method returns a set of the nodes in this flat representation */
 
   public Set<FlatNode> getNodeSet() {
@@ -106,6 +122,8 @@ public class FlatMethod extends FlatNode {
       visited.add(fn);
       for(int i=0; i<fn.numNext(); i++) {
        FlatNode nn=fn.getNext(i);
+       if (nn==null)
+         continue;
        if (!visited.contains(nn))
          tovisit.add(nn);
       }
index 5bc5da965084a05de647df52433144b5101bd718..ba2c3a8dc5624c8856e45c8130459ff495c8f607 100644 (file)
@@ -5,7 +5,7 @@ import java.util.Set;
 import java.util.Iterator;
 
 public class FlatNode {
-  protected Vector next;
+  public Vector next;
   protected Vector prev;
 
   public FlatNode() {
@@ -117,12 +117,14 @@ public class FlatNode {
     }
     for(int i=0;i<next.size();i++) {
       FlatNode nnext=(FlatNode)next.get(i);
-      fnnew.next.set(i,nnext);;
+      fnnew.next.set(i,nnext);
       for(int j=0;j<nnext.numPrev();j++) {
        FlatNode n=nnext.getPrev(j);
        if (n==this)
          nnext.prev.set(j, fnnew);
       }
     }
+    next=null;
+    prev=null;
   }
 }
index d5eb728a7a9d871174ecb7e8e2a43759917bd00c..12657520f57320e1a89fc8871082afd533fb4ff0 100644 (file)
@@ -36,6 +36,13 @@ public class TempDescriptor extends Descriptor {
       return new TempDescriptor(name+"_"+currentid, type, tag);
   }
 
+  public TempDescriptor createNew(String x) {
+    if (tag==null)
+      return new TempDescriptor(name+"_"+currentid+"_"+x, type);
+    else
+      return new TempDescriptor(name+"_"+currentid+"_"+x, type, tag);
+  }
+
   public static TempDescriptor tempFactory() {
     return new TempDescriptor("temp_"+currentid);
   }
index 40b8a9decd9617d5575e31e476d00a2ed6c4f97f..ab961244519f5d515d7e13057cccf52294ea4e63 100644 (file)
@@ -70,6 +70,8 @@ void dc_t_chashreset() {
 void dc_t_chashInsertOnce(void * key, void *val) {
   chashlistnode_t *ptr;
 
+  if (key==NULL)
+    return;
 
   if(dc_c_numelements > (dc_c_threshold)) {
     //Resize