small changes
authorbdemsky <bdemsky>
Tue, 12 May 2009 03:28:59 +0000 (03:28 +0000)
committerbdemsky <bdemsky>
Tue, 12 May 2009 03:28:59 +0000 (03:28 +0000)
plus bugfixes...one race condition on riskyflag vs lock fixed

Robust/src/Analysis/Locality/TypeAnalysis.java
Robust/src/Benchmarks/SingleTM/KMeans/makefile
Robust/src/IR/Flat/BuildCode.java
Robust/src/Runtime/STM/stm.c
Robust/src/Runtime/thread.c

index e90b860f9a60f15a51d9c38099e339cae772f758..6045213296e804a008f48b96f7fc4f8cad71bdac 100644 (file)
@@ -92,6 +92,15 @@ public class TypeAnalysis {
     return namemap.get(td);
   }
 
+  public Set<TypeDescriptor> expandSet(Set<TypeDescriptor> tdset) {
+    HashSet<TypeDescriptor> expandedSet=new HashSet<TypeDescriptor>();
+    for(Iterator<TypeDescriptor> it=tdset.iterator();it.hasNext();) {
+      TypeDescriptor td=it.next();
+      expandedSet.addAll(expand(td));
+    }
+    return expandedSet;
+  }
+
   public boolean couldAlias(TypeDescriptor td1, TypeDescriptor td2) {
     return namemap.get(td1).contains(td2);
   }
@@ -181,4 +190,4 @@ public class TypeAnalysis {
     }
   }
 
-}
\ No newline at end of file
+}
index 6e2c4dcca1da265212d1fa5eb4e78c7086814d81..af62dbef5304eba864d92f42941cafcb180397d5 100644 (file)
@@ -6,7 +6,7 @@ SRC=${MAINCLASS}.java \
     Common.java \
     GlobalArgs.java \
     ../../../ClassLibrary/JavaSTM/Barrier.java
-FLAGS=-mainclass ${MAINCLASS} -singleTM -optimize -debug -dcopts -transstats -joptimize -stmstats
+FLAGS=-mainclass ${MAINCLASS} -singleTM -optimize -debug -dcopts -transstats -joptimize
 
 default:
        ../../../buildscript ${FLAGS} -o ${MAINCLASS} ${SRC}
index c73003690e898360c9645a2c25fe44e01a485b90..8b11ed2aec60d4d6949508e9643313f592c75920 100644 (file)
@@ -241,16 +241,6 @@ public class BuildCode {
     }
     if (state.THREAD||state.DSM||state.SINGLETM) {
       outmethod.println("initializethreads();");
-      outmethod.println("#ifdef STMSTATS\n");
-      outmethod.println("objlockscope = calloc(1, sizeof(objlockstate_t));");
-      outmethod.println("pthread_mutex_init(&lockedobjstore, NULL);");
-      outmethod.println("for(i=0; i<MAXOBJLIST; i++) {");
-      outmethod.println("  pthread_mutex_init(&(objlockscope->lock[i]), NULL);");
-      outmethod.println("}");
-      outmethod.println("for(i=0; i<TOTALNUMCLASSANDARRAY; i++) {");
-      outmethod.println("  typesCausingAbort[i] = 0;");
-      outmethod.println("}");
-      outmethod.println("#endif\n");
     }
     if (state.DSM) {
       outmethod.println("if (dstmStartup(argv[1])) {");
index 234f2391162aaff91afbcc1aca10a8dddc7b7c92..2cef92ee5a217c23e7de18675a2ef213afc6a0ef 100644 (file)
@@ -62,21 +62,20 @@ void ABORTCOUNT(objheader_t * x) {
   x->abortCount++;  
   if (x->abortCount > MAXABORTS && (x->riskyflag != 1)) {       
     //makes riskflag sticky
-    x->riskyflag = 1;                   
     pthread_mutex_lock(&lockedobjstore); 
     if (objlockscope->offset<MAXOBJLIST) { 
       x->objlock=&(objlockscope->lock[objlockscope->offset++]);
     } else { 
       objlockstate_t *tmp=malloc(sizeof(objlockstate_t)); 
-      int i; 
-      for(i=0; i<MAXOBJLIST; i++) 
-        pthread_mutex_init(&(tmp->lock[i]), NULL); 
       tmp->next=objlockscope; 
-      x->objlock=&(tmp->lock[0]); 
       tmp->offset=1; 
-      objlockscope=tmp; 
+      x->objlock=&(tmp->lock[0]); 
+      objlockscope=tmp;
     } 
     pthread_mutex_unlock(&lockedobjstore); 
+    pthread_mutex_init(x->objlock, NULL);
+    //should put a memory barrier here
+    x->riskyflag = 1;                   
   }
 }
 #endif
@@ -148,12 +147,7 @@ objheader_t *transCreateObj(void * ptr, unsigned int size) {
   objheader_t *retval=&tmp[1];
   tmp->lock=RW_LOCK_BIAS;
   tmp->version = 1;
-  tmp->abortCount = 0;
-  tmp->accessCount = 0;
-  tmp->riskyflag = 0;
-  tmp->trec = NULL;
   //initialize obj lock to the header
-  tmp->objlock = NULL;
   STATUS(tmp)=NEW;
   // don't insert into table
   if (newobjs->offset<MAXOBJLIST) {
@@ -737,8 +731,10 @@ int transCommitProcess(void ** oidwrlocked, int numoidwrlocked) {
     dst->___cachedCode___=src->___cachedCode___;
     dst->___cachedHash___=src->___cachedHash___;
     memcpy(&dst[1], &src[1], tmpsize-sizeof(struct ___Object___));
-    header->version += 1;
+    __asm__ __volatile__("": : :"memory");
+    header->version++;
   }
+  __asm__ __volatile__("": : :"memory");
 
   /* Release write locks */
   for(i=0; i< numoidwrlocked; i++) {
@@ -759,6 +755,7 @@ int transCommitProcess(void ** oidwrlocked, int numoidwrlocked) {
     ptr=ptr->next;
   }
 #endif
+
   return 0;
 }
 
index 18bb22810958a5209074263d2a2ef891dc0cafff..678e284748942847ffd38ee1b3987457b116cf1c 100644 (file)
@@ -118,6 +118,14 @@ void initializethreads() {
   trec=calloc(1, sizeof(threadrec_t));
   trec->blocked = 0;
   lockedobjs=calloc(1, sizeof(struct objlist));
+  objlockscope = calloc(1, sizeof(objlockstate_t));
+  pthread_mutex_init(&lockedobjstore, NULL);
+  { 
+    int i;
+    for(i=0; i<TOTALNUMCLASSANDARRAY; i++) {
+      typesCausingAbort[i] = 0;
+    }
+  }
 #endif
 #endif
 }