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) {
46 //count live objects per unit
48 tmc_spin_barrier_wait(&pmc_heapptr->barrier);
50 if (BAMBOO_NUM_OF_CORE==STARTUPCORE) {
53 tmc_spin_barrier_wait(&pmc_heapptr->barrier);
54 //set up forwarding pointers
56 tmc_spin_barrier_wait(&pmc_heapptr->barrier);
58 pmc_doreferenceupdate();
59 tmc_spin_barrier_wait(&pmc_heapptr->barrier);
62 tmc_spin_barrier_wait(&pmc_heapptr->barrier);
65 void gettype_size(void * ptr, int * ttype, unsigned int * tsize) {
66 int type = ((int *)ptr)[0];
67 if(type < NUMCLASSES) {
69 *tsize = classsize[type];
73 struct ArrayObject *ao=(struct ArrayObject *)ptr;
74 unsigned int elementsize=classsize[type];
75 unsigned int length=ao->___length___;
76 *tsize = sizeof(struct ArrayObject)+length*elementsize;