From: bdemsky Date: Fri, 15 Apr 2011 23:20:10 +0000 (+0000) Subject: split garbage collector into three files... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e6f782d8a5f62830f4fe7239118668171f048f39;p=IRC.git split garbage collector into three files... --- diff --git a/Robust/src/Runtime/garbage.c b/Robust/src/Runtime/garbage.c index 0a267c08..3b995eae 100644 --- a/Robust/src/Runtime/garbage.c +++ b/Robust/src/Runtime/garbage.c @@ -37,7 +37,6 @@ extern deque* deques; #include "delaycomp.h" #endif - #define NUMPTRS 100 #ifndef INITIALHEAPSIZE_MB @@ -75,10 +74,6 @@ __thread struct listitem litem; #endif #endif -#ifdef MLP -__thread SESEcommon* seseCommon; -#endif - //Need to check if pointers are transaction pointers //this also catches the special flag value of 1 for local copies #ifdef DSTM @@ -305,20 +300,6 @@ int moreItems() { return 1; } -#ifdef TASK -struct pointerblock *taghead=NULL; -int tagindex=0; - -void enqueuetag(struct ___TagDescriptor___ *ptr) { - if (tagindex==NUMPTRS) { - struct pointerblock * tmp=malloc(sizeof(struct pointerblock)); - tmp->next=taghead; - taghead=tmp; - tagindex=0; - } - taghead->ptrs[tagindex++]=ptr; -} -#endif #if defined(STM)||defined(THREADS)||defined(MLP) #ifndef MAC @@ -384,128 +365,6 @@ void doinitstuff() { #endif } -void searchoojroots() { -#ifdef MLP -#ifdef SQUEUE - { - int i; - deque* dq; - dequeItem *di; - int j; - - // goes over ready-to-run SESEs - for( i = 0; i < numWorkSchedWorkers; ++i ) { - dq = &(deques[i]); - - di=dq->head; - - do { - // check all the relevant indices of this - // node in the deque, noting if we are in - // the top/bottom node which can be partially - // full - - // WHAT? - //SESEcommon* common = (SESEcommon*) n->itsDataArr[j]; - //if(common==seseCommon){ - // skip the current running SESE - // continue; - //} - di=(dequeItem *) EXTRACTPTR((INTPTR)di); - SESEcommon* seseRec = (SESEcommon*) di->work; - if (seseRec!=NULL) { - struct garbagelist* gl = (struct garbagelist*) &(seseRec[1]); - struct garbagelist* glroot = gl; - - updateAscendantSESE( seseRec ); - - while( gl != NULL ) { - int k; - for( k = 0; k < gl->size; k++ ) { - void* orig = gl->array[k]; - ENQUEUE( orig, gl->array[k] ); - } - gl = gl->next; - } - } - // we only have to move across the nodes - // of the deque if the top and bottom are - // not the same already - di=di->next; - } while( di !=NULL) ; - } - } -#else - { - int i; - deque* dq; - dequeNode* botNode; - int botIndx; - dequeNode* topNode; - int topIndx; - dequeNode* n; - int j; - int jLo; - int jHi; - - // goes over ready-to-run SESEs - for( i = 0; i < numWorkSchedWorkers; ++i ) { - dq = &(deques[i]); - - botNode = dqDecodePtr( dq->bottom ); - botIndx = dqDecodeIdx( dq->bottom ); - - topNode = dqDecodePtr( dq->top ); - topIndx = dqDecodeIdx( dq->top ); - - - n = botNode; - do { - // check all the relevant indices of this - // node in the deque, noting if we are in - // the top/bottom node which can be partially - // full - if( n == botNode ) { jLo = botIndx; } else { jLo = 0; } - if( n == topNode ) { jHi = topIndx; } else { jHi = DQNODE_ARRAYSIZE; } - - for( j = jLo; j < jHi; ++j ) { - - // WHAT? - //SESEcommon* common = (SESEcommon*) n->itsDataArr[j]; - //if(common==seseCommon){ - // continue; - //} - - SESEcommon* seseRec = (SESEcommon*) n->itsDataArr[j]; - - struct garbagelist* gl = (struct garbagelist*) &(seseRec[1]); - struct garbagelist* glroot = gl; - - updateAscendantSESE( seseRec ); - - while( gl != NULL ) { - int k; - for( k = 0; k < gl->size; k++ ) { - void* orig = gl->array[k]; - ENQUEUE( orig, gl->array[k] ); - } - gl = gl->next; - } - } - - // we only have to move across the nodes - // of the deque if the top and bottom are - // not the same already - if( botNode != topNode ) { - n = n->next; - } - } while( n != topNode ); - } - } -#endif -#endif -} - void searchglobalroots() { #if defined(THREADS)||defined(DSTM)||defined(STM)||defined(MLP) { @@ -520,100 +379,7 @@ void searchglobalroots() { } -void searchtaskroots() { -#ifdef TASK - { - /* Update objectsets */ - int i; - for(i=0; iobjectset; - struct ObjectNode * ptr=set->listhead; - while(ptr!=NULL) { - void *orig=(void *)ptr->key; - ENQUEUE(orig, *((void **)(&ptr->key))); - ptr=ptr->lnext; - } - ObjectHashrehash(set); /* Rehash the table */ - p=p->next; - } -#endif - } - } - -#ifndef FASTCHECK - if (forward!=NULL) { - struct cnode * ptr=forward->listhead; - while(ptr!=NULL) { - void * orig=(void *)ptr->key; - ENQUEUE(orig, *((void **)(&ptr->key))); - ptr=ptr->lnext; - } - crehash(forward); /* Rehash the table */ - } - - if (reverse!=NULL) { - struct cnode * ptr=reverse->listhead; - while(ptr!=NULL) { - void *orig=(void *)ptr->val; - ENQUEUE(orig, *((void**)(&ptr->val))); - ptr=ptr->lnext; - } - } -#endif - - { - struct RuntimeNode * ptr=fdtoobject->listhead; - while(ptr!=NULL) { - void *orig=(void *)ptr->data; - ENQUEUE(orig, *((void**)(&ptr->data))); - ptr=ptr->lnext; - } - } - { - /* Update current task descriptor */ - int i; - for(i=0; inumParameters; i++) { - void *orig=currtpd->parameterArray[i]; - ENQUEUE(orig, currtpd->parameterArray[i]); - } - - } - - /* Update active tasks */ - { - struct genpointerlist * ptr=activetasks->list; - while(ptr!=NULL) { - struct taskparamdescriptor *tpd=ptr->src; - int i; - for(i=0; inumParameters; i++) { - void * orig=tpd->parameterArray[i]; - ENQUEUE(orig, tpd->parameterArray[i]); - } - ptr=ptr->inext; - } - genrehash(activetasks); - } - - /* Update failed tasks */ - { - struct genpointerlist * ptr=failedtasks->list; - while(ptr!=NULL) { - struct taskparamdescriptor *tpd=ptr->src; - int i; - for(i=0; inumParameters; i++) { - void * orig=tpd->parameterArray[i]; - ENQUEUE(orig, tpd->parameterArray[i]); - } - ptr=ptr->inext; - } - genrehash(failedtasks); - } -#endif -} void searchstack(struct garbagelist *stackptr) { while(stackptr!=NULL) { @@ -626,6 +392,20 @@ void searchstack(struct garbagelist *stackptr) { } } +#ifdef JNI +void searchjnitable(struct jnireferences *jniptr) { + while(jniptr!=NULL) { + int i; + //update table + for(i=0;iindex;i++) { + ENQUEUE(jniptr->array[i]->ref, jniptr->array[i]->ref); + } + //go to next table + jniptr=jniptr->next; + } +} +#endif + #if defined(THREADS)||defined(DSTM)||defined(STM)||defined(MLP) void searchthreadroots(struct garbagelist * stackptr) { @@ -648,6 +428,9 @@ void searchthreadroots(struct garbagelist * stackptr) { ENQUEUE(orig, lvector->locks[i].object); } #endif +#ifdef JNI + searchjnitable(*listptr->jnirefs); +#endif #ifdef STM if ((*listptr->tc_table)!=NULL) { fixtable(listptr->tc_table, listptr->tc_list, listptr->tc_structs, listptr->tc_size); @@ -684,8 +467,12 @@ void searchroots(struct garbagelist * stackptr) { ENQUEUE(___fcrevert___, ___fcrevert___); #endif searchglobalroots(); +#ifdef TASK searchtaskroots(); +#endif +#ifdef MLP searchoojroots(); +#endif } @@ -768,65 +555,6 @@ void collect(struct garbagelist * stackptr) { #endif } -#ifdef TASK -/* Fix up the references from tags. This can't be done earlier, - because we don't want tags to keep objects alive */ -void fixtags() { - while(taghead!=NULL) { - int i; - struct pointerblock *tmp=taghead->next; - for(i=0; iptrs[i]; - struct ___Object___ *obj=tagd->flagptr; - struct ___TagDescriptor___ *copy=((struct ___TagDescriptor___**)tagd)[1]; - if (obj==NULL) { - /* Zero object case */ - } else if (obj->type==-1) { - /* Single object case */ - copy->flagptr=((struct ___Object___**)obj)[1]; - } else if (obj->type==OBJECTARRAYTYPE) { - /* Array case */ - struct ArrayObject *ao=(struct ArrayObject *) obj; - int livecount=0; - int j; - int k=0; - struct ArrayObject *aonew; - - /* Count live objects */ - for(j=0; j___cachedCode___; j++) { - struct ___Object___ * tobj=ARRAYGET(ao, struct ___Object___ *, j); - if (tobj->type==-1) - livecount++; - } - - livecount=((livecount-1)/OBJECTARRAYINTERVAL+1)*OBJECTARRAYINTERVAL; - aonew=(struct ArrayObject *) tomalloc(sizeof(struct ArrayObject)+sizeof(struct ___Object___*)*livecount); - memcpy(aonew, ao, sizeof(struct ArrayObject)); - aonew->type=OBJECTARRAYTYPE; - aonew->___length___=livecount; - copy->flagptr=aonew; - for(j=0; j___cachedCode___; j++) { - struct ___Object___ * tobj=ARRAYGET(ao, struct ___Object___ *, j); - if (tobj->type==-1) { - struct ___Object___ * tobjcpy=((struct ___Object___**)tobj)[1]; - ARRAYSET(aonew, struct ___Object___*, k++,tobjcpy); - } - } - aonew->___cachedCode___=k; - for(; kflagptr=NULL; - } - } - free(taghead); - taghead=tmp; - tagindex=NUMPTRS; - } -} -#endif void * tomalloc(int size) { void * ptr=to_heapptr; @@ -1124,147 +852,6 @@ int gc_createcopy(void * orig, void ** copy_ptr) { } } -#ifdef MLP -updateForwardList(struct Queue *forwardList, int prevUpdate){ - - struct QueueItem * fqItem=getHead(forwardList); - while(fqItem!=NULL){ - SESEcommon* seseRec = (SESEcommon*)(fqItem->objectptr); - struct garbagelist * gl=(struct garbagelist *)&(seseRec[1]); - if(prevUpdate==TRUE){ - updateAscendantSESE(seseRec); - } - // do something here - while(gl!=NULL) { - int i; - for(i=0; isize; i++) { - void * orig=gl->array[i]; - ENQUEUE(orig, gl->array[i]); - } - gl=gl->next; - } - // iterate forwarding list of seseRec - struct Queue* fList=&seseRec->forwardList; - updateForwardList(fList,prevUpdate); - fqItem=getNextQueueItem(fqItem); - } - -} - -updateMemoryQueue(SESEcommon* seseParent){ - // update memory queue - int i,binidx; - for(i=0; inumMemoryQueue; i++){ - MemoryQueue *memoryQueue=seseParent->memoryQueueArray[i]; - MemoryQueueItem *memoryItem=memoryQueue->head; - while(memoryItem!=NULL){ - if(memoryItem->type==HASHTABLE){ - Hashtable *ht=(Hashtable*)memoryItem; - for(binidx=0; binidxarray[binidx]; - BinItem *binItem=bin->head; - while(binItem!=NULL){ - if(binItem->type==READBIN){ - ReadBinItem* readBinItem=(ReadBinItem*)binItem; - int ridx; - for(ridx=0; ridxindex; ridx++){ - REntry *rentry=readBinItem->array[ridx]; - SESEcommon* seseRec = (SESEcommon*)(rentry->seseRec); - struct garbagelist * gl= (struct garbagelist *)&(seseRec[1]); - updateAscendantSESE(seseRec); - while(gl!=NULL) { - int i; - for(i=0; isize; i++) { - void * orig=gl->array[i]; - ENQUEUE(orig, gl->array[i]); - } - gl=gl->next; - } - } - }else{ //writebin - REntry *rentry=((WriteBinItem*)binItem)->val; - SESEcommon* seseRec = (SESEcommon*)(rentry->seseRec); - struct garbagelist * gl= (struct garbagelist *)&(seseRec[1]); - updateAscendantSESE(seseRec); - while(gl!=NULL) { - int i; - for(i=0; isize; i++) { - void * orig=gl->array[i]; - ENQUEUE(orig, gl->array[i]); - } - gl=gl->next; - } - } - binItem=binItem->next; - } - } - }else if(memoryItem->type==VECTOR){ - Vector *vt=(Vector*)memoryItem; - int idx; - for(idx=0; idxindex; idx++){ - REntry *rentry=vt->array[idx]; - if(rentry!=NULL){ - SESEcommon* seseRec = (SESEcommon*)(rentry->seseRec); - struct garbagelist * gl= (struct garbagelist *)&(seseRec[1]); - updateAscendantSESE(seseRec); - while(gl!=NULL) { - int i; - for(i=0; isize; i++) { - void * orig=gl->array[i]; - ENQUEUE(orig, gl->array[i]); - } - gl=gl->next; - } - } - } - }else if(memoryItem->type==SINGLEITEM){ - SCC *scc=(SCC*)memoryItem; - REntry *rentry=scc->val; - if(rentry!=NULL){ - SESEcommon* seseRec = (SESEcommon*)(rentry->seseRec); - struct garbagelist * gl= (struct garbagelist *)&(seseRec[1]); - updateAscendantSESE(seseRec); - while(gl!=NULL) { - int i; - for(i=0; isize; i++) { - void * orig=gl->array[i]; - ENQUEUE(orig, gl->array[i]); - } - gl=gl->next; - } - } - } - memoryItem=memoryItem->next; - } - } - } - - updateAscendantSESE(SESEcommon* seseRec){ - int prevIdx; - for(prevIdx=0; prevIdx<(seseRec->numDependentSESErecords); prevIdx++){ - SESEcommon* prevSESE = (SESEcommon*) - ( - ((INTPTR)seseRec) + - seseRec->offsetToDepSESErecords + - (sizeof(INTPTR)*prevIdx) - ); - - if(prevSESE!=NULL){ - struct garbagelist * prevgl=(struct garbagelist *)&(((SESEcommon*)(prevSESE))[1]); - while(prevgl!=NULL) { - int i; - for(i=0; isize; i++) { - void * orig=prevgl->array[i]; - ENQUEUE(orig, prevgl->array[i]); - } - prevgl=prevgl->next; - } - } - } - - } -#endif - int within(void *ptr){ //debug function if(ptr>curr_heapptr || ptr #ifndef MAC +__thread struct jnireferences * jnirefs; + struct _jobject * getwrapped(void * objptr) { if ((jnirefs->index)>=MAXJNIREFS) printf("OVERFLOW IN JOBJECT\n"); diff --git a/Robust/src/Runtime/oojgarbage.c b/Robust/src/Runtime/oojgarbage.c new file mode 100644 index 00000000..8a14558f --- /dev/null +++ b/Robust/src/Runtime/oojgarbage.c @@ -0,0 +1,262 @@ +#include "garbage.h" + +#ifdef MLP +__thread SESEcommon* seseCommon; + +void searchoojroots() { +#ifdef SQUEUE + { + int i; + deque* dq; + dequeItem *di; + int j; + + // goes over ready-to-run SESEs + for( i = 0; i < numWorkSchedWorkers; ++i ) { + dq = &(deques[i]); + + di=dq->head; + + do { + // check all the relevant indices of this + // node in the deque, noting if we are in + // the top/bottom node which can be partially + // full + + // WHAT? + //SESEcommon* common = (SESEcommon*) n->itsDataArr[j]; + //if(common==seseCommon){ + // skip the current running SESE + // continue; + //} + di=(dequeItem *) EXTRACTPTR((INTPTR)di); + SESEcommon* seseRec = (SESEcommon*) di->work; + if (seseRec!=NULL) { + struct garbagelist* gl = (struct garbagelist*) &(seseRec[1]); + struct garbagelist* glroot = gl; + + updateAscendantSESE( seseRec ); + + while( gl != NULL ) { + int k; + for( k = 0; k < gl->size; k++ ) { + void* orig = gl->array[k]; + ENQUEUE( orig, gl->array[k] ); + } + gl = gl->next; + } + } + // we only have to move across the nodes + // of the deque if the top and bottom are + // not the same already + di=di->next; + } while( di !=NULL) ; + } + } +#else + { + int i; + deque* dq; + dequeNode* botNode; + int botIndx; + dequeNode* topNode; + int topIndx; + dequeNode* n; + int j; + int jLo; + int jHi; + + // goes over ready-to-run SESEs + for( i = 0; i < numWorkSchedWorkers; ++i ) { + dq = &(deques[i]); + + botNode = dqDecodePtr( dq->bottom ); + botIndx = dqDecodeIdx( dq->bottom ); + + topNode = dqDecodePtr( dq->top ); + topIndx = dqDecodeIdx( dq->top ); + + + n = botNode; + do { + // check all the relevant indices of this + // node in the deque, noting if we are in + // the top/bottom node which can be partially + // full + if( n == botNode ) { jLo = botIndx; } else { jLo = 0; } + if( n == topNode ) { jHi = topIndx; } else { jHi = DQNODE_ARRAYSIZE; } + + for( j = jLo; j < jHi; ++j ) { + + // WHAT? + //SESEcommon* common = (SESEcommon*) n->itsDataArr[j]; + //if(common==seseCommon){ + // continue; + //} + + SESEcommon* seseRec = (SESEcommon*) n->itsDataArr[j]; + + struct garbagelist* gl = (struct garbagelist*) &(seseRec[1]); + struct garbagelist* glroot = gl; + + updateAscendantSESE( seseRec ); + + while( gl != NULL ) { + int k; + for( k = 0; k < gl->size; k++ ) { + void* orig = gl->array[k]; + ENQUEUE( orig, gl->array[k] ); + } + gl = gl->next; + } + } + + // we only have to move across the nodes + // of the deque if the top and bottom are + // not the same already + if( botNode != topNode ) { + n = n->next; + } + } while( n != topNode ); + } + } +#endif +} + +updateForwardList(struct Queue *forwardList, int prevUpdate) { + struct QueueItem * fqItem=getHead(forwardList); + while(fqItem!=NULL){ + SESEcommon* seseRec = (SESEcommon*)(fqItem->objectptr); + struct garbagelist * gl=(struct garbagelist *)&(seseRec[1]); + if(prevUpdate==TRUE){ + updateAscendantSESE(seseRec); + } + // do something here + while(gl!=NULL) { + int i; + for(i=0; isize; i++) { + void * orig=gl->array[i]; + ENQUEUE(orig, gl->array[i]); + } + gl=gl->next; + } + // iterate forwarding list of seseRec + struct Queue* fList=&seseRec->forwardList; + updateForwardList(fList,prevUpdate); + fqItem=getNextQueueItem(fqItem); + } + +} + +updateMemoryQueue(SESEcommon* seseParent){ + // update memory queue + int i,binidx; + for(i=0; inumMemoryQueue; i++){ + MemoryQueue *memoryQueue=seseParent->memoryQueueArray[i]; + MemoryQueueItem *memoryItem=memoryQueue->head; + while(memoryItem!=NULL){ + if(memoryItem->type==HASHTABLE){ + Hashtable *ht=(Hashtable*)memoryItem; + for(binidx=0; binidxarray[binidx]; + BinItem *binItem=bin->head; + while(binItem!=NULL){ + if(binItem->type==READBIN){ + ReadBinItem* readBinItem=(ReadBinItem*)binItem; + int ridx; + for(ridx=0; ridxindex; ridx++){ + REntry *rentry=readBinItem->array[ridx]; + SESEcommon* seseRec = (SESEcommon*)(rentry->seseRec); + struct garbagelist * gl= (struct garbagelist *)&(seseRec[1]); + updateAscendantSESE(seseRec); + while(gl!=NULL) { + int i; + for(i=0; isize; i++) { + void * orig=gl->array[i]; + ENQUEUE(orig, gl->array[i]); + } + gl=gl->next; + } + } + }else{ //writebin + REntry *rentry=((WriteBinItem*)binItem)->val; + SESEcommon* seseRec = (SESEcommon*)(rentry->seseRec); + struct garbagelist * gl= (struct garbagelist *)&(seseRec[1]); + updateAscendantSESE(seseRec); + while(gl!=NULL) { + int i; + for(i=0; isize; i++) { + void * orig=gl->array[i]; + ENQUEUE(orig, gl->array[i]); + } + gl=gl->next; + } + } + binItem=binItem->next; + } + } + }else if(memoryItem->type==VECTOR){ + Vector *vt=(Vector*)memoryItem; + int idx; + for(idx=0; idxindex; idx++){ + REntry *rentry=vt->array[idx]; + if(rentry!=NULL){ + SESEcommon* seseRec = (SESEcommon*)(rentry->seseRec); + struct garbagelist * gl= (struct garbagelist *)&(seseRec[1]); + updateAscendantSESE(seseRec); + while(gl!=NULL) { + int i; + for(i=0; isize; i++) { + void * orig=gl->array[i]; + ENQUEUE(orig, gl->array[i]); + } + gl=gl->next; + } + } + } + }else if(memoryItem->type==SINGLEITEM){ + SCC *scc=(SCC*)memoryItem; + REntry *rentry=scc->val; + if(rentry!=NULL){ + SESEcommon* seseRec = (SESEcommon*)(rentry->seseRec); + struct garbagelist * gl= (struct garbagelist *)&(seseRec[1]); + updateAscendantSESE(seseRec); + while(gl!=NULL) { + int i; + for(i=0; isize; i++) { + void * orig=gl->array[i]; + ENQUEUE(orig, gl->array[i]); + } + gl=gl->next; + } + } + } + memoryItem=memoryItem->next; + } + } + } + + updateAscendantSESE(SESEcommon* seseRec){ + int prevIdx; + for(prevIdx=0; prevIdx<(seseRec->numDependentSESErecords); prevIdx++){ + SESEcommon* prevSESE = (SESEcommon*) + ( + ((INTPTR)seseRec) + + seseRec->offsetToDepSESErecords + + (sizeof(INTPTR)*prevIdx) + ); + + if(prevSESE!=NULL){ + struct garbagelist * prevgl=(struct garbagelist *)&(((SESEcommon*)(prevSESE))[1]); + while(prevgl!=NULL) { + int i; + for(i=0; isize; i++) { + void * orig=prevgl->array[i]; + ENQUEUE(orig, prevgl->array[i]); + } + prevgl=prevgl->next; + } + } + } + } +#endif diff --git a/Robust/src/Runtime/taskgarbage.c b/Robust/src/Runtime/taskgarbage.c new file mode 100644 index 00000000..e2f08c40 --- /dev/null +++ b/Robust/src/Runtime/taskgarbage.c @@ -0,0 +1,166 @@ +#include "garbage.h" +#ifdef TASK +void searchtaskroots() { + { + /* Update objectsets */ + int i; + for(i=0; iobjectset; + struct ObjectNode * ptr=set->listhead; + while(ptr!=NULL) { + void *orig=(void *)ptr->key; + ENQUEUE(orig, *((void **)(&ptr->key))); + ptr=ptr->lnext; + } + ObjectHashrehash(set); /* Rehash the table */ + p=p->next; + } +#endif + } + } + +#ifndef FASTCHECK + if (forward!=NULL) { + struct cnode * ptr=forward->listhead; + while(ptr!=NULL) { + void * orig=(void *)ptr->key; + ENQUEUE(orig, *((void **)(&ptr->key))); + ptr=ptr->lnext; + } + crehash(forward); /* Rehash the table */ + } + + if (reverse!=NULL) { + struct cnode * ptr=reverse->listhead; + while(ptr!=NULL) { + void *orig=(void *)ptr->val; + ENQUEUE(orig, *((void**)(&ptr->val))); + ptr=ptr->lnext; + } + } +#endif + + { + struct RuntimeNode * ptr=fdtoobject->listhead; + while(ptr!=NULL) { + void *orig=(void *)ptr->data; + ENQUEUE(orig, *((void**)(&ptr->data))); + ptr=ptr->lnext; + } + } + + { + /* Update current task descriptor */ + int i; + for(i=0; inumParameters; i++) { + void *orig=currtpd->parameterArray[i]; + ENQUEUE(orig, currtpd->parameterArray[i]); + } + + } + + /* Update active tasks */ + { + struct genpointerlist * ptr=activetasks->list; + while(ptr!=NULL) { + struct taskparamdescriptor *tpd=ptr->src; + int i; + for(i=0; inumParameters; i++) { + void * orig=tpd->parameterArray[i]; + ENQUEUE(orig, tpd->parameterArray[i]); + } + ptr=ptr->inext; + } + genrehash(activetasks); + } + + /* Update failed tasks */ + { + struct genpointerlist * ptr=failedtasks->list; + while(ptr!=NULL) { + struct taskparamdescriptor *tpd=ptr->src; + int i; + for(i=0; inumParameters; i++) { + void * orig=tpd->parameterArray[i]; + ENQUEUE(orig, tpd->parameterArray[i]); + } + ptr=ptr->inext; + } + genrehash(failedtasks); + } +} + +struct pointerblock *taghead=NULL; +int tagindex=0; + +void enqueuetag(struct ___TagDescriptor___ *ptr) { + if (tagindex==NUMPTRS) { + struct pointerblock * tmp=malloc(sizeof(struct pointerblock)); + tmp->next=taghead; + taghead=tmp; + tagindex=0; + } + taghead->ptrs[tagindex++]=ptr; +} + +/* Fix up the references from tags. This can't be done earlier, + because we don't want tags to keep objects alive */ +void fixtags() { + while(taghead!=NULL) { + int i; + struct pointerblock *tmp=taghead->next; + for(i=0; iptrs[i]; + struct ___Object___ *obj=tagd->flagptr; + struct ___TagDescriptor___ *copy=((struct ___TagDescriptor___**)tagd)[1]; + if (obj==NULL) { + /* Zero object case */ + } else if (obj->type==-1) { + /* Single object case */ + copy->flagptr=((struct ___Object___**)obj)[1]; + } else if (obj->type==OBJECTARRAYTYPE) { + /* Array case */ + struct ArrayObject *ao=(struct ArrayObject *) obj; + int livecount=0; + int j; + int k=0; + struct ArrayObject *aonew; + + /* Count live objects */ + for(j=0; j___cachedCode___; j++) { + struct ___Object___ * tobj=ARRAYGET(ao, struct ___Object___ *, j); + if (tobj->type==-1) + livecount++; + } + + livecount=((livecount-1)/OBJECTARRAYINTERVAL+1)*OBJECTARRAYINTERVAL; + aonew=(struct ArrayObject *) tomalloc(sizeof(struct ArrayObject)+sizeof(struct ___Object___*)*livecount); + memcpy(aonew, ao, sizeof(struct ArrayObject)); + aonew->type=OBJECTARRAYTYPE; + aonew->___length___=livecount; + copy->flagptr=aonew; + for(j=0; j___cachedCode___; j++) { + struct ___Object___ * tobj=ARRAYGET(ao, struct ___Object___ *, j); + if (tobj->type==-1) { + struct ___Object___ * tobjcpy=((struct ___Object___**)tobj)[1]; + ARRAYSET(aonew, struct ___Object___*, k++,tobjcpy); + } + } + aonew->___cachedCode___=k; + for(; kflagptr=NULL; + } + } + free(taghead); + taghead=tmp; + tagindex=NUMPTRS; + } +} +#endif diff --git a/Robust/src/Runtime/thread.c b/Robust/src/Runtime/thread.c index ef75f1c4..f3b01829 100644 --- a/Robust/src/Runtime/thread.c +++ b/Robust/src/Runtime/thread.c @@ -286,6 +286,10 @@ void initializethreads() { litem.prev=NULL; litem.next=list; litem.lvector=&lvector; +#ifdef JNI + litem.jnirefs=&jnirefs; + jnirefs=NULL; +#endif lvector.index=0; if(list!=NULL) list->prev=&litem; @@ -330,6 +334,10 @@ void initthread(struct ___Thread___ * ___this___) { pthread_setspecific(memorybasekey, &memorybase); pthread_setspecific(memorytopkey, &memorytop); pthread_setspecific(threadlocks, &lvector); +#endif +#ifdef JNI + litem.jnirefs=&jnirefs; + jnirefs=NULL; #endif litem.lvector=&lvector; lvector.index=0; diff --git a/Robust/src/Tests/dotest b/Robust/src/Tests/dotest index 09a2c52a..ffce5033 100755 --- a/Robust/src/Tests/dotest +++ b/Robust/src/Tests/dotest @@ -7,7 +7,7 @@ shift dir=`pwd` echo Doing Test $ARG1 -../buildscript -64bit -debug -joptimize -robustroot ${dir}/../ -mainclass $ARG1 $ARG2 -o $ARG1 +../buildscript -mac -64bit -debug -joptimize -robustroot ${dir}/../ -mainclass $ARG1 $ARG2 -o $ARG1 $ARG1.bin $@ &> output/$ARG1.output diff output/$ARG1.output output/$ARG1.output.goal rm $ARG1.bin diff --git a/Robust/src/buildscript b/Robust/src/buildscript index b50930c4..77d3fe71 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -1242,6 +1242,7 @@ $ROBUSTROOT/Runtime/file.c $ROBUSTROOT/Runtime/Queue.c \ $ROBUSTROOT/Runtime/SimpleHash.c $ROBUSTROOT/Runtime/option.c \ $ROBUSTROOT/Runtime/ObjectHash.c \ $ROBUSTROOT/Runtime/garbage.c $ROBUSTROOT/Runtime/socket.c \ +$ROBUSTROOT/Runtime/taskgarbage.c $ROBUSTROOT/Runtime/oojgarbage.c \ $ROBUSTROOT/Runtime/math.c \ $ROBUSTROOT/Runtime/GenericHashtable.c $ROBUSTROOT/Runtime/object.c"