bug fixes checked in
authorbdemsky <bdemsky>
Thu, 18 Oct 2007 05:34:17 +0000 (05:34 +0000)
committerbdemsky <bdemsky>
Thu, 18 Oct 2007 05:34:17 +0000 (05:34 +0000)
Robust/src/Runtime/checkpoint.c
Robust/src/Runtime/garbage.c
Robust/src/Runtime/task.c

index 6fd62de7421af93e993fafb34a35018875fcdd57..64373652fac82c3c5820ad274d0ac8ecd8eb3cd4 100644 (file)
@@ -72,6 +72,18 @@ void ** makecheckpoint(int numparams, void ** srcpointer, struct RuntimeHash * f
       void *cpy;
       RuntimeHashget(forward, (int) ptr, (int *) &cpy);
       unsigned int * pointer=pointerarray[type];
+#ifdef TASK
+      if (type==TAGTYPE) {
+       void *objptr=((struct ___TagDescriptor___*)ptr)->flagptr;
+       if (objptr!=NULL) {
+         void * copy=createcopy(objptr);
+         RuntimeHashadd(forward, (int) objptr, (int) copy);
+         RuntimeHashadd(reverse, (int) copy, (int) objptr);
+         RuntimeHashadd(todo, (int) objptr, (int) objptr);
+         ((struct ___TagDescriptor___*)cpy)->flagptr=copy;
+       }
+      } else
+#endif
       if (pointer==0) {
        /* Array of primitives */
        /* Do nothing */
@@ -176,7 +188,19 @@ void restorecheckpoint(int numparams, void ** original, void ** checkpoint, stru
       RuntimeHashget(reverse, (int) ptr, (int *) &cpy);
       pointer=pointerarray[type];
       size=classsize[type];
-
+#ifdef TASK
+      if (type==TAGTYPE) {
+       void *objptr=((struct ___TagDescriptor___*)ptr)->flagptr;
+       memcpy(cpy, ptr, size);
+       if (objptr!=NULL) {
+         if (!RuntimeHashcontainskey(visited, (int) objptr)) {
+           RuntimeHashadd(visited, (int) objptr, (int) objptr);
+           RuntimeHashadd(todo, (int) objptr, (int) objptr);
+         }
+         RuntimeHashget(reverse, (int) objptr, (int *) & (((struct ___TagDescriptor___ *)cpy)->flagptr));
+       }
+      } else
+#endif
       if (pointer==0) {
        /* Array of primitives */
        struct ArrayObject *ao=(struct ArrayObject *) ptr;
index e2b688b320f4fd93d233c0cca373a623e61c3c08..7ead1fb476bd599c01debd1da5339f8ee4b7d3d9 100644 (file)
@@ -319,6 +319,9 @@ void collect(struct garbagelist * stackptr) {
 }
 
 #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;
@@ -327,7 +330,9 @@ void fixtags() {
       struct ___TagDescriptor___ *tagd=taghead->ptrs[i];
       struct ___Object___ *obj=tagd->flagptr;
       struct ___TagDescriptor___ *copy=((struct ___TagDescriptor___**)tagd)[1];
-      if (obj->type==-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) {
index 3bf5012da847bb12414bd86aa0ee9feaf383a229..bee156d401cd759729fce03763be4e9d8b171790 100644 (file)
@@ -202,7 +202,7 @@ void tagset(struct ___Object___ * obj, struct ___TagDescriptor___ * tagd) {
          ARRAYSET(aonew, struct ___Object___*, i, ARRAYGET(ao, struct ___Object___*, i));
        }
        ARRAYSET(aonew, struct ___Object___ *, ao->___cachedCode___, obj);
-       tagd->flagptr=(struct ___Object___ *) ao;
+       tagd->flagptr=(struct ___Object___ *) aonew;
       }
     }
   }
@@ -268,7 +268,6 @@ void tagclear(struct ___Object___ * obj, struct ___TagDescriptor___ * tagd) {
   }
  ENDCLEAR:
   return;
-  
 }
  
 /* This function allocates a new tag. */