more bug fixes
authorbdemsky <bdemsky>
Wed, 24 Jun 2009 02:01:43 +0000 (02:01 +0000)
committerbdemsky <bdemsky>
Wed, 24 Jun 2009 02:01:43 +0000 (02:01 +0000)
Robust/src/Analysis/Locality/DelayComputation.java
Robust/src/Analysis/Locality/DiscoverConflicts.java
Robust/src/Analysis/Locality/GenerateConversions.java
Robust/src/IR/Flat/AtomicRecord.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/Flat/FlatGlobalConvNode.java
Robust/src/Runtime/STM/delaycomp.h
Robust/src/Runtime/STM/stm.c
Robust/src/Runtime/thread.c

index 6aa84d2a6cb0fc226ffd23f6ec72d91592b9bc2d..5396750f91d2a2d8f1107c532dfd834fb3b962ad 100644 (file)
@@ -227,7 +227,18 @@ public class DelayComputation {
       FlatNode fn=toanalyze.iterator().next();
       toanalyze.remove(fn);
       Hashtable<TempDescriptor, HashSet<FlatNode>> tmptofn=new Hashtable<TempDescriptor, HashSet<FlatNode>>();
-      
+
+      //Don't process non-atomic nodes
+      if (locality.getAtomic(lb).get(fn).intValue()==0) {
+       if (!map.containsKey(fn)) {
+         map.put(fn, new Hashtable<TempDescriptor, HashSet<FlatNode>>());
+         //enqueue next nodes
+         for(int i=0;i<fn.numNext();i++)
+           toanalyze.add(fn.getNext(i));
+       }
+       continue;
+      }
+
       //Do merge on incoming edges
       for(int i=0;i<fn.numPrev();i++) {
        FlatNode fnprev=fn.getPrev(i);
@@ -262,8 +273,8 @@ public class DelayComputation {
        for(int i=0;i<writeset.length;i++) {
          TempDescriptor tmp=writeset[i];
          HashSet<FlatNode> set=new HashSet<FlatNode>();
-         set.add(fn);
          tmptofn.put(tmp,set);
+         set.add(fn);
        }
        if (fn.numNext()>1) {
          //We have a conditional branch...need to handle this carefully
@@ -272,6 +283,9 @@ public class DelayComputation {
          if (!set0.equals(set1)||set0.size()>1) {
            //This branch is important--need to remember how it goes
            livenodes.add(fn);
+         } else {
+           System.out.println("Removing branch:"+fn);
+           System.out.println("set0="+set0+" set1="+set1);
          }
        }
       }
index 7b45289a019bdf805d73a76ec2d0aa98f02125ae..197e735bf36cd4207eba72136a883323ca0f1ec6 100644 (file)
@@ -169,7 +169,7 @@ public class DiscoverConflicts {
        switch(fn.kind()) {
 
          //We might need to translate arguments to pointer comparison
-
+         
        case FKind.FlatOpNode: { 
          FlatOpNode fon=(FlatOpNode)fn;
          if (fon.getOp().getOp()==Operation.EQUAL||
@@ -202,6 +202,29 @@ public class DiscoverConflicts {
          break;
        }
 
+       case FKind.FlatGlobalConvNode: { 
+         //need to translate these if the value we read from may be a
+         //shadow...  check this by seeing if any of the values we
+         //may read are in the transread set or came from our caller
+         //or a method we called
+
+         FlatGlobalConvNode fgcn=(FlatGlobalConvNode)fn;
+         if (fgcn.getLocality()!=lb)
+           break;
+
+         Set<TempFlatPair> tfpset=tmap.get(fgcn.getSrc());
+         if (tfpset!=null) {
+           for(Iterator<TempFlatPair> tfpit=tfpset.iterator();tfpit.hasNext();) {
+             TempFlatPair tfp=tfpit.next();
+             if (tfset.contains(tfp)||outofscope(tfp)) {
+               srctrans.add(fgcn);
+               break;
+             }
+           }
+         }
+         break;
+       }
+
        case FKind.FlatSetFieldNode: { 
          //need to translate these if the value we read from may be a
          //shadow...  check this by seeing if any of the values we
index 41bcc0e140ae244d63d09ad2fcc34735ad41522d..b5ad3c00427b4f64ad7b4780b2552fe3d7ba2377 100644 (file)
@@ -89,7 +89,7 @@ public class GenerateConversions {
              TempNodePair tnp2=new TempNodePair(tnp.getTemp());
              tnp2.setNode(fn);
              tempset.add(tnp2);
-             nodetoconvs2.get(fn).add(tnp.getTemp());  //have to hide cached copies from gc
+             nodetoconvs2.get(fn).add(tnp.getTemp());  //have to hide cached copies from gc -- add unused converted temps
            } else
              tempset.add(tnp);
          } else
@@ -145,6 +145,7 @@ public class GenerateConversions {
        for(Iterator<TempDescriptor> tempit=tempset.iterator(); tempit.hasNext();) {
          TempDescriptor tmpd=tempit.next();
          FlatGlobalConvNode fgcn=new FlatGlobalConvNode(tmpd, lb, false, nodetoconvs.get(fn).contains(tmpd));
+         fgcn.setAtomicEnter(((FlatAtomicExitNode)fn).getAtomicEnter());
          atomictab.put(fgcn, atomictab.get(fn));
          temptab.put(fgcn, (Hashtable<TempDescriptor, Integer>)temptab.get(fn).clone());
 
@@ -232,6 +233,7 @@ public class GenerateConversions {
        Set<TempDescriptor> tempset=nodetotranstemps.get(fn);
        for(Iterator<TempDescriptor> tempit=tempset.iterator(); tempit.hasNext();) {
          FlatGlobalConvNode fgcn=new FlatGlobalConvNode(tempit.next(), lb, true);
+         fgcn.setAtomicEnter((FlatAtomicEnterNode)fn);
          atomictab.put(fgcn, atomictab.get(fn));
          temptab.put(fgcn, (Hashtable<TempDescriptor, Integer>)temptab.get(fn).clone());
          fgcn.addNext(fn.getNext(0));
index cb347d7ede8c68152c8d286a82152feb73309d2e..5ab4c942d681c95be6c470692d42b1b1f27b1bd7 100644 (file)
@@ -4,6 +4,7 @@ import java.util.Set;
 public class AtomicRecord {
   String name;
   Set<TempDescriptor> livein;
+  Set<TempDescriptor> reallivein;
   Set<TempDescriptor> liveout;
   Set<TempDescriptor> liveoutvirtualread;
   
index 3af68ef8b5135ae81505024d079d95ac1af4353b..48f20209856d1c2440bc2b24fa78c9970613b307 100644 (file)
@@ -1500,6 +1500,7 @@ public class BuildCode {
     ClassDescriptor cn=md!=null ? md.getClassDesc() : null;
     ParamsObject objectparams=(ParamsObject)paramstable.get(lb!=null ? lb : md!=null ? md : task);
 
+    HashSet<AtomicRecord> arset=null;
 
     if (state.DELAYCOMP&&!lb.isAtomic()&&lb.getHasAtomic()) {
       //create map
@@ -1509,7 +1510,8 @@ public class BuildCode {
       //fix these so we get right strings for local variables
       localsprefixaddr=localsprefix;
       localsprefixderef=localsprefix+"->";
-
+      arset=new HashSet<AtomicRecord>();
+      
       //Generate commit methods here
       for(Iterator<FlatNode> fnit=fm.getNodeSet().iterator();fnit.hasNext();) {
        FlatNode fn=fnit.next();
@@ -1522,6 +1524,7 @@ public class BuildCode {
          String methodname=md.getSymbol()+(atomicmethodcount++);
          AtomicRecord ar=new AtomicRecord();
          ar.name=methodname;
+         arset.add(ar);
 
          atomicmethodmap.put(faen, ar);
 
@@ -1533,6 +1536,7 @@ public class BuildCode {
          Set<TempDescriptor> liveout=delaycomp.liveout(lb, faen);
          Set<TempDescriptor> liveoutvirtualread=delaycomp.liveoutvirtualread(lb, faen);
          ar.livein=liveinto;
+         ar.reallivein=new HashSet(liveinto);
          ar.liveout=liveout;
          ar.liveoutvirtualread=liveoutvirtualread;
 
@@ -1590,6 +1594,13 @@ public class BuildCode {
     generateHeader(fm, lb, md!=null ? md : task,output);
     TempObject objecttemp=(TempObject) tempstable.get(lb!=null ? lb : md!=null ? md : task);
 
+    if (state.DELAYCOMP&&!lb.isAtomic()&&lb.getHasAtomic()) {
+      for(Iterator<AtomicRecord> arit=arset.iterator();arit.hasNext();) {
+       AtomicRecord ar=arit.next();
+       output.println("struct atomicprimitives_"+ar.name+" primitives_"+ar.name+";");
+      }
+    }
+
     if (GENERATEPRECISEGC) {
       if (md!=null&&(state.DSM||state.SINGLETM))
        output.print("   struct "+cn.getSafeSymbol()+lb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals "+localsprefix+"={");
@@ -2007,7 +2018,7 @@ public class BuildCode {
        if (state.DELAYCOMP) {
          if (firstpass) {
            //need to record which way it should go
-           output.print("   ");  
+           output.print("   ");
            if (storeset!=null&&storeset.contains(current_node)) {
              //need to store which way branch goes
              generateStoreFlatCondBranch(fm, lb, (FlatCondBranch)current_node, "L"+nodetolabel.get(current_node.getNext(1)), output);
@@ -2412,10 +2423,12 @@ public class BuildCode {
       }
     } else {
       /* Need to convert to OID */
-      if (fgcn.doConvert()) {
-       output.println(generateTemp(fm, fgcn.getSrc(),lb)+"=(void *)COMPOID("+generateTemp(fm, fgcn.getSrc(),lb)+");");
-      } else {
-       output.println(generateTemp(fm, fgcn.getSrc(),lb)+"=NULL;");
+      if ((dc==null)||dc.getNeedSrcTrans(lb,fgcn)) {
+       if (fgcn.doConvert()||(delaycomp!=null&&atomicmethodmap.get(fgcn.getAtomicEnter()).reallivein.contains(fgcn.getSrc()))) {
+         output.println(generateTemp(fm, fgcn.getSrc(),lb)+"=(void *)COMPOID("+generateTemp(fm, fgcn.getSrc(),lb)+");");
+       } else {
+         output.println(generateTemp(fm, fgcn.getSrc(),lb)+"=NULL;");
+       }
       }
     }
   }
@@ -2443,6 +2456,24 @@ public class BuildCode {
 
     if (locality.getAtomic(lb).get(faen.getPrev(0)).intValue()>0)
       return;
+
+
+    if (state.DELAYCOMP) {
+      AtomicRecord ar=atomicmethodmap.get(faen);
+      //copy in
+      for(Iterator<TempDescriptor> tmpit=ar.livein.iterator();tmpit.hasNext();) {
+       TempDescriptor tmp=tmpit.next();
+       output.println("primitives_"+ar.name+"."+tmp.getSafeSymbol()+"="+tmp.getSafeSymbol()+";");
+      }
+
+      //copy outs that depend on path
+      for(Iterator<TempDescriptor> tmpit=ar.liveoutvirtualread.iterator();tmpit.hasNext();) {
+       TempDescriptor tmp=tmpit.next();
+       if (!ar.livein.contains(tmp))
+         output.println("primitives_"+ar.name+"."+tmp.getSafeSymbol()+"="+tmp.getSafeSymbol()+";");
+      }
+    }
+
     /* Backup the temps. */
     for(Iterator<TempDescriptor> tmpit=locality.getTemps(lb).get(faen).iterator(); tmpit.hasNext();) {
       TempDescriptor tmp=tmpit.next();
@@ -2498,23 +2529,9 @@ public class BuildCode {
     }
     if (state.DELAYCOMP) {
       AtomicRecord ar=atomicmethodmap.get(faen.getAtomicEnter());
-      output.println("{");
-      output.println("struct atomicprimitives_"+ar.name+" primitives;");
-      //copy in
-      for(Iterator<TempDescriptor> tmpit=ar.livein.iterator();tmpit.hasNext();) {
-       TempDescriptor tmp=tmpit.next();
-       output.println("primitives."+tmp.getSafeSymbol()+"="+tmp.getSafeSymbol()+";");
-      }
-
-      //copy outs that depend on path
-      for(Iterator<TempDescriptor> tmpit=ar.liveoutvirtualread.iterator();tmpit.hasNext();) {
-       TempDescriptor tmp=tmpit.next();
-       if (!ar.livein.contains(tmp))
-         output.println("primitives."+tmp.getSafeSymbol()+"="+tmp.getSafeSymbol()+";");
-      }
 
       //do call
-      output.println("if (transCommit((void (*)(void *, void *, void *))&"+ar.name+", &primitives, &"+localsprefix+", "+paramsprefix+")) {");
+      output.println("if (transCommit((void (*)(void *, void *, void *))&"+ar.name+", &primitives_"+ar.name+", &"+localsprefix+", "+paramsprefix+")) {");
     } else
       output.println("if (transCommit()) {");
     /* Transaction aborts if it returns true */
@@ -2536,10 +2553,9 @@ public class BuildCode {
       output.println("else {");
       for(Iterator<TempDescriptor> tmpit=ar.liveout.iterator();tmpit.hasNext();) {
        TempDescriptor tmp=tmpit.next();
-       output.println(tmp.getSafeSymbol()+"=primitives."+tmp.getSafeSymbol()+";");
+       output.println(tmp.getSafeSymbol()+"=primitives_"+ar.name+"."+tmp.getSafeSymbol()+";");
       }
       output.println("}");
-      output.println("}");
     }
   }
 
index 92c6b51bada74b07c9a0b3866218cfd18de8c61e..f03815c89d35a36bb042bb533c1f8156ad3c6b25 100644 (file)
@@ -7,6 +7,7 @@ public class FlatGlobalConvNode extends FlatNode {
   LocalityBinding lb;
   boolean makePtr;
   boolean convert=true;
+  FlatAtomicEnterNode faen;
 
   public FlatGlobalConvNode(TempDescriptor src, LocalityBinding lb, boolean makePtr) {
     this.src=src;
@@ -21,6 +22,14 @@ public class FlatGlobalConvNode extends FlatNode {
     this.convert=doactualconvert;
   }
 
+  public FlatAtomicEnterNode getAtomicEnter() {
+    return faen;
+  }
+
+  public void setAtomicEnter(FlatAtomicEnterNode faen) {
+    this.faen=faen;
+  }
+
   boolean doConvert() {
     return convert;
   }
index 1f87c795ad6f1cdd830416ab5a699ea9d096cc20..88fc96fa749e98149a3b096d200d13e8875b965b 100644 (file)
@@ -5,8 +5,8 @@
 //them for now..probably a real implementation would page protect the
 //page after...then default to something simpler
 
-#define MAXPOINTERS 1024*1024*16
-#define MAXVALUES 1024*1024*16
+#define MAXPOINTERS 1024*1024*4
+#define MAXVALUES 1024*1024*4
 
 struct pointerlist {
   int count;
@@ -24,55 +24,55 @@ extern __thread struct primitivelist primstack;
 
 //Pointers
 
-#define RESTOREPTR(x) x=ptrstack.array[--ptrstack.count]
+#define RESTOREPTR(x) x=ptrstack.array[ptrstack.count++];
 
-#define STOREPTR(x) ptrstack.array[ptrstack.count++]=x; dc_t_chashInsertOnce(x,x);
+#define STOREPTR(x) {void * y=COMPOID(x); ptrstack.array[ptrstack.count++]=y; dc_t_chashInsertOnce(y,y);}
 
 //Branches
 
-#define RESTOREANDBRANCH(loc) if (primstack.array[--primstack.count]) goto loc
+#define RESTOREANDBRANCH(loc) if (primstack.array[primstack.count++]) goto loc
 
 #define STOREANDBRANCH(cond, loc) if (primstack.array[primstack.count++]=cond) goto loc
 
 //Integers
 
-#define RESTOREI(x) x=primstack.array[--primstack.count]
+#define RESTOREI(x) x=primstack.array[primstack.count++]
 
 #define STOREI(x) primstack.array[primstack.count++]=x
 
 //Floats
 
-#define RESTOREF(x) x=*((float *)&primstack.array[--primstack.count])
+#define RESTOREF(x) x=*((float *)&primstack.array[primstack.count++])
 
 #define STOREF(x) *((float *)&primstack.array[primstack.count++])=x
 
 //Doubles
 
-#define RESTORED(x) x=*((double *)&primstack.array[primstack.count-=2])
+#define RESTORED(x) x=*((double *)&primstack.array[primstack.count]); primstack.count+=2
 
 #define STORED(x) *((double *)&primstack.array[primstack.count])=x; primstack.count+=2
 
 //Bytes
 
-#define RESTOREB(x) x=*((char *)&primstack.array[--primstack.count])
+#define RESTOREB(x) x=*((char *)&primstack.array[primstack.count++])
 
 #define STOREB(x) *((char *)&primstack.array[primstack.count++])=x
 
 //Characters
 
-#define RESTOREC(x) x=*((short *)&primstack.array[--primstack.count])
+#define RESTOREC(x) x=*((short *)&primstack.array[primstack.count++])
 
 #define STOREC(x) *((short *)&primstack.array[primstack.count++])=x
 
-//Doubles
+//Longs
 
-#define RESTOREJ(x) x=*((long long *)&primstack.array[primstack.count-=2])
+#define RESTOREJ(x) x=*((long long *)&primstack.array[primstack.count]); primstack.count+=2
 
 #define STOREJ(x) *((long long *)&primstack.array[primstack.count])=x; primstack.count+=2
 
 //Booleans
 
-#define RESTOREZ(x) x=primstack.array[--primstack.count]
+#define RESTOREZ(x) x=primstack.array[primstack.count++]
 
 #define STOREZ(x) primstack.array[primstack.count++]=x
 
index e395c5d8d206c7ea68acab5ddb066d84f35d8225..fb35ff39436299ac5336c964d84862be3ab391d6 100644 (file)
@@ -331,6 +331,8 @@ int transCommit() {
       t_chashreset();
 #ifdef DELAYCOMP
       dc_t_chashreset();
+      ptrstack.count=0;
+      primstack.count=0;
 #endif
       return TRANS_ABORT;
     }
@@ -349,6 +351,8 @@ int transCommit() {
       t_chashreset();
 #ifdef DELAYCOMP
       dc_t_chashreset();
+      ptrstack.count=0;
+      primstack.count=0;
 #endif
       return 0;
     }
@@ -372,6 +376,8 @@ int transCommit() {
        t_chashreset();
 #ifdef DELAYCOMP
        dc_t_chashreset();
+       ptrstack.count=0;
+       primstack.count=0;
 #endif
        return TRANS_ABORT;
       }
@@ -1051,6 +1057,8 @@ void transAbortProcess(void **oidwrlocked, int numoidwrlocked) {
 
 #ifdef DELAYCOMP
   //  call commit method
+  ptrstack.count=0;
+  primstack.count=0;
   commitmethod(params, locals, primitives);
 #endif
 
index 26eb93903ac16bb174377aef2423de25c0351960..8582a0165f6d9988436bba512ab545390852455b 100644 (file)
@@ -138,6 +138,8 @@ void threadhandler(int sig, struct sigcontext ctx) {
   threadexit();
 }
 
+struct primitivelist *pl;
+
 void initializethreads() {
   struct sigaction sig;
   threadcount=1;
@@ -175,6 +177,9 @@ void initializethreads() {
   t_chashCreate(CHASH_SIZE, CLOADFACTOR);
 #ifdef DELAYCOMP
   dc_t_chashCreate(CHASH_SIZE, CLOADFACTOR);
+  ptrstack.count=0;
+  primstack.count=0;
+  pl=&primstack;
 #endif
 #ifdef STMSTATS
   trec=calloc(1, sizeof(threadrec_t));
@@ -239,6 +244,8 @@ void initthread(struct ___Thread___ * ___this___) {
   t_chashCreate(CHASH_SIZE, CLOADFACTOR);
 #ifdef DELAYCOMP
   dc_t_chashCreate(CHASH_SIZE, CLOADFACTOR);
+  ptrstack.count=0;
+  primstack.count=0;
 #endif
  ___Thread____NNR____staticStart____L___Thread___((struct ___Thread____NNR____staticStart____L___Thread____params *)p);
  objstrDelete(t_cache);