for(int i=0;i<NUMPMCUNITS;i++) {
if (!tmc_spin_mutex_trylock(&pmc_heapptr->units[i].lock)) {
//got lock
- void *unitbase=gcbaseva+i*UNITSIZE;
- void *unittop=unitbase+UNITSIZE;
+ void *unitbase=(i==0)?gcbaseva:pmc_heapptr->unit[i-1]->endptr;
+ void *unittop=pmc_heapptr->unit[i]->endptr;
pmc_countbytes(&pmc_heapptr->unit[i], unitbase, unittop);
}
}
return;
if (endregion==-1)
endregion=NUMPMCUNITS;
- region->startptr=gcbaseva+startregion*UNITSIZE;
- region->endptr=gcbaseva+endregion*UNITSIZE;
- pmc_forward(region, totalbytes, region->startptr, region->endptr, BAMBOO_NUM_OF_CORE&1);
+ region->startptr=(i==0)?gcbaseva:pmc_heapptr->units[i-1].endptr;
+ region->endptr=pmc_heapptr->units[i].endptr;
+
+ if (BAMBOO_NUM_OF_CORE&1) {
+ //backward direction
+ region->lastptr=region->endptr-totalbytes;
+ } else {
+ //forward direction
+ region->lastptr=region->startptr+totalbytes;
+ }
+
+ pmc_forward(region, totalbytes, region->startptr, region->endptr, !(BAMBOO_NUM_OF_CORE&1));
}
--- /dev/null
+#ifndef PMC_MEM_H
+#define PMC_MEM_H
+
+void * pmc_alloc(unsigned int * numbytesallocated, unsigned int minimumbytes) {
+ for(int i=0;i<NUMCORES4GC;i+=2) {
+ void *startptr=pmc_heapptr->regions[i].lastptr;
+ void *finishptr=pmc_heapptr->regions[i+1].lastptr;
+ if ((finishptr-startptr)>minimumbytes) {
+
+ }
+ }
+}
+
+#endif
void pmc_docompact() {
struct pmc_region * region=&pmc_heapptr->regions[BAMBOO_NUM_OF_CORE];
- pmc_compact(region, BAMBOO_NUM_OF_CORE&1, region->startptr, region->endptr);
+ pmc_compact(region, !(BAMBOO_NUM_OF_CORE&1), region->startptr, region->endptr);
}
void pmc_compact(struct pmc_region * region, int forward, void *bottomptr, void *topptr) {
if (forward) {
void *tmpptr=bottomptr;
- void *lastptr;
while(tmpptr<topptr) {
unsigned int type;
unsigned int size;
if (forwardptr) {
memmove(forwardptr, tmpptr, size);
}
- lastptr=forwardptr+size;
tmpptr+=size;
}
- region->lastptr=lastptr;
} else {
struct ___Object___ *backward=region->lastobj;
struct ___Object___ *lastobj=NULL;