#define NUMPTRS 120
struct pointerblock {
- unsigned int ptrs[NUMPTRS];
+ void * ptrs[NUMPTRS];
struct pointerblock *next;
};
#define NUMLOBJPTRS 20
struct lobjpointerblock {
- unsigned int lobjs[NUMLOBJPTRS];
+ void * lobjs[NUMLOBJPTRS];
int lengths[NUMLOBJPTRS];
int hosts[NUMLOBJPTRS];
struct lobjpointerblock *next;
////////////////////////////////////////////////////////////////////
// functions that should be invoked with interrupts off
////////////////////////////////////////////////////////////////////
-static void gc_enqueue_I(unsigned int ptr) {
+static void gc_enqueue_I(void * ptr) {
if (gcheadindex==NUMPTRS) {
struct pointerblock * tmp;
if (gcspare!=NULL) {
}
// dequeue and destroy the queue
-static unsigned int gc_dequeue_I() {
+static void * gc_dequeue_I() {
if (gctailindex==NUMPTRS) {
struct pointerblock *tmp=gctail;
gctail=gctail->next;
}
// dequeue and do not destroy the queue
-static unsigned int gc_dequeue2_I() {
+static void * gc_dequeue2_I() {
if (gctailindex2==NUMPTRS) {
- struct pointerblock *tmp=gctail2;
gctail2=gctail2->next;
gctailindex2=0;
}
// should be invoked with interruption closed
// enqueue a large obj: start addr & length
-static void gc_lobjenqueue_I(unsigned int ptr,
+static void gc_lobjenqueue_I(void * ptr,
unsigned int length,
unsigned int host) {
if (gclobjheadindex==NUMLOBJPTRS) {
}
// dequeue and destroy the queue
-static unsigned int gc_lobjdequeue_I(unsigned int * length,
+static void * gc_lobjdequeue_I(unsigned int * length,
unsigned int * host) {
if (gclobjtailindex==NUMLOBJPTRS) {
struct lobjpointerblock *tmp=gclobjtail;
gclobjtailindex2 = gclobjtailindex;
}
-static unsigned int gc_lobjdequeue4_I(unsigned int * length,
+static void * gc_lobjdequeue4_I(unsigned int * length,
unsigned int * host) {
if (gclobjtailindex2==NUMLOBJPTRS) {
gclobjtail2=gclobjtail2->next;
////////////////////////////////////////////////////////////////////
// functions that can be invoked in normal places
////////////////////////////////////////////////////////////////////
-static void gc_enqueue(unsigned int ptr) {
+static void gc_enqueue(void * ptr) {
BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
if (gcheadindex==NUMPTRS) {
struct pointerblock * tmp;
BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
}
-static unsigned int gc_dequeue() {
+static void * gc_dequeue() {
BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
if (gctailindex==NUMPTRS) {
struct pointerblock *tmp=gctail;
gcspare->next = NULL;
}
}
- unsigned int r = gctail->ptrs[gctailindex++];
+ void * r = gctail->ptrs[gctailindex++];
BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
return r;
}
}
// dequeue and do not destroy the queue
-static unsigned int gc_dequeue2() {
+static void * gc_dequeue2() {
BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
if (gctailindex2==NUMPTRS) {
- struct pointerblock *tmp=gctail2;
gctail2=gctail2->next;
gctailindex2=0;
}
- unsigned int r = gctail2->ptrs[gctailindex2++];
+ void * r = gctail2->ptrs[gctailindex2++];
BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
return r;
}
return r;
}
-static void gc_lobjenqueue(unsigned int ptr,
+static void gc_lobjenqueue(void * ptr,
unsigned int length,
unsigned int host) {
BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
#define BAMBOO_CACHE_MODE_COORDS 4
typedef struct gc_cache_revise_info {
- unsigned int orig_page_start_va;
- unsigned int orig_page_end_va;
+ void * orig_page_start_va;
+ void * orig_page_end_va;
unsigned int orig_page_index;
- unsigned int to_page_start_va;
- unsigned int to_page_end_va;
+ void * to_page_start_va;
+ void * to_page_end_va;
unsigned int to_page_index;
unsigned int revised_sampling[NUMCORESACTIVE];
} gc_cache_revise_info_t;
gc_cache_revise_information.orig_page_index=((unsigned INTPTR)(orig->blockbase-gcbaseva))/BAMBOO_PAGE_SIZE;
}
-INLINE static void samplingDataConvert(unsigned int current_ptr) {
- unsigned int tmp_factor=current_ptr-gc_cache_revise_information.to_page_start_va;
- unsigned int topage=gc_cache_revise_information.to_page_index;
- unsigned int oldpage=gc_cache_revise_information.orig_page_index;
+INLINE static void samplingDataConvert(void * current_ptr) {
+ unsigned INTPTR tmp_factor=(unsigned INTPTR)(current_ptr-gc_cache_revise_information.to_page_start_va);
+ unsigned INTPTR topage=gc_cache_revise_information.to_page_index;
+ unsigned INTPTR oldpage=gc_cache_revise_information.orig_page_index;
int * newtable=&gccachesamplingtbl_r[topage];
int * oldtable=&gccachesamplingtbl[oldpage];
}
INLINE static void completePageConvert(struct moveHelper * orig,struct moveHelper * to,unsigned int current_ptr,bool closeToPage) {
- unsigned int ptr=0;
- unsigned int tocompare=0;
+ void *ptr;
+ void *tocompare;
if(closeToPage) {
ptr=to->ptr;
tocompare=gc_cache_revise_information.to_page_end_va;
// prepare for an new orig page
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*(tmp_index+1);
gc_cache_revise_information.orig_page_index=tmp_index;
gc_cache_revise_information.to_page_start_va=to->ptr;
if(closeToPage) {
gccorestatus[i] = 1;
gcnumsendobjs[0][i] = gcnumsendobjs[1][i] = 0;
gcnumreceiveobjs[0][i] = gcnumreceiveobjs[1][i] = 0;
- gcloads[i] = 0;
+ gcloads[i] = NULL;
gcrequiredmems[i] = 0;
gcfilledblocks[i] = 0;
gcstopblock[i] = 0;
unsigned int tmpcoreptr = 0;
BASEPTR(i, numpbc, &tmpcoreptr);
// init some data strutures for compact phase
- gcloads[i] = 0;
+ gcloads[i] = NULL;
gcfilledblocks[i] = 0;
gcrequiredmems[i] = 0;
gccorestatus[i] = 1;
return retval;
}
-INLINE void compact2Heaptophelper_I(unsigned int coren,unsigned int* p,unsigned int* numblocks,unsigned int* remain) {
+INLINE void compact2Heaptophelper_I(unsigned int coren, void ** p,unsigned int* numblocks,unsigned int* remain) {
unsigned int b;
unsigned int memneed = gcrequiredmems[coren] + BAMBOO_CACHE_LINE_SIZE;
if(STARTUPCORE == coren) {
BAMBOO_MEMSET_WH((unsigned int)(toptr+size), -2, isize-size);
}
// store mapping info
- gcmappingtbl[OBJMAPPINGINDEX((unsigned int)origptr)]=(unsigned int)toptr;
+ gcmappingtbl[OBJMAPPINGINDEX(origptr)]=(unsigned int)toptr;
gccurr_heaptop -= isize;
to->ptr += isize;
to->offset += isize;
};
// compute the remaining size of block #b
-// p--relative position to the bottom of the shared heap
+// p--ptr
+
#define GC_BLOCK_REMAIN_SIZE(b, p) \
- ((b)<NUMCORES4GC)?((BAMBOO_SMEM_SIZE_L)-((p)%(BAMBOO_SMEM_SIZE_L))):((BAMBOO_SMEM_SIZE)-((p)%(BAMBOO_SMEM_SIZE)))
+ b<NUMCORES4GC?BAMBOO_SMEM_SIZE_L-(((unsigned INTPTR)(p-gcbaseva))%BAMBOO_SMEM_SIZE_L):BAMBOO_SMEM_SIZE-(((unsigned INTPTR)(p-gcbaseva))%BAMBOO_SMEM_SIZE)
bool gcfindSpareMem_I(unsigned int * startaddr,unsigned int * tomove,unsigned int * dstcore,unsigned int requiredmem,unsigned int requiredcore);
void compact();
if(size >= isize) {
// have enough space in the block, malloc
return mallocmem(*tofindb, *totest, size, allocsize);
- break;
} else {
// no enough space yet, try to append next continuous block
*totest = *totest + 1;
int* totest,
int isize,
int * allocsize) {
- int i=0;
- int j=0;
int size = 0;
int bound = BAMBOO_SMEM_SIZE_L;
while(*totest<(gcnumblock-bamboo_reserved_smem)) {
if(size >= isize) {
// have enough space in the block, malloc
return mallocmem(*tofindb, *totest, size, allocsize);
- break;
} else {
// no enough space yet, try to append next continuous block
*totest = *totest + 1;
int k;
int gccorenum=(coren<NUMCORES4GC)?(coren):(coren%NUMCORES4GC);
int totest,tofindb;
- int bound=BAMBOO_SMEM_SIZE_L;
- int foundsmem=0;
int size=0;
for(k=0;k<NUM_CORES2TEST;k++) {
if(core2test[gccorenum][k]==-1) {
void * mem = NULL;
int tofindb = bamboo_free_block;
int totest = tofindb;
- int bound = BAMBOO_SMEM_SIZE_L;
- int foundsmem = 0;
- int size = 0;
if(tofindb > gcnumblock-1-bamboo_reserved_smem) {
// Out of shared memory
*allocsize = 0;
#include "multicoregarbage.h"
#include "multicoretaskprofile.h"
#include "gcqueue.h"
+#include "runtime_arch.h"
int msgsizearray[] = {
0, //MSGSTART,
MSG_INDEXINC_I();
int filledblocks = msgdata[msgdataindex];
MSG_INDEXINC_I();
- int heaptop = msgdata[msgdataindex];
+ void * heaptop = (void *) msgdata[msgdataindex];
MSG_INDEXINC_I();
int data4 = msgdata[msgdataindex];
MSG_INDEXINC_I();
}
if(data4 > 0) {
// ask for more mem
- int startaddr = 0;
+ void * startaddr = NULL;
int tomove = 0;
int dstcore = 0;
if(gcfindSpareMem_I(&startaddr, &tomove, &dstcore, data4, cnum)) {
// main function for each core
inline void run(int argc, char** argv) {
- int i = 0;
bool sendStall = false;
bool isfirst = true;
bool tocontinue = false;