From 464c6b5feb326c49355f87ff60113a1437c6bb73 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Mon, 2 Feb 2009 09:29:42 +0000 Subject: [PATCH] new fastcheck option for bristlecone --- Robust/src/Runtime/garbage.c | 11 ++++++ Robust/src/Runtime/localobjects.c | 66 +++++++++++++++++++++++++++++++ Robust/src/Runtime/localobjects.h | 14 +++++++ Robust/src/Runtime/runtime.h | 4 ++ Robust/src/Runtime/task.c | 24 +++++++++++ 5 files changed, 119 insertions(+) create mode 100644 Robust/src/Runtime/localobjects.c create mode 100644 Robust/src/Runtime/localobjects.h diff --git a/Robust/src/Runtime/garbage.c b/Robust/src/Runtime/garbage.c index 44a51c40..bad83e8f 100644 --- a/Robust/src/Runtime/garbage.c +++ b/Robust/src/Runtime/garbage.c @@ -54,6 +54,13 @@ int listcount=0; dst=copy; \ } \ } +#elif defined(FASTCHECK) +#define ENQUEUE(orig, dst) \ + if (((unsigned int)orig)!=1) { \ + void *copy; \ + if (gc_createcopy(orig,©)) \ + enqueue(orig);\ + dst=copy; } #else #define ENQUEUE(orig, dst) \ void *copy; \ @@ -187,6 +194,10 @@ void collect(struct garbagelist * stackptr) { } #endif +#ifdef FASTCHECK + ENQUEUE(___fcrevert___, ___fcrevert___); +#endif + #ifdef TASK { /* Update objectsets */ diff --git a/Robust/src/Runtime/localobjects.c b/Robust/src/Runtime/localobjects.c new file mode 100644 index 00000000..bd991ea5 --- /dev/null +++ b/Robust/src/Runtime/localobjects.c @@ -0,0 +1,66 @@ +#include "localobjects.h" +#include + +void REVERT_OBJ(struct ___Object___ * obj) { + int type=((int *)obj)[0]; + struct ___Object___ * copyobj=obj->___localcopy___; + if(((int)copyobj)==1) { + obj->___localcopy___=NULL; + obj->___nextobject___=NULL; + } else if (type___length___; + int size=sizeof(struct ArrayObject)+length*elementsize; + memcpy(obj, copyobj, size); + } +} + +#ifdef PRECISE_GC +void COPY_OBJ(struct garbagelist * gl, struct ___Object___ *obj) { +#else +void COPY_OBJ(struct ___Object___ *obj) { +#endif + int type=((int *)obj)[0]; + if (type___localcopy___=newobj; +#else + memcpy(newobj, obj, size); + obj->___localcopy___=newobj; +#endif + } else { + /* We have an array */ + struct ArrayObject *ao=(struct ArrayObject *)obj; + int elementsize=classsize[type]; + int length=ao->___length___; + int size=sizeof(struct ArrayObject)+length*elementsize; +#ifdef PRECISE_GC + int ptrarray[]={1, (int) gl, (int) obj}; + struct ___Object___ * newobj=mygcmalloc((struct garbagelist *)ptrarray, size); +#else + struct ___Object___ * newobj=FREEMALLOC(size); +#endif +#ifdef PRECISE_GC + memcpy(newobj, (struct ___Object___ *) ptrarray[2], size); + ((struct ___Object___*)ptrarray[2])->___localcopy___=newobj; +#else + memcpy(newobj, obj, size); + obj->___localcopy___=newobj; +#endif + } +} diff --git a/Robust/src/Runtime/localobjects.h b/Robust/src/Runtime/localobjects.h new file mode 100644 index 00000000..c1c7be13 --- /dev/null +++ b/Robust/src/Runtime/localobjects.h @@ -0,0 +1,14 @@ +#ifndef LOCALOBJECT_H +#define LOCALOBJECT_H +#include "structdefs.h" +#include "garbage.h" +void REVERT_OBJ(struct ___Object___ *); +#define COMMIT_OBJ(obj) obj->___localcopy___=NULL; \ + obj->___nextobject___=NULL + +#ifdef PRECISE_GC +void COPY_OBJ(struct garbagelist * gl, struct ___Object___ *obj); +#else +void COPY_OBJ(struct ___Object___ *obj); +#endif +#endif diff --git a/Robust/src/Runtime/runtime.h b/Robust/src/Runtime/runtime.h index d6e332be..68692e80 100644 --- a/Robust/src/Runtime/runtime.h +++ b/Robust/src/Runtime/runtime.h @@ -111,6 +111,10 @@ struct RuntimeHash * lockRedirectTbl; #endif #endif +#ifdef FASTCHECK +extern struct ___Object___ * ___fcrevert___; +#endif + #ifdef MULTICORE void flagorand(void * ptr, int ormask, int andmask, struct parameterwrapper ** queues, int length); void flagorandinit(void * ptr, int ormask, int andmask); diff --git a/Robust/src/Runtime/task.c b/Robust/src/Runtime/task.c index 229e66f7..3fa38516 100644 --- a/Robust/src/Runtime/task.c +++ b/Robust/src/Runtime/task.c @@ -22,6 +22,11 @@ extern int errors; #include "instrument.h" #endif +#ifdef FASTCHECK +struct ___Object___ * ___fcrevert___; +#include "localobjects.h" +#endif + struct genhashtable * activetasks; struct parameterwrapper * objectqueues[NUMCLASSES]; struct genhashtable * failedtasks; @@ -1166,9 +1171,13 @@ parameterpresent: { /* Checkpoint the state */ +#ifdef FASTCHECK + ___fcrevert___=NULL; +#else forward=cCreate(256, 0.4); reverse=cCreate(256, 0.4); void ** checkpoint=makecheckpoint(currtpd->task->numParameters, currtpd->parameterArray, forward, reverse); +#endif int x; if (x=setjmp(error_handler)) { int counter; @@ -1177,7 +1186,11 @@ parameterpresent: printf("Fatal Error=%d, Recovering!\n",x); #endif genputtable(failedtasks,currtpd,currtpd); +#ifdef FASTCHECK + REVERT_OBJ(___fcrevert___); +#else restorecheckpoint(currtpd->task->numParameters, currtpd->parameterArray, checkpoint, forward, reverse); +#endif #ifdef OPTIONAL for(counter=0; countertask->numParameters; counter++) { @@ -1189,11 +1202,14 @@ parameterpresent: RUNFREE(fsesarray[counter]); } #endif +#ifndef FASTCHECK cDelete(forward); cDelete(reverse); freemalloc(); forward=NULL; reverse=NULL; +#endif + } else { if (injectfailures) { if ((((double)random())/RAND_MAX)___nextobject___; + COMMIT_OBJ(___fcrevert___); + ___fcrevert___=tmpptr; + } +#else cDelete(forward); cDelete(reverse); freemalloc(); +#endif // Free up task parameter descriptor RUNFREE(currtpd->parameterArray); #ifdef OPTIONAL -- 2.34.1