large number of bug corrections
authorbdemsky <bdemsky>
Wed, 8 Apr 2009 02:45:47 +0000 (02:45 +0000)
committerbdemsky <bdemsky>
Wed, 8 Apr 2009 02:45:47 +0000 (02:45 +0000)
Robust/src/Benchmarks/SingleTM/RainForest/RainForest.java
Robust/src/Benchmarks/SingleTM/RainForest/makefile
Robust/src/Runtime/STM/stm.c
Robust/src/Runtime/garbage.c
Robust/src/Runtime/runtime.c

index 3c2ce264636197c2d2f94dfa9733c3ba299789a7..f185a92f19ad8e48d685093d8f27cfbd60ca3c0b 100644 (file)
@@ -175,6 +175,7 @@ public class RainForest extends Thread {
       tmp.join();
     }
     System.printString("Finished\n");
+    System.exit(0);
   }
 
   public void doOneMove(GameMap[][] land, Player gamer) {
index c9ba9650d03ed80ac5e228b46be1fae7d179271f..e334ce62978455e77412ba49d9e7e2c12b3a8eff 100644 (file)
@@ -10,7 +10,7 @@ SRC=tmp${MAINCLASS}.java \
        Node.java \
        AStarPathFinder.java 
 
-FLAGS=-singleTM -nooptimize -mainclass ${MAINCLASS} -debug
+FLAGS=-singleTM -nooptimize -mainclass ${MAINCLASS} -debug -transstats
 
 default:
        cpp ${MAINCLASS}.java > tmp1${MAINCLASS}.java
index 56680152a4b8df833c4daaa7667ed12d27931a98..2c9bae708233313e0acffccc2c8b14db3aeae7b7 100644 (file)
@@ -276,6 +276,7 @@ int traverseCache() {
   
   /* Decide the final response */
   if (softabort) {
+    transAbortProcess(oidrdlocked, &numoidrdlocked, oidwrlocked, &numoidwrlocked);
     return TRANS_SOFT_ABORT;
   } else {
     transCommitProcess(oidrdlocked, &numoidrdlocked, oidwrlocked, &numoidwrlocked);
index 11984fa9243fd8d9b33f551c74436bca1a60f7d0..647cd36c4d8f5175da9e4fb146e8357b176c55f6 100644 (file)
@@ -156,31 +156,34 @@ void fixtable(chashlistnode_t ** tc_table, unsigned int tc_size) {
        break;                  //key = val =0 for element if not present within the hash table
       }
       SENQUEUE(key, key);
-      if (key>=curr_heapbase&&key<curr_heaptop) {
+      if (curr->val>=curr_heapbase&&curr->val<curr_heaptop) {
        SENQUEUE(curr->val, curr->val);
       } else {
        //rewrite transaction cache entry
-       void *ptr=curr->val;
-       int type=((int *)ptr)[0];
+       void *vptr=curr->val;
+       int type=((int *)vptr)[0];
        unsigned int *pointer=pointerarray[type];
        if (pointer==0) {
          //array of primitives - do nothing
+         struct ArrayObject *ao=(struct ArrayObject *) vptr;
+         SENQUEUE((void *)ao->___objlocation___, *((void **)&ao->___objlocation___));
        } else if (((int)pointer)==1) {
          //array of pointers
-         struct ArrayObject *ao=(struct ArrayObject *) ptr;
+         struct ArrayObject *ao=(struct ArrayObject *) vptr;
          int length=ao->___length___;
          int i;
+         SENQUEUE((void *)ao->___objlocation___, *((void **)&ao->___objlocation___));
          for(i=0; i<length; i++) {
            void *objptr=((void **)(((char *)&ao->___length___)+sizeof(int)))[i];
-           ENQUEUE(objptr, ((void **)(((char *)&ao->___length___)+sizeof(int)))[i]);
+           SENQUEUE(objptr, ((void **)(((char *)&ao->___length___)+sizeof(int)))[i]);
          }
        } else {
          int size=pointer[0];
          int i;
          for(i=1; i<=size; i++) {
            unsigned int offset=pointer[i];
-           void * objptr=*((void **)(((int)ptr)+offset));
-           ENQUEUE(objptr, *((void **)(((int)ptr)+offset)));
+           void * objptr=*((void **)(((int)vptr)+offset));
+           SENQUEUE(objptr, *((void **)(((int)vptr)+offset)));
          }
        }
       }
@@ -197,6 +200,12 @@ void fixtable(chashlistnode_t ** tc_table, unsigned int tc_size) {
        if (!isfirst) {
          free(curr);
        }
+      } else if (isfirst) {
+       chashlistnode_t *newnode= calloc(1, sizeof(chashlistnode_t));
+       newnode->key = curr->key;
+       newnode->val = curr->val;
+       newnode->next = tmp->next;
+       tmp->next=newnode;
       } else {
        curr->next=tmp->next;
        tmp->next=curr;
@@ -206,7 +215,7 @@ void fixtable(chashlistnode_t ** tc_table, unsigned int tc_size) {
     } while(curr!=NULL);
   }
   free(ptr);
-  *tc_table=node;
+  (*tc_table)=node;
 }
 #endif
 
@@ -258,6 +267,11 @@ void collect(struct garbagelist * stackptr) {
   }
 #endif
 
+#ifdef STM
+    if (c_table!=NULL)
+      fixtable(&c_table, c_size);
+#endif
+
   /* Check current stack */
 #if defined(THREADS)||defined(DSTM)||defined(STM)
   {
@@ -411,6 +425,11 @@ void collect(struct garbagelist * stackptr) {
       struct ArrayObject *ao_cpy=(struct ArrayObject *) cpy;
       ENQUEUE((void *)ao->___nextobject___, *((void **)&ao_cpy->___nextobject___));
       ENQUEUE((void *)ao->___localcopy___, *((void **)&ao_cpy->___localcopy___));
+#endif
+#if defined(STM)
+      struct ArrayObject *ao=(struct ArrayObject *) ptr;
+      struct ArrayObject *ao_cpy=(struct ArrayObject *) cpy;
+      SENQUEUE((void *)ao->___objlocation___, *((void **)&ao_cpy->___objlocation___));
 #endif
     } else if (((int)pointer)==1) {
       /* Array of pointers */
@@ -419,6 +438,9 @@ void collect(struct garbagelist * stackptr) {
 #if (defined(DSTM)||defined(FASTCHECK))
       ENQUEUE((void *)ao->___nextobject___, *((void **)&ao_cpy->___nextobject___));
       ENQUEUE((void *)ao->___localcopy___, *((void **)&ao_cpy->___localcopy___));
+#endif
+#if defined(STM)
+      SENQUEUE((void *)ao->___objlocation___, *((void **)&ao_cpy->___objlocation___));
 #endif
       int length=ao->___length___;
       int i;
@@ -692,9 +714,16 @@ int gc_createcopy(void * orig, void ** copy_ptr) {
     }
     if (type<NUMCLASSES) {
       /* We have a normal object */
+#ifdef STM
+      int size=classsize[type]+sizeof(objheader_t);
+      void *newobj=tomalloc(size);
+      memcpy(newobj,((char *) orig)-sizeof(objheader_t), size);
+      newobj=((char *)newobj)+sizeof(objheader_t);
+#else
       int size=classsize[type];
       void *newobj=tomalloc(size);
       memcpy(newobj, orig, size);
+#endif
       ((int *)orig)[0]=-1;
       ((void **)orig)[1]=newobj;
       *copy_ptr=newobj;
@@ -704,9 +733,17 @@ int gc_createcopy(void * orig, void ** copy_ptr) {
       struct ArrayObject *ao=(struct ArrayObject *)orig;
       int elementsize=classsize[type];
       int length=ao->___length___;
+#ifdef STM
+      int size=sizeof(struct ArrayObject)+length*elementsize+sizeof(objheader_t);
+      void *newobj=tomalloc(size);
+      memcpy(newobj, ((char*)orig)-sizeof(objheader_t), size);
+      newobj=((char *)newobj)+sizeof(objheader_t);
+#else
       int size=sizeof(struct ArrayObject)+length*elementsize;
       void *newobj=tomalloc(size);
       memcpy(newobj, orig, size);
+#endif
+
       ((int *)orig)[0]=-1;
       ((void **)orig)[1]=newobj;
       *copy_ptr=newobj;
index 895001edd68e1a7f66a2429bbf1c77c6634b8e99..25ee0f816ad60f6f1346614084654cbbe1fa68a9 100644 (file)
@@ -100,6 +100,11 @@ void injectinstructionfailure() {
 }
 
 void CALL11(___System______exit____I,int ___status___, int ___status___) {
+#ifdef TRANSSTATS
+  printf("numTransCommit = %d\n", numTransCommit);
+  printf("numTransAbort = %d\n", numTransAbort);
+  printf("nSoftAbort = %d\n", nSoftAbort);
+#endif
   exit(___status___);
 }