From c8754dcf8b81de0a6b09c91c305341398549e55f Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 18 Oct 2007 05:34:17 +0000 Subject: [PATCH] bug fixes checked in --- Robust/src/Runtime/checkpoint.c | 26 +++++++++++++++++++++++++- Robust/src/Runtime/garbage.c | 7 ++++++- Robust/src/Runtime/task.c | 3 +-- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/Robust/src/Runtime/checkpoint.c b/Robust/src/Runtime/checkpoint.c index 6fd62de7..64373652 100644 --- a/Robust/src/Runtime/checkpoint.c +++ b/Robust/src/Runtime/checkpoint.c @@ -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; diff --git a/Robust/src/Runtime/garbage.c b/Robust/src/Runtime/garbage.c index e2b688b3..7ead1fb4 100644 --- a/Robust/src/Runtime/garbage.c +++ b/Robust/src/Runtime/garbage.c @@ -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) { diff --git a/Robust/src/Runtime/task.c b/Robust/src/Runtime/task.c index 3bf5012d..bee156d4 100644 --- a/Robust/src/Runtime/task.c +++ b/Robust/src/Runtime/task.c @@ -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. */ -- 2.34.1