//Comment: should build dummy byte arrays to allow skipping data...
void pmc_countbytes(struct pmc_unit * unit, void *bottomptr, void *topptr) {
- tprintf("%x--%x\n",bottomptr, topptr);
void *tmpptr=bottomptr;
unsigned int totalbytes=0;
while(tmpptr<topptr) {
region->highunit=endregion;
region->startptr=(startregion==0)?gcbaseva:pmc_heapptr->units[startregion-1].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) {
//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 {
//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));
if (!fwddirection) {
//reset boundaries of beginning units
- while(endunit<forwardptr) {
+ while(endunit<=region->lastptr) {
pmc_heapptr->units[currunit].endptr=endunit;
currunit++;
endunit=pmc_unitend(currunit);
//reset boundaries of end units
unsigned int lastunit=region->highunit-1;
void * lastunitend=pmc_unitend(lastunit);
- while(lastunitend>forwardptr) {
+ while(lastunitend>=region->lastptr) {
pmc_heapptr->units[lastunit].endptr=lastunitend;
lastunit--;
lastunitend=pmc_unitend(lastunit);
if (((struct ___Object___ *)tmpptr)->marked) {
((struct ___Object___ *)tmpptr)->marked=forwardptr;
+ tprintf("Forwarding %x->%x\n", tmpptr, forwardptr);
void *newforwardptr=forwardptr+size;
- while(newforwardptr>endunit) {
+ while(newforwardptr>=endunit) {
pmc_heapptr->regions[currunit].endptr=newforwardptr;
currunit++;
endunit=pmc_unitend(currunit);
}
tmpptr+=size;
}
+ tprintf("forwardptr=%x\n",forwardptr);
region->lastobj=lastobj;
}
#include "runtime_arch.h"
#include "pmc_forward.h"
#include "pmc_refupdate.h"
+#include "multicoremgc.h"
+#include "runtime.h"
+#include "thread.h"
#define pmcupdateObj(objptr) ((void *)((struct ___Object___ *)objptr)->marked)
-#define PMCUPDATEOBJ(obj) {void *updatetmpptr=obj; if (updatetmpptr!=NULL) {obj=pmcupdateObj(updatetmpptr);}}
+#define PMCUPDATEOBJ(obj) {void *updatetmpptr=obj; if (updatetmpptr!=NULL) {obj=pmcupdateObj(updatetmpptr);if (obj==NULL) {tprintf("BAD REF UPDATE %x->%x in %u\n",updatetmpptr,obj,__LINE__);}}}
-#define PMCUPDATEOBJNONNULL(obj) {void *updatetmpptr=obj; obj=pmcupdateObj(updatetmpptr);}
+#define PMCUPDATEOBJNONNULL(obj) {void *updatetmpptr=obj; obj=pmcupdateObj(updatetmpptr);if (obj==NULL) {tprintf("BAD REF UPDATE in %x->%x %u\n",updatetmpptr,obj,__LINE__);}}
void pmc_updatePtrs(void *ptr, int type) {
unsigned int * pointer=pointerarray[type];
}
}
-void pmc_doreferenceupdate() {
+void pmc_updategarbagelist(struct garbagelist *listptr) {
+ for(;listptr!=NULL; listptr=listptr->next) {
+ for(int i=0; i<listptr->size; i++) {
+ PMCUPDATEOBJ(listptr->array[i]);
+ }
+ }
+}
+
+void pmc_updateRuntimePtrs(struct garbagelist * stackptr) {
+ // update current stack
+ pmc_updategarbagelist(stackptr);
+
+ // update static pointers global_defs_p
+ if(STARTUPCORE == BAMBOO_NUM_OF_CORE) {
+ pmc_updategarbagelist((struct garbagelist *)global_defs_p);
+ }
+
+#ifdef TASK
+ // update objectsets
+ if(BAMBOO_NUM_OF_CORE < NUMCORESACTIVE) {
+ for(int i=0; i<NUMCLASSES; i++) {
+ struct parameterwrapper ** queues = objectqueues[BAMBOO_NUM_OF_CORE][i];
+ int length = numqueues[BAMBOO_NUM_OF_CORE][i];
+ for(int j = 0; j < length; ++j) {
+ struct parameterwrapper * parameter = queues[j];
+ struct ObjectHash * set=parameter->objectset;
+ for(struct ObjectNode * ptr=set->listhead;ptr!=NULL;ptr=ptr->lnext) {
+ PMCUPDATEOBJNONNULL(ptr->key);
+ }
+ ObjectHashrehash(set);
+ }
+ }
+ }
+
+ // update current task descriptor
+ if(currtpd != NULL) {
+ for(int i=0; i<currtpd->numParameters; i++) {
+ // the parameter can not be NULL
+ PMCUPDATEOBJNONNULL(currtpd->parameterArray[i]);
+ }
+ }
+
+ // update active tasks
+ if(activetasks != NULL) {
+ for(struct genpointerlist * ptr=activetasks->list;ptr!=NULL;ptr=ptr->inext){
+ struct taskparamdescriptor *tpd=ptr->src;
+ for(int i=0; i<tpd->numParameters; i++) {
+ // the parameter can not be NULL
+ PMCUPDATEOBJNONNULL(tpd->parameterArray[i]);
+ }
+ }
+ genrehash(activetasks);
+ }
+
+ // update cached transferred obj
+ for(struct QueueItem * tmpobjptr = getHead(&objqueue);tmpobjptr != NULL;tmpobjptr = getNextQueueItem(tmpobjptr)) {
+ struct transObjInfo * objInfo=(struct transObjInfo *)(tmpobjptr->objectptr);
+ // the obj can not be NULL
+ PMCUPDATEOBJNONNULL(objInfo->objptr);
+ }
+
+ // update cached objs to be transferred
+ for(struct QueueItem * item = getHead(totransobjqueue);item != NULL;item = getNextQueueItem(item)) {
+ struct transObjInfo * totransobj = (struct transObjInfo *)(item->objectptr);
+ // the obj can not be NULL
+ PMCUPDATEOBJNONNULL(totransobj->objptr);
+ }
+
+ // enqueue lock related info
+ for(int i = 0; i < runtime_locklen; ++i) {
+ PMCUPDATEOBJ(runtime_locks[i].redirectlock);
+ PMCUPDATEOBJ(runtime_locks[i].value);
+ }
+#endif
+
+#ifdef MGC
+ // update the bamboo_threadlocks
+ for(int i = 0; i < bamboo_threadlocks.index; i++) {
+ // the locked obj can not be NULL
+ PMCUPDATEOBJNONNULL(bamboo_threadlocks.locks[i].object);
+ }
+
+ // update the bamboo_current_thread
+ PMCUPDATEOBJ(bamboo_current_thread);
+
+ // update global thread queue
+ if(STARTUPCORE == BAMBOO_NUM_OF_CORE) {
+ unsigned int thread_counter = *((unsigned int*)(bamboo_thread_queue+1));
+ if(thread_counter > 0) {
+ unsigned int start = *((unsigned int*)(bamboo_thread_queue+2));
+ for(int i = thread_counter; i > 0; i--) {
+ // the thread obj can not be NULL
+ PMCUPDATEOBJNONNULL(*((void **)&bamboo_thread_queue[4+start]));
+ start = (start+1)&bamboo_max_thread_num_mask;
+ }
+ }
+ unlockthreadqueue();
+ }
+#endif
+}
+
+
+void pmc_doreferenceupdate(struct garbagelist *stackptr) {
struct pmc_region * region=&pmc_heapptr->regions[BAMBOO_NUM_OF_CORE];
+ pmc_updateRuntimePtrs(stackptr);
pmc_referenceupdate(region->startptr, region->endptr);
}