// TODO: DO NOT support tag!!!
#ifdef MULTICORE_GC
#include "runtime.h"
+#include "multicoreruntime.h"
#include "multicoregarbage.h"
#include "multicoregcmark.h"
#include "gcqueue.h"
#include "multicoregccompact.h"
#include "multicoregcflush.h"
-#include "multicoreruntime.h"
#include "multicoregcprofile.h"
#include "gcqueue.h"
extern unsigned int gcmem_mixed_usedmem;
#endif // SMEMM
+volatile bool gcflag;
+gc_status_t gc_status_info;
+
#ifdef GC_DEBUG
// dump whole mem in blocks
void dumpSMem() {
bamboo_smem_zero_top = NULL;
gcflag = false;
- gcprocessing = false;
- gcphase = FINISHPHASE;
+ gc_status_info.gcprocessing = false;
+ gc_status_info.gcphase = FINISHPHASE;
+
gcprecheck = true;
gccurr_heaptop = 0;
gcself_numsendobjs = 0;
gcmovepending = 0;
gcblock2fill = 0;
#ifdef SMEMM
- gcmem_mixed_threshold = (unsigned int)((BAMBOO_SHARED_MEM_SIZE
- -bamboo_reserved_smem*BAMBOO_SMEM_SIZE)*0.8);
+ gcmem_mixed_threshold=(unsigned int)((BAMBOO_SHARED_MEM_SIZE-bamboo_reserved_smem*BAMBOO_SMEM_SIZE)*0.8);
gcmem_mixed_usedmem = 0;
#endif
#ifdef MGC_SPEC
gc_profile_flag = false;
-#endif
-#ifdef GC_FLUSH_DTLB
- gc_num_flush_dtlb = 0;
#endif
gc_localheap_s = false;
#ifdef GC_CACHE_ADAPT
}
if(i == NUMCORESACTIVE) {
// all the core status info are the latest,stop mark phase
- gcphase = COMPACTPHASE;
+ gc_status_info.gcphase = COMPACTPHASE;
// restore the gcstatus for all cores
for(int i = 0; i < NUMCORESACTIVE; i++) {
gccorestatus[i] = 1;
}
void gc_collect(struct garbagelist * stackptr) {
- gcprocessing = true;
+ gc_status_info.gcprocessing = true;
// inform the master that this core is at a gc safe point and is ready to
// do gc
send_msg_4(STARTUPCORE,GCFINISHPRE,BAMBOO_NUM_OF_CORE,self_numsendobjs,self_numreceiveobjs);
}
void gc_nocollect(struct garbagelist * stackptr) {
- gcprocessing = true;
+ gc_status_info.gcprocessing = true;
// inform the master that this core is at a gc safe point and is ready to
// do gc
send_msg_4(STARTUPCORE,GCFINISHPRE,BAMBOO_NUM_OF_CORE,self_numsendobjs,self_numreceiveobjs);
GC_PRINTF("Start mark phase \n");
GC_SEND_MSG_1_TO_CLIENT(GCSTART);
- gcphase = MARKPHASE;
+ gc_status_info.gcphase = MARKPHASE;
// mark phase
- while(MARKPHASE == gcphase) {
+ while(MARKPHASE == gc_status_info.gcphase) {
mark(isfirst, stackptr);
isfirst=false;
// check gcstatus
}
void master_updaterefs(struct garbagelist * stackptr) {
- gcphase = FLUSHPHASE;
+ gc_status_info.gcphase = FLUSHPHASE;
GC_SEND_MSG_1_TO_CLIENT(GCSTARTFLUSH);
GCPROFILE_ITEM();
GC_PRINTF("Start flush phase \n");
flush(stackptr);
// now the master core need to decide the new cache strategy
CACHEADAPT_MASTER();
- GC_CHECK_ALL_CORE_STATUS(FLUSHPHASE==gcphase);
+ GC_CHECK_ALL_CORE_STATUS(FLUSHPHASE==gc_status_info.gcphase);
GC_PRINTF("Finish flush phase \n");
}
void master_finish() {
- gcphase = FINISHPHASE;
+ gc_status_info.gcphase = FINISHPHASE;
// invalidate all shared mem pointers
// put it here as it takes time to inform all the other cores to
gcflag = false;
GC_SEND_MSG_1_TO_CLIENT(GCFINISH);
- gcprocessing = false;
+ gc_status_info.gcprocessing = false;
if(gcflag) {
// inform other cores to stop and wait for gc
gcprecheck = true;
void gc_master(struct garbagelist * stackptr) {
tprintf("start GC !!!!!!!!!!!!! \n");
- gcprocessing = true;
- gcphase = INITPHASE;
+ gc_status_info.gcprocessing = true;
+ gc_status_info.gcphase = INITPHASE;
waitconfirm = false;
numconfirm = 0;
master_finish();
GC_PRINTF("gc finished \n");
- tprintf("finish GC ! %d \n", gcflag);
+ tprintf("finish GC ! %d \n",gcflag);
}
void pregccheck() {
// we need to make sure during the gcinit phase the shared heap is not
// touched. Otherwise, there would be problem when adapt the cache strategy.
BAMBOO_CLOSE_CUR_MSP();
-#ifdef GC_FLUSH_DTLB
- if(gc_num_flush_dtlb < GC_NUM_FLUSH_DTLB) {
- BAMBOO_CLEAN_DTLB();
- gc_num_flush_dtlb++;
- }
-#endif
#if defined(GC_CACHE_ADAPT)&&defined(GC_CACHE_SAMPLING)
// get the sampling data
bamboo_output_dtlb_sampling();
bool gc(struct garbagelist * stackptr) {
// check if do gc
if(!gcflag) {
- gcprocessing = false;
+ gc_status_info.gcprocessing = false;
return false;
}