From 420058a56d74f10b5720ea1575710438f8326184 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 24 Jun 2011 00:37:51 +0000 Subject: [PATCH] bug fixes --- Robust/src/Runtime/bamboo/markbit.h | 8 +++- Robust/src/Runtime/bamboo/multicoregarbage.h | 2 + .../src/Runtime/bamboo/multicoregccompact.c | 2 + Robust/src/Runtime/bamboo/multicoregcflush.c | 35 +++++++------- Robust/src/Runtime/bamboo/multicoregcmark.c | 47 ++++++++----------- Robust/src/Runtime/mem.c | 1 - 6 files changed, 48 insertions(+), 47 deletions(-) diff --git a/Robust/src/Runtime/bamboo/markbit.h b/Robust/src/Runtime/bamboo/markbit.h index e56354f0..6eba7ba9 100644 --- a/Robust/src/Runtime/bamboo/markbit.h +++ b/Robust/src/Runtime/bamboo/markbit.h @@ -119,8 +119,12 @@ static inline void clearMark(void *ptr) { unsigned int bits=(index>48)?32:bitmarkmappingarray[index]; unsigned int bitstotoss=32-bits; - unsigned int bitstotosspluslobits=bitstotoss-lobits; - gcmarktbl[hibits]^=((orighi>>(bitstotosspluslobits))<>bitstotoss)<>lobits; gcmarktbl[hibits+1]^=(lowpart>>bitstotoss)<<(bitstotoss+revlobits); } } diff --git a/Robust/src/Runtime/bamboo/multicoregarbage.h b/Robust/src/Runtime/bamboo/multicoregarbage.h index 53503cd6..cd426c7a 100644 --- a/Robust/src/Runtime/bamboo/multicoregarbage.h +++ b/Robust/src/Runtime/bamboo/multicoregarbage.h @@ -13,6 +13,8 @@ //#define GC_PRINTF if(0) tprintf //#endif +#define TR() tprintf("%u\n",__LINE__) + // data structures for GC #define BAMBOO_SMEM_SIZE_L (BAMBOO_SMEM_SIZE * 2) #define BAMBOO_LARGE_SMEM_BOUND (BAMBOO_SMEM_SIZE_L*NUMCORES4GC) diff --git a/Robust/src/Runtime/bamboo/multicoregccompact.c b/Robust/src/Runtime/bamboo/multicoregccompact.c index bb5db5b4..a7434d46 100644 --- a/Robust/src/Runtime/bamboo/multicoregccompact.c +++ b/Robust/src/Runtime/bamboo/multicoregccompact.c @@ -337,6 +337,7 @@ unsigned int compactblocks(struct moveHelper * orig, struct moveHelper * to) { return length; } //good to move objects and update pointers + gcmappingtbl[OBJMAPPINGINDEX(origptr)]=toptr; origptr+=length; toptr=endtoptr; @@ -345,6 +346,7 @@ unsigned int compactblocks(struct moveHelper * orig, struct moveHelper * to) { } to->ptr=toptr; orig->ptr=origptr; + gccurr_heaptop-=(unsigned INTPTR)(toptr-toptrinit); return 0; } diff --git a/Robust/src/Runtime/bamboo/multicoregcflush.c b/Robust/src/Runtime/bamboo/multicoregcflush.c index d70a89c3..740f7a25 100644 --- a/Robust/src/Runtime/bamboo/multicoregcflush.c +++ b/Robust/src/Runtime/bamboo/multicoregcflush.c @@ -26,13 +26,14 @@ extern struct lockvector bamboo_threadlocks; // NOTE: the objptr should not be NULL and should not be non shared ptr #define updateObj(objptr) gcmappingtbl[OBJMAPPINGINDEX(objptr)] -#define UPDATEOBJ(obj, tt) {void *updatetmpptr=obj; if (updatetmpptr!=NULL) obj=updateObj(updatetmpptr);} -#define UPDATEOBJNONNULL(obj, tt) {void *updatetmpptr=obj; obj=updateObj(updatetmpptr);} +//#define UPDATEOBJ(obj) {void *updatetmpptr=obj; if (updatetmpptr!=NULL) obj=updateObj(updatetmpptr);if (objnext) { for(int i=0; isize; i++) { - UPDATEOBJ(listptr->array[i], i); + UPDATEOBJ(listptr->array[i]); } } } @@ -56,7 +57,7 @@ INLINE void updateRuntimePtrs(struct garbagelist * stackptr) { struct parameterwrapper * parameter = queues[j]; struct ObjectHash * set=parameter->objectset; for(struct ObjectNode * ptr=set->listhead;ptr!=NULL;ptr=ptr->lnext) { - UPDATEOBJNONNULL(ptr->key, 0); + UPDATEOBJNONNULL(ptr->key); } ObjectHashrehash(set); } @@ -67,7 +68,7 @@ INLINE void updateRuntimePtrs(struct garbagelist * stackptr) { if(currtpd != NULL) { for(int i=0; inumParameters; i++) { // the parameter can not be NULL - UPDATEOBJNONNULL(currtpd->parameterArray[i], i); + UPDATEOBJNONNULL(currtpd->parameterArray[i]); } } @@ -77,7 +78,7 @@ INLINE void updateRuntimePtrs(struct garbagelist * stackptr) { struct taskparamdescriptor *tpd=ptr->src; for(int i=0; inumParameters; i++) { // the parameter can not be NULL - UPDATEOBJNONNULL(tpd->parameterArray[i], i); + UPDATEOBJNONNULL(tpd->parameterArray[i]); } } genrehash(activetasks); @@ -87,20 +88,20 @@ INLINE void updateRuntimePtrs(struct garbagelist * stackptr) { for(struct QueueItem * tmpobjptr = getHead(&objqueue);tmpobjptr != NULL;tmpobjptr = getNextQueueItem(tmpobjptr)) { struct transObjInfo * objInfo=(struct transObjInfo *)(tmpobjptr->objectptr); // the obj can not be NULL - UPDATEOBJNONNULL(objInfo->objptr, 0); + UPDATEOBJNONNULL(objInfo->objptr); } // update cached objs to be transferred for(struct QueueItem * item = getHead(totransobjqueue);item != NULL;item = getNextQueueItem(item)) { struct transObjInfo * totransobj = (struct transObjInfo *)(item->objectptr); // the obj can not be NULL - UPDATEOBJNONNULL(totransobj->objptr, 0); + UPDATEOBJNONNULL(totransobj->objptr); } // enqueue lock related info for(int i = 0; i < runtime_locklen; ++i) { - UPDATEOBJ(runtime_locks[i].redirectlock, i); - UPDATEOBJ(runtime_locks[i].value, i); + UPDATEOBJ(runtime_locks[i].redirectlock); + UPDATEOBJ(runtime_locks[i].value); } #endif @@ -108,11 +109,11 @@ INLINE void updateRuntimePtrs(struct garbagelist * stackptr) { // update the bamboo_threadlocks for(int i = 0; i < bamboo_threadlocks.index; i++) { // the locked obj can not be NULL - UPDATEOBJNONNULL(bamboo_threadlocks.locks[i].object, i); + UPDATEOBJNONNULL(bamboo_threadlocks.locks[i].object); } // update the bamboo_current_thread - UPDATEOBJ(bamboo_current_thread, 0); + UPDATEOBJ(bamboo_current_thread); // update global thread queue if(STARTUPCORE == BAMBOO_NUM_OF_CORE) { @@ -121,7 +122,7 @@ INLINE void updateRuntimePtrs(struct garbagelist * stackptr) { unsigned int start = *((unsigned int*)(bamboo_thread_queue+2)); for(int i = thread_counter; i > 0; i--) { // the thread obj can not be NULL - UPDATEOBJNONNULL(bamboo_thread_queue[4+start], 0); + UPDATEOBJNONNULL(bamboo_thread_queue[4+start]); start = (start+1)&bamboo_max_thread_num_mask; } } @@ -142,7 +143,7 @@ INLINE void updatePtrsInObj(void * ptr) { unsigned int size=pointer[0]; for(int i=1; i<=size; i++) { unsigned int offset=pointer[i]; - UPDATEOBJ(*((void **)(((char *)ptr)+offset)), i); + UPDATEOBJ(*((void **)(((char *)ptr)+offset))); } #endif } else if (((unsigned int)pointer)==1) { @@ -150,7 +151,7 @@ INLINE void updatePtrsInObj(void * ptr) { struct ArrayObject *ao=(struct ArrayObject *) ptr; int length=ao->___length___; for(int j=0; j___length___)+sizeof(int)))[j], j); + UPDATEOBJ(((void **)(((char *)&ao->___length___)+sizeof(int)))[j]); } #ifdef OBJECTHASPOINTERS pointer=pointerarray[OBJECTTYPE]; @@ -159,7 +160,7 @@ INLINE void updatePtrsInObj(void * ptr) { for(int i=1; i<=size; i++) { unsigned int offset=pointer[i]; - UPDATEOBJ(*((void **)(((char *)ptr)+offset)), i); + UPDATEOBJ(*((void **)(((char *)ptr)+offset))); } #endif } else { @@ -167,7 +168,7 @@ INLINE void updatePtrsInObj(void * ptr) { for(int i=1; i<=size; i++) { unsigned int offset=pointer[i]; - UPDATEOBJ(*((void **)(((char *)ptr)+offset)), i); + UPDATEOBJ(*((void **)(((char *)ptr)+offset))); } } } diff --git a/Robust/src/Runtime/bamboo/multicoregcmark.c b/Robust/src/Runtime/bamboo/multicoregcmark.c index 0dfa1a78..336d83f0 100644 --- a/Robust/src/Runtime/bamboo/multicoregcmark.c +++ b/Robust/src/Runtime/bamboo/multicoregcmark.c @@ -48,12 +48,12 @@ INLINE bool isLarge(void * ptr, int * ttype, unsigned int * tsize) { } //push the null check into the mark macro -//#define MARKOBJ(objptr, ii) {void * marktmpptr=objptr; if (marktmpptr!=NULL) markObj(marktmpptr, __LINE__, ii);} -//#define MARKOBJNONNULL(objptr, ii) {markObj(objptr, __LINE__, ii);} -#define MARKOBJ(objptr, ii) {void * marktmpptr=objptr; if (marktmpptr!=NULL) markObj(marktmpptr);} +//#define MARKOBJ(objptr) {void * marktmpptr=objptr; if (marktmpptr!=NULL) {markObj(marktmpptr);if ((marktmpptr(gcbaseva+BAMBOO_SHARED_MEM_SIZE))) tprintf("Bad pointer %x in line %u\n",marktmpptr, __LINE__); }} -#define MARKOBJNONNULL(objptr, ii) {markObj(objptr);} +#define MARKOBJ(objptr) {void * marktmpptr=objptr; if (marktmpptr!=NULL) {markObj(marktmpptr);}} + +#define MARKOBJNONNULL(objptr) {markObj(objptr);} // NOTE: the objptr should not be NULL and should be a shared obj void markObj(void * objptr) { @@ -81,7 +81,7 @@ void markgarbagelist(struct garbagelist * listptr) { for(;listptr!=NULL;listptr=listptr->next) { int size=listptr->size; for(int i=0; iarray[i], i); + MARKOBJ(listptr->array[i]); } } } @@ -111,7 +111,7 @@ void tomark(struct garbagelist * stackptr) { struct ObjectHash * set=parameter->objectset; struct ObjectNode * ptr=set->listhead; for(;ptr!=NULL;ptr=ptr->lnext) { - MARKOBJNONNULL((void *)ptr->key, 0); + MARKOBJNONNULL((void *)ptr->key); } } } @@ -121,7 +121,7 @@ void tomark(struct garbagelist * stackptr) { if(currtpd != NULL) { for(int i=0; inumParameters; i++) { // currtpd->parameterArray[i] can not be NULL - MARKOBJNONNULL(currtpd->parameterArray[i], i); + MARKOBJNONNULL(currtpd->parameterArray[i]); } } @@ -132,7 +132,7 @@ void tomark(struct garbagelist * stackptr) { struct taskparamdescriptor *tpd=ptr->src; for(int i=0; inumParameters; i++) { // the tpd->parameterArray[i] can not be NULL - MARKOBJNONNULL(tpd->parameterArray[i], i); + MARKOBJNONNULL(tpd->parameterArray[i]); } } } @@ -142,7 +142,7 @@ void tomark(struct garbagelist * stackptr) { for(;tmpobjptr != NULL;tmpobjptr=getNextQueueItem(tmpobjptr)) { struct transObjInfo * objInfo=(struct transObjInfo *)(tmpobjptr->objectptr); // the objptr can not be NULL - MARKOBJNONNULL(objInfo->objptr, 0); + MARKOBJNONNULL(objInfo->objptr); } // enqueue cached objs to be transferred @@ -150,13 +150,13 @@ void tomark(struct garbagelist * stackptr) { for(;item != NULL;item=getNextQueueItem(item)) { struct transObjInfo * totransobj=(struct transObjInfo *)(item->objectptr); // the objptr can not be NULL - MARKOBJNONNULL(totransobj->objptr, 0); + MARKOBJNONNULL(totransobj->objptr); } // enqueue lock related info for(int i = 0; i < runtime_locklen; i++) { - MARKOBJ((void *)(runtime_locks[i].redirectlock), 0); - MARKOBJ((void *)(runtime_locks[i].value), i); + MARKOBJ((void *)(runtime_locks[i].redirectlock)); + MARKOBJ((void *)(runtime_locks[i].value)); } #endif @@ -169,7 +169,7 @@ void tomark(struct garbagelist * stackptr) { unsigned int start = *((unsigned int*)(bamboo_thread_queue+2)); for(int i = thread_counter; i > 0; i--) { // the thread obj can not be NULL - MARKOBJNONNULL((void *)bamboo_thread_queue[4+start], 0); + MARKOBJNONNULL((void *)bamboo_thread_queue[4+start]); start = (start+1)&bamboo_max_thread_num_mask; } } @@ -178,11 +178,11 @@ void tomark(struct garbagelist * stackptr) { // enqueue the bamboo_threadlocks for(int i = 0; i < bamboo_threadlocks.index; i++) { // the locks can not be NULL - MARKOBJNONNULL((void *)(bamboo_threadlocks.locks[i].object), i); + MARKOBJNONNULL((void *)(bamboo_threadlocks.locks[i].object)); } // enqueue the bamboo_current_thread - MARKOBJ(bamboo_current_thread, 0); + MARKOBJ(bamboo_current_thread); #endif } @@ -198,7 +198,7 @@ INLINE void scanPtrsInObj(void * ptr, int type) { for(int i=1; i<=size; i++) { unsigned int offset=pointer[i]; void * objptr=*((void **)(((char *)ptr)+offset)); - MARKOBJ(objptr, i); + MARKOBJ(objptr); } #endif } else if (((unsigned int)pointer)==1) { @@ -207,7 +207,7 @@ INLINE void scanPtrsInObj(void * ptr, int type) { int length=ao->___length___; for(int i=0; i___length___)+sizeof(int)))[i]; - MARKOBJ(objptr, i); + MARKOBJ(objptr); } #ifdef OBJECTHASPOINTERS pointer=pointerarray[OBJECTTYPE]; @@ -216,7 +216,7 @@ INLINE void scanPtrsInObj(void * ptr, int type) { for(int i=1; i<=size; i++) { unsigned int offset=pointer[i]; void * objptr=*((void **)(((char *)ptr)+offset)); - MARKOBJ(objptr, i); + MARKOBJ(objptr); } #endif } else { @@ -225,7 +225,7 @@ INLINE void scanPtrsInObj(void * ptr, int type) { for(int i=1; i<=size; i++) { unsigned int offset=pointer[i]; void * objptr=*((void **)(((char *)ptr)+offset)); - MARKOBJ(objptr, i); + MARKOBJ(objptr); } } } @@ -239,19 +239,16 @@ void mark(struct garbagelist * stackptr) { // mark phase while(MARKPHASE == gc_status_info.gcphase) { int counter = 0; - while(gc_moreItems()) { sendStall = false; gc_status_info.gcbusystatus = true; void * ptr = gc_dequeue(); - unsigned int size = 0; unsigned int type = 0; bool islarge=isLarge(ptr, &type, &size); unsigned int iunits = ALIGNUNITS(size); - setLengthMarked(ptr,iunits); - + if(islarge) { // ptr is a large object and not marked or enqueued printf("NEED TO SUPPORT LARGE OBJECTS!\n"); @@ -260,7 +257,6 @@ void mark(struct garbagelist * stackptr) { unsigned int isize=iunits<