if (startregion==-1)
return;
if (endregion==-1)
- endregion=NUMPMCUNITS-1;
+ endregion=NUMPMCUNITS;
region->lowunit=startregion;
region->highunit=endregion;
region->startptr=(startregion==0)?gcbaseva:pmc_heapptr->units[startregion-1].endptr;
- region->endptr=pmc_heapptr->units[endregion].endptr;
-
+ region->endptr=pmc_heapptr->units[endregion-1].endptr;
+ tprintf("startregion=%u gcbaseva=%x\n", startregion, gcbaseva);
+ tprintf("totalbytes=%u\n", totalbytes);
if (BAMBOO_NUM_OF_CORE&1) {
- //backward direction
+ //upward in memory
region->lastptr=region->endptr-totalbytes;
+ tprintf("(up) Assigning lastptr for %u to %x ep=%x\n", BAMBOO_NUM_OF_CORE, region->lastptr, region->endptr);
} else {
- //forward direction
+ //downward in memory
region->lastptr=region->startptr+totalbytes;
+ tprintf("(down) Assigning lastptr for %u to %x sp=%x\n", BAMBOO_NUM_OF_CORE, region->lastptr, region->startptr);
}
pmc_forward(region, totalbytes, region->startptr, region->endptr, !(BAMBOO_NUM_OF_CORE&1));
}
+//fwddirection=1 means move things to lower addresses
void pmc_forward(struct pmc_region *region, unsigned int totalbytes, void *bottomptr, void *topptr, bool fwddirection) {
void *tmpptr=bottomptr;
void *forwardptr=fwddirection?bottomptr:(topptr-totalbytes);
unsigned int lastunit=region->highunit-1;
void * lastunitend=pmc_unitend(lastunit);
while(lastunitend>forwardptr) {
- pmc_heapptr->units[currunit].endptr=lastunitend;
+ pmc_heapptr->units[lastunit].endptr=lastunitend;
lastunit--;
lastunitend=pmc_unitend(lastunit);
}
} else
pmc_heapptr->regions[i].lastptr=pmc_heapptr->units[i*4-1].endptr;
pmc_heapptr->regions[i].lowunit=4*i;
- pmc_heapptr->regions[i].highunit=4*i+3;
+ pmc_heapptr->regions[i].highunit=4*(i+1);
pmc_heapptr->regions[i+1].lastptr=pmc_heapptr->units[(i+1)*4+3].endptr;
pmc_heapptr->regions[i+1].lowunit=4*(i+1);
- pmc_heapptr->regions[i+1].highunit=4*(i+1)+3;
+ pmc_heapptr->regions[i+1].highunit=4*(i+2);
}
for(int i=0;i<NUMCORES4GC;i++) {
tprintf("%u lastptr=%x\n", i, pmc_heapptr->regions[i].lastptr);
struct pmc_region *region=&pmc_heapptr->regions[i];
unsigned int startindex=region->lowunit;
unsigned int endindex=pmc_heapptr->regions[i+1].highunit;
- tprintf("Padding %x-%x\n",startptr, finishptr);
for(unsigned int index=startindex;index<endindex;index++) {
void *ptr=pmc_unitend(index);
+ tprintf("index=%u ptr=%x\n", index, ptr);
if ((ptr>startptr)&&(ptr<=finishptr)) {
pmc_heapptr->units[index].endptr=ptr;
padspace(startptr, (unsigned int)(ptr-startptr));
startptr=ptr;
}
- if (ptr>finishptr)
+ if (ptr>finishptr) {
+ void *prevunitptr=pmc_heapptr->units[index-1].endptr;
+ padspace(startptr, finishptr-startptr);
break;
+ }
}
}
}
if (bamboo_smem_size) {
- tprintf("Padding %u bytes at %x\n", bamboo_smem_size, bamboo_cur_msp);
padspace(bamboo_cur_msp, bamboo_smem_size);
}
tmc_spin_barrier_wait(&pmc_heapptr->barrier);
//reset memory allocation
bamboo_cur_msp=NULL;
bamboo_smem_size=0;
+ tprintf("done\n");
if (BAMBOO_NUM_OF_CORE==STARTUPCORE) {
tmc_spin_barrier_wait(&pmc_heapptr->barrier);
void padspace(void *ptr, unsigned int length) {
//zero small blocks
+ tprintf("Padspace from %x to %x\n", ptr, ptr+length);
if (length<sizeof(struct ArrayObject)) {
BAMBOO_MEMSET_WH(ptr,0,length);
} else {
//generate fake arrays for big blocks
struct ArrayObject *ao=(struct ArrayObject *)ptr;
- ao->type=CHARARRAYTYPE;
+ ao->type=BYTEARRAYTYPE;
unsigned arraylength=length-sizeof(struct ArrayObject);
ao->___length___=arraylength;
+ ao->marked=0;
}
}
void *startptr=pmc_heapptr->regions[i].lastptr;
void *finishptr=pmc_heapptr->regions[i+1].lastptr;
+ tprintf("%u %x - %x\n",i, startptr, finishptr);
+
if ((finishptr-startptr)>memcheck) {
struct pmc_region *region=&pmc_heapptr->regions[i];
tmc_spin_mutex_lock(®ion->lock);
*numbytesallocated=(unsigned int)(newstartptr-startptr);
tmc_spin_mutex_unlock(®ion->lock);
+ tprintf("fptr=%x\n", finishptr);
+ tprintf("Allocing %x to %x\n", startptr, newstartptr);
return startptr;
} while(0);
tmc_spin_mutex_unlock(®ion->lock);
#define pmcupdateObj(objptr) ((void *)((struct ___Object___ *)objptr)->marked)
-#define PMCUPDATEOBJ(obj) {void *updatetmpptr=obj; tprintf("UP%x\n", updatetmpptr); if (updatetmpptr!=NULL) {obj=pmcupdateObj(updatetmpptr);}}
+#define PMCUPDATEOBJ(obj) {void *updatetmpptr=obj; if (updatetmpptr!=NULL) {obj=pmcupdateObj(updatetmpptr);}}
#define PMCUPDATEOBJNONNULL(obj) {void *updatetmpptr=obj; obj=pmcupdateObj(updatetmpptr);}
unsigned int size;
gettype_size(tmpptr, &type, &size);
size=((size-1)&(~(ALIGNMENTSIZE-1)))+ALIGNMENTSIZE;
- tprintf("%x typ=%u sz=%u\n", tmpptr, type, size);
if (!type) {
tmpptr+=ALIGNMENTSIZE;
continue;
pmc_updatePtrs(tmpptr, type);
}
tmpptr+=size;
- tprintf("INC\n");
}
}