From b252ac14d9ad1fa183b79a1edebca303057a8e16 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 17 Aug 2007 01:33:39 +0000 Subject: [PATCH] get some space for optional fs's --- Robust/src/IR/Flat/BuildCode.java | 4 +-- Robust/src/Runtime/ObjectHash.c | 14 ----------- Robust/src/Runtime/checkpoint.c | 4 +-- Robust/src/Runtime/garbage.c | 6 ++--- Robust/src/Runtime/runtime.h | 9 ++++--- Robust/src/Runtime/task.c | 41 +++++++++++++++---------------- Robust/src/buildscript | 1 + 7 files changed, 34 insertions(+), 45 deletions(-) diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 7a5ddc6f..f253e6da 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -2126,9 +2126,9 @@ public class BuildCode { } - //GENERATE STRUCTS - output.println("#include \"optionalstruct.h\"\n\n"); + if (state.OPTIONAL) + output.println("#include \"optionalstruct.h\"\n\n"); HashSet processedcd = new HashSet(); int maxotd=0; diff --git a/Robust/src/Runtime/ObjectHash.c b/Robust/src/Runtime/ObjectHash.c index de85a533..b3a42abe 100755 --- a/Robust/src/Runtime/ObjectHash.c +++ b/Robust/src/Runtime/ObjectHash.c @@ -206,20 +206,6 @@ int ObjectHashcount(struct ObjectHash *thisvar,int key) { return count; } -struct ObjectHash * ObjectHashimageSet(struct ObjectHash *thisvar, int key) { - struct ObjectHash * newset=allocateObjectHash(2*ObjectHashcount(thisvar,key)+4); - unsigned int hashkey = (unsigned int)key % thisvar->size; - - struct ObjectNode *ptr = thisvar->bucket[hashkey]; - while (ptr) { - if (ptr->key == key) { - ObjectHashadd(newset,ptr->data,ptr->data); - } - ptr = ptr->next; - } - return newset; -} - int ObjectHashget(struct ObjectHash *thisvar, int key, int *data, int *data2) { unsigned int hashkey = (unsigned int)key % thisvar->size; diff --git a/Robust/src/Runtime/checkpoint.c b/Robust/src/Runtime/checkpoint.c index f77a551d..6fd62de7 100644 --- a/Robust/src/Runtime/checkpoint.c +++ b/Robust/src/Runtime/checkpoint.c @@ -71,7 +71,7 @@ void ** makecheckpoint(int numparams, void ** srcpointer, struct RuntimeHash * f { void *cpy; RuntimeHashget(forward, (int) ptr, (int *) &cpy); - int * pointer=pointerarray[type]; + unsigned int * pointer=pointerarray[type]; if (pointer==0) { /* Array of primitives */ /* Do nothing */ @@ -171,7 +171,7 @@ void restorecheckpoint(int numparams, void ** original, void ** checkpoint, stru { void *cpy; - int *pointer; + unsigned int *pointer; int size; RuntimeHashget(reverse, (int) ptr, (int *) &cpy); pointer=pointerarray[type]; diff --git a/Robust/src/Runtime/garbage.c b/Robust/src/Runtime/garbage.c index e86f2c1b..1e7a63f7 100644 --- a/Robust/src/Runtime/garbage.c +++ b/Robust/src/Runtime/garbage.c @@ -164,8 +164,8 @@ void collect(struct garbagelist * stackptr) { for(i=0;iobjectset; - struct RuntimeNode * ptr=set->listhead; + struct ObjectHash * set=p->objectset; + struct ObjectNode * ptr=set->listhead; while(ptr!=NULL) { void *orig=(void *)ptr->key; void *copy; @@ -175,7 +175,7 @@ void collect(struct garbagelist * stackptr) { ptr=ptr->lnext; } - RuntimeHashrehash(set); /* Rehash the table */ + ObjectHashrehash(set); /* Rehash the table */ p=p->next; } } diff --git a/Robust/src/Runtime/runtime.h b/Robust/src/Runtime/runtime.h index a90508fb..96cc3087 100644 --- a/Robust/src/Runtime/runtime.h +++ b/Robust/src/Runtime/runtime.h @@ -66,9 +66,12 @@ void createstartupobject(); #ifdef TASK #include "SimpleHash.h" +#include "ObjectHash.h" #include "task.h" #include "structdefs.h" +#ifdef OPTIONAL #include "optionalstruct.h" +#endif void flagorand(void * ptr, int ormask, int andmask); void flagorandinit(void * ptr, int ormask, int andmask); @@ -77,8 +80,8 @@ void processtasks(); struct tagobjectiterator { int istag; /* 0 if object iterator, 1 if tag iterator */ - struct RuntimeIterator it; /* Object iterator */ - struct RuntimeHash * objectset; + struct ObjectIterator it; /* Object iterator */ + struct ObjectHash * objectset; int slot; int tagobjindex; /* Index for tag or object depending on use */ /*if tag we have an object binding */ @@ -91,7 +94,7 @@ struct tagobjectiterator { struct parameterwrapper { struct parameterwrapper *next; - struct RuntimeHash * objectset; + struct ObjectHash * objectset; int numberofterms; int * intarray; int numbertags; diff --git a/Robust/src/Runtime/task.c b/Robust/src/Runtime/task.c index 88633ca0..bdde536a 100644 --- a/Robust/src/Runtime/task.c +++ b/Robust/src/Runtime/task.c @@ -443,8 +443,7 @@ void flagorandinit(void * ptr, int ormask, int andmask) { temp=(struct ___Object___ *)node->key; if(temp->failedstatus==1 && temp->hashcode==currobj->hashcode){ if(temp!=currobj){ - RuntimeHashget(flagptr->objectset, (int)temp, (int *) &ptr); - RuntimeHashremove(flagptr->objectset, (int)temp, (int) ptr);//remove from wrapper + ObjectHashremove(flagptr->objectset, (int)temp);//remove from wrapper //delete the fields that wont be removed by the GC. if(temp->exitfses!=NULL) RUNFREE(temp->exitfses); if(temp->otds!=NULL) RUNFREE(temp->otds); @@ -452,8 +451,7 @@ void flagorandinit(void * ptr, int ormask, int andmask) { } else{ //remove from wrapper - RuntimeHashget(flagptr->objectset, (int)temp, (int *) &ptr); - RuntimeHashremove(flagptr->objectset, (int)temp, (int) ptr); + ObjectHashremove(flagptr->objectset, (int)temp); goto nextwrapper; } } @@ -474,8 +472,9 @@ void flagorandinit(void * ptr, int ormask, int andmask) { while(flagptr!=NULL) { struct parameterwrapper *next; struct ___Object___ * tag=ptr->___tags___; - RuntimeHashget(flagptr->objectset, (int) ptr, (int *) &next); - RuntimeHashremove(flagptr->objectset, (int)ptr, (int) next); + int FIXME; + ObjectHashget(flagptr->objectset, (int) ptr, (int *) &next, &FIXME); + ObjectHashremove(flagptr->objectset, (int)ptr); flagptr=next; } @@ -767,9 +766,9 @@ void flagorandinit(void * ptr, int ormask, int andmask) { //test if the predicate member is true struct parameterwrapper * paramwrapper = objectqueues[currpred->type]; while(paramwrapper!=NULL){ - struct RuntimeIterator * it = allocateRuntimeIterator(paramwrapper->objectset->listhead); + struct ObjectIterator * it = allocateObjectIterator(paramwrapper->objectset->listhead); do{ - struct ___Object___ * obj = (struct ___Object___ *)Runkey(it); + struct ___Object___ * obj = (struct ___Object___ *)Objkey(it); printf("obj type : %i\n", obj->type); if(obj->type == currpred->type){ //test the predicate @@ -777,8 +776,8 @@ void flagorandinit(void * ptr, int ormask, int andmask) { //only if good goto enqueuetask; } - Runnext(it); - }while(RunhasNext(it)); + Objnext(it); + }while(ObjhasNext(it)); paramwrapper=paramwrapper->next; } printf("not the good predicate"); @@ -797,7 +796,7 @@ void flagorandinit(void * ptr, int ormask, int andmask) { struct taskdescriptor * task=parameter->task; - RuntimeHashadd(parameter->objectset, (int) ptr, (int) prevptr);//this add the object to parameterwrapper + ObjectHashadd(parameter->objectset, (int) ptr, (int) prevptr, 0);//this add the object to parameterwrapper /* Add enqueued object to parameter vector */ taskpointerarray[parameter->slot]=ptr; @@ -988,7 +987,7 @@ void executetasks() { if(obj->failedstatus==1){ struct ___Object___ *temp=NULL; struct parameterwrapper * ptr; - struct RuntimeNode * node = pw->objectset->listhead; + struct ObjectNode * node = pw->objectset->listhead; while(node!=NULL){ temp=(struct ___Object___ *)node->key; if(temp->failedstatus==1 && temp->hashcode==obj->hashcode){ @@ -1004,7 +1003,7 @@ void executetasks() { else #endif { - if (!RuntimeHashcontainskey(pw->objectset, (int) parameter)) { + if (!ObjectHashcontainskey(pw->objectset, (int) parameter)) { RUNFREE(currtpd->parameterArray); RUNFREE(currtpd); goto newtask; @@ -1123,7 +1122,7 @@ void processtags(struct parameterdescriptor *pd, int index, struct parameterwrap void processobject(struct parameterwrapper *parameter, int index, struct parameterdescriptor *pd, int *iteratorcount, int * statusarray, int numparams) { int i; int tagcount=0; - struct RuntimeHash * objectset=((struct parameterwrapper *)pd->queue)->objectset; + struct ObjectHash * objectset=((struct parameterwrapper *)pd->queue)->objectset; parameter->iterators[*iteratorcount].istag=0; parameter->iterators[*iteratorcount].slot=index; @@ -1223,7 +1222,7 @@ void processtasks() { struct parameterwrapper ** ptr=&objectqueues[param->type]; param->queue=parameter; - parameter->objectset=allocateRuntimeHash(10); + parameter->objectset=allocateObjectHash(10); parameter->numberofterms=param->numberterms; parameter->intarray=param->intarray; parameter->numbertags=param->numbertags; @@ -1251,7 +1250,7 @@ void toiReset(struct tagobjectiterator * it) { } else if (it->numtags>0) { it->tagobjindex=0; } else { - RuntimeHashiterator(it->objectset, &it->it); + ObjectHashiterator(it->objectset, &it->it); } } @@ -1287,7 +1286,7 @@ int toiHasNext(struct tagobjectiterator *it, void ** objectarray) { if (objptr->type!=OBJECTARRAYTYPE) { if (it->tagobjindex>0) return 0; - if (!RuntimeHashcontainskey(it->objectset, (int) objptr)) + if (!ObjectHashcontainskey(it->objectset, (int) objptr)) return 0; for(i=1;inumtags;i++) { struct ___TagDescriptor___ *tag2=objectarray[it->tagbindings[i]]; @@ -1301,7 +1300,7 @@ int toiHasNext(struct tagobjectiterator *it, void ** objectarray) { int i; for(tagindex=it->tagobjindex;tagindex___cachedCode___;tagindex++) { struct ___Object___ *objptr=ARRAYGET(ao, struct ___Object___*, tagindex); - if (!RuntimeHashcontainskey(it->objectset, (int) objptr)) + if (!ObjectHashcontainskey(it->objectset, (int) objptr)) continue; for(i=1;inumtags;i++) { struct ___TagDescriptor___ *tag2=objectarray[it->tagbindings[i]]; @@ -1316,7 +1315,7 @@ int toiHasNext(struct tagobjectiterator *it, void ** objectarray) { return 0; } } else { - return RunhasNext(&it->it); + return ObjhasNext(&it->it); } } @@ -1361,8 +1360,8 @@ void toiNext(struct tagobjectiterator *it , void ** objectarray) { } } else { /* Iterate object */ - objectarray[it->slot]=(void *)Runkey(&it->it); - Runnext(&it->it); + objectarray[it->slot]=(void *)Objkey(&it->it); + Objnext(&it->it); } } diff --git a/Robust/src/buildscript b/Robust/src/buildscript index 55e661a0..5c9ebbf0 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -187,6 +187,7 @@ INCLUDES="$INCLUDES -I$ROBUSTROOT/Runtime -I. -IRuntime/include \ FILES="$ROBUSTROOT/Runtime/runtime.c $ROBUSTROOT/Runtime/task.c \ $ROBUSTROOT/Runtime/file.c $ROBUSTROOT/Runtime/Queue.c \ $ROBUSTROOT/Runtime/SimpleHash.c $ROBUSTROOT/Runtime/option.c \ +$ROBUSTROOT/Runtime/ObjectHash.c \ $ROBUSTROOT/Runtime/garbage.c $ROBUSTROOT/Runtime/socket.c \ $ROBUSTROOT/Runtime/GenericHashtable.c $ROBUSTROOT/Runtime/object.c" -- 2.34.1