X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=Robust%2Fsrc%2FRuntime%2Fbamboo%2Fpmc_forward.c;h=c60d7ce5c4060770d4893c89559eaaaedf316910;hb=72dee3fc5239f592523fd4307f436cc1baf82eac;hp=d50053a3236d7f22311877ef7ac532d053693602;hpb=76ee11520efa01f7174718515e048fdd8f2c1032;p=IRC.git diff --git a/Robust/src/Runtime/bamboo/pmc_forward.c b/Robust/src/Runtime/bamboo/pmc_forward.c index d50053a3..c60d7ce5 100644 --- a/Robust/src/Runtime/bamboo/pmc_forward.c +++ b/Robust/src/Runtime/bamboo/pmc_forward.c @@ -1,8 +1,9 @@ +#include "multicoregc.h" #include "pmc_forward.h" #include "runtime_arch.h" #include "bambooalign.h" #include "pmc_garbage.h" -#include "multicoregc.h" + void pmc_count() { for(int i=0;iunits[i-1].endptr; void *unittop=pmc_heapptr->units[i].endptr; + //tprintf("Cnt: %x - %x\n", unitbase, unittop); pmc_countbytes(&pmc_heapptr->units[i], unitbase, unittop); } } @@ -17,20 +19,32 @@ 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; + void * lastunmarked=NULL; + bool padokay=false; while(tmpptrmarked) + if (((struct ___Object___ *)tmpptr)->marked) { + if (lastunmarked!=NULL) { + if (padokay) + padspace(lastunmarked, (unsigned INTPTR) (tmpptr-lastunmarked)); + padokay=false; + lastunmarked=NULL; + } totalbytes+=size; + } else if (lastunmarked!=NULL) + lastunmarked=tmpptr; + else + padokay=true; tmpptr+=size; } unit->numbytes=totalbytes; @@ -47,8 +61,16 @@ void pmc_processunits() { int totalbytes=0; int numregions=0; + pmc_heapptr->regions[0].startptr=gcbaseva; + pmc_heapptr->regions[0].lowunit=0; + for(int i=0;i0&&(totalbytes+pmc_heapptr->units[i].numbytes)>livebytespercore) { + pmc_heapptr->regions[regionnum].highunit=i; + pmc_heapptr->regions[regionnum].endptr=pmc_heapptr->units[i-1].endptr; + + pmc_heapptr->regions[regionnum+1].startptr=pmc_heapptr->units[i-1].endptr; + pmc_heapptr->regions[regionnum+1].lowunit=i; regionnum++; totalbytes-=livebytespercore; numregions=0; @@ -58,6 +80,17 @@ void pmc_processunits() { tmc_spin_mutex_init(&pmc_heapptr->units[i].lock); totalbytes+=pmc_heapptr->units[i].numbytes; } + pmc_heapptr->regions[regionnum].highunit=NUMPMCUNITS; + pmc_heapptr->regions[regionnum].endptr=pmc_heapptr->units[NUMPMCUNITS-1].endptr; + regionnum++; + for(;regionnumregions[regionnum].highunit=NUMPMCUNITS; + pmc_heapptr->regions[regionnum].endptr=pmc_heapptr->units[NUMPMCUNITS-1].endptr; + if ((regionnum+1)regions[regionnum+1].startptr=pmc_heapptr->units[NUMPMCUNITS-1].endptr; + pmc_heapptr->regions[regionnum+1].lowunit=NUMPMCUNITS; + } + } } void pmc_doforward() { @@ -65,63 +98,50 @@ void pmc_doforward() { int endregion=-1; unsigned int totalbytes=0; struct pmc_region * region=&pmc_heapptr->regions[BAMBOO_NUM_OF_CORE]; - for(int i=0;iunits[i].regionnum) { - startregion=i; - } - if (BAMBOO_NUM_OF_COREunits[i].regionnum) { - endregion=i; - break; - } - if (startregion!=-1) { - totalbytes+=pmc_heapptr->units[i].numbytes; - } + for(int index=region->lowunit; indexhighunit;index++) { + totalbytes+=pmc_heapptr->units[index].numbytes; } - if (startregion==-1) - return; - if (endregion==-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-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)); } //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 pmc_forward(struct pmc_region *region, unsigned int totalbytes, void *bottomptr, void *topptr, bool lower) { void *tmpptr=bottomptr; - void *forwardptr=fwddirection?bottomptr:(topptr-totalbytes); + void *forwardptr=lower?bottomptr:(topptr-totalbytes); struct ___Object___ *lastobj=NULL; unsigned int currunit=region->lowunit; void *endunit=pmc_unitend(currunit); + bool internal=!(BAMBOO_NUM_OF_CORE&1); + int highbound=internal?region->highunit:region->highunit-1; + + + if (!lower) { + //We're resetting the boundaries of units at the low address end of the region... + //Be sure not to reset the boundary of our last unit...it is shared with another region - if (!fwddirection) { - //reset boundaries of beginning units - while(endunitlastptr&&(currunitunits[currunit].endptr=endunit; + //tprintf("Ch2: %u -> %x\n", currunit, endunit); currunit++; endunit=pmc_unitend(currunit); } } else { - //reset boundaries of end units - unsigned int lastunit=region->highunit-1; + //We're resetting the boundaries of units at the high address end of the region... + //Very top most unit defines boundary of region...we can't move that right now + unsigned int lastunit=internal?region->highunit-1:region->highunit-2; void * lastunitend=pmc_unitend(lastunit); - while(lastunitend>forwardptr) { + while(lastunitend>=region->lastptr) { pmc_heapptr->units[lastunit].endptr=lastunitend; + //tprintf("Ch3: %u -> %x\n", lastunit, lastunitend); lastunit--; lastunitend=pmc_unitend(lastunit); } @@ -139,20 +159,25 @@ 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) { - pmc_heapptr->regions[currunit].endptr=newforwardptr; + //Need to make sure that unit boundaries do not fall in the middle of an object... + //Unless the unit boundary is at the end of the region...then just ignore it. + while(newforwardptr>=endunit&&currunitunits[currunit].endptr=newforwardptr; + //tprintf("Ch4: %u -> %x\n", currunit, newforwardptr); currunit++; endunit=pmc_unitend(currunit); } forwardptr=newforwardptr; - if (lastobj&&!fwddirection) { + if (!lower) { ((struct ___Object___ *)tmpptr)->backward=lastobj; lastobj=(struct ___Object___ *)tmpptr; } } tmpptr+=size; } + //tprintf("forwardptr=%x\n",forwardptr); region->lastobj=lastobj; }