From 8355f957ae106a2b2de4768457dd50bab6fc771e Mon Sep 17 00:00:00 2001 From: bdemsky Date: Mon, 11 Apr 2011 08:34:55 +0000 Subject: [PATCH] bug fixes --- Robust/src/Runtime/garbage.c | 61 ++++++++++-------------------------- Robust/src/Runtime/object.c | 8 ++--- Robust/src/Runtime/object.h | 4 --- Robust/src/Runtime/runtime.h | 26 ++++++++------- Robust/src/Runtime/thread.c | 12 ++++++- 5 files changed, 46 insertions(+), 65 deletions(-) diff --git a/Robust/src/Runtime/garbage.c b/Robust/src/Runtime/garbage.c index 4bc11974..01e39484 100644 --- a/Robust/src/Runtime/garbage.c +++ b/Robust/src/Runtime/garbage.c @@ -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;iindex;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;iindex;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 } diff --git a/Robust/src/Runtime/object.c b/Robust/src/Runtime/object.c index 59c6bb9b..9192bb40 100644 --- a/Robust/src/Runtime/object.c +++ b/Robust/src/Runtime/object.c @@ -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) { diff --git a/Robust/src/Runtime/object.h b/Robust/src/Runtime/object.h index fb3881d9..724c1b35 100644 --- a/Robust/src/Runtime/object.h +++ b/Robust/src/Runtime/object.h @@ -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 diff --git a/Robust/src/Runtime/runtime.h b/Robust/src/Runtime/runtime.h index 28d9cc79..b014f85d 100644 --- a/Robust/src/Runtime/runtime.h +++ b/Robust/src/Runtime/runtime.h @@ -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 { diff --git a/Robust/src/Runtime/thread.c b/Robust/src/Runtime/thread.c index 7624cb3b..30a97db6 100644 --- a/Robust/src/Runtime/thread.c +++ b/Robust/src/Runtime/thread.c @@ -8,6 +8,9 @@ #include "option.h" #include #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; -- 2.34.1