bug fixes
authorbdemsky <bdemsky>
Mon, 20 Jul 2009 22:02:30 +0000 (22:02 +0000)
committerbdemsky <bdemsky>
Mon, 20 Jul 2009 22:02:30 +0000 (22:02 +0000)
Robust/src/Analysis/Locality/DelayComputation.java
Robust/src/Analysis/Locality/LocalityAnalysis.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/Runtime/STM/stm.c
Robust/src/Runtime/STM/stmlock.c
Robust/src/Runtime/STM/stmlock.h

index 011938a17e29a3a69f484ad4a1fae1e7d9ee02df..2216689d6d47daec15cf758ba880338005b5eb2e 100644 (file)
@@ -509,15 +509,11 @@ public class DelayComputation {
       
       //See if flatnode is definitely no delay
       if (fn.kind()==FKind.FlatCall) {
-       isnodelay=true;
-       //Have to deal with fields/arrays
        FlatCall fcall=(FlatCall)fn;
        MethodDescriptor mdcall=fcall.getMethod();
-       nodelayfieldwrset.addAll(gft.getFieldsAll(mdcall));
-       nodelayarraywrset.addAll(typeanalysis.expandSet(gft.getArraysAll(mdcall)));
-       //Have to deal with field/array reads
-       nodelayfieldrdset.addAll(gft.getFieldsRdAll(mdcall));
-       nodelayarrayrdset.addAll(typeanalysis.expandSet(gft.getArraysRdAll(mdcall)));
+       if (!mdcall.getClassDesc().getSymbol().equals("System")||
+           (!mdcall.getSymbol().equals("println")&&!mdcall.getSymbol().equals("printString")))
+         isnodelay=true;
       }
       
       //Delay branches if possible
@@ -599,6 +595,18 @@ public class DelayComputation {
          //have to do expansion
          nodelayarrayrdset.addAll(typeanalysis.expand(((FlatElementNode)fn).getSrc().getType()));
        }
+
+       //See if flatnode is definitely no delay
+       if (fn.kind()==FKind.FlatCall) {
+         //Have to deal with fields/arrays
+         FlatCall fcall=(FlatCall)fn;
+         MethodDescriptor mdcall=fcall.getMethod();
+         nodelayfieldwrset.addAll(gft.getFieldsAll(mdcall));
+         nodelayarraywrset.addAll(typeanalysis.expandSet(gft.getArraysAll(mdcall)));
+         //Have to deal with field/array reads
+         nodelayfieldrdset.addAll(gft.getFieldsRdAll(mdcall));
+         nodelayarrayrdset.addAll(typeanalysis.expandSet(gft.getArraysRdAll(mdcall)));
+       }
       } else {
        //Need to know which objects to lock on
        switch(fn.kind()) {
index 6a705e86a2d34580e62dfa4bf9b8c65a7f1112d8..b4562ec4c8b4cacebd76f29a4919230346b44a52 100644 (file)
@@ -504,8 +504,8 @@ public class LocalityAnalysis {
        }
       } else {
        Integer thistype=currtable.get(fc.getThis());
-       if (!thistype.equals(NORMAL)) {
-         throw new Error("Called start on possible scratch object");
+       if (!thistype.equals(NORMAL)&&!thistype.equals(STMEITHER)) {
+         throw new Error("Called start on possible scratch object"+thistype);
        }
        lb.setGlobal(0,currtable.get(fc.getThis()));
       }
index e3d6bf1fc283d2de906618687e4928f5bcae25a3..ffc2df2f45cb7b5e4233833fb77bd09ad9dc6b4c 100644 (file)
@@ -2676,11 +2676,11 @@ public class BuildCode {
 
   private void generateFlatCall(FlatMethod fm, LocalityBinding lb, FlatCall fc, PrintWriter output) {
     MethodDescriptor md=fc.getMethod();
-    ParamsObject objectparams=(ParamsObject)paramstable.get(state.DSM||state.SINGLETM ? locality.getBinding(lb, fc) : md);
+    ParamsObject objectparams=(ParamsObject)paramstable.get(lb!=null ? locality.getBinding(lb, fc) : md);
     ClassDescriptor cn=md.getClassDesc();
     output.println("{");
     if (GENERATEPRECISEGC) {
-      if (state.DSM||state.SINGLETM) {
+      if (lb!=null) {
        LocalityBinding fclb=locality.getBinding(lb, fc);
        output.print("       struct "+cn.getSafeSymbol()+fclb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={");
       } else
@@ -2722,7 +2722,7 @@ public class BuildCode {
     /* Do we need to do virtual dispatch? */
     if (md.isStatic()||md.getReturnType()==null||singleCall(fc.getThis().getType().getClassDesc(),md)) {
       //no
-      if (state.DSM||state.SINGLETM) {
+      if (lb!=null) {
        LocalityBinding fclb=locality.getBinding(lb, fc);
        output.print(cn.getSafeSymbol()+fclb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor());
       } else {
@@ -2739,7 +2739,7 @@ public class BuildCode {
 
       boolean printcomma=false;
       if (GENERATEPRECISEGC) {
-       if (state.DSM||state.SINGLETM) {
+       if (lb!=null) {
          LocalityBinding fclb=locality.getBinding(lb, fc);
          output.print("struct "+cn.getSafeSymbol()+fclb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params * ");
        } else
@@ -2759,7 +2759,7 @@ public class BuildCode {
       }
 
 
-      if (state.DSM||state.SINGLETM) {
+      if (lb!=null) {
        LocalityBinding fclb=locality.getBinding(lb, fc);
        output.print("))virtualtable["+generateTemp(fm,fc.getThis(),lb)+"->type*"+maxcount+"+"+virtualcalls.getLocalityNumber(fclb)+"])");
       } else
@@ -2900,6 +2900,7 @@ public class BuildCode {
       boolean srcptr=fsfn.getSrc().getType().isPtr();
       String src=generateTemp(fm,fsfn.getSrc(),lb);
       String dst=generateTemp(fm,fsfn.getDst(),lb);
+      output.println("//"+srcptr+" "+fsfn.getSrc().getType().isNull());
       if (srcptr&&!fsfn.getSrc().getType().isNull()) {
        output.println("{");
        if ((dc==null)||dc.getNeedSrcTrans(lb, fsfn)&&
index ac9867585413d63b22deb12d7dca7f768963f516..2578796ac60dc0f5e5600cf09b44d04dcc375282 100644 (file)
@@ -60,11 +60,32 @@ int typesCausingAbort[TOTALNUMCLASSANDARRAY];
 #define DEBUGSTM(x...)
 #endif
 
-#ifdef FASTMEMCPY
-void * A_memcpy (void * dest, const void * src, size_t count);
-#else
-#define A_memcpy memcpy
-#endif
+//#ifdef FASTMEMCPY
+//void * A_memcpy (void * dest, const void * src, size_t count);
+//#else
+//#define A_memcpy memcpy
+//#endif
+
+void * A_memcpy (void * dest, const void * src, size_t count) {
+  int off=0;
+  INTPTR *desti=(INTPTR *)dest;
+  INTPTR *srci=(INTPTR *)src;
+
+  //word copy
+  while(count>=sizeof(INTPTR)) {
+    desti[off]=srci[off];
+    off+=1;
+    count-=sizeof(INTPTR);
+  }
+  off*=sizeof(INTPTR);
+  //byte copy
+  while(count>0) {
+    ((char *)dest)[off]=((char *)src)[off];
+    off++;
+    count--;
+  }
+}
+
 
 extern void * curr_heapbase;
 extern void * curr_heapptr;
@@ -256,7 +277,8 @@ void *objstrAlloc(unsigned int size) {
  * -copies the object into the transaction cache
  * =============================================================
  */
-__attribute__ ((pure)) void *transRead(void * oid, void *gl) {
+//__attribute__ ((pure)) 
+void *transRead(void * oid, void *gl) {
   objheader_t *tmp, *objheader;
   objheader_t *objcopy;
   int size;
@@ -274,6 +296,7 @@ __attribute__ ((pure)) void *transRead(void * oid, void *gl) {
   }
 #endif
   A_memcpy(objcopy, header, size);
+
   /* Insert into cache's lookup table */
   STATUS(objcopy)=0;
   if (((unsigned INTPTR)oid)<((unsigned INTPTR ) curr_heapbase)|| ((unsigned INTPTR)oid) >((unsigned INTPTR) curr_heapptr))
@@ -615,6 +638,7 @@ int traverseCache() {
     objheader_t *header=oidrdlocked[i];
     unsigned int version=oidrdversion[i];
     if(header->lock>0) { //not write locked
+      CFENCE;
       if(version != header->version) { /* versions do not match */
 #ifdef DELAYCOMP
        transAbortProcess(oidwrlocked, numoidwrtotal);
@@ -912,7 +936,8 @@ int alttraverseCache() {
   for(i=0; i<numoidrdlocked; i++) {
     objheader_t * header=oidrdlocked[i];
     unsigned int version=oidrdversion[i];
-    if(header->lock>=0) {
+    if(header->lock>0) {
+      CFENCE;
       if(version != header->version) {
 #ifdef DELAYCOMP
        transAbortProcess(oidwrlocked, numoidwrtotal);
@@ -1137,12 +1162,8 @@ void transAbortProcess(void **oidwrlocked, int numoidwrlocked) {
     dst->___cachedCode___=src->___cachedCode___;
     dst->___cachedHash___=src->___cachedHash___;
     A_memcpy(&dst[1], &src[1], tmpsize-sizeof(struct ___Object___));
-    __asm__ __volatile__("": : :"memory");
-#ifndef DELAYCOMP
-    header->version++;
-#endif
   }
-  __asm__ __volatile__("": : :"memory");
+  CFENCE;
 
 #ifdef DELAYCOMP
   //  call commit method
@@ -1159,9 +1180,7 @@ void transAbortProcess(void **oidwrlocked, int numoidwrlocked) {
   for(i=numoidwrlocked-1; i>=0; i--) {
 #endif
     header = (objheader_t *)oidwrlocked[i];
-#ifdef DELAYCOMP
     header->version++;
-#endif
     write_unlock(&header->lock);
   }
 
@@ -1328,7 +1347,7 @@ objheader_t * needLock(objheader_t *header, void *gl) {
   } else { //failed to get lock
     trec->blocked=1;
     //memory barrier
-    __asm__ __volatile__("":::"memory");
+    CFENCE;
     //see if other thread is blocked
     if(ptr->blocked == 1) {
       //it might be block, so ignore lock and clear our blocked flag
index 7da44b6673586ca3be54f06f8bad897dc1d80f84..971f90262c7f16d04798f541a2f9d62150a4d4f6 100644 (file)
@@ -18,6 +18,6 @@ int write_trylock(volatile unsigned int *lock) {
 */
 
 void write_unlock(volatile unsigned int *lock) {
-  __asm __volatile__("movl $1, %0" : "+m" (*__xg(lock))::"memory");
+  __asm __volatile__("movl $1, %0" : "+m" (*lock)::"memory");
 }
 
index 7b9c6d76700e2b882d3fde214ca3420460395145..a396d8a530b9ef75e613f7b19b105b50b06f77a1 100644 (file)
@@ -3,6 +3,7 @@
 
 #define RW_LOCK_BIAS                 1
 #define LOCK_UNLOCKED          { LOCK_BIAS }
+#define CFENCE   asm volatile("":::"memory");
 
 struct __xchg_dummy {
        unsigned long a[100];
@@ -23,7 +24,7 @@ static inline int write_trylock(volatile unsigned int *lock) {
   int retval=0;
   __asm__ __volatile__("xchgl %0,%1"
                       : "=r"(retval)
-                      : "m"(*__xg(lock)), "0"(retval)
+                      : "m"(*lock), "0"(retval)
                       : "memory");
   return retval;
 }