From e88c7be24fa60bcb3ee500d5882e70af0ef2805f Mon Sep 17 00:00:00 2001 From: bdemsky Date: Wed, 15 Jun 2011 01:52:54 +0000 Subject: [PATCH] more work towards type checking --- Robust/src/Runtime/bamboo/multicorecache.c | 6 +++--- Robust/src/Runtime/bamboo/multicoregarbage.c | 18 +++++++++--------- Robust/src/Runtime/bamboo/multicoregarbage.h | 13 ++++++------- Robust/src/Runtime/bamboo/multicoregccompact.c | 17 ++++++++--------- Robust/src/Runtime/bamboo/multicoregcflush.c | 2 +- 5 files changed, 27 insertions(+), 29 deletions(-) diff --git a/Robust/src/Runtime/bamboo/multicorecache.c b/Robust/src/Runtime/bamboo/multicorecache.c index b00b9be6..a897765c 100644 --- a/Robust/src/Runtime/bamboo/multicorecache.c +++ b/Robust/src/Runtime/bamboo/multicorecache.c @@ -92,7 +92,7 @@ void cacheAdapt_policy_local(int coren){ for(; page_index < page_index_end; page_index++) { bamboo_cache_policy_t policy = {0}; unsigned int block = 0; - BLOCKINDEX(page_sva, block); + BLOCKINDEX((void *) page_sva, block); unsigned int coren = gc_block2core[block%(NUMCORES4GC*2)]; CACHEADAPT_POLICY_SET_HOST_CORE(policy, coren); CACHEADAPT_CHANGE_POLICY_4_PAGE(tmp_p,page_index,policy); @@ -464,7 +464,7 @@ void gc_output_cache_sampling() { for(page_index = 0; page_index < page_num; page_index++) { page_sva = gcbaseva + (BAMBOO_PAGE_SIZE) * page_index; unsigned int block = 0; - BLOCKINDEX(page_sva, block); + BLOCKINDEX((void *) page_sva, block); unsigned int coren = gc_block2core[block%(NUMCORES4GC*2)]; printf("%x, %d, %d, ",(int)page_sva,page_index,coren); for(int i = 0; i < NUMCORESACTIVE; i++) { @@ -494,7 +494,7 @@ void gc_output_cache_sampling_r() { for(page_index = 0; page_index < page_num; page_index++) { page_sva = gcbaseva + (BAMBOO_PAGE_SIZE) * page_index; unsigned int block = 0; - BLOCKINDEX(page_sva, block); + BLOCKINDEX((void *)page_sva, block); unsigned int coren = gc_block2core[block%(NUMCORES4GC*2)]; printf(" %x, %d, %d, ",(int)page_sva,page_index,coren); int accesscore = 0; // TODO diff --git a/Robust/src/Runtime/bamboo/multicoregarbage.c b/Robust/src/Runtime/bamboo/multicoregarbage.c index 6f539f8e..d92dc6fd 100644 --- a/Robust/src/Runtime/bamboo/multicoregarbage.c +++ b/Robust/src/Runtime/bamboo/multicoregarbage.c @@ -46,7 +46,7 @@ void dumpSMem() { *((int *)(i + 4*12)), *((int *)(i + 4*13)), *((int *)(i + 4*14)), *((int *)(i + 4*15))); } - sblock = gcreservedsb; + sblock = 0; bool advanceblock = false; // remaining memory for(i=gcbaseva; (unsigned int)i<(unsigned int)(gcbaseva+BAMBOO_SHARED_MEM_SIZE); i+=4*16) { @@ -301,7 +301,7 @@ INLINE int loadbalance(void ** heaptop) { // num of blocks per core unsigned int numbpc = (unsigned int)b/(unsigned int)(NUMCORES4GC); gctopblock = b; - RESIDECORE(heaptop, gctopcore); + RESIDECORE(*heaptop, gctopcore); return numbpc; } @@ -395,14 +395,14 @@ INLINE bool cacheLObjs() { } // update the bmmboo_smemtbl to record current shared mem usage -void updateSmemTbl(unsigned int coren, unsigned int localtop) { +void updateSmemTbl(unsigned int coren, void * localtop) { unsigned int ltopcore = 0; unsigned int bound = BAMBOO_SMEM_SIZE_L; BLOCKINDEX(localtop, ltopcore); if((unsigned int)localtop>=(unsigned int)(gcbaseva+BAMBOO_LARGE_SMEM_BOUND)){ bound = BAMBOO_SMEM_SIZE; } - unsigned int load = (unsigned int)(localtop-gcbaseva)%(unsigned int)bound; + unsigned int load = (unsigned INTPTR)(localtop-gcbaseva)%(unsigned int)bound; unsigned int toset = 0; for(int j=0; 1; j++) { for(int i=0; i<2; i++) { @@ -460,7 +460,7 @@ INLINE unsigned int checkCurrHeapTop() { return gcbaseva; } -INLINE void movelobj(unsigned int tmpheaptop,unsigned int ptr,int size,int isize) { +INLINE void movelobj(void * tmpheaptop, void * ptr,int size,int isize) { // move the large obj if((unsigned int)gcheaptop < (unsigned int)(tmpheaptop+size)) { memmove(tmpheaptop, gcheaptop, size); @@ -471,7 +471,7 @@ INLINE void movelobj(unsigned int tmpheaptop,unsigned int ptr,int size,int isize BAMBOO_MEMSET_WH(tmpheaptop+size, -2, isize-size); gcheaptop += size; // cache the mapping info - gcmappingtbl[OBJMAPPINGINDEX((unsigned int)ptr)]=(unsigned int)tmpheaptop; + gcmappingtbl[OBJMAPPINGINDEX(ptr)]=tmpheaptop; tmpheaptop += isize; } @@ -491,14 +491,14 @@ INLINE void moveLObjs() { gcmem_mixed_usedmem += tomove; #endif // flush the sbstartbl - BAMBOO_MEMSET_WH(&(gcsbstarttbl[gcreservedsb]),'\0',(BAMBOO_SHARED_MEM_SIZE/BAMBOO_SMEM_SIZE-(unsigned int)gcreservedsb)*sizeof(unsigned int)); + BAMBOO_MEMSET_WH(gcsbstarttbl,'\0',(BAMBOO_SHARED_MEM_SIZE/BAMBOO_SMEM_SIZE)*sizeof(unsigned int)); if(tomove == 0) { gcheaptop = tmpheaptop; } else { // check how many blocks it acrosses unsigned INTPTR remain = (unsigned INTPTR) (tmpheaptop-gcbaseva); //number of the sblock - unsigned int sb = remain/BAMBOO_SMEM_SIZE+(unsigned int)gcreservedsb; + unsigned int sb = remain/BAMBOO_SMEM_SIZE; unsigned int b = 0; // number of the block BLOCKINDEX(tmpheaptop, b); // check the remaining space in this block @@ -540,7 +540,7 @@ INLINE void moveLObjs() { remain -= BAMBOO_CACHE_LINE_SIZE; tmpheaptop += BAMBOO_CACHE_LINE_SIZE; BLOCKINDEX(tmpheaptop, b); - sb = (unsigned int)(tmpheaptop-gcbaseva)/(BAMBOO_SMEM_SIZE)+gcreservedsb; + sb = (unsigned int)(tmpheaptop-gcbaseva)/(BAMBOO_SMEM_SIZE); } // move the obj movelobj(tmpheaptop,ptr,size,isize); diff --git a/Robust/src/Runtime/bamboo/multicoregarbage.h b/Robust/src/Runtime/bamboo/multicoregarbage.h index 21725f09..336d114e 100644 --- a/Robust/src/Runtime/bamboo/multicoregarbage.h +++ b/Robust/src/Runtime/bamboo/multicoregarbage.h @@ -62,7 +62,7 @@ unsigned int gcself_numreceiveobjs; // for load balancing unsigned int gcheaptop; -unsigned int gcloads[NUMCORES4GC]; +unsigned INTPTR gcloads[NUMCORES4GC]; unsigned int gctopcore; // the core host the top of the heap unsigned int gctopblock; // the number of current top block @@ -86,7 +86,7 @@ volatile unsigned int gcmovepending; // The bottom of the shared memory = sbstart tbl + smemtbl + bamboo_rmsp // These three types of table are always reside at the bottom of the shared // memory and will never be moved or garbage collected -unsigned int * gcmappingtbl; +void ** gcmappingtbl; unsigned int bamboo_rmsp_size; unsigned int * gcmarktbl; @@ -120,7 +120,7 @@ unsigned int size_cachepolicytbl; #define WAITFORGCPHASE(phase) while(gc_status_info.gcphase != phase) ; -#define OBJMAPPINGINDEX(p) (((unsigned int)p-gcbaseva)/bamboo_baseobjsize) + #define ISSHAREDOBJ(p) \ ((((unsigned int)p)>=gcbaseva)&&(((unsigned int)p)<(gcbaseva+(BAMBOO_SHARED_MEM_SIZE)))) @@ -132,6 +132,7 @@ unsigned int size_cachepolicytbl; /* Number of bits used for each alignment unit */ #define BITSPERALIGNMENT 2 #define ALIGNOBJSIZE(x) (x>>ALIGNMENTSHIFT) +#define OBJMAPPINGINDEX(p) ALIGNOBJSIZE((unsigned INTPTR)(p-gcbaseva)) //There are two bits per object //00 means not marked @@ -169,11 +170,9 @@ unsigned int size_cachepolicytbl; } \ } -// mapping of pointer to core # -#define RESIDECORE(p, c) \ - { \ +#define RESIDECORE(p, c) { \ if(1 == (NUMCORES4GC)) { \ - (*((unsigned int*)c)) = 0; \ + c = 0; \ } else { \ unsigned INTPTR b; \ BLOCKINDEX(p, b); \ diff --git a/Robust/src/Runtime/bamboo/multicoregccompact.c b/Robust/src/Runtime/bamboo/multicoregccompact.c index 65d04309..81303f5b 100644 --- a/Robust/src/Runtime/bamboo/multicoregccompact.c +++ b/Robust/src/Runtime/bamboo/multicoregccompact.c @@ -25,7 +25,7 @@ INLINE void gc_resetCoreStatus() { } // should be invoked with interrupt closed -INLINE int assignSpareMem_I(unsigned int sourcecore,unsigned int * requiredmem,unsigned int * tomove,unsigned int * startaddr) { +INLINE int assignSpareMem_I(unsigned int sourcecore,unsigned int * requiredmem, void ** tomove, void ** startaddr) { unsigned int b = 0; BLOCKINDEX(gcloads[sourcecore], b); unsigned int boundptr = BOUNDPTR(b); @@ -46,7 +46,7 @@ INLINE int assignSpareMem_I(unsigned int sourcecore,unsigned int * requiredmem,u } } -INLINE int assignSpareMem(unsigned int sourcecore,unsigned int * requiredmem,unsigned int * tomove,unsigned int * startaddr) { +INLINE int assignSpareMem(unsigned int sourcecore,unsigned int * requiredmem,unsigned int * tomove, void ** startaddr) { BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(); int retval=assignSpareMem_I(sourcecore, requiredmem, tomove, startaddr); BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); @@ -95,9 +95,8 @@ INLINE void compact2Heaptophelper_I(unsigned int coren,unsigned int* p,unsigned INLINE void compact2Heaptop() { // no cores with spare mem and some cores are blocked with pending move // find the current heap top and make them move to the heap top - unsigned int p; + unsigned int p = gcloads[gctopcore]; unsigned int numblocks = gcfilledblocks[gctopcore]; - p = gcloads[gctopcore]; unsigned int b; BLOCKINDEX(p, b); unsigned int remain=GC_BLOCK_REMAIN_SIZE(b, p); @@ -219,7 +218,7 @@ outernextSBlock: } // check the bamboo_smemtbl to decide the real bound orig->bound = orig->base + bamboo_smemtbl[blocknum]; - } else if(0 == (orig->blockbase%BAMBOO_SMEM_SIZE)) { + } else if(0 == ((unsigned INTPTR)orig->blockbase)%BAMBOO_SMEM_SIZE) { orig->sblockindex += 1; sbchanged = true; } @@ -257,7 +256,7 @@ INLINE bool initOrig_Dst(struct moveHelper * orig,struct moveHelper * to) { to->bound = BAMBOO_SMEM_SIZE_L; BASEPTR(BAMBOO_NUM_OF_CORE, to->numblocks, &(to->base)); - unsigned int tobase = to->base; + void * tobase = to->base; to->ptr = tobase + to->offset; // init the orig ptr @@ -265,11 +264,11 @@ INLINE bool initOrig_Dst(struct moveHelper * orig,struct moveHelper * to) { orig->base = tobase; unsigned int blocknum = 0; BLOCKINDEX(orig->base, blocknum); - unsigned int origbase = orig->base; + void * origbase = orig->base; // check the bamboo_smemtbl to decide the real bound - orig->bound = origbase + (unsigned int)bamboo_smemtbl[blocknum]; + orig->bound = origbase + (unsigned INTPTR)bamboo_smemtbl[blocknum]; orig->blockbase = origbase; - orig->sblockindex = (unsigned int)(origbase - gcbaseva) / BAMBOO_SMEM_SIZE; + orig->sblockindex = (unsigned INTPTR)(origbase - gcbaseva) / BAMBOO_SMEM_SIZE; int sbstart = gcsbstarttbl[orig->sblockindex]; if(sbstart == -1) { diff --git a/Robust/src/Runtime/bamboo/multicoregcflush.c b/Robust/src/Runtime/bamboo/multicoregcflush.c index 89542016..e18cc596 100644 --- a/Robust/src/Runtime/bamboo/multicoregcflush.c +++ b/Robust/src/Runtime/bamboo/multicoregcflush.c @@ -28,7 +28,7 @@ extern struct lockvector bamboo_threadlocks; #define FLUSHOBJNONNULL(obj, tt) {void *flushtmpptr=obj; obj=flushObj(flushtmpptr);} INLINE void * flushObj(void * objptr) { - return gcmappingtbl[OBJMAPPINGINDEX((unsigned int)objptr)]; + return gcmappingtbl[OBJMAPPINGINDEX(objptr)]; } INLINE void updategarbagelist(struct garbagelist *listptr) { -- 2.34.1