#include "runtime.h"
#include "structdefs.h"
#include <string.h>
+#ifdef DMALLOC
+#include "dmalloc.h"
+#endif
#define MALLOCSIZE 20*1024
{
void *cpy;
RuntimeHashget(forward, (int) ptr, (int *) &cpy);
- int * pointer=pointerarray[type];
+ 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 */
}
}
}
+ freeRuntimeHash(todo);
return newarray;
}
void restorecheckpoint(int numparams, void ** original, void ** checkpoint, struct RuntimeHash *forward, struct RuntimeHash * reverse) {
struct RuntimeHash *todo=allocateRuntimeHash(100);
+ struct RuntimeHash *visited=allocateRuntimeHash(100);
int i;
for(i=0;i<numparams;i++) {
- RuntimeHashadd(todo, (int) checkpoint[i], (int) checkpoint[i]);
+ if (checkpoint[i]!=NULL) {
+ RuntimeHashadd(todo, (int) checkpoint[i], (int) checkpoint[i]);
+ RuntimeHashadd(visited, (int) checkpoint[i], (int) checkpoint[i]);
+ }
}
-
+
while(RuntimeHashcountset(todo)!=0) {
void * ptr=(void *) RuntimeHashfirstkey(todo);
int type=((int *)ptr)[0];
RuntimeHashremove(todo, (int) ptr, (int) ptr);
+
{
void *cpy;
- int *pointer;
+ unsigned int *pointer;
int size;
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;
void *objptr=((void **)(((char *)& ao->___length___)+sizeof(int)))[i];
if (objptr==NULL)
((void **)(((char *)& ao_cpy->___length___)+sizeof(int)))[i]=NULL;
- else
+ else {
+ if (!RuntimeHashcontainskey(visited, (int) objptr)) {
+ RuntimeHashadd(visited, (int) objptr, (int) objptr);
+ RuntimeHashadd(todo, (int) objptr, (int) objptr);
+ }
RuntimeHashget(reverse, (int) objptr, (int *) &((void **)(((char *)& ao_cpy->___length___)+sizeof(int)))[i]);
+ }
}
} else {
int numptr=pointer[0];
void * objptr=*((void **)(((int)ptr)+offset));
if (objptr==NULL)
*((void **) (((int)cpy)+offset))=NULL;
- else
+ else {
+ if (!RuntimeHashcontainskey(visited, (int) objptr)) {
+ RuntimeHashadd(visited, (int) objptr, (int) objptr);
+ RuntimeHashadd(todo, (int) objptr, (int) objptr);
+ }
RuntimeHashget(reverse, (int) objptr, (int *) &(((char *)cpy)[offset]));
+ }
}
if (hasflags[type]) {
(((void **)cpy)[2])=flagptr;
- flagorand(cpy, 1, 0xFFFFFFFF);
+ flagorandinit(cpy, 0, 0xFFFFFFFF);
}
}
}
}
+ freeRuntimeHash(todo);
+ freeRuntimeHash(visited);
}