From 76ee11520efa01f7174718515e048fdd8f2c1032 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 7 Jul 2011 22:49:49 +0000 Subject: [PATCH] more bug fixes --- Robust/src/Runtime/bamboo/pmc_forward.c | 16 ++++++++++------ Robust/src/Runtime/bamboo/pmc_garbage.c | 17 +++++++++++------ Robust/src/Runtime/bamboo/pmc_mem.c | 4 ++++ Robust/src/Runtime/bamboo/pmc_refupdate.c | 4 +--- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/Robust/src/Runtime/bamboo/pmc_forward.c b/Robust/src/Runtime/bamboo/pmc_forward.c index 804179cb..d50053a3 100644 --- a/Robust/src/Runtime/bamboo/pmc_forward.c +++ b/Robust/src/Runtime/bamboo/pmc_forward.c @@ -80,24 +80,28 @@ void pmc_doforward() { if (startregion==-1) return; if (endregion==-1) - endregion=NUMPMCUNITS-1; + endregion=NUMPMCUNITS; region->lowunit=startregion; region->highunit=endregion; region->startptr=(startregion==0)?gcbaseva:pmc_heapptr->units[startregion-1].endptr; - region->endptr=pmc_heapptr->units[endregion].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) { - //backward direction + //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 { - //forward direction + //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)); } +//fwddirection=1 means move things to lower addresses void pmc_forward(struct pmc_region *region, unsigned int totalbytes, void *bottomptr, void *topptr, bool fwddirection) { void *tmpptr=bottomptr; void *forwardptr=fwddirection?bottomptr:(topptr-totalbytes); @@ -117,7 +121,7 @@ void pmc_forward(struct pmc_region *region, unsigned int totalbytes, void *botto unsigned int lastunit=region->highunit-1; void * lastunitend=pmc_unitend(lastunit); while(lastunitend>forwardptr) { - pmc_heapptr->units[currunit].endptr=lastunitend; + pmc_heapptr->units[lastunit].endptr=lastunitend; lastunit--; lastunitend=pmc_unitend(lastunit); } diff --git a/Robust/src/Runtime/bamboo/pmc_garbage.c b/Robust/src/Runtime/bamboo/pmc_garbage.c index 2c277911..46b7619c 100644 --- a/Robust/src/Runtime/bamboo/pmc_garbage.c +++ b/Robust/src/Runtime/bamboo/pmc_garbage.c @@ -39,10 +39,10 @@ void pmc_onceInit() { } else pmc_heapptr->regions[i].lastptr=pmc_heapptr->units[i*4-1].endptr; pmc_heapptr->regions[i].lowunit=4*i; - pmc_heapptr->regions[i].highunit=4*i+3; + pmc_heapptr->regions[i].highunit=4*(i+1); pmc_heapptr->regions[i+1].lastptr=pmc_heapptr->units[(i+1)*4+3].endptr; pmc_heapptr->regions[i+1].lowunit=4*(i+1); - pmc_heapptr->regions[i+1].highunit=4*(i+1)+3; + pmc_heapptr->regions[i+1].highunit=4*(i+2); } for(int i=0;iregions[i].lastptr); @@ -59,22 +59,24 @@ void pmc_init() { struct pmc_region *region=&pmc_heapptr->regions[i]; unsigned int startindex=region->lowunit; unsigned int endindex=pmc_heapptr->regions[i+1].highunit; - tprintf("Padding %x-%x\n",startptr, finishptr); for(unsigned int index=startindex;indexstartptr)&&(ptr<=finishptr)) { pmc_heapptr->units[index].endptr=ptr; padspace(startptr, (unsigned int)(ptr-startptr)); startptr=ptr; } - if (ptr>finishptr) + if (ptr>finishptr) { + void *prevunitptr=pmc_heapptr->units[index-1].endptr; + padspace(startptr, finishptr-startptr); break; + } } } } if (bamboo_smem_size) { - tprintf("Padding %u bytes at %x\n", bamboo_smem_size, bamboo_cur_msp); padspace(bamboo_cur_msp, bamboo_smem_size); } tmc_spin_barrier_wait(&pmc_heapptr->barrier); @@ -112,6 +114,7 @@ void gc(struct garbagelist *gl) { //reset memory allocation bamboo_cur_msp=NULL; bamboo_smem_size=0; + tprintf("done\n"); if (BAMBOO_NUM_OF_CORE==STARTUPCORE) { tmc_spin_barrier_wait(&pmc_heapptr->barrier); @@ -126,14 +129,16 @@ void gc(struct garbagelist *gl) { void padspace(void *ptr, unsigned int length) { //zero small blocks + tprintf("Padspace from %x to %x\n", ptr, ptr+length); if (lengthtype=CHARARRAYTYPE; + ao->type=BYTEARRAYTYPE; unsigned arraylength=length-sizeof(struct ArrayObject); ao->___length___=arraylength; + ao->marked=0; } } diff --git a/Robust/src/Runtime/bamboo/pmc_mem.c b/Robust/src/Runtime/bamboo/pmc_mem.c index ed36e97c..a4980846 100644 --- a/Robust/src/Runtime/bamboo/pmc_mem.c +++ b/Robust/src/Runtime/bamboo/pmc_mem.c @@ -13,6 +13,8 @@ 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); @@ -38,6 +40,8 @@ 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 5c612086..a99c2bb1 100644 --- a/Robust/src/Runtime/bamboo/pmc_refupdate.c +++ b/Robust/src/Runtime/bamboo/pmc_refupdate.c @@ -8,7 +8,7 @@ #define pmcupdateObj(objptr) ((void *)((struct ___Object___ *)objptr)->marked) -#define PMCUPDATEOBJ(obj) {void *updatetmpptr=obj; tprintf("UP%x\n", updatetmpptr); if (updatetmpptr!=NULL) {obj=pmcupdateObj(updatetmpptr);}} +#define PMCUPDATEOBJ(obj) {void *updatetmpptr=obj; if (updatetmpptr!=NULL) {obj=pmcupdateObj(updatetmpptr);}} #define PMCUPDATEOBJNONNULL(obj) {void *updatetmpptr=obj; obj=pmcupdateObj(updatetmpptr);} @@ -46,7 +46,6 @@ void pmc_referenceupdate(void *bottomptr, void *topptr) { unsigned int size; gettype_size(tmpptr, &type, &size); size=((size-1)&(~(ALIGNMENTSIZE-1)))+ALIGNMENTSIZE; - tprintf("%x typ=%u sz=%u\n", tmpptr, type, size); if (!type) { tmpptr+=ALIGNMENTSIZE; continue; @@ -56,7 +55,6 @@ void pmc_referenceupdate(void *bottomptr, void *topptr) { pmc_updatePtrs(tmpptr, type); } tmpptr+=size; - tprintf("INC\n"); } } -- 2.34.1