From: bdemsky Date: Fri, 8 Jul 2011 00:08:45 +0000 (+0000) Subject: more bug fixes X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d796d46ff338395c6736a39ce61286a14f81bc9c;p=IRC.git more bug fixes --- diff --git a/Robust/src/Runtime/bamboo/pmc_forward.c b/Robust/src/Runtime/bamboo/pmc_forward.c index d50053a3..15477bac 100644 --- a/Robust/src/Runtime/bamboo/pmc_forward.c +++ b/Robust/src/Runtime/bamboo/pmc_forward.c @@ -17,7 +17,6 @@ void pmc_count() { //Comment: should build dummy byte arrays to allow skipping data... void pmc_countbytes(struct pmc_unit * unit, void *bottomptr, void *topptr) { - tprintf("%x--%x\n",bottomptr, topptr); void *tmpptr=bottomptr; unsigned int totalbytes=0; while(tmpptrhighunit=endregion; region->startptr=(startregion==0)?gcbaseva:pmc_heapptr->units[startregion-1].endptr; region->endptr=pmc_heapptr->units[endregion-1].endptr; - tprintf("startregion=%u gcbaseva=%x\n", startregion, gcbaseva); - tprintf("totalbytes=%u\n", totalbytes); if (BAMBOO_NUM_OF_CORE&1) { //upward in memory region->lastptr=region->endptr-totalbytes; - tprintf("(up) Assigning lastptr for %u to %x ep=%x\n", BAMBOO_NUM_OF_CORE, region->lastptr, region->endptr); } else { //downward in memory region->lastptr=region->startptr+totalbytes; - tprintf("(down) Assigning lastptr for %u to %x sp=%x\n", BAMBOO_NUM_OF_CORE, region->lastptr, region->startptr); } pmc_forward(region, totalbytes, region->startptr, region->endptr, !(BAMBOO_NUM_OF_CORE&1)); @@ -111,7 +106,7 @@ void pmc_forward(struct pmc_region *region, unsigned int totalbytes, void *botto if (!fwddirection) { //reset boundaries of beginning units - while(endunitlastptr) { pmc_heapptr->units[currunit].endptr=endunit; currunit++; endunit=pmc_unitend(currunit); @@ -120,7 +115,7 @@ void pmc_forward(struct pmc_region *region, unsigned int totalbytes, void *botto //reset boundaries of end units unsigned int lastunit=region->highunit-1; void * lastunitend=pmc_unitend(lastunit); - while(lastunitend>forwardptr) { + while(lastunitend>=region->lastptr) { pmc_heapptr->units[lastunit].endptr=lastunitend; lastunit--; lastunitend=pmc_unitend(lastunit); @@ -139,8 +134,9 @@ void pmc_forward(struct pmc_region *region, unsigned int totalbytes, void *botto if (((struct ___Object___ *)tmpptr)->marked) { ((struct ___Object___ *)tmpptr)->marked=forwardptr; + tprintf("Forwarding %x->%x\n", tmpptr, forwardptr); void *newforwardptr=forwardptr+size; - while(newforwardptr>endunit) { + while(newforwardptr>=endunit) { pmc_heapptr->regions[currunit].endptr=newforwardptr; currunit++; endunit=pmc_unitend(currunit); @@ -154,5 +150,6 @@ void pmc_forward(struct pmc_region *region, unsigned int totalbytes, void *botto } tmpptr+=size; } + tprintf("forwardptr=%x\n",forwardptr); region->lastobj=lastobj; } diff --git a/Robust/src/Runtime/bamboo/pmc_garbage.c b/Robust/src/Runtime/bamboo/pmc_garbage.c index 46b7619c..f56043d9 100644 --- a/Robust/src/Runtime/bamboo/pmc_garbage.c +++ b/Robust/src/Runtime/bamboo/pmc_garbage.c @@ -62,7 +62,6 @@ void pmc_init() { for(unsigned int index=startindex;indexstartptr)&&(ptr<=finishptr)) { pmc_heapptr->units[index].endptr=ptr; padspace(startptr, (unsigned int)(ptr-startptr)); @@ -106,7 +105,7 @@ void gc(struct garbagelist *gl) { tmc_spin_barrier_wait(&pmc_heapptr->barrier); //update pointers tprintf("updaterefs\n"); - pmc_doreferenceupdate(); + pmc_doreferenceupdate(gl); tmc_spin_barrier_wait(&pmc_heapptr->barrier); //compact data tprintf("compact\n"); diff --git a/Robust/src/Runtime/bamboo/pmc_mem.c b/Robust/src/Runtime/bamboo/pmc_mem.c index a4980846..ed36e97c 100644 --- a/Robust/src/Runtime/bamboo/pmc_mem.c +++ b/Robust/src/Runtime/bamboo/pmc_mem.c @@ -13,8 +13,6 @@ void * pmc_alloc(unsigned int * numbytesallocated, unsigned int minimumbytes) { void *startptr=pmc_heapptr->regions[i].lastptr; void *finishptr=pmc_heapptr->regions[i+1].lastptr; - tprintf("%u %x - %x\n",i, startptr, finishptr); - if ((finishptr-startptr)>memcheck) { struct pmc_region *region=&pmc_heapptr->regions[i]; tmc_spin_mutex_lock(®ion->lock); @@ -40,8 +38,6 @@ void * pmc_alloc(unsigned int * numbytesallocated, unsigned int minimumbytes) { *numbytesallocated=(unsigned int)(newstartptr-startptr); tmc_spin_mutex_unlock(®ion->lock); - tprintf("fptr=%x\n", finishptr); - tprintf("Allocing %x to %x\n", startptr, newstartptr); return startptr; } while(0); tmc_spin_mutex_unlock(®ion->lock); diff --git a/Robust/src/Runtime/bamboo/pmc_refupdate.c b/Robust/src/Runtime/bamboo/pmc_refupdate.c index a99c2bb1..7bc9baa2 100644 --- a/Robust/src/Runtime/bamboo/pmc_refupdate.c +++ b/Robust/src/Runtime/bamboo/pmc_refupdate.c @@ -4,13 +4,16 @@ #include "runtime_arch.h" #include "pmc_forward.h" #include "pmc_refupdate.h" +#include "multicoremgc.h" +#include "runtime.h" +#include "thread.h" #define pmcupdateObj(objptr) ((void *)((struct ___Object___ *)objptr)->marked) -#define PMCUPDATEOBJ(obj) {void *updatetmpptr=obj; if (updatetmpptr!=NULL) {obj=pmcupdateObj(updatetmpptr);}} +#define PMCUPDATEOBJ(obj) {void *updatetmpptr=obj; if (updatetmpptr!=NULL) {obj=pmcupdateObj(updatetmpptr);if (obj==NULL) {tprintf("BAD REF UPDATE %x->%x in %u\n",updatetmpptr,obj,__LINE__);}}} -#define PMCUPDATEOBJNONNULL(obj) {void *updatetmpptr=obj; obj=pmcupdateObj(updatetmpptr);} +#define PMCUPDATEOBJNONNULL(obj) {void *updatetmpptr=obj; obj=pmcupdateObj(updatetmpptr);if (obj==NULL) {tprintf("BAD REF UPDATE in %x->%x %u\n",updatetmpptr,obj,__LINE__);}} void pmc_updatePtrs(void *ptr, int type) { unsigned int * pointer=pointerarray[type]; @@ -33,8 +36,111 @@ void pmc_updatePtrs(void *ptr, int type) { } } -void pmc_doreferenceupdate() { +void pmc_updategarbagelist(struct garbagelist *listptr) { + for(;listptr!=NULL; listptr=listptr->next) { + for(int i=0; isize; i++) { + PMCUPDATEOBJ(listptr->array[i]); + } + } +} + +void pmc_updateRuntimePtrs(struct garbagelist * stackptr) { + // update current stack + pmc_updategarbagelist(stackptr); + + // update static pointers global_defs_p + if(STARTUPCORE == BAMBOO_NUM_OF_CORE) { + pmc_updategarbagelist((struct garbagelist *)global_defs_p); + } + +#ifdef TASK + // update objectsets + if(BAMBOO_NUM_OF_CORE < NUMCORESACTIVE) { + for(int i=0; iobjectset; + for(struct ObjectNode * ptr=set->listhead;ptr!=NULL;ptr=ptr->lnext) { + PMCUPDATEOBJNONNULL(ptr->key); + } + ObjectHashrehash(set); + } + } + } + + // update current task descriptor + if(currtpd != NULL) { + for(int i=0; inumParameters; i++) { + // the parameter can not be NULL + PMCUPDATEOBJNONNULL(currtpd->parameterArray[i]); + } + } + + // update active tasks + if(activetasks != NULL) { + for(struct genpointerlist * ptr=activetasks->list;ptr!=NULL;ptr=ptr->inext){ + struct taskparamdescriptor *tpd=ptr->src; + for(int i=0; inumParameters; i++) { + // the parameter can not be NULL + PMCUPDATEOBJNONNULL(tpd->parameterArray[i]); + } + } + genrehash(activetasks); + } + + // update cached transferred obj + for(struct QueueItem * tmpobjptr = getHead(&objqueue);tmpobjptr != NULL;tmpobjptr = getNextQueueItem(tmpobjptr)) { + struct transObjInfo * objInfo=(struct transObjInfo *)(tmpobjptr->objectptr); + // the obj can not be NULL + PMCUPDATEOBJNONNULL(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 + PMCUPDATEOBJNONNULL(totransobj->objptr); + } + + // enqueue lock related info + for(int i = 0; i < runtime_locklen; ++i) { + PMCUPDATEOBJ(runtime_locks[i].redirectlock); + PMCUPDATEOBJ(runtime_locks[i].value); + } +#endif + +#ifdef MGC + // update the bamboo_threadlocks + for(int i = 0; i < bamboo_threadlocks.index; i++) { + // the locked obj can not be NULL + PMCUPDATEOBJNONNULL(bamboo_threadlocks.locks[i].object); + } + + // update the bamboo_current_thread + PMCUPDATEOBJ(bamboo_current_thread); + + // update global thread queue + if(STARTUPCORE == BAMBOO_NUM_OF_CORE) { + unsigned int thread_counter = *((unsigned int*)(bamboo_thread_queue+1)); + if(thread_counter > 0) { + unsigned int start = *((unsigned int*)(bamboo_thread_queue+2)); + for(int i = thread_counter; i > 0; i--) { + // the thread obj can not be NULL + PMCUPDATEOBJNONNULL(*((void **)&bamboo_thread_queue[4+start])); + start = (start+1)&bamboo_max_thread_num_mask; + } + } + unlockthreadqueue(); + } +#endif +} + + +void pmc_doreferenceupdate(struct garbagelist *stackptr) { struct pmc_region * region=&pmc_heapptr->regions[BAMBOO_NUM_OF_CORE]; + pmc_updateRuntimePtrs(stackptr); pmc_referenceupdate(region->startptr, region->endptr); } diff --git a/Robust/src/Runtime/bamboo/pmc_refupdate.h b/Robust/src/Runtime/bamboo/pmc_refupdate.h index 107b90ef..9e9019f6 100644 --- a/Robust/src/Runtime/bamboo/pmc_refupdate.h +++ b/Robust/src/Runtime/bamboo/pmc_refupdate.h @@ -1,9 +1,16 @@ #ifndef PMC_REFUPDATE_H #define PMC_REFUPDATE_H +#include "multicore.h" +#include "multicoregc.h" +#include "structdefs.h" + void pmc_updatePtrs(void *ptr, int type); -void pmc_doreferenceupdate(); +void pmc_doreferenceupdate(struct garbagelist *); void pmc_referenceupdate(void *bottomptr, void *topptr); void pmc_docompact(); void pmc_compact(struct pmc_region * region, int forward, void *bottomptr, void *topptr); +void pmc_updategarbagelist(struct garbagelist *listptr); +void pmc_updateRuntimePtrs(struct garbagelist * stackptr); + #endif