3 #include "structdefs.h"
4 #include "SimpleHash.h"
5 #include "GenericHashtable.h"
10 extern struct genhashtable * activetasks;
11 extern struct genhashtable * failedtasks;
12 extern struct taskparamdescriptor *currtpd;
13 extern struct ctable *forward;
14 extern struct ctable *reverse;
15 extern struct RuntimeHash *fdtoobject;
18 extern struct parameterwrapper * objectqueues[NUMCLASSES];
22 void searchtaskroots() {
24 /* Update objectsets */
26 for(i=0; i<NUMCLASSES; i++) {
27 #if !defined(MULTICORE)
28 struct parameterwrapper * p=objectqueues[i];
30 struct ObjectHash * set=p->objectset;
31 struct ObjectNode * ptr=set->listhead;
33 void *orig=(void *)ptr->key;
34 ENQUEUE(orig, *((void **)(&ptr->key)));
37 ObjectHashrehash(set); /* Rehash the table */
46 struct cnode * ptr=forward->listhead;
48 void * orig=(void *)ptr->key;
49 ENQUEUE(orig, *((void **)(&ptr->key)));
52 crehash(forward); /* Rehash the table */
56 struct cnode * ptr=reverse->listhead;
58 void *orig=(void *)ptr->val;
59 ENQUEUE(orig, *((void**)(&ptr->val)));
66 struct RuntimeNode * ptr=fdtoobject->listhead;
68 void *orig=(void *)ptr->data;
69 ENQUEUE(orig, *((void**)(&ptr->data)));
75 /* Update current task descriptor */
77 for(i=0; i<currtpd->numParameters; i++) {
78 void *orig=currtpd->parameterArray[i];
79 ENQUEUE(orig, currtpd->parameterArray[i]);
84 /* Update active tasks */
86 struct genpointerlist * ptr=activetasks->list;
88 struct taskparamdescriptor *tpd=ptr->src;
90 for(i=0; i<tpd->numParameters; i++) {
91 void * orig=tpd->parameterArray[i];
92 ENQUEUE(orig, tpd->parameterArray[i]);
96 genrehash(activetasks);
99 /* Update failed tasks */
101 struct genpointerlist * ptr=failedtasks->list;
103 struct taskparamdescriptor *tpd=ptr->src;
105 for(i=0; i<tpd->numParameters; i++) {
106 void * orig=tpd->parameterArray[i];
107 ENQUEUE(orig, tpd->parameterArray[i]);
111 genrehash(failedtasks);
115 struct pointerblock *taghead=NULL;
118 void enqueuetag(struct ___TagDescriptor___ *ptr) {
119 if (tagindex==NUMPTRS) {
120 struct pointerblock * tmp=malloc(sizeof(struct pointerblock));
125 taghead->ptrs[tagindex++]=ptr;
128 /* Fix up the references from tags. This can't be done earlier,
129 because we don't want tags to keep objects alive */
131 while(taghead!=NULL) {
133 struct pointerblock *tmp=taghead->next;
134 for(i=0; i<tagindex; i++) {
135 struct ___TagDescriptor___ *tagd=taghead->ptrs[i];
136 struct ___Object___ *obj=tagd->flagptr;
137 struct ___TagDescriptor___ *copy=((struct ___TagDescriptor___**)tagd)[1];
139 /* Zero object case */
140 } else if (obj->type==-1) {
141 /* Single object case */
142 copy->flagptr=((struct ___Object___**)obj)[1];
143 } else if (obj->type==OBJECTARRAYTYPE) {
145 struct ArrayObject *ao=(struct ArrayObject *) obj;
149 struct ArrayObject *aonew;
151 /* Count live objects */
152 for(j=0; j<ao->___cachedCode___; j++) {
153 struct ___Object___ * tobj=ARRAYGET(ao, struct ___Object___ *, j);
158 livecount=((livecount-1)/OBJECTARRAYINTERVAL+1)*OBJECTARRAYINTERVAL;
159 aonew=(struct ArrayObject *) tomalloc(sizeof(struct ArrayObject)+sizeof(struct ___Object___*)*livecount);
160 memcpy(aonew, ao, sizeof(struct ArrayObject));
161 aonew->type=OBJECTARRAYTYPE;
162 aonew->___length___=livecount;
164 for(j=0; j<ao->___cachedCode___; j++) {
165 struct ___Object___ * tobj=ARRAYGET(ao, struct ___Object___ *, j);
166 if (tobj->type==-1) {
167 struct ___Object___ * tobjcpy=((struct ___Object___**)tobj)[1];
168 ARRAYSET(aonew, struct ___Object___*, k++,tobjcpy);
171 aonew->___cachedCode___=k;
172 for(; k<livecount; k++) {
173 ARRAYSET(aonew, struct ___Object___*, k, NULL);
176 /* No object live anymore */