change objects
[IRC.git] / Robust / src / Runtime / bamboo / multicoregarbage.c
1 // TODO: DO NOT support tag!!!
2 #ifdef MULTICORE_GC
3 #include "runtime.h"
4 #include "multicoreruntime.h"
5 #include "multicoregarbage.h"
6 #include "multicoregcmark.h"
7 #include "gcqueue.h"
8 #include "multicoregccompact.h"
9 #include "multicoregcflush.h"
10 #include "multicoregcprofile.h"
11 #include "gcqueue.h"
12
13 #ifdef SMEMM
14 extern unsigned int gcmem_mixed_threshold;
15 extern unsigned int gcmem_mixed_usedmem;
16 #endif // SMEMM
17
18 volatile bool gcflag;
19 gc_status_t gc_status_info;
20
21 unsigned long long gc_output_cache_policy_time=0;
22
23 #ifdef GC_DEBUG
24 // dump whole mem in blocks
25 void dumpSMem() {
26   int block = 0;
27   int sblock = 0;
28   unsigned int j = 0;
29   void * i = 0;
30   int coren = 0;
31   int x = 0;
32   int y = 0;
33   printf("(%x,%x) Dump shared mem: \n",udn_tile_coord_x(),udn_tile_coord_y());
34   // reserved blocks for sblocktbl
35   printf("(%x,%x) ++++ reserved sblocks ++++ \n", udn_tile_coord_x(),
36          udn_tile_coord_y());
37   for(i=BAMBOO_BASE_VA; (unsinged int)i<(unsigned int)gcbaseva; i+= 4*16) {
38     printf("(%x,%x) 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x \n",
39         udn_tile_coord_x(), udn_tile_coord_y(),
40         *((int *)(i)), *((int *)(i + 4)),
41         *((int *)(i + 4*2)), *((int *)(i + 4*3)),
42         *((int *)(i + 4*4)), *((int *)(i + 4*5)),
43         *((int *)(i + 4*6)), *((int *)(i + 4*7)),
44         *((int *)(i + 4*8)), *((int *)(i + 4*9)),
45         *((int *)(i + 4*10)), *((int *)(i + 4*11)),
46         *((int *)(i + 4*12)), *((int *)(i + 4*13)),
47         *((int *)(i + 4*14)), *((int *)(i + 4*15)));
48   }
49   sblock = 0;
50   bool advanceblock = false;
51   // remaining memory
52   for(i=gcbaseva; (unsigned int)i<(unsigned int)(gcbaseva+BAMBOO_SHARED_MEM_SIZE); i+=4*16) {
53     advanceblock = false;
54     // computing sblock # and block #, core coordinate (x,y) also
55     if(j%((BAMBOO_SMEM_SIZE)/(4*16)) == 0) {
56       // finished a sblock
57       if(j < ((BAMBOO_LARGE_SMEM_BOUND)/(4*16))) {
58         if((j > 0) && (j%((BAMBOO_SMEM_SIZE_L)/(4*16)) == 0)) {
59           // finished a block
60           block++;
61           advanceblock = true;  
62         }
63       } else {
64         // finished a block
65         block++;
66         advanceblock = true;
67       }
68       // compute core #
69       if(advanceblock) {
70         coren = gc_block2core[block%(NUMCORES4GC*2)];
71       }
72       // compute core coordinate
73       x = BAMBOO_COORDS_X(coren);
74       y = BAMBOO_COORDS_Y(coren);
75       printf("(%x,%x) ==== %d, %d : core (%d,%d), saddr %x====\n",
76           udn_tile_coord_x(), udn_tile_coord_y(),block, sblock++, x, y,
77           (sblock-1)*(BAMBOO_SMEM_SIZE)+gcbaseva);
78     }
79     j++;
80     printf("(%x,%x) 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x \n",
81         udn_tile_coord_x(), udn_tile_coord_y(),
82         *((int *)(i)), *((int *)(i + 4)),
83         *((int *)(i + 4*2)), *((int *)(i + 4*3)),
84         *((int *)(i + 4*4)), *((int *)(i + 4*5)),
85         *((int *)(i + 4*6)), *((int *)(i + 4*7)),
86         *((int *)(i + 4*8)), *((int *)(i + 4*9)),
87         *((int *)(i + 4*10)), *((int *)(i + 4*11)),
88         *((int *)(i + 4*12)), *((int *)(i + 4*13)),
89         *((int *)(i + 4*14)), *((int *)(i + 4*15)));
90   }
91   printf("(%x,%x) \n", udn_tile_coord_x(), udn_tile_coord_y());
92 }
93 #endif
94
95 void initmulticoregcdata() {
96   if(STARTUPCORE == BAMBOO_NUM_OF_CORE) {
97     // startup core to initialize corestatus[]
98     for(int i = 0; i < NUMCORESACTIVE; i++) {
99       gccorestatus[i] = 1;
100       gcnumsendobjs[0][i] = gcnumsendobjs[1][i] = 0;
101       gcnumreceiveobjs[0][i] = gcnumreceiveobjs[1][i] = 0;
102     } 
103     for(int i = 0; i < NUMCORES4GC; i++) {
104       gcloads[i] = 0;
105       gcrequiredmems[i] = 0;
106       gcstopblock[i] = 0;
107       gcfilledblocks[i] = 0;
108     }
109   }
110
111   bamboo_smem_zero_top = NULL;
112   gcflag = false;
113   gc_status_info.gcprocessing = false;
114   gc_status_info.gcphase = FINISHPHASE;
115
116   gcprecheck = true;
117   gccurr_heaptop = 0;
118   gcself_numsendobjs = 0;
119   gcself_numreceiveobjs = 0;
120   gcmarkedptrbound = 0;
121   gcforwardobjtbl = allocateMGCHash_I(128);
122   gcnumlobjs = 0;
123   gcheaptop = 0;
124   gctopcore = 0;
125   gctopblock = 0;
126   gcmovestartaddr = 0;
127   gctomove = false;
128   gcmovepending = 0;
129   gcblock2fill = 0;
130 #ifdef SMEMM
131   gcmem_mixed_threshold=(unsigned int)((BAMBOO_SHARED_MEM_SIZE-bamboo_reserved_smem*BAMBOO_SMEM_SIZE)*0.8);
132   gcmem_mixed_usedmem = 0;
133 #endif
134 #ifdef MGC_SPEC
135   gc_profile_flag = false;
136 #endif
137   gc_localheap_s = false;
138 #ifdef GC_CACHE_ADAPT
139   gccachestage = false;
140 #endif 
141
142   INIT_MULTICORE_GCPROFILE_DATA();
143 }
144
145 void dismulticoregcdata() {
146   freeMGCHash(gcforwardobjtbl);
147 }
148
149 void initGC() {
150   if(STARTUPCORE == BAMBOO_NUM_OF_CORE) {
151     for(int i = 0; i < NUMCORES4GC; i++) {
152       gccorestatus[i] = 1;
153       gcnumsendobjs[0][i] = gcnumsendobjs[1][i] = 0;
154       gcnumreceiveobjs[0][i] = gcnumreceiveobjs[1][i] = 0;
155       gcloads[i] = 0;
156       gcrequiredmems[i] = 0;
157       gcfilledblocks[i] = 0;
158       gcstopblock[i] = 0;
159     } 
160     for(int i = NUMCORES4GC; i < NUMCORESACTIVE; i++) {
161       gccorestatus[i] = 1;
162       gcnumsendobjs[0][i] = gcnumsendobjs[1][i] = 0;
163       gcnumreceiveobjs[0][i] = gcnumreceiveobjs[1][i] = 0;
164     }
165     gcheaptop = 0;
166     gctopcore = 0;
167     gctopblock = 0;
168     gcnumsrobjs_index = 0;
169   } 
170   gcself_numsendobjs = 0;
171   gcself_numreceiveobjs = 0;
172   gcmarkedptrbound = 0;
173   gcnumlobjs = 0;
174   gcmovestartaddr = 0;
175   gctomove = false;
176   gcblock2fill = 0;
177   gcmovepending = 0;
178   gccurr_heaptop = 0;
179
180   gc_queueinit();
181
182   MGCHashreset(gcforwardobjtbl);
183
184   GCPROFILE_INIT();
185   gc_output_cache_policy_time=0;
186
187
188 bool gc_checkAllCoreStatus() {
189   BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
190   for(int i = 0; i < NUMCORESACTIVE; i++) {
191     if(gccorestatus[i] != 0) {
192       BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
193       return false;
194     }  
195   }  
196   BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
197   return true;
198 }
199
200 // NOTE: should be invoked with interrupts turned off
201 bool gc_checkAllCoreStatus_I() {
202   for(int i = 0; i < NUMCORESACTIVE; i++) {
203     if(gccorestatus[i] != 0) {
204       return false;
205     }  
206   }  
207   return true;
208 }
209
210 void checkMarkStatus_p2() {
211   // check if the sum of send objs and receive obj are the same
212   // yes->check if the info is the latest; no->go on executing
213   unsigned int sumsendobj = 0;
214   for(int i = 0; i < NUMCORESACTIVE; i++) {
215     sumsendobj += gcnumsendobjs[gcnumsrobjs_index][i];
216   } 
217   for(int i = 0; i < NUMCORESACTIVE; i++) {
218     sumsendobj -= gcnumreceiveobjs[gcnumsrobjs_index][i];
219   } 
220   if(0 == sumsendobj) {
221     // Check if there are changes of the numsendobjs or numreceiveobjs 
222     // on each core
223     int i = 0;
224     for(i = 0; i < NUMCORESACTIVE; i++) {
225       if((gcnumsendobjs[0][i]!=gcnumsendobjs[1][i])||(gcnumreceiveobjs[0][i]!=gcnumreceiveobjs[1][i]) ) {
226         break;
227       }
228     }  
229     if(i == NUMCORESACTIVE) {    
230       // all the core status info are the latest,stop mark phase
231       gc_status_info.gcphase = COMPACTPHASE;
232       // restore the gcstatus for all cores
233       for(int i = 0; i < NUMCORESACTIVE; i++) {
234         gccorestatus[i] = 1;
235       }  
236     } else {
237       // There were changes between phase 1 and phase 2, can not decide 
238       // whether the mark phase has been finished
239       waitconfirm = false;
240       // As it fails in phase 2, flip the entries
241       gcnumsrobjs_index = (gcnumsrobjs_index == 0) ? 1 : 0;
242     } 
243   } else {
244     // There were changes between phase 1 and phase 2, can not decide 
245     // whether the mark phase has been finished
246     waitconfirm = false;
247     // As it fails in phase 2, flip the entries
248     gcnumsrobjs_index = (gcnumsrobjs_index == 0) ? 1 : 0;
249   }
250 }
251
252 void checkMarkStatus() {
253   if((!waitconfirm)||(waitconfirm && (numconfirm == 0))) {
254     unsigned int entry_index = 0;
255     if(waitconfirm) {
256       // phase 2
257       entry_index = (gcnumsrobjs_index == 0) ? 1 : 0;
258     } else {
259       // phase 1
260       entry_index = gcnumsrobjs_index;
261     }
262     BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
263     gccorestatus[BAMBOO_NUM_OF_CORE] = 0;  
264     gcnumsendobjs[entry_index][BAMBOO_NUM_OF_CORE] = gcself_numsendobjs;
265     gcnumreceiveobjs[entry_index][BAMBOO_NUM_OF_CORE] = gcself_numreceiveobjs;
266     // check the status of all cores
267     if (gc_checkAllCoreStatus_I()) {
268       // ask for confirm
269       if(!waitconfirm) {
270         // the first time found all cores stall
271         // send out status confirm msg to all other cores
272         // reset the corestatus array too    
273         waitconfirm = true;
274         numconfirm = NUMCORESACTIVE - 1;
275         BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
276         GC_SEND_MSG_1_TO_CLIENT(GCMARKCONFIRM);
277       } else {
278         // Phase 2
279         checkMarkStatus_p2(); 
280         BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
281       }
282     } else {
283       BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
284     } 
285   } 
286
287
288 // compute load balance for all cores
289 int loadbalance(void ** heaptop, unsigned int * topblock, unsigned int * topcore) {
290   // compute load balance
291   // get the total loads
292   unsigned int tloads = 0;
293   for(int i = 0; i < NUMCORES4GC; i++) {
294     tloads += gcloads[i];
295   }
296   *heaptop = gcbaseva + tloads;
297
298   unsigned int topblockindex;
299   
300   BLOCKINDEX(topblockindex, *heaptop);
301   // num of blocks per core
302   unsigned int numbpc = (topblockindex+NUMCORES4GC-1)/NUMCORES4GC;
303   
304   *topblock = topblockindex;
305   RESIDECORE(*heaptop, *topcore);
306   return numbpc;
307 }
308
309
310 // update the bmmboo_smemtbl to record current shared mem usage
311 void updateSmemTbl(unsigned int coren, void * localtop) {
312   unsigned int ltopcore = 0;
313   unsigned int bound = BAMBOO_SMEM_SIZE_L;
314   BLOCKINDEX(ltopcore, localtop);
315   if((unsigned int)localtop>=(unsigned int)(gcbaseva+BAMBOO_LARGE_SMEM_BOUND)){
316     bound = BAMBOO_SMEM_SIZE;
317   }
318   unsigned int load = (unsigned INTPTR)(localtop-gcbaseva)%(unsigned int)bound;
319   unsigned int toset = 0;
320   for(int j=0; 1; j++) {
321     for(int i=0; i<2; i++) {
322       toset = gc_core2block[2*coren+i]+(unsigned int)(NUMCORES4GC*2)*j;
323       if(toset < ltopcore) {
324         bamboo_smemtbl[toset]=BLOCKSIZE(toset<NUMCORES4GC);
325 #ifdef SMEMM
326         gcmem_mixed_usedmem += bamboo_smemtbl[toset];
327 #endif
328       } else if(toset == ltopcore) {
329         bamboo_smemtbl[toset] = load;
330 #ifdef SMEMM
331         gcmem_mixed_usedmem += bamboo_smemtbl[toset];
332 #endif
333         return;
334       } else {
335         return;
336       }
337     }
338   }
339 }
340
341 void gc_collect(struct garbagelist * stackptr) {
342   gc_status_info.gcprocessing = true;
343   // inform the master that this core is at a gc safe point and is ready to 
344   // do gc
345   send_msg_4(STARTUPCORE,GCFINISHPRE,BAMBOO_NUM_OF_CORE,self_numsendobjs,self_numreceiveobjs);
346
347   // core collector routine
348   //wait for init phase
349   WAITFORGCPHASE(INITPHASE);
350
351   GC_PRINTF("Do initGC\n");
352   initGC();
353   CACHEADAPT_GC(true);
354   //send init finish msg to core coordinator
355   send_msg_2(STARTUPCORE,GCFINISHINIT,BAMBOO_NUM_OF_CORE);
356
357   //wait for mark phase
358   WAITFORGCPHASE(MARKPHASE);
359
360   GC_PRINTF("Start mark phase\n");
361   mark(true, stackptr);
362   GC_PRINTF("Finish mark phase, start compact phase\n");
363   compact();
364   GC_PRINTF("Finish compact phase\n");
365
366   WAITFORGCPHASE(UPDATEPHASE);
367
368   GC_PRINTF("Start flush phase\n");
369   GCPROFILE_INFO_2_MASTER();
370   flush(stackptr);
371   GC_PRINTF("Finish flush phase\n");
372
373   CACHEADAPT_PHASE_CLIENT();
374
375   // invalidate all shared mem pointers
376   bamboo_cur_msp = NULL;
377   bamboo_smem_size = 0;
378   bamboo_smem_zero_top = NULL;
379   gcflag = false;
380
381   WAITFORGCPHASE(FINISHPHASE);
382
383   GC_PRINTF("Finish gc! \n");
384
385
386 void gc_nocollect(struct garbagelist * stackptr) {
387   gc_status_info.gcprocessing = true;
388   // inform the master that this core is at a gc safe point and is ready to 
389   // do gc
390   send_msg_4(STARTUPCORE,GCFINISHPRE,BAMBOO_NUM_OF_CORE,self_numsendobjs,self_numreceiveobjs);
391   
392   WAITFORGCPHASE(INITPHASE);
393
394   GC_PRINTF("Do initGC\n");
395   initGC();
396   CACHEADAPT_GC(true);
397   //send init finish msg to core coordinator
398   send_msg_2(STARTUPCORE,GCFINISHINIT,BAMBOO_NUM_OF_CORE);
399
400   WAITFORGCPHASE(MARKPHASE);
401
402   GC_PRINTF("Start mark phase\n"); 
403   mark(true, stackptr);
404   GC_PRINTF("Finish mark phase, wait for flush\n");
405
406   // non-gc core collector routine
407   WAITFORGCPHASE(UPDATEPHASE);
408
409   GC_PRINTF("Start flush phase\n");
410   GCPROFILE_INFO_2_MASTER();
411   flush(stackptr);
412   GC_PRINTF("Finish flush phase\n"); 
413
414   CACHEADAPT_PHASE_CLIENT();
415
416   // invalidate all shared mem pointers
417   bamboo_cur_msp = NULL;
418   bamboo_smem_size = 0;
419   bamboo_smem_zero_top = NULL;
420
421   gcflag = false;
422   WAITFORGCPHASE(FINISHPHASE);
423
424   GC_PRINTF("Finish gc! \n");
425 }
426
427 void master_mark(struct garbagelist *stackptr) {
428   bool isfirst = true;
429
430   GC_PRINTF("Start mark phase \n");
431   GC_SEND_MSG_1_TO_CLIENT(GCSTART);
432   gc_status_info.gcphase = MARKPHASE;
433   // mark phase
434
435   while(MARKPHASE == gc_status_info.gcphase) {
436     mark(isfirst, stackptr);
437     isfirst=false;
438     // check gcstatus
439     checkMarkStatus();
440   }
441 }
442
443 void master_getlargeobjs() {
444   // send msgs to all cores requiring large objs info
445   // Note: only need to ask gc cores, non-gc cores do not host any objs
446   numconfirm = NUMCORES4GC - 1;
447   for(int i = 1; i < NUMCORES4GC; i++) {
448     send_msg_1(i,GCLOBJREQUEST);
449   }
450   gcloads[BAMBOO_NUM_OF_CORE] = gccurr_heaptop;
451   //spin until we have all responses
452   while(numconfirm!=0) ;
453
454   // check the heaptop
455   if(gcheaptop < gcmarkedptrbound) {
456     gcheaptop = gcmarkedptrbound;
457   }
458   GCPROFILE_ITEM();
459   GC_PRINTF("prepare to cache large objs \n");
460
461 }
462
463
464 void master_updaterefs(struct garbagelist * stackptr) {
465   gc_status_info.gcphase = UPDATEPHASE;
466   GC_SEND_MSG_1_TO_CLIENT(GCSTARTUPDATE);
467   GCPROFILE_ITEM();
468   GC_PRINTF("Start flush phase \n");
469   // flush phase
470   flush(stackptr);
471   GC_CHECK_ALL_CORE_STATUS(UPDATEPHASE==gc_status_info.gcphase);
472   GC_PRINTF("Finish flush phase \n");
473 }
474
475 void master_finish() {
476   gc_status_info.gcphase = FINISHPHASE;
477   
478   // invalidate all shared mem pointers
479   // put it here as it takes time to inform all the other cores to
480   // finish gc and it might cause problem when some core resumes
481   // mutator earlier than the other cores
482   bamboo_cur_msp = NULL;
483   bamboo_smem_size = 0;
484   bamboo_smem_zero_top = NULL;
485   
486   GCPROFILE_END();
487   unsigned long long tmpt = BAMBOO_GET_EXE_TIME();
488   CACHEADAPT_OUTPUT_CACHE_POLICY();
489   gc_output_cache_policy_time += (BAMBOO_GET_EXE_TIME()-tmpt);
490   gcflag = false;
491   GC_SEND_MSG_1_TO_CLIENT(GCFINISH);
492   
493   gc_status_info.gcprocessing = false;
494   if(gcflag) {
495     // inform other cores to stop and wait for gc
496     gcprecheck = true;
497     for(int i = 0; i < NUMCORESACTIVE; i++) {
498       // reuse the gcnumsendobjs & gcnumreceiveobjs
499       gcnumsendobjs[0][i] = 0;
500       gcnumreceiveobjs[0][i] = 0;
501     }
502     GC_SEND_MSG_1_TO_CLIENT(GCSTARTPRE);
503   }
504 }
505
506 void gc_master(struct garbagelist * stackptr) {
507   tprintf("start GC !!!!!!!!!!!!! \n");
508   gc_status_info.gcprocessing = true;
509   gc_status_info.gcphase = INITPHASE;
510
511   waitconfirm = false;
512   numconfirm = 0;
513   initGC();
514   GC_SEND_MSG_1_TO_CLIENT(GCSTARTINIT);
515   CACHEADAPT_GC(true);
516   GC_PRINTF("Check core status \n");
517   GC_CHECK_ALL_CORE_STATUS(true);
518   GCPROFILE_ITEM();
519   unsigned long long tmpt = BAMBOO_GET_EXE_TIME();
520   CACHEADAPT_OUTPUT_CACHE_SAMPLING();
521   gc_output_cache_policy_time += (BAMBOO_GET_EXE_TIME()-tmpt);
522
523   // do mark phase
524   master_mark(stackptr);
525
526   // get large objects from all cores
527   master_getlargeobjs();
528
529   // compact the heap
530   master_compact();
531   
532   // update the references
533   master_updaterefs(stackptr);
534
535   // do cache adaptation
536   CACHEADAPT_PHASE_MASTER();
537
538   // do finish up stuff
539   master_finish();
540
541   GC_PRINTF("gc finished   \n");
542   tprintf("finish GC ! %d \n",gcflag);
543
544
545 void pregccheck() {
546   while(true) {
547     BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
548     gcnumsendobjs[0][BAMBOO_NUM_OF_CORE] = self_numsendobjs;
549     gcnumreceiveobjs[0][BAMBOO_NUM_OF_CORE] = self_numreceiveobjs;
550     int sumsendobj = 0;
551     for(int i = 0; i < NUMCORESACTIVE; i++) {
552       sumsendobj += gcnumsendobjs[0][i];
553     }  
554     for(int i = 0; i < NUMCORESACTIVE; i++) {
555       sumsendobj -= gcnumreceiveobjs[0][i];
556     } 
557     if(0 != sumsendobj) {
558       // there were still some msgs on the fly, wait until there 
559       // are some update pregc information coming and check it again
560       gcprecheck = false;
561       BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
562
563       while(!gcprecheck) ;
564     } else {
565       BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
566       return;
567     }
568   }
569 }
570
571 void pregcprocessing() {
572 #if defined(GC_CACHE_ADAPT)&&defined(GC_CACHE_SAMPLING)
573   // disable the timer interrupt
574   bamboo_mask_timer_intr();
575 #endif
576   // Zero out the remaining memory here because for the GC_CACHE_ADAPT version,
577   // we need to make sure during the gcinit phase the shared heap is not 
578   // touched. Otherwise, there would be problem when adapt the cache strategy.
579   BAMBOO_CLOSE_CUR_MSP();
580 #if defined(GC_CACHE_ADAPT)&&defined(GC_CACHE_SAMPLING)
581   // get the sampling data 
582   bamboo_output_dtlb_sampling();
583 #endif
584 }
585
586 void postgcprocessing() {
587 #if defined(GC_CACHE_ADAPT)&&defined(GC_CACHE_SAMPLING)
588   // enable the timer interrupt
589   bamboo_tile_timer_set_next_event(GC_TILE_TIMER_EVENT_SETTING); 
590   bamboo_unmask_timer_intr();
591 #endif
592 }
593
594 bool gc(struct garbagelist * stackptr) {
595   // check if do gc
596   if(!gcflag) {
597     gc_status_info.gcprocessing = false;
598     return false;
599   }
600
601   // core coordinator routine
602   if(0 == BAMBOO_NUM_OF_CORE) {
603     GC_PRINTF("Check if we can do gc or not\n");
604     gccorestatus[BAMBOO_NUM_OF_CORE] = 0;
605     if(!gc_checkAllCoreStatus()) {
606       // some of the cores are still executing the mutator and did not reach
607       // some gc safe point, therefore it is not ready to do gc
608       gcflag = true;
609       return false;
610     } else {
611       GCPROFILE_START();
612       pregccheck();
613     }
614     GC_PRINTF("start gc! \n");
615     pregcprocessing();
616     gc_master(stackptr);
617   } else if(BAMBOO_NUM_OF_CORE < NUMCORES4GC) {
618     pregcprocessing();
619     gc_collect(stackptr);
620   } else {
621     pregcprocessing();
622     gc_nocollect(stackptr);
623   }
624   postgcprocessing();
625
626   return true;
627
628
629 #endif