From d38d10e480529cab98d733de3942e5a1cef82027 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 22 Oct 2010 04:50:57 +0000 Subject: [PATCH] changes towards rcr working... comment out jin's checkin...it breaks code generation in x86... --- Robust/src/IR/Flat/BuildCode.java | 4 +- .../src/IR/Flat/RuntimeConflictResolver.java | 3 +- Robust/src/Runtime/oooJava/hashStructure.c | 84 ++++++++++++++++--- Robust/src/Runtime/oooJava/hashStructure.h | 3 + Robust/src/Tests/rcr/makefile | 2 +- Robust/src/Tests/rcr/test.java | 28 ++++--- 6 files changed, 100 insertions(+), 24 deletions(-) diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 860eae84..4206824c 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -436,7 +436,9 @@ public class BuildCode { outmethod.println(" int i;"); outputStaticBlocks(outmethod); - outputClassObjects(outmethod); + /* + outputClassObjects(outmethod); + */ if (state.MLP || state.OOOJAVA) { diff --git a/Robust/src/IR/Flat/RuntimeConflictResolver.java b/Robust/src/IR/Flat/RuntimeConflictResolver.java index aa8334f0..cf3d14e3 100644 --- a/Robust/src/IR/Flat/RuntimeConflictResolver.java +++ b/Robust/src/IR/Flat/RuntimeConflictResolver.java @@ -800,7 +800,8 @@ public class RuntimeConflictResolver { //This is done with the assumption that an array of object stores pointers. currCase.append("{\n int i;\n"); currCase.append(" for(i = 0; i<((struct ArrayObject *) " + prefix + " )->___length___; i++ ) {\n"); - currCase.append(" struct ___Object___ * arrayElement = ((INTPTR *)(&(((struct ArrayObject *) " + prefix + " )->___length___) + sizeof(int)))[i];\n"); + //XXXXXXXXX + currCase.append(" struct ___Object___ * arrayElement =((struct ___Object___ **)(((char *) &(((struct ArrayObject *)"+ prefix+")->___length___))+sizeof(int)))[i];\n"); currCase.append(" if( arrayElement != NULL && ("); for(Integer i: allocSitesWithProblems) { diff --git a/Robust/src/Runtime/oooJava/hashStructure.c b/Robust/src/Runtime/oooJava/hashStructure.c index 7a6ae4c5..4529dedd 100644 --- a/Robust/src/Runtime/oooJava/hashStructure.c +++ b/Robust/src/Runtime/oooJava/hashStructure.c @@ -46,8 +46,7 @@ inline int rcr_generateKey(void * ptr){ return (((struct ___Object___ *) ptr)->oid)&RH_MASK; } -//consider SPEC flag -int rcr_WRITEBINCASE(HashStructure *T, void *ptr, SESEcommon *task, int index) { +inline int rcr_BWRITEBINCASE(HashStructure *T, void *ptr, SESEcommon *task, int index, int mode) { //chain of bins exists => tail is valid //if there is something in front of us, then we are not ready BinItem_rcr * val; @@ -84,14 +83,24 @@ int rcr_WRITEBINCASE(HashStructure *T, void *ptr, SESEcommon *task, int index) { WriteBinItem_rcr * td = (WriteBinItem_rcr *)bintail; //last one is to check for SESE blocks in a while loop. if(unlikely(td->task == task)) { - be->head=val; + bitvt bit=1<bitindexwr)) { td->bitindexwr|=bit; td->bitindexrd|=bit; - return (bintail->status==READY)?SPECREADY:SPECNOTREADY; - } else + be->head=val; + if (mode) { + while(bintail->status!=READY) { + BARRIER(); + } + return SPECREADY; + } else { + return (bintail->status==READY)?SPECREADY:SPECNOTREADY; + } + } else { + be->head=val; return SPECREADY; + } } } else { TraverserData * td = &((ReadBinItem_rcr *)bintail)->array[((ReadBinItem_rcr *)bintail)->index - 1]; @@ -138,10 +147,17 @@ int rcr_WRITEBINCASE(HashStructure *T, void *ptr, SESEcommon *task, int index) { //RELEASE LOCK be->head=val; - return status; + if (mode) { + while(b->item.status==NOTREADY) { + BARRIER(); + } + return status&SPEC; + } else { + return status; + } } -int rcr_READBINCASE(HashStructure *T, void *ptr, SESEcommon * task, int index) { +inline int rcr_BREADBINCASE(HashStructure *T, void *ptr, SESEcommon *task, int index, int mode) { BinItem_rcr * val; int key=rcr_generateKey(ptr); BinElement_rcr * be = &(T->array[key]); @@ -187,7 +203,14 @@ int rcr_READBINCASE(HashStructure *T, void *ptr, SESEcommon * task, int index) { } else status=SPECREADY; be->head=val; - return status; + if (mode) { + while(bintail->status!=READY) { + BARRIER(); + } + return SPECREADY; + } else { + return status; + } } } else { TraverserData * td = &((ReadBinItem_rcr *)bintail)->array[((ReadBinItem_rcr *)bintail)->index - 1]; @@ -201,19 +224,58 @@ int rcr_READBINCASE(HashStructure *T, void *ptr, SESEcommon * task, int index) { } else status=SPECREADY; be->head=val; - return status; + if (mode) { + while(bintail->status!=READY) { + BARRIER(); + } + return status&SPEC; + } else { + return status; + } } } if (ISREADBIN(bintail->type)) { - return rcr_TAILREADCASE(T, ptr, val, bintail, key, task, index); + int stat=rcr_TAILREADCASE(T, ptr, val, bintail, key, task, index); + if (mode) { + struct BinItem_rcr * bt=be->tail; + while(bt->status!=READY) { + BARRIER(); + } + return READY; + } else { + return stat; + } } else { rcr_TAILWRITECASE(T, ptr, val, bintail, key, task, index); - return NOTREADY; + if (mode) { + struct BinItem_rcr * bt=be->tail; + while(bt->status!=READY) { + BARRIER(); + } + return READY; + } else { + return NOTREADY; + } } } +int rcr_WRITEBINCASE(HashStructure *T, void *ptr, SESEcommon *task, int index) { + return rcr_BWRITEBINCASE(T, ptr, task, index, 0); +} +int rcr_READBINCASE(HashStructure *T, void *ptr, SESEcommon * task, int index) { + return rcr_BREADBINCASE(T, ptr, task, index, 0); +} + +int rcr_WTWRITEBINCASE(HashStructure *T, void *ptr, SESEcommon *task, int index) { + return rcr_BWRITEBINCASE(T, ptr, task, index, 1); +} + +int rcr_WTREADBINCASE(HashStructure *T, void *ptr, SESEcommon * task, int index) { + return rcr_BREADBINCASE(T, ptr, task, index, 1); +} + int rcr_TAILREADCASE(HashStructure *T, void * ptr, BinItem_rcr *val, BinItem_rcr *bintail, int key, SESEcommon * task, int index) { ReadBinItem_rcr * readbintail=(ReadBinItem_rcr*)T->array[key].tail; int status, retval; diff --git a/Robust/src/Runtime/oooJava/hashStructure.h b/Robust/src/Runtime/oooJava/hashStructure.h index 946945c6..9dcee308 100644 --- a/Robust/src/Runtime/oooJava/hashStructure.h +++ b/Robust/src/Runtime/oooJava/hashStructure.h @@ -86,6 +86,9 @@ inline int rcr_generateKey(void * ptr); void RESOLVE(SESEcommon *record, bitvt mask); int rcr_WRITEBINCASE(HashStructure *T, void *ptr, SESEcommon *task, int index); int rcr_READBINCASE(HashStructure *T, void *ptr, SESEcommon * task, int index); + +int rcr_WTWRITEBINCASE(HashStructure *T, void *ptr, SESEcommon *task, int index); +int rcr_WTREADBINCASE(HashStructure *T, void *ptr, SESEcommon * task, int index); int rcr_TAILREADCASE(HashStructure *T, void * ptr, BinItem_rcr *val, BinItem_rcr *bintail, int key, SESEcommon * task, int index); void rcr_TAILWRITECASE(HashStructure *T, void *ptr, BinItem_rcr *val, BinItem_rcr *bintail, int key, SESEcommon * task, int index); diff --git a/Robust/src/Tests/rcr/makefile b/Robust/src/Tests/rcr/makefile index 7e478f53..118488c1 100644 --- a/Robust/src/Tests/rcr/makefile +++ b/Robust/src/Tests/rcr/makefile @@ -6,7 +6,7 @@ SOURCE_FILES=test.java BUILDSCRIPT=../../buildscript USEOOO= -rcr -ooojava 8 2 -ooodebug -BSFLAGS= -64bit -mainclass test -nooptimize -debug +BSFLAGS= -64bit -mainclass test -optimize -debug DISJOINT= -disjoint -disjoint-k 1 -enable-assertions #-disjoint-desire-determinism diff --git a/Robust/src/Tests/rcr/test.java b/Robust/src/Tests/rcr/test.java index 2f5ee3e0..ae6628ce 100644 --- a/Robust/src/Tests/rcr/test.java +++ b/Robust/src/Tests/rcr/test.java @@ -1,18 +1,26 @@ public class test { - foo f; + int f; public test() {} - public static void main(String x[]) { - test r=new test(); - r.f=new foo(); - int z; - sese foo { - r.f.x=2; + public static void main(String xz[]) { + test[] r=new test[10]; + for(int i=0;i<10;i++) { + r[i]=new test();r[i].f=0; } - sese bar { - z=r.f.x; + + for (int z=0;z<100000;z++) { + for (int i=0;i<10;i++) { + test x=r[i]; + sese foo { + int t=x.f; + x.f=t+1; + } + } + } + sese print { + for(int i=0;i<10;i++) + System.out.println(r[i].f); } - System.out.println(z); } } -- 2.34.1