From d35208053ed91d2f78258abcbbf5f334d1895fec Mon Sep 17 00:00:00 2001 From: jzhou Date: Sat, 6 Aug 2011 00:11:34 +0000 Subject: [PATCH] Previous fix is still buggy, this one really fix that bug --- .../src/Runtime/bamboo/multicoregccompact.c | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/Robust/src/Runtime/bamboo/multicoregccompact.c b/Robust/src/Runtime/bamboo/multicoregccompact.c index d0adbc6f..294f976b 100644 --- a/Robust/src/Runtime/bamboo/multicoregccompact.c +++ b/Robust/src/Runtime/bamboo/multicoregccompact.c @@ -58,8 +58,16 @@ void handleReturnMem_I(unsigned int cnum, void *heaptop) { struct blockrecord * blockrecord=&allocationinfo.blocktable[blockindex]; - unsigned INTPTR newusedspace=(unsigned INTPTR)(heaptop-OFFSET2BASEVA(blockindex)-gcbaseva); - if(blockrecord->usedspace < newusedspace) { + unsigned INTPTR newusedspace=heaptop-OFFSET2BASEVA(blockindex)-gcbaseva; + if((blockrecord->corenum!=cnum) && (newusedspace==0)) { + // In this case, the cnum core just filled up a previous block and returned + // the end address of that block which belongs to the following block. We + // need to fix up the blockindex to the previous full block. As that block + // has been marked as BS_USED already, nothing else is needed here. + blockindex--; + localblocknum=GLOBALBLOCK2LOCAL(blockindex); + blockrecord=&allocationinfo.blocktable[blockindex]; + } else { blockrecord->status=BS_FREE; blockrecord->usedspace=newusedspace; blockrecord->freespace=BLOCKSIZE(localblocknum)-blockrecord->usedspace; @@ -67,19 +75,19 @@ void handleReturnMem_I(unsigned int cnum, void *heaptop) { if (blockindex < allocationinfo.lowestfreeblock) { allocationinfo.lowestfreeblock=blockindex; } + } - /* This is our own block...means we should mark other blocks above us as free*/ - - if (cnum==blockrecord->corenum) { - unsigned INTPTR nextlocalblocknum=localblocknum+1; - for(;nextlocalblocknumstatus=BS_FREE; - nextblockrecord->usedspace=0; - //this is true because this cannot be the lowest block - nextblockrecord->freespace=BLOCKSIZE(1); - } + /* This is our own block...means we should mark other blocks above us as free*/ + + if (cnum==blockrecord->corenum) { + unsigned INTPTR nextlocalblocknum=localblocknum+1; + for(;nextlocalblocknumstatus=BS_FREE; + nextblockrecord->usedspace=0; + //this is true because this cannot be the lowest block + nextblockrecord->freespace=BLOCKSIZE(1); } } -- 2.34.1