gcheaptop = 0;
gctopcore = 0;
gctopblock = 0;
+#ifdef MAPPINGTBL_DEBUG
+ // initialize the gcmappingtbl
+ BAMBOO_MEMSET_WH(gcmappingtbl, 0, bamboo_rmsp_size);
+#endif
} // if(STARTUPCORE == BAMBOO_NUM_OF_CORE)
gcself_numsendobjs = 0;
gcself_numreceiveobjs = 0;
gcmarkedptrbound = 0;
- gcobj2map = 0;
- gcmappedobj = 0;
gcnumlobjs = 0;
gcmovestartaddr = 0;
gctomove = false;
}
gclobjhead->next = gclobjhead->prev = NULL;
-#ifdef LOCALHASHTBL_TEST
- freeRuntimeHash(gcpointertbl);
- gcpointertbl = allocateRuntimeHash(20);
-#else
- mgchashreset(gcpointertbl);
-#endif
-
freeMGCHash(gcforwardobjtbl);
gcforwardobjtbl = allocateMGCHash(20, 3);
- // initialize the mapping info related structures
- if((BAMBOO_NUM_OF_CORE < NUMCORES4GC) && (gcsharedptbl != NULL)) {
- // Never free the shared hash table, just reset it
- mgcsharedhashReset(gcsharedptbl);
- }
#ifdef GC_PROFILE
gc_num_livespace = 0;
gc_num_freespace = 0;
GC_BAMBOO_DEBUGPRINT_REG(isize);
GC_BAMBOO_DEBUGPRINT_REG(base);
gcheaptop += size;
- // cache the mapping info anyway
- BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
-#ifdef LOCALHASHTBL_TEST
- RuntimeHashadd_I(gcpointertbl, ptr, tmpheaptop);
-#else
- mgchashInsert_I(gcpointertbl, ptr, tmpheaptop);
-#endif
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+ // cache the mapping info
+ gcmappingtbl[OBJMAPPINGINDEX((int)ptr)] = (INTPTR)tmpheaptop;
GC_BAMBOO_DEBUGPRINT(0xcdca);
GC_BAMBOO_DEBUGPRINT_REG(ptr);
GC_BAMBOO_DEBUGPRINT_REG(tmpheaptop);
- if(host != BAMBOO_NUM_OF_CORE) {
- // send the original host core with the mapping info
- send_msg_3(host, GCLOBJMAPPING, ptr, tmpheaptop, false);
- GC_BAMBOO_DEBUGPRINT(0xcdcb);
- GC_BAMBOO_DEBUGPRINT_REG(ptr);
- GC_BAMBOO_DEBUGPRINT_REG(tmpheaptop);
- } // if(host != BAMBOO_NUM_OF_CORE)
tmpheaptop += isize;
// set the gcsbstarttbl and bamboo_smemtbl
gcheaptop += size;
cpysize += isize;
- // cache the mapping info anyway
- BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
-#ifdef LOCALHASHTBL_TEST
- RuntimeHashadd_I(gcpointertbl, ptr, tmpheaptop);
-#else
- mgchashInsert_I(gcpointertbl, ptr, tmpheaptop);
-#endif
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+ // cache the mapping info
+ gcmappingtbl[OBJMAPPINGINDEX((int)ptr)] = (INTPTR)tmpheaptop;
GC_BAMBOO_DEBUGPRINT(0xcdcc);
GC_BAMBOO_DEBUGPRINT_REG(ptr);
GC_BAMBOO_DEBUGPRINT_REG(tmpheaptop);
GC_BAMBOO_DEBUGPRINT_REG(*((int*)tmpheaptop));
- if(host != BAMBOO_NUM_OF_CORE) {
- // send the original host core with the mapping info
- send_msg_3(host, GCLOBJMAPPING, ptr, tmpheaptop, false);
- GC_BAMBOO_DEBUGPRINT(0xcdcd);
- GC_BAMBOO_DEBUGPRINT_REG(ptr);
- GC_BAMBOO_DEBUGPRINT_REG(tmpheaptop);
- } // if(host != BAMBOO_NUM_OF_CORE)
tmpheaptop += isize;
// update bamboo_smemtbl
// ptr is not an active obj or has been marked
checkfield = false;
} // if(isLarge(ptr, &type, &size)) else ...
- } /* can never reach here
+ } /* can never reach here
else {
// check if this obj has been forwarded
if(!MGCHashcontains(gcforwardobjtbl, (int)ptr)) {
BAMBOO_MEMSET_WH(toptr+size, -2, isize-size);
}
// store mapping info
- BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
-#ifdef LOCALHASHTBL_TEST
- RuntimeHashadd_I(gcpointertbl, origptr, toptr);
-#else
- mgchashInsert_I(gcpointertbl, origptr, toptr);
-#endif
- if(isremote) {
- // add to the sharedptbl
- if(gcsharedptbl != NULL) {
- mgcsharedhashInsert_I(gcsharedptbl, origptr, toptr);
- }
- }
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+ gcmappingtbl[OBJMAPPINGINDEX((int)origptr)] = (INTPTR)toptr;
GC_BAMBOO_DEBUGPRINT(0xcdce);
GC_BAMBOO_DEBUGPRINT_REG(origptr);
GC_BAMBOO_DEBUGPRINT_REG(toptr);
#endif // GC_CACHE_ADAPT
} // if(mark == 1)
GC_BAMBOO_DEBUGPRINT(0xe205);
+
// move to next obj
orig->ptr += size;
GC_BAMBOO_DEBUGPRINT(0xe402);
GC_BAMBOO_DEBUGPRINT_REG(objptr);
// a shared obj ptr, change to new address
- BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
-#ifdef LOCALHASHTBL_TEST
- RuntimeHashget(gcpointertbl, objptr, &dstptr);
-#else
- dstptr = mgchashSearch(gcpointertbl, objptr);
-#endif
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+ dstptr = gcmappingtbl[OBJMAPPINGINDEX((int)objptr)];
GC_BAMBOO_DEBUGPRINT_REG(dstptr);
if(NULL == dstptr) {
GC_BAMBOO_DEBUGPRINT(0xe403);
GC_BAMBOO_DEBUGPRINT_REG(objptr);
GC_BAMBOO_DEBUGPRINT_REG(hostcore(objptr));
- if(hostcore(objptr) == BAMBOO_NUM_OF_CORE) {
- // error! the obj is right on this core, but cannot find it
- GC_BAMBOO_DEBUGPRINT_REG(objptr);
- BAMBOO_EXIT(0xb003);
- } else {
- int hostc = hostcore(objptr);
- // check the corresponsing sharedptbl
- BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
- mgcsharedhashtbl_t * sptbl = gcrpointertbls[hostc];
- if(sptbl != NULL) {
- dstptr = mgcsharedhashSearch(sptbl, (int)objptr);
- if(dstptr != NULL) {
-#ifdef LOCALHASHTBL_TEST
- RuntimeHashadd_I(gcpointertbl, (int)objptr, (int)dstptr);
-#else
- mgchashInsert_I(gcpointertbl, (int)objptr, (int)dstptr);
-#endif
- }
- }
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
-
- if(dstptr == NULL) {
- // still can not get the mapping info,
- // send msg to host core for the mapping info
- gcobj2map = (int)objptr;
- gcismapped = false;
- gcmappedobj = NULL;
- // the first time require the mapping, send msg to the hostcore
- // for the mapping info
- send_msg_3(hostc, GCMAPREQUEST, (int)objptr,
- BAMBOO_NUM_OF_CORE, false);
- while(true) {
- if(gcismapped) {
- break;
- }
- }
- BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
-#ifdef LOCALHASHTBL_TEST
- RuntimeHashget(gcpointertbl, objptr, &dstptr);
-#else
- dstptr = mgchashSearch(gcpointertbl, objptr);
-#endif
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
- } // if(dstptr == NULL)
- } // if(hostcore(objptr) == BAMBOO_NUM_OF_CORE) else ...
- GC_BAMBOO_DEBUGPRINT_REG(dstptr);
+ // error! the obj is right on this core, but cannot find it
+ GC_BAMBOO_DEBUGPRINT_REG(objptr);
+ BAMBOO_EXIT(0xb003);
} // if(NULL == dstptr)
} // if(ISSHAREDOBJ(objptr))
// if not a shared obj, return NULL to indicate no need to flush
#endif
} // void flushRuntimeObj(struct garbagelist * stackptr)
-inline void transmappinginfo() {
- // broadcast the sharedptbl pointer
- for(int i = 0; i < NUMCORESACTIVE; i++) {
- if(i != BAMBOO_NUM_OF_CORE) {
- send_msg_3(i, GCMAPTBL, gcsharedptbl, BAMBOO_NUM_OF_CORE, false);
- }
- }
-
- if(STARTUPCORE != BAMBOO_NUM_OF_CORE) {
- send_msg_2(STARTUPCORE, GCFINISHMAPINFO, BAMBOO_NUM_OF_CORE, false);
- }
-}
-
inline void flush(struct garbagelist * stackptr) {
flushRuntimeObj(stackptr);
if(ISSHAREDOBJ(ptr)) {
((int *)(ptr))[BAMBOOMARKBIT] = INIT;
}
- } // if((!ISSHAREDOBJ(ptr)) || (((int *)(ptr))[BAMBOOMARKBIT] == COMPACTED))
+ } //if((!ISSHAREDOBJ(ptr))||(((int *)(ptr))[BAMBOOMARKBIT] == COMPACTED))
} // while(gc_moreItems())
GC_BAMBOO_DEBUGPRINT(0xe308);
udn_tile_coord_y());
#endif
- while(true) {
- if(MAPPHASE == gcphase) {
- break;
- }
- }
-#ifdef RAWPATH // TODO GC_DEBUG
- printf("(%x,%x) Start map phase\n", udn_tile_coord_x(),
- udn_tile_coord_y());
-#endif
- transmappinginfo();
-#ifdef RAWPATH // TODO GC_DEBUG
- printf("(%x,%x) Finish map phase\n", udn_tile_coord_x(),
- udn_tile_coord_y());
-#endif
-
while(true) {
if(FLUSHPHASE == gcphase) {
break;
RUNFREE(to);
orig = to = NULL;
- gcphase = MAPPHASE;
- gccorestatus[BAMBOO_NUM_OF_CORE] = 1;
- // Note: all cores should flush their runtime data including non-gc
- // cores
- for(i = 1; i < NUMCORES4GC; ++i) {
- // send start flush messages to all cores
- gccorestatus[i] = 1;
- send_msg_1(i, GCSTARTMAPINFO, false);
- }
-#ifdef GC_PROFILE
- gc_profileItem();
-#endif
-#ifdef RAWPATH // TODO GC_DEBUG
- printf("(%x,%x) Start map phase \n", udn_tile_coord_x(),
- udn_tile_coord_y());
-#endif
- // mapinto phase
- transmappinginfo();
-#ifdef RAWPATH // TODO GC_DEBUG
- printf("(%x,%x) Finish map phase \n", udn_tile_coord_x(),
- udn_tile_coord_y());
-#endif
- gccorestatus[BAMBOO_NUM_OF_CORE] = 0;
- while(MAPPHASE == gcphase) {
- // check the status of all cores
- BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
- if(gc_checkCoreStatus_I()) {
- // all cores have finished sending mapping info
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
- break;
- }
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
- } // while(MAPPHASE == gcphase)
-
gcphase = FLUSHPHASE;
gccorestatus[BAMBOO_NUM_OF_CORE] = 1;
// Note: all cores should flush their runtime data including non-gc
// disable the timer interrupt
bamboo_mask_timer_intr();
#endif
-#endif
+#endif
// core coordinator routine
if(0 == BAMBOO_NUM_OF_CORE) {
#ifdef GC_DEBUG
gcself_numsendobjs = 0;
gcself_numreceiveobjs = 0;
gcmarkedptrbound = 0;
-#ifdef LOCALHASHTBL_TEST
+/*#ifdef LOCALHASHTBL_TEST
gcpointertbl = allocateRuntimeHash_I(20);
#else
gcpointertbl = mgchashCreate_I(2000, 0.75);
-#endif
+#endif*/
gcforwardobjtbl = allocateMGCHash_I(20, 3);
- gcobj2map = 0;
- gcmappedobj = 0;
+ /*gcobj2map = 0;
+ gcmappedobj = 0;*/
gcnumlobjs = 0;
gcheaptop = 0;
gctopcore = 0;
gctomove = false;
gcmovepending = 0;
gcblock2fill = 0;
- if(BAMBOO_NUM_OF_CORE < NUMCORES4GC) {
- int t_size = ((BAMBOO_RMSP_SIZE)-sizeof(mgcsharedhashtbl_t)*2
- -128*sizeof(size_t))/sizeof(mgcsharedhashlistnode_t)-2;
- int kk = 0;
- unsigned int tmp_k = 1 << (sizeof(int)*8 -1);
- while(((t_size & tmp_k) == 0) && (kk < sizeof(int)*8)) {
- t_size = t_size << 1;
- kk++;
- }
- t_size = tmp_k >> kk;
- gcsharedptbl = mgcsharedhashCreate_I(t_size,0.30);
- } else {
- gcsharedptbl = NULL;
- }
- BAMBOO_MEMSET_WH(gcrpointertbls, 0,
- sizeof(mgcsharedhashtbl_t *)*NUMCORES4GC);
#ifdef SMEMM
gcmem_mixed_threshold = (unsigned int)((BAMBOO_SHARED_MEM_SIZE
-bamboo_reserved_smem*BAMBOO_SMEM_SIZE)*0.8);
INLINE void disruntimedata() {
#ifdef MULTICORE_GC
-#ifdef LOCALHASHTBL_TEST
- freeRuntimeHash(gcpointertbl);
-#else
- mgchashDelete(gcpointertbl);
-#endif
freeMGCHash(gcforwardobjtbl);
#endif // MULTICORE_GC
#ifdef TASK
case GCSTARTPRE:
case GCSTARTINIT:
case GCSTART:
- case GCSTARTMAPINFO:
case GCSTARTFLUSH:
case GCFINISH:
case GCMARKCONFIRM:
case GCSTARTCOMPACT:
case GCMARKEDOBJ:
case GCFINISHINIT:
- case GCFINISHMAPINFO:
case GCFINISHFLUSH:
#ifdef GC_CACHE_ADAPT
case GCFINISHPREF:
case MEMREQUEST:
case MEMRESPONSE:
-#ifdef MULTICORE_GC
- case GCMAPREQUEST:
- case GCMAPINFO:
- case GCMAPTBL:
- case GCLOBJMAPPING:
-#endif
{
msglength = 3;
break;
gcphase = COMPACTPHASE;
}
-INLINE void processmsg_gcstartmapinfo_I() {
- gcphase = MAPPHASE;
-}
-
INLINE void processmsg_gcstartflush_I() {
gcphase = FLUSHPHASE;
}
} // if(cnum < NUMCORES4GC)
}
-INLINE void processmsg_gcfinishmapinfo_I() {
- int data1 = msgdata[msgdataindex];
- MSG_INDEXINC_I();
- // received a map phase finish msg
- if(BAMBOO_NUM_OF_CORE != STARTUPCORE) {
- // non startup core can not receive this msg
-#ifndef CLOSE_PRINT
- BAMBOO_DEBUGPRINT_REG(data1);
-#endif
- BAMBOO_EXIT(0xe018);
- }
- // all cores should do flush
- if(data1 < NUMCORES4GC) {
- gccorestatus[data1] = 0;
- }
-}
-
-
INLINE void processmsg_gcfinishflush_I() {
int data1 = msgdata[msgdataindex];
MSG_INDEXINC_I();
MSG_INDEXINC_I(); //msgdata[3];
}
-INLINE void processmsg_gcmaprequest_I() {
- void * dstptr = NULL;
- int data1 = msgdata[msgdataindex];
- MSG_INDEXINC_I();
- int data2 = msgdata[msgdataindex];
- MSG_INDEXINC_I();
-#ifdef LOCALHASHTBL_TEST
- RuntimeHashget(gcpointertbl, data1, &dstptr);
-#else
- dstptr = mgchashSearch(gcpointertbl, data1);
-#endif
- if(NULL == dstptr) {
- // no such pointer in this core, something is wrong
-#ifndef CLOSE_PRINT
- BAMBOO_DEBUGPRINT_REG(data1);
- BAMBOO_DEBUGPRINT_REG(data2);
-#endif
- BAMBOO_EXIT(0xe01c);
- } else {
- // send back the mapping info, cache the msg first
- if(BAMBOO_CHECK_SEND_MODE()) {
- cache_msg_3(data2, GCMAPINFO, data1, (int)dstptr);
- } else {
- send_msg_3(data2, GCMAPINFO, data1, (int)dstptr, true);
- }
- }
-}
-
-INLINE void processmsg_gcmapinfo_I() {
- int data1 = msgdata[msgdataindex];
- MSG_INDEXINC_I();
- gcmappedobj = msgdata[msgdataindex]; // [2]
- MSG_INDEXINC_I();
-#ifdef LOCALHASHTBL_TEST
- RuntimeHashadd_I(gcpointertbl, data1, gcmappedobj);
-#else
- mgchashInsert_I(gcpointertbl, data1, gcmappedobj);
-#endif
- if(data1 == gcobj2map) {
- gcismapped = true;
- }
-}
-
-INLINE void processmsg_gcmaptbl_I() {
- int data1 = msgdata[msgdataindex];
- MSG_INDEXINC_I();
- int data2 = msgdata[msgdataindex];
- MSG_INDEXINC_I();
- gcrpointertbls[data2] = (mgcsharedhashtbl_t *)data1;
-}
-
INLINE void processmsg_gclobjinfo_I() {
numconfirm--;
} // for(int k = 5; k < msgdata[1];)
}
-INLINE void processmsg_gclobjmapping_I() {
- int data1 = msgdata[msgdataindex];
- MSG_INDEXINC_I();
- int data2 = msgdata[msgdataindex];
- MSG_INDEXINC_I();
-#ifdef LOCALHASHTBL_TEST
- RuntimeHashadd_I(gcpointertbl, data1, data2);
-#else
- mgchashInsert_I(gcpointertbl, data1, data2);
-#endif
- mgcsharedhashInsert_I(gcsharedptbl, data1, data2);
-}
-
#ifdef GC_PROFILE
INLINE void processmsg_gcprofiles_I() {
int data1 = msgdata[msgdataindex];
break;
} // case GCSTARTCOMPACT
- case GCSTARTMAPINFO: {
- // received a flush phase start msg
- processmsg_gcstartmapinfo_I();
- break;
- } // case GCSTARTFLUSH
-
case GCSTARTFLUSH: {
// received a flush phase start msg
processmsg_gcstartflush_I();
break;
} // case GCFINISHCOMPACT
- case GCFINISHMAPINFO: {
- processmsg_gcfinishmapinfo_I();
- break;
- } // case GCFINISHMAPINFO
-
case GCFINISHFLUSH: {
processmsg_gcfinishflush_I();
break;
break;
} // case GCMOVESTART
- case GCMAPREQUEST: {
- // received a mapping info request msg
- processmsg_gcmaprequest_I();
- break;
- } // case GCMAPREQUEST
-
- case GCMAPINFO: {
- // received a mapping info response msg
- processmsg_gcmapinfo_I();
- break;
- } // case GCMAPINFO
-
- case GCMAPTBL: {
- // received a mapping tbl response msg
- processmsg_gcmaptbl_I();
- break;
- } // case GCMAPTBL
-
case GCLOBJREQUEST: {
// received a large objs info request msg
transferMarkResults_I();
break;
} // case GCLOBJINFO
- case GCLOBJMAPPING: {
- // received a large obj mapping info msg
- processmsg_gclobjmapping_I();
- break;
- } // case GCLOBJMAPPING
-
#ifdef GC_PROFILE
case GCPROFILES: {
// received a gcprofiles msg