bug fixes
authorbdemsky <bdemsky>
Mon, 11 Apr 2011 08:34:55 +0000 (08:34 +0000)
committerbdemsky <bdemsky>
Mon, 11 Apr 2011 08:34:55 +0000 (08:34 +0000)
Robust/src/Runtime/garbage.c
Robust/src/Runtime/object.c
Robust/src/Runtime/object.h
Robust/src/Runtime/runtime.h
Robust/src/Runtime/thread.c

index 4bc119745f73f0d44afe12b5ff5a232caa964295..01e394846701d6b139164c18b2af997d4c14392f 100644 (file)
@@ -398,23 +398,23 @@ void collect(struct garbagelist * stackptr) {
   }
 #if defined(THREADS)||defined(DSTM)||defined(STM)||defined(MLP)
   /* Go to next thread */
+#ifndef MAC
+  //skip over us
+  if (listptr==&litem) {
+#ifdef MLP
+    // update forward list & memory queue for the current SESE
+    updateForwardList(&((SESEcommon*)listptr->seseCommon)->forwardList,FALSE);
+    updateMemoryQueue((SESEcommon*)(listptr->seseCommon));
 #ifdef THREADS
   {
     struct lockvector * lvector=listptr->lvector;
     int i;
     for(i=0;i<lvector->index;i++) {
-      struct ___Object___ *orig=lvector->locks[i].object
+      struct ___Object___ *orig=lvector->locks[i].object;
       ENQUEUE(orig, lvector->locks[i].object);
     }
   }
 #endif
-#ifndef MAC
-  //skip over us
-  if (listptr==&litem) {
-#ifdef MLP
-    // update forward list & memory queue for the current SESE
-    updateForwardList(&((SESEcommon*)listptr->seseCommon)->forwardList,FALSE);
-    updateMemoryQueue((SESEcommon*)(listptr->seseCommon));
 #endif
     listptr=listptr->next;
   }
@@ -429,8 +429,14 @@ void collect(struct garbagelist * stackptr) {
  
   if (listptr!=NULL) {
 #ifdef THREADS
-    void * orig=listptr->locklist;
-    ENQUEUE(orig, listptr->locklist);
+  {
+    struct lockvector * lvector=listptr->lvector;
+    int i;
+    for(i=0;i<lvector->index;i++) {
+      struct ___Object___ *orig=lvector->locks[i].object;
+      ENQUEUE(orig, lvector->locks[i].object);
+    }
+  }
 #endif
 #ifdef STM
     if ((*listptr->tc_table)!=NULL) {
@@ -715,19 +721,6 @@ void collect(struct garbagelist * stackptr) {
       struct ArrayObject *ao=(struct ArrayObject *) ptr;
       struct ArrayObject *ao_cpy=(struct ArrayObject *) cpy;
       SENQUEUE((void *)ao->___objlocation___, *((void **)&ao_cpy->___objlocation___));
-#endif
-#ifdef THREADS
-      {
-       pointer=pointerarray[OBJECTTYPE];
-       //handle object class
-       INTPTR size=pointer[0];
-       int i;
-       for(i=1; i<=size; i++) {
-         unsigned int offset=pointer[i];
-         void * objptr=*((void **)(((char *)ptr)+offset));
-         ENQUEUE(objptr, *((void **)(((char *)cpy)+offset)));
-       }
-      }
 #endif
     } else if (((INTPTR)pointer)==1) {
       /* Array of pointers */
@@ -746,19 +739,6 @@ void collect(struct garbagelist * stackptr) {
        void *objptr=((void **)(((char *)&ao->___length___)+sizeof(int)))[i];
        ENQUEUE(objptr, ((void **)(((char *)&ao_cpy->___length___)+sizeof(int)))[i]);
       }
-#ifdef THREADS
-      {
-       pointer=pointerarray[OBJECTTYPE];
-       //handle object class
-       INTPTR size=pointer[0];
-       int i;
-       for(i=1; i<=size; i++) {
-         unsigned int offset=pointer[i];
-         void * objptr=*((void **)(((char *)ptr)+offset));
-         ENQUEUE(objptr, *((void **)(((char *)cpy)+offset)));
-       }
-      }
-#endif
     } else {
       INTPTR size=pointer[0];
       int i;
@@ -874,9 +854,6 @@ void stopforgc(struct garbagelist * ptr) {
 #endif
 #ifndef MAC
   litem.stackptr=ptr;
-#ifdef THREADS
-  litem.locklist=pthread_getspecific(threadlocks);
-#endif
 #if defined(STM)||defined(THREADS)||defined(MLP)
   litem.base=&memorybase;
 #endif
@@ -894,9 +871,6 @@ void stopforgc(struct garbagelist * ptr) {
   //handle MAC
   struct listitem *litem=pthread_getspecific(litemkey);
   litem->stackptr=ptr;
-#ifdef THREADS
-  litem->locklist=pthread_getspecific(threadlocks);
-#endif
 #endif
   pthread_mutex_lock(&gclistlock);
   listcount++;
@@ -918,9 +892,6 @@ void restartaftergc() {
 #ifdef THREADS
 #ifdef MAC
   struct listitem *litem=pthread_getspecific(litemkey);
-  pthread_setspecific(threadlocks,litem->locklist);
-#else
-  pthread_setspecific(threadlocks,litem.locklist);
 #endif
 #endif
 }
index 59c6bb9b22ee26a3811a16be136b1f412d0c2b6d..9192bb405bf8f3e87ccf672a57bcc8f69098c323 100644 (file)
@@ -14,7 +14,7 @@
 #endif
 
 #ifndef MAC
-extern __thread struct lockvector lvector;
+__thread struct lockvector lvector;
 #endif
 
 #ifdef D___Object______nativehashCode____
@@ -47,7 +47,7 @@ void CALL01(___Object______MonitorEnter____, struct ___Object___ * ___this___) {
 #else
   struct lockvector *lptr=&lvector;
 #endif
-  struct lockpair *lpair=lptr->locks[lptr->index];
+  struct lockpair *lpair=&lptr->locks[lptr->index];
   pthread_t self=pthread_self();
   lpair->object=VAR(___this___);
   lptr->index++;
@@ -107,7 +107,7 @@ void CALL01(___Object______wait____, struct ___Object___ * ___this___) {
 
   while(1) {
     if (VAR(___this___)->lockcount==0) {
-      if (CAS32(&VAR(___this___)->lockcount, 0, lockcount)==0) {
+      if (CAS32(&VAR(___this___)->lockcount, 0, 1)==0) {
        VAR(___this___)->tid=self;
        BARRIER();
        return;
@@ -132,7 +132,7 @@ void CALL01(___Object______MonitorExit____, struct ___Object___ * ___this___) {
 #else
   struct lockvector *lptr=&lvector;
 #endif
-  struct lockpair *lpair=lptr->locks[--lptr->index];
+  struct lockpair *lpair=&lptr->locks[--lptr->index];
   pthread_t self=pthread_self();
   
   if (lpair->islastlock) {
index fb3881d934630fac2e819ba3ab3d1b186ace33eb..724c1b35ddaadf4edeeef62357e929b35b306479 100644 (file)
@@ -4,10 +4,6 @@
 #include "structdefs.h"
 #include "methodheaders.h"
 
-#ifndef MAC
-extern __thread struct lockvector lvector;
-#endif
-
 #ifdef D___Object______nativehashCode____
 int CALL01(___Object______nativehashCode____, struct ___Object___ * ___this___);
 #endif 
index 28d9cc798e9b64fcd17ec622efc0390cdd8c7dd0..b014f85d6bcc5e4d24881c05e951ab918656842d 100644 (file)
@@ -157,17 +157,6 @@ inline void setupsmemmode(void);
 #endif
 #endif
 
-#ifdef TASK
-#ifndef MULTICORE
-#include "chash.h"
-#include "ObjectHash.h"
-#include "structdefs.h"
-#endif
-#include "task.h"
-#ifdef OPTIONAL
-#include "optionalstruct.h"
-#endif
-
 #define MAXLOCKS 256
 
 struct lockpair {
@@ -180,6 +169,21 @@ struct lockvector {
   struct lockpair locks[MAXLOCKS];
 };
 
+#ifndef MAC
+extern __thread struct lockvector lvector;
+#endif
+
+#ifdef TASK
+#ifndef MULTICORE
+#include "chash.h"
+#include "ObjectHash.h"
+#include "structdefs.h"
+#endif
+#include "task.h"
+#ifdef OPTIONAL
+#include "optionalstruct.h"
+#endif
+
 
 #ifdef OPTIONAL
 struct failedtasklist {
index 7624cb3b9199c597a8e165390f4d9c10d581d27d..30a97db6ee844344cab8ebe5b847362ead809aa6 100644 (file)
@@ -8,6 +8,9 @@
 #include "option.h"
 #include <signal.h>
 #include "methodheaders.h"
+#ifndef MULTICORE
+#include "mlp_lock.h"
+#endif
 
 #ifdef DSTM
 #ifdef RECOVERY
@@ -171,8 +174,8 @@ void initializethreads() {
   pthread_cond_init(&objcond,NULL);
   pthread_mutex_init(&joinlock,NULL);
   pthread_cond_init(&joincond,NULL);
-  pthread_key_create(&threadlocks, NULL);
 #ifdef MAC
+  pthread_key_create(&threadlocks, NULL);
   pthread_key_create(&litem, NULL);
 #endif
   processOptions();
@@ -245,6 +248,10 @@ void initializethreads() {
 #endif
 #ifdef MAC
   struct listitem *litem=malloc(sizeof(struct listitem));
+  struct lockvector *lvector=malloc(sizeof(struct lockvector));
+  litem->lockvector=lvector;
+  lvector->index=0;
+  pthread_setspecific(threadlocks, lvector);
   pthread_setspecific(litemkey, litem);
   litem->prev=NULL;
   litem->next=list;
@@ -255,6 +262,8 @@ void initializethreads() {
   //Add our litem to list of threads
   litem.prev=NULL;
   litem.next=list;
+  litem.lvector=&lvector;
+  lvector.index=0;
   if(list!=NULL)
     list->prev=&litem;
   list=&litem;
@@ -294,6 +303,7 @@ void initthread(struct ___Thread___ * ___this___) {
   pthread_setspecific(threadlocks, &lvector);
 #endif
   litem.lvector=&lvector;
+  lvector.index=0;
   litem.prev=NULL;
   pthread_mutex_lock(&gclistlock);
   litem.next=list;