From 61e6f967fd4ab332c7cd14f2cb5cdb402c223da8 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Wed, 8 Apr 2009 02:45:47 +0000 Subject: [PATCH] large number of bug corrections --- .../SingleTM/RainForest/RainForest.java | 1 + .../Benchmarks/SingleTM/RainForest/makefile | 2 +- Robust/src/Runtime/STM/stm.c | 1 + Robust/src/Runtime/garbage.c | 53 ++++++++++++++++--- Robust/src/Runtime/runtime.c | 5 ++ 5 files changed, 53 insertions(+), 9 deletions(-) diff --git a/Robust/src/Benchmarks/SingleTM/RainForest/RainForest.java b/Robust/src/Benchmarks/SingleTM/RainForest/RainForest.java index 3c2ce264..f185a92f 100644 --- a/Robust/src/Benchmarks/SingleTM/RainForest/RainForest.java +++ b/Robust/src/Benchmarks/SingleTM/RainForest/RainForest.java @@ -175,6 +175,7 @@ public class RainForest extends Thread { tmp.join(); } System.printString("Finished\n"); + System.exit(0); } public void doOneMove(GameMap[][] land, Player gamer) { diff --git a/Robust/src/Benchmarks/SingleTM/RainForest/makefile b/Robust/src/Benchmarks/SingleTM/RainForest/makefile index c9ba9650..e334ce62 100644 --- a/Robust/src/Benchmarks/SingleTM/RainForest/makefile +++ b/Robust/src/Benchmarks/SingleTM/RainForest/makefile @@ -10,7 +10,7 @@ SRC=tmp${MAINCLASS}.java \ Node.java \ AStarPathFinder.java -FLAGS=-singleTM -nooptimize -mainclass ${MAINCLASS} -debug +FLAGS=-singleTM -nooptimize -mainclass ${MAINCLASS} -debug -transstats default: cpp ${MAINCLASS}.java > tmp1${MAINCLASS}.java diff --git a/Robust/src/Runtime/STM/stm.c b/Robust/src/Runtime/STM/stm.c index 56680152..2c9bae70 100644 --- a/Robust/src/Runtime/STM/stm.c +++ b/Robust/src/Runtime/STM/stm.c @@ -276,6 +276,7 @@ int traverseCache() { /* Decide the final response */ if (softabort) { + transAbortProcess(oidrdlocked, &numoidrdlocked, oidwrlocked, &numoidwrlocked); return TRANS_SOFT_ABORT; } else { transCommitProcess(oidrdlocked, &numoidrdlocked, oidwrlocked, &numoidwrlocked); diff --git a/Robust/src/Runtime/garbage.c b/Robust/src/Runtime/garbage.c index 11984fa9..647cd36c 100644 --- a/Robust/src/Runtime/garbage.c +++ b/Robust/src/Runtime/garbage.c @@ -156,31 +156,34 @@ void fixtable(chashlistnode_t ** tc_table, unsigned int tc_size) { break; //key = val =0 for element if not present within the hash table } SENQUEUE(key, key); - if (key>=curr_heapbase&&keyval>=curr_heapbase&&curr->valval, curr->val); } else { //rewrite transaction cache entry - void *ptr=curr->val; - int type=((int *)ptr)[0]; + void *vptr=curr->val; + int type=((int *)vptr)[0]; unsigned int *pointer=pointerarray[type]; if (pointer==0) { //array of primitives - do nothing + struct ArrayObject *ao=(struct ArrayObject *) vptr; + SENQUEUE((void *)ao->___objlocation___, *((void **)&ao->___objlocation___)); } else if (((int)pointer)==1) { //array of pointers - struct ArrayObject *ao=(struct ArrayObject *) ptr; + struct ArrayObject *ao=(struct ArrayObject *) vptr; int length=ao->___length___; int i; + SENQUEUE((void *)ao->___objlocation___, *((void **)&ao->___objlocation___)); for(i=0; i___length___)+sizeof(int)))[i]; - ENQUEUE(objptr, ((void **)(((char *)&ao->___length___)+sizeof(int)))[i]); + SENQUEUE(objptr, ((void **)(((char *)&ao->___length___)+sizeof(int)))[i]); } } else { int size=pointer[0]; int i; for(i=1; i<=size; i++) { unsigned int offset=pointer[i]; - void * objptr=*((void **)(((int)ptr)+offset)); - ENQUEUE(objptr, *((void **)(((int)ptr)+offset))); + void * objptr=*((void **)(((int)vptr)+offset)); + SENQUEUE(objptr, *((void **)(((int)vptr)+offset))); } } } @@ -197,6 +200,12 @@ void fixtable(chashlistnode_t ** tc_table, unsigned int tc_size) { if (!isfirst) { free(curr); } + } else if (isfirst) { + chashlistnode_t *newnode= calloc(1, sizeof(chashlistnode_t)); + newnode->key = curr->key; + newnode->val = curr->val; + newnode->next = tmp->next; + tmp->next=newnode; } else { curr->next=tmp->next; tmp->next=curr; @@ -206,7 +215,7 @@ void fixtable(chashlistnode_t ** tc_table, unsigned int tc_size) { } while(curr!=NULL); } free(ptr); - *tc_table=node; + (*tc_table)=node; } #endif @@ -258,6 +267,11 @@ void collect(struct garbagelist * stackptr) { } #endif +#ifdef STM + if (c_table!=NULL) + fixtable(&c_table, c_size); +#endif + /* Check current stack */ #if defined(THREADS)||defined(DSTM)||defined(STM) { @@ -411,6 +425,11 @@ void collect(struct garbagelist * stackptr) { struct ArrayObject *ao_cpy=(struct ArrayObject *) cpy; ENQUEUE((void *)ao->___nextobject___, *((void **)&ao_cpy->___nextobject___)); ENQUEUE((void *)ao->___localcopy___, *((void **)&ao_cpy->___localcopy___)); +#endif +#if defined(STM) + struct ArrayObject *ao=(struct ArrayObject *) ptr; + struct ArrayObject *ao_cpy=(struct ArrayObject *) cpy; + SENQUEUE((void *)ao->___objlocation___, *((void **)&ao_cpy->___objlocation___)); #endif } else if (((int)pointer)==1) { /* Array of pointers */ @@ -419,6 +438,9 @@ void collect(struct garbagelist * stackptr) { #if (defined(DSTM)||defined(FASTCHECK)) ENQUEUE((void *)ao->___nextobject___, *((void **)&ao_cpy->___nextobject___)); ENQUEUE((void *)ao->___localcopy___, *((void **)&ao_cpy->___localcopy___)); +#endif +#if defined(STM) + SENQUEUE((void *)ao->___objlocation___, *((void **)&ao_cpy->___objlocation___)); #endif int length=ao->___length___; int i; @@ -692,9 +714,16 @@ int gc_createcopy(void * orig, void ** copy_ptr) { } if (type___length___; +#ifdef STM + int size=sizeof(struct ArrayObject)+length*elementsize+sizeof(objheader_t); + void *newobj=tomalloc(size); + memcpy(newobj, ((char*)orig)-sizeof(objheader_t), size); + newobj=((char *)newobj)+sizeof(objheader_t); +#else int size=sizeof(struct ArrayObject)+length*elementsize; void *newobj=tomalloc(size); memcpy(newobj, orig, size); +#endif + ((int *)orig)[0]=-1; ((void **)orig)[1]=newobj; *copy_ptr=newobj; diff --git a/Robust/src/Runtime/runtime.c b/Robust/src/Runtime/runtime.c index 895001ed..25ee0f81 100644 --- a/Robust/src/Runtime/runtime.c +++ b/Robust/src/Runtime/runtime.c @@ -100,6 +100,11 @@ void injectinstructionfailure() { } void CALL11(___System______exit____I,int ___status___, int ___status___) { +#ifdef TRANSSTATS + printf("numTransCommit = %d\n", numTransCommit); + printf("numTransAbort = %d\n", numTransAbort); + printf("nSoftAbort = %d\n", nSoftAbort); +#endif exit(___status___); } -- 2.34.1