thisvar->mask = ((size>>1)-1)<<1;
thisvar->bucket=(int *) RUNCALLOC(sizeof(unsigned int)*size);
//Set data counts
- thisvar->num4conflicts = conflicts;
return thisvar;
}
#ifdef MULTICORE
-struct MGCHash * allocateMGCHash_I(int size,int conflicts) {
+struct MGCHash * allocateMGCHash_I(int size) {
struct MGCHash *thisvar;
thisvar=(struct MGCHash *)RUNMALLOC_I(sizeof(struct MGCHash));
thisvar->mask = ((size>>1)-1)<<1;
+ thisvar->size = size;
thisvar->bucket=(int *) RUNCALLOC_I(sizeof(int)*size);
- //Set data counts
- thisvar->num4conflicts = conflicts;
return thisvar;
}
for(; page_index < page_index_end; page_index++) {
bamboo_cache_policy_t policy = {0};
unsigned int block = 0;
- BLOCKINDEX(page_sva, &block);
+ BLOCKINDEX(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);
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(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++) {
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(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
extern gc_cache_revise_info_t gc_cache_revise_information;
INLINE static void samplingDataReviseInit(struct moveHelper * orig,struct moveHelper * to) {
- gc_cache_revise_information.to_page_start_va=(unsigned int)to->ptr;
- unsigned int toindex=(unsigned int)(to->base-gcbaseva)/(BAMBOO_PAGE_SIZE);
- gc_cache_revise_information.to_page_end_va=gcbaseva+(BAMBOO_PAGE_SIZE)*(toindex+1);
+ gc_cache_revise_information.to_page_start_va=to->ptr;
+ unsigned int toindex=(unsigned INTPTR)(to->base-gcbaseva)/BAMBOO_PAGE_SIZE;
+ gc_cache_revise_information.to_page_end_va=gcbaseva+BAMBOO_PAGE_SIZE*(toindex+1);
gc_cache_revise_information.to_page_index=toindex;
- gc_cache_revise_information.orig_page_start_va=(unsigned int)orig->ptr;
- gc_cache_revise_information.orig_page_end_va=gcbaseva+(BAMBOO_PAGE_SIZE)*(((unsigned int)(orig->ptr)-gcbaseva)/(BAMBOO_PAGE_SIZE)+1);
- gc_cache_revise_information.orig_page_index=((unsigned int)(orig->blockbase)-gcbaseva)/(BAMBOO_PAGE_SIZE);
+ gc_cache_revise_information.orig_page_start_va=orig->ptr;
+ gc_cache_revise_information.orig_page_end_va=gcbaseva+BAMBOO_PAGE_SIZE*(((unsigned INTPTR)(orig->ptr-gcbaseva))/BAMBOO_PAGE_SIZE+1);
+ gc_cache_revise_information.orig_page_index=((unsigned INTPTR)(orig->blockbase-gcbaseva))/BAMBOO_PAGE_SIZE;
}
INLINE static void samplingDataConvert(unsigned int current_ptr) {
// compute the impact of this page for the new page
samplingDataConvert(current_ptr);
// prepare for an new orig page
- unsigned int tmp_index=(unsigned int)((unsigned int)orig->ptr-gcbaseva)/(BAMBOO_PAGE_SIZE);
+ unsigned INTPTR tmp_index=((unsigned INTPTR)(orig->ptr-gcbaseva))/BAMBOO_PAGE_SIZE;
gc_cache_revise_information.orig_page_start_va=orig->ptr;
- gc_cache_revise_information.orig_page_end_va=gcbaseva+(BAMBOO_PAGE_SIZE)*(unsigned int)(tmp_index+1);
+ gc_cache_revise_information.orig_page_end_va=gcbaseva+BAMBOO_PAGE_SIZE*(unsigned int)(tmp_index+1);
gc_cache_revise_information.orig_page_index=tmp_index;
gc_cache_revise_information.to_page_start_va=to->ptr;
if(closeToPage) {
- gc_cache_revise_information.to_page_end_va=gcbaseva+(BAMBOO_PAGE_SIZE)*(((unsigned int)(to->ptr)-gcbaseva)/(BAMBOO_PAGE_SIZE)+1);
- gc_cache_revise_information.to_page_index=((unsigned int)(to->ptr)-gcbaseva)/(BAMBOO_PAGE_SIZE);
+ gc_cache_revise_information.to_page_end_va=gcbaseva+BAMBOO_PAGE_SIZE*(((unsigned INTPTR)(to->ptr-gcbaseva))/BAMBOO_PAGE_SIZE+1);
+ gc_cache_revise_information.to_page_index=((unsigned INTPTR)(to->ptr-gcbaseva))/BAMBOO_PAGE_SIZE;
}
}
}
}
// compute load balance for all cores
-INLINE int loadbalance(unsigned int * heaptop) {
+INLINE int loadbalance(void ** heaptop) {
// compute load balance
// get the total loads
unsigned int tloads = gcloads[STARTUPCORE];
*heaptop = gcbaseva + tloads;
unsigned int b = 0;
- BLOCKINDEX(*heaptop, &b);
+ BLOCKINDEX(*heaptop, b);
// num of blocks per core
unsigned int numbpc = (unsigned int)b/(unsigned int)(NUMCORES4GC);
gctopblock = b;
- RESIDECORE(heaptop, &gctopcore);
+ RESIDECORE(heaptop, gctopcore);
return numbpc;
}
void updateSmemTbl(unsigned int coren, unsigned int localtop) {
unsigned int ltopcore = 0;
unsigned int bound = BAMBOO_SMEM_SIZE_L;
- BLOCKINDEX(localtop, <opcore);
+ BLOCKINDEX(localtop, ltopcore);
if((unsigned int)localtop>=(unsigned int)(gcbaseva+BAMBOO_LARGE_SMEM_BOUND)){
bound = BAMBOO_SMEM_SIZE;
}
#endif
unsigned int size = 0;
unsigned int bound = 0;
- unsigned int tmpheaptop = checkCurrHeapTop();
+ void * tmpheaptop = checkCurrHeapTop();
// move large objs from gcheaptop to tmpheaptop
// write the header first
gcheaptop = tmpheaptop;
} else {
// check how many blocks it acrosses
- unsigned int remain = tmpheaptop-gcbaseva;
+ unsigned INTPTR remain = (unsigned INTPTR) (tmpheaptop-gcbaseva);
//number of the sblock
unsigned int sb = remain/BAMBOO_SMEM_SIZE+(unsigned int)gcreservedsb;
unsigned int b = 0; // number of the block
- BLOCKINDEX(tmpheaptop, &b);
+ BLOCKINDEX(tmpheaptop, b);
// check the remaining space in this block
bound = (BAMBOO_SMEM_SIZE);
if(remain < (BAMBOO_LARGE_SMEM_BOUND)) {
}
remain -= BAMBOO_CACHE_LINE_SIZE;
tmpheaptop += BAMBOO_CACHE_LINE_SIZE;
- BLOCKINDEX(tmpheaptop, &b);
+ BLOCKINDEX(tmpheaptop, b);
sb = (unsigned int)(tmpheaptop-gcbaseva)/(BAMBOO_SMEM_SIZE)+gcreservedsb;
}
// move the obj
}
sb += tmpsbs;
bound = BLOCKSIZE(b<NUMCORES4GC);
- BLOCKINDEX(tmpheaptop-1, &tmpsbs);
+ BLOCKINDEX(tmpheaptop-1, tmpsbs);
for(; b < tmpsbs; b++) {
bamboo_smemtbl[b] = bound;
if(b==NUMCORES4GC-1) {
void master_compact() {
// predict number of blocks to fill for each core
- unsigned int tmpheaptop = 0;
+ void * tmpheaptop = 0;
int numpbc = loadbalance(&tmpheaptop);
//tprintf("numpbc: %d \n", numpbc);
- numpbc = (BAMBOO_SHARED_MEM_SIZE)/(BAMBOO_SMEM_SIZE);
+ numpbc = BAMBOO_SHARED_MEM_SIZE/BAMBOO_SMEM_SIZE;
GC_PRINTF("mark phase finished \n");
- tmpheaptop = gcbaseva + (BAMBOO_SHARED_MEM_SIZE);
+ tmpheaptop = gcbaseva + BAMBOO_SHARED_MEM_SIZE;
for(int i = 0; i < NUMCORES4GC; i++) {
unsigned int tmpcoreptr = 0;
BASEPTR(i, numpbc, &tmpcoreptr);
#define ALIGNMENTBYTES 32
#define ALIGNMENTSHIFT 5
+
+/* Number of bits used for each alignment unit */
+#define BITSPERALIGNMENT 2
#define ALIGNOBJSIZE(x) (x>>ALIGNMENTSHIFT)
//There are two bits per object
#define MARKEDLATER 2
//sets y to the marked status of x
-#define GETMARKED(y,x) { unsigned int offset=ALIGNOBJSIZE(x-gcbaseva); \
+#define GETMARKED(y,x) { unsigned INTPTR offset=ALIGNOBJSIZE((unsigned INTPTR)(x-gcbaseva)); \
y=(gcmarktbl[offset>>4]>>((offset&15)<<1))&3; }
//sets the marked status of x to y (assumes zero'd)
-#define SETMARKED(y,x) { unsigned int offset=ALIGNOBJSIZE(x-gcbaseva); \
+#define SETMARKED(y,x) { unsigned INTPTR offset=ALIGNOBJSIZE((unsigned INTPTR)(x-gcbaseva)); \
gcmarktbl[offset>>4]|=y<<((offset&15)<<1); }
//sets the marked status of x to y (assumes zero'd)
-#define RESETMARKED(x) { unsigned int offset=ALIGNOBJSIZE(x-gcbaseva); \
+#define RESETMARKED(x) { unsigned INTPTR offset=ALIGNOBJSIZE((unsigned INTPTR)(x-gcbaseva)); \
gcmarktbl[offset>>4]&=~(3<<((offset&15)<<1)); }
#define ALIGNSIZE(s, as) (*((unsigned int*)as))=((((unsigned int)(s-1))&(~(BAMBOO_CACHE_LINE_MASK)))+(BAMBOO_CACHE_LINE_SIZE))
// the global index
#define BLOCKINDEX(p, b) \
{ \
- unsigned int t = (p) - gcbaseva; \
- if(t < (BAMBOO_LARGE_SMEM_BOUND)) { \
- (*((unsigned int*)b)) = t / (BAMBOO_SMEM_SIZE_L); \
+ unsigned INTPTR t = (unsigned INTPTR)(p - gcbaseva); \
+ if(t < BAMBOO_LARGE_SMEM_BOUND) { \
+ b = t / BAMBOO_SMEM_SIZE_L; \
} else { \
- (*((unsigned int*)b)) = NUMCORES4GC+((t-(BAMBOO_LARGE_SMEM_BOUND))/(BAMBOO_SMEM_SIZE)); \
+ b = NUMCORES4GC+((t-BAMBOO_LARGE_SMEM_BOUND)/BAMBOO_SMEM_SIZE); \
} \
}
if(1 == (NUMCORES4GC)) { \
(*((unsigned int*)c)) = 0; \
} else { \
- unsigned int b; \
- BLOCKINDEX((p), &b); \
- (*((unsigned int*)c)) = gc_block2core[(b%(NUMCORES4GC*2))]; \
+ unsigned INTPTR b; \
+ BLOCKINDEX(p, b); \
+ c = gc_block2core[(b%(NUMCORES4GC*2))]; \
} \
}
INLINE static unsigned int hostcore(void * ptr) {
// check the host core of ptr
unsigned int host = 0;
- RESIDECORE(ptr, &host);
+ RESIDECORE(ptr, host);
return host;
}
// should be invoked with interrupt closed
INLINE int assignSpareMem_I(unsigned int sourcecore,unsigned int * requiredmem,unsigned int * tomove,unsigned int * startaddr) {
unsigned int b = 0;
- BLOCKINDEX(gcloads[sourcecore], &b);
+ BLOCKINDEX(gcloads[sourcecore], b);
unsigned int boundptr = BOUNDPTR(b);
unsigned int remain = boundptr - gcloads[sourcecore];
unsigned int memneed = requiredmem + BAMBOO_CACHE_LINE_SIZE;
gctopblock++;
*numblocks = gcstopblock[gctopcore];
*p = gcloads[gctopcore];
- BLOCKINDEX(*p, &b);
+ BLOCKINDEX(*p, b);
*remain=GC_BLOCK_REMAIN_SIZE(b, (*p));
}
gcmovepending--;
unsigned int numblocks = gcfilledblocks[gctopcore];
p = gcloads[gctopcore];
unsigned int b;
- BLOCKINDEX(p, &b);
+ BLOCKINDEX(p, b);
unsigned int remain=GC_BLOCK_REMAIN_SIZE(b, p);
// check if the top core finishes
BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
orig->sblockindex=(unsigned int)(orig->blockbase-gcbaseva)/BAMBOO_SMEM_SIZE;
sbchanged = true;
unsigned int blocknum = 0;
- BLOCKINDEX(orig->base, &blocknum);
+ BLOCKINDEX(orig->base, blocknum);
if(bamboo_smemtbl[blocknum] == 0) {
// goto next block
goto innernextSBlock;
orig->numblocks = 0;
orig->base = tobase;
unsigned int blocknum = 0;
- BLOCKINDEX(orig->base, &blocknum);
+ BLOCKINDEX(orig->base, blocknum);
unsigned int origbase = orig->base;
// check the bamboo_smemtbl to decide the real bound
orig->bound = origbase + (unsigned int)bamboo_smemtbl[blocknum];
}
ALIGNSIZE(size, &isize); // no matter is the obj marked or not
// should be able to across
- unsigned int origptr = (unsigned int)(orig->ptr);
+ void * origptr = orig->ptr;
int markedstatus;
GETMARKED(markedstatus, origptr);
struct moveHelper {
unsigned int numblocks; // block num for heap
- unsigned int base; // base virtual address of current heap block
- unsigned int ptr; // virtual address of current heap top
+ void * base; // base virtual address of current heap block
+ void * ptr; // virtual address of current heap top
unsigned int offset; // offset in current heap block
- unsigned int blockbase; // virtual address of current small block to check
+ void * blockbase; // virtual address of current small block to check
unsigned int blockbound; // bound virtual address of current small blcok
unsigned int sblockindex; // index of the small blocks
unsigned int top; // real size of current heap block to check
flushRuntimeObj(stackptr);
while(gc_moreItems()) {
- unsigned int ptr = gc_dequeue();
+ void * ptr = (void *) gc_dequeue();
// should be a local shared obj and should have mapping info
FLUSHOBJNONNULL(ptr, 0);
BAMBOO_ASSERT(ptr != NULL);
// lobjs are flushed in sequence.
// flush lobjs
while(gc_lobjmoreItems_I()) {
- unsigned int ptr = gc_lobjdequeue_I(NULL, NULL);
+ void * ptr = (void *) gc_lobjdequeue_I(NULL, NULL);
FLUSHOBJ(ptr, 0);
BAMBOO_ASSERT(ptr!=NULL);
+ int markedstatus;
GETMARKED(markedstatus, ptr);
if(markedstatus==MARKEDFIRST) {
- flushPtrsInObj((void *)ptr);
+ flushPtrsInObj(ptr);
// restore the mark field, indicating that this obj has been flushed
RESETMARKED(ptr);
}
INLINE bool isLarge(void * ptr, int * ttype, unsigned int * tsize) {
// check if a pointer refers to a large object
gettype_size(ptr, ttype, tsize);
- unsigned int blocksize = (((unsigned int)ptr-gcbaseva) < (BAMBOO_LARGE_SMEM_BOUND))? BAMBOO_SMEM_SIZE_L:BAMBOO_SMEM_SIZE;
+ unsigned INTPTR blocksize = (((unsigned INTPTR)(ptr-gcbaseva)) < BAMBOO_LARGE_SMEM_BOUND)? BAMBOO_SMEM_SIZE_L:BAMBOO_SMEM_SIZE;
// ptr is a start of a block OR it crosses the boundary of current block
return *tsize > blocksize;
}
INLINE void processmsg_gcmarkedobj_I() {
- int data1 = msgdata[msgdataindex];
+ void * data1 = (void *) msgdata[msgdataindex];
MSG_INDEXINC_I();
BAMBOO_ASSERT(ISSHAREDOBJ(data1));