1 #include "multicoregc.h"
2 #include "multicoreruntime.h"
3 #include "pmc_garbage.h"
4 #include "runtime_arch.h"
6 struct pmc_heap * pmc_heapptr;
7 struct pmc_queue * pmc_localqueue;
10 void incrementthreads() {
11 tmc_spin_mutex_lock(&pmc_heapptr->lock);
12 pmc_heapptr->numthreads++;
13 tmc_spin_mutex_unlock(&pmc_heapptr->lock);
16 void decrementthreads() {
17 tmc_spin_mutex_lock(&pmc_heapptr->lock);
18 pmc_heapptr->numthreads--;
19 tmc_spin_mutex_unlock(&pmc_heapptr->lock);
22 void * pmc_unitend(unsigned int index) {
23 return gcbaseva+(index+1)*NUMPMCUNITS;
27 pmc_localqueue=&pmc_heapptr->regions[BAMBOO_NUM_OF_CORE].markqueue;
28 pmc_queueinit(pmc_localqueue);
29 tmc_spin_barrier_init(&pmc_heapptr->barrier, NUMCORES4GC);
30 for(int i=0;i<NUMPMCUNITS;i++) {
31 pmc_heapptr->units[i].endptr=pmc_unitend(i);
36 if (BAMBOO_NUM_OF_CORE==STARTUPCORE) {
37 pmc_heapptr->numthreads=NUMCORES4GC;
39 tmc_spin_barrier_wait(&pmc_heapptr->barrier);
42 void gc(struct garbagelist *gl) {
48 //count live objects per unit
51 tmc_spin_barrier_wait(&pmc_heapptr->barrier);
54 if (BAMBOO_NUM_OF_CORE==STARTUPCORE) {
57 tmc_spin_barrier_wait(&pmc_heapptr->barrier);
58 //set up forwarding pointers
61 tmc_spin_barrier_wait(&pmc_heapptr->barrier);
63 tprintf("updaterefs\n");
64 pmc_doreferenceupdate();
65 tmc_spin_barrier_wait(&pmc_heapptr->barrier);
69 tmc_spin_barrier_wait(&pmc_heapptr->barrier);
72 void gettype_size(void * ptr, int * ttype, unsigned int * tsize) {
73 int type = ((int *)ptr)[0];
74 if(type < NUMCLASSES) {
76 *tsize = classsize[type];
80 struct ArrayObject *ao=(struct ArrayObject *)ptr;
81 unsigned int elementsize=classsize[type];
82 unsigned int length=ao->___length___;
83 *tsize = sizeof(struct ArrayObject)+length*elementsize;