unsigned int bits=(index>48)?32:bitmarkmappingarray[index];
unsigned int bitstotoss=32-bits;
- unsigned int bitstotosspluslobits=bitstotoss-lobits;
- gcmarktbl[hibits]^=((orighi>>(bitstotosspluslobits))<<bitstotosspluslobits);
+
+ if ((bits+lobits)<32) {
+ unsigned int bitstotossminuslobits=bitstotoss-lobits;
+ gcmarktbl[hibits]^=(hipart>>bitstotoss)<<bitstotossminuslobits;
+ } else
+ gcmarktbl[hibits]^=hipart>>lobits;
gcmarktbl[hibits+1]^=(lowpart>>bitstotoss)<<(bitstotoss+revlobits);
}
}
//#define GC_PRINTF if(0) tprintf
//#endif
+#define TR() tprintf("%u\n",__LINE__)
+
// data structures for GC
#define BAMBOO_SMEM_SIZE_L (BAMBOO_SMEM_SIZE * 2)
#define BAMBOO_LARGE_SMEM_BOUND (BAMBOO_SMEM_SIZE_L*NUMCORES4GC)
return length;
}
//good to move objects and update pointers
+
gcmappingtbl[OBJMAPPINGINDEX(origptr)]=toptr;
origptr+=length;
toptr=endtoptr;
}
to->ptr=toptr;
orig->ptr=origptr;
+ gccurr_heaptop-=(unsigned INTPTR)(toptr-toptrinit);
return 0;
}
// NOTE: the objptr should not be NULL and should not be non shared ptr
#define updateObj(objptr) gcmappingtbl[OBJMAPPINGINDEX(objptr)]
-#define UPDATEOBJ(obj, tt) {void *updatetmpptr=obj; if (updatetmpptr!=NULL) obj=updateObj(updatetmpptr);}
-#define UPDATEOBJNONNULL(obj, tt) {void *updatetmpptr=obj; obj=updateObj(updatetmpptr);}
+//#define UPDATEOBJ(obj) {void *updatetmpptr=obj; if (updatetmpptr!=NULL) obj=updateObj(updatetmpptr);if (obj<gcbaseva) tprintf("BAD PTR %x to %x in %u\n", updatetmpptr, obj, __LINE__);}
+#define UPDATEOBJ(obj) {void *updatetmpptr=obj; if (updatetmpptr!=NULL) obj=updateObj(updatetmpptr);}
+#define UPDATEOBJNONNULL(obj) {void *updatetmpptr=obj; obj=updateObj(updatetmpptr);}
INLINE void updategarbagelist(struct garbagelist *listptr) {
for(;listptr!=NULL; listptr=listptr->next) {
for(int i=0; i<listptr->size; i++) {
- UPDATEOBJ(listptr->array[i], i);
+ UPDATEOBJ(listptr->array[i]);
}
}
}
struct parameterwrapper * parameter = queues[j];
struct ObjectHash * set=parameter->objectset;
for(struct ObjectNode * ptr=set->listhead;ptr!=NULL;ptr=ptr->lnext) {
- UPDATEOBJNONNULL(ptr->key, 0);
+ UPDATEOBJNONNULL(ptr->key);
}
ObjectHashrehash(set);
}
if(currtpd != NULL) {
for(int i=0; i<currtpd->numParameters; i++) {
// the parameter can not be NULL
- UPDATEOBJNONNULL(currtpd->parameterArray[i], i);
+ UPDATEOBJNONNULL(currtpd->parameterArray[i]);
}
}
struct taskparamdescriptor *tpd=ptr->src;
for(int i=0; i<tpd->numParameters; i++) {
// the parameter can not be NULL
- UPDATEOBJNONNULL(tpd->parameterArray[i], i);
+ UPDATEOBJNONNULL(tpd->parameterArray[i]);
}
}
genrehash(activetasks);
for(struct QueueItem * tmpobjptr = getHead(&objqueue);tmpobjptr != NULL;tmpobjptr = getNextQueueItem(tmpobjptr)) {
struct transObjInfo * objInfo=(struct transObjInfo *)(tmpobjptr->objectptr);
// the obj can not be NULL
- UPDATEOBJNONNULL(objInfo->objptr, 0);
+ UPDATEOBJNONNULL(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
- UPDATEOBJNONNULL(totransobj->objptr, 0);
+ UPDATEOBJNONNULL(totransobj->objptr);
}
// enqueue lock related info
for(int i = 0; i < runtime_locklen; ++i) {
- UPDATEOBJ(runtime_locks[i].redirectlock, i);
- UPDATEOBJ(runtime_locks[i].value, i);
+ UPDATEOBJ(runtime_locks[i].redirectlock);
+ UPDATEOBJ(runtime_locks[i].value);
}
#endif
// update the bamboo_threadlocks
for(int i = 0; i < bamboo_threadlocks.index; i++) {
// the locked obj can not be NULL
- UPDATEOBJNONNULL(bamboo_threadlocks.locks[i].object, i);
+ UPDATEOBJNONNULL(bamboo_threadlocks.locks[i].object);
}
// update the bamboo_current_thread
- UPDATEOBJ(bamboo_current_thread, 0);
+ UPDATEOBJ(bamboo_current_thread);
// update global thread queue
if(STARTUPCORE == BAMBOO_NUM_OF_CORE) {
unsigned int start = *((unsigned int*)(bamboo_thread_queue+2));
for(int i = thread_counter; i > 0; i--) {
// the thread obj can not be NULL
- UPDATEOBJNONNULL(bamboo_thread_queue[4+start], 0);
+ UPDATEOBJNONNULL(bamboo_thread_queue[4+start]);
start = (start+1)&bamboo_max_thread_num_mask;
}
}
unsigned int size=pointer[0];
for(int i=1; i<=size; i++) {
unsigned int offset=pointer[i];
- UPDATEOBJ(*((void **)(((char *)ptr)+offset)), i);
+ UPDATEOBJ(*((void **)(((char *)ptr)+offset)));
}
#endif
} else if (((unsigned int)pointer)==1) {
struct ArrayObject *ao=(struct ArrayObject *) ptr;
int length=ao->___length___;
for(int j=0; j<length; j++) {
- UPDATEOBJ(((void **)(((char *)&ao->___length___)+sizeof(int)))[j], j);
+ UPDATEOBJ(((void **)(((char *)&ao->___length___)+sizeof(int)))[j]);
}
#ifdef OBJECTHASPOINTERS
pointer=pointerarray[OBJECTTYPE];
for(int i=1; i<=size; i++) {
unsigned int offset=pointer[i];
- UPDATEOBJ(*((void **)(((char *)ptr)+offset)), i);
+ UPDATEOBJ(*((void **)(((char *)ptr)+offset)));
}
#endif
} else {
for(int i=1; i<=size; i++) {
unsigned int offset=pointer[i];
- UPDATEOBJ(*((void **)(((char *)ptr)+offset)), i);
+ UPDATEOBJ(*((void **)(((char *)ptr)+offset)));
}
}
}
}
//push the null check into the mark macro
-//#define MARKOBJ(objptr, ii) {void * marktmpptr=objptr; if (marktmpptr!=NULL) markObj(marktmpptr, __LINE__, ii);}
-//#define MARKOBJNONNULL(objptr, ii) {markObj(objptr, __LINE__, ii);}
-#define MARKOBJ(objptr, ii) {void * marktmpptr=objptr; if (marktmpptr!=NULL) markObj(marktmpptr);}
+//#define MARKOBJ(objptr) {void * marktmpptr=objptr; if (marktmpptr!=NULL) {markObj(marktmpptr);if ((marktmpptr<gcbaseva)||(marktmpptr>(gcbaseva+BAMBOO_SHARED_MEM_SIZE))) tprintf("Bad pointer %x in line %u\n",marktmpptr, __LINE__); }}
-#define MARKOBJNONNULL(objptr, ii) {markObj(objptr);}
+#define MARKOBJ(objptr) {void * marktmpptr=objptr; if (marktmpptr!=NULL) {markObj(marktmpptr);}}
+
+#define MARKOBJNONNULL(objptr) {markObj(objptr);}
// NOTE: the objptr should not be NULL and should be a shared obj
void markObj(void * objptr) {
for(;listptr!=NULL;listptr=listptr->next) {
int size=listptr->size;
for(int i=0; i<size; i++) {
- MARKOBJ(listptr->array[i], i);
+ MARKOBJ(listptr->array[i]);
}
}
}
struct ObjectHash * set=parameter->objectset;
struct ObjectNode * ptr=set->listhead;
for(;ptr!=NULL;ptr=ptr->lnext) {
- MARKOBJNONNULL((void *)ptr->key, 0);
+ MARKOBJNONNULL((void *)ptr->key);
}
}
}
if(currtpd != NULL) {
for(int i=0; i<currtpd->numParameters; i++) {
// currtpd->parameterArray[i] can not be NULL
- MARKOBJNONNULL(currtpd->parameterArray[i], i);
+ MARKOBJNONNULL(currtpd->parameterArray[i]);
}
}
struct taskparamdescriptor *tpd=ptr->src;
for(int i=0; i<tpd->numParameters; i++) {
// the tpd->parameterArray[i] can not be NULL
- MARKOBJNONNULL(tpd->parameterArray[i], i);
+ MARKOBJNONNULL(tpd->parameterArray[i]);
}
}
}
for(;tmpobjptr != NULL;tmpobjptr=getNextQueueItem(tmpobjptr)) {
struct transObjInfo * objInfo=(struct transObjInfo *)(tmpobjptr->objectptr);
// the objptr can not be NULL
- MARKOBJNONNULL(objInfo->objptr, 0);
+ MARKOBJNONNULL(objInfo->objptr);
}
// enqueue cached objs to be transferred
for(;item != NULL;item=getNextQueueItem(item)) {
struct transObjInfo * totransobj=(struct transObjInfo *)(item->objectptr);
// the objptr can not be NULL
- MARKOBJNONNULL(totransobj->objptr, 0);
+ MARKOBJNONNULL(totransobj->objptr);
}
// enqueue lock related info
for(int i = 0; i < runtime_locklen; i++) {
- MARKOBJ((void *)(runtime_locks[i].redirectlock), 0);
- MARKOBJ((void *)(runtime_locks[i].value), i);
+ MARKOBJ((void *)(runtime_locks[i].redirectlock));
+ MARKOBJ((void *)(runtime_locks[i].value));
}
#endif
unsigned int start = *((unsigned int*)(bamboo_thread_queue+2));
for(int i = thread_counter; i > 0; i--) {
// the thread obj can not be NULL
- MARKOBJNONNULL((void *)bamboo_thread_queue[4+start], 0);
+ MARKOBJNONNULL((void *)bamboo_thread_queue[4+start]);
start = (start+1)&bamboo_max_thread_num_mask;
}
}
// enqueue the bamboo_threadlocks
for(int i = 0; i < bamboo_threadlocks.index; i++) {
// the locks can not be NULL
- MARKOBJNONNULL((void *)(bamboo_threadlocks.locks[i].object), i);
+ MARKOBJNONNULL((void *)(bamboo_threadlocks.locks[i].object));
}
// enqueue the bamboo_current_thread
- MARKOBJ(bamboo_current_thread, 0);
+ MARKOBJ(bamboo_current_thread);
#endif
}
for(int i=1; i<=size; i++) {
unsigned int offset=pointer[i];
void * objptr=*((void **)(((char *)ptr)+offset));
- MARKOBJ(objptr, i);
+ MARKOBJ(objptr);
}
#endif
} else if (((unsigned int)pointer)==1) {
int length=ao->___length___;
for(int i=0; i<length; i++) {
void *objptr=((void **)(((char *)&ao->___length___)+sizeof(int)))[i];
- MARKOBJ(objptr, i);
+ MARKOBJ(objptr);
}
#ifdef OBJECTHASPOINTERS
pointer=pointerarray[OBJECTTYPE];
for(int i=1; i<=size; i++) {
unsigned int offset=pointer[i];
void * objptr=*((void **)(((char *)ptr)+offset));
- MARKOBJ(objptr, i);
+ MARKOBJ(objptr);
}
#endif
} else {
for(int i=1; i<=size; i++) {
unsigned int offset=pointer[i];
void * objptr=*((void **)(((char *)ptr)+offset));
- MARKOBJ(objptr, i);
+ MARKOBJ(objptr);
}
}
}
// mark phase
while(MARKPHASE == gc_status_info.gcphase) {
int counter = 0;
-
while(gc_moreItems()) {
sendStall = false;
gc_status_info.gcbusystatus = true;
void * ptr = gc_dequeue();
-
unsigned int size = 0;
unsigned int type = 0;
bool islarge=isLarge(ptr, &type, &size);
unsigned int iunits = ALIGNUNITS(size);
-
setLengthMarked(ptr,iunits);
-
+
if(islarge) {
// ptr is a large object and not marked or enqueued
printf("NEED TO SUPPORT LARGE OBJECTS!\n");
unsigned int isize=iunits<<ALIGNMENTSHIFT;
gccurr_heaptop += isize;
}
-
// scan the pointers in object
scanPtrsInObj(ptr, type);
}
sendStall = true;
}
}
-
if(BAMBOO_NUM_OF_CORE == STARTUPCORE)
checkMarkStatus();
}
-
- BAMBOO_CACHE_MF();
}
#endif // MULTICORE_GC
gc(stackptr);
}
p = BAMBOO_SHARE_MEM_CALLOC(isize); // calloc(m, isize);
-
if(p == NULL) {
// no more global shared memory
if(hasgc < 5) {