From 80cdacf567a47515a22507651fc5f5f8319e9ea5 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Wed, 12 Sep 2007 22:34:26 +0000 Subject: [PATCH] changes --- .../Analysis/Locality/LocalityAnalysis.java | 44 +++++++++++++++---- Robust/src/IR/Flat/BuildCode.java | 2 +- Robust/src/IR/TypeUtil.java | 1 + Robust/src/Runtime/garbage.c | 25 ++++++----- Robust/src/Runtime/garbage.h | 2 +- Robust/src/Runtime/thread.c | 6 +++ Robust/src/buildscript | 2 +- 7 files changed, 58 insertions(+), 24 deletions(-) diff --git a/Robust/src/Analysis/Locality/LocalityAnalysis.java b/Robust/src/Analysis/Locality/LocalityAnalysis.java index de795283..641843e9 100644 --- a/Robust/src/Analysis/Locality/LocalityAnalysis.java +++ b/Robust/src/Analysis/Locality/LocalityAnalysis.java @@ -317,11 +317,31 @@ public class LocalityAnalysis { void processCallNode(LocalityBinding currlb, FlatCall fc, Hashtable currtable, boolean isatomic) { MethodDescriptor nodemd=fc.getMethod(); Set methodset=null; + Set runmethodset=null; if (nodemd.isStatic()||nodemd.getReturnType()==null) { methodset=new HashSet(); methodset.add(nodemd); } else { methodset=callgraph.getMethods(nodemd, fc.getThis().getType()); + // Build start -> run link + if (nodemd.getClassDesc().getSymbol().equals(TypeUtil.ThreadClass)&& + nodemd.getSymbol().equals("start")&&!nodemd.getModifiers().isStatic()&& + nodemd.numParameters()==1&&nodemd.getParamType(0).isInt()) { + assert(nodemd.getModifiers().isNative()); + + MethodDescriptor runmd=null; + for(Iterator methodit=nodemd.getClassDesc().getMethodTable().getSet("run").iterator();methodit.hasNext();) { + MethodDescriptor md=(MethodDescriptor) methodit.next(); + if (md.numParameters()!=0||md.getModifiers().isStatic()) + continue; + runmd=md; + break; + } + if (runmd!=null) { + runmethodset=callgraph.getMethods(runmd,fc.getThis().getType()); + methodset.addAll(runmethodset); + } else throw new Error("Can't find run method"); + } } Integer currreturnval=EITHER; //Start off with the either value for(Iterator methodit=methodset.iterator();methodit.hasNext();) { @@ -332,17 +352,25 @@ public class LocalityAnalysis { if (isnative&&isatomic) { System.out.println("Don't call native methods in atomic blocks!"); } - for(int i=0;i -#ifdef THREADS +#if defined(THREADS) || defined(DSTM) #include "thread.h" #endif + #ifdef DMALLOC #include "dmalloc.h" #endif @@ -30,7 +31,7 @@ extern struct RuntimeHash *reverse; extern struct RuntimeHash *fdtoobject; #endif -#ifdef THREADS +#if defined(THREADS) || defined(DSTM) int needtocollect=0; struct listitem * list=NULL; int listcount=0; @@ -128,7 +129,7 @@ void enqueuetag(struct ___TagDescriptor___ *ptr) { void collect(struct garbagelist * stackptr) { -#ifdef THREADS +#if defined(THREADS)||defined(DSTM) needtocollect=1; pthread_mutex_lock(&gclistlock); while(1) { @@ -154,7 +155,7 @@ void collect(struct garbagelist * stackptr) { #endif /* Check current stack */ -#ifdef THREADS +#if defined(THREADS)||defined(DSTM) { struct listitem *listptr=list; while(1) { @@ -168,7 +169,7 @@ void collect(struct garbagelist * stackptr) { } stackptr=stackptr->next; } -#ifdef THREADS +#if defined(THREADS)||defined(DSTM) /* Go to next thread */ if (listptr!=NULL) { void * orig=listptr->locklist; @@ -311,7 +312,7 @@ void collect(struct garbagelist * stackptr) { fixtags(); #endif -#ifdef THREADS +#if defined(THREADS)||defined(DSTM) needtocollect=0; pthread_mutex_unlock(&gclistlock); #endif @@ -378,7 +379,7 @@ void * tomalloc(int size) { return ptr; } -#ifdef THREADS +#if defined(THREADS)||defined(DSTM) void checkcollect(void * ptr) { if (needtocollect) { @@ -425,7 +426,7 @@ void restartaftergc(struct listitem * litem) { void * mygcmalloc(struct garbagelist * stackptr, int size) { void *ptr; -#ifdef THREADS +#if defined(THREADS)||defined(DSTM) if (pthread_mutex_trylock(&gclock)!=0) { struct listitem *tmp=stopforgc(stackptr); pthread_mutex_lock(&gclock); @@ -449,7 +450,7 @@ void * mygcmalloc(struct garbagelist * stackptr, int size) { to_heaptop=to_heapbase+INITIALHEAPSIZE; to_heapptr=to_heapbase; ptr=curr_heapbase; -#ifdef THREADS +#if defined(THREADS)||defined(DSTM) pthread_mutex_unlock(&gclock); #endif return ptr; @@ -498,20 +499,20 @@ void * mygcmalloc(struct garbagelist * stackptr, int size) { /* Not enough room :(, redo gc */ if (curr_heapptr>curr_heapgcpoint) { -#ifdef THREADS +#if defined(THREADS)||defined(DSTM) pthread_mutex_unlock(&gclock); #endif return mygcmalloc(stackptr, size); } bzero(tmp, curr_heaptop-tmp); -#ifdef THREADS +#if defined(THREADS)||defined(DSTM) pthread_mutex_unlock(&gclock); #endif return tmp; } } else { -#ifdef THREADS +#if defined(THREADS)||defined(DSTM) pthread_mutex_unlock(&gclock); #endif return ptr; diff --git a/Robust/src/Runtime/garbage.h b/Robust/src/Runtime/garbage.h index c021ac64..5a65de65 100644 --- a/Robust/src/Runtime/garbage.h +++ b/Robust/src/Runtime/garbage.h @@ -17,7 +17,7 @@ struct listitem { void fixtags(); #endif -#ifdef THREADS +#if defined(THREADS)||defined(DSTM) void checkcollect(void * ptr); struct listitem * stopforgc(struct garbagelist * ptr); void restartaftergc(struct listitem * litem); diff --git a/Robust/src/Runtime/thread.c b/Robust/src/Runtime/thread.c index a8b19c02..b070cbb0 100644 --- a/Robust/src/Runtime/thread.c +++ b/Robust/src/Runtime/thread.c @@ -17,6 +17,7 @@ pthread_cond_t objcond; pthread_key_t threadlocks; void threadexit() { +#ifdef THREADS struct ___Object___ *ll=pthread_getspecific(threadlocks); while(ll!=NULL) { struct ___Object___ *llnext=ll->___nextlockobject___; @@ -29,6 +30,7 @@ void threadexit() { pthread_mutex_lock(&objlock);//wake everyone up pthread_cond_broadcast(&objcond); pthread_mutex_unlock(&objlock); +#endif pthread_mutex_lock(&gclistlock); threadcount--; pthread_cond_signal(&gccond); @@ -66,6 +68,7 @@ void initializethreads() { sigaction(SIGFPE,&sig,0); } +#ifdef THREADS void initthread(struct ___Thread___ * ___this___) { #ifdef PRECISE_GC struct ___Thread______staticStart____L___Thread____params p={1, NULL, ___this___}; @@ -78,6 +81,7 @@ void initthread(struct ___Thread___ * ___this___) { pthread_cond_signal(&gccond); pthread_mutex_unlock(&gclistlock); } +#endif void CALL11(___Thread______sleep____J, long long ___millis___, long long ___millis___) { #ifdef THREADS @@ -93,6 +97,7 @@ void CALL11(___Thread______sleep____J, long long ___millis___, long long ___mill #endif } +#ifdef THREADS void CALL01(___Thread______nativeCreate____, struct ___Thread___ * ___this___) { pthread_t thread; int retval; @@ -112,3 +117,4 @@ void CALL01(___Thread______nativeCreate____, struct ___Thread___ * ___this___) { pthread_attr_destroy(&nattr); } +#endif diff --git a/Robust/src/buildscript b/Robust/src/buildscript index 6b9e0f04..11048407 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -198,7 +198,7 @@ $ROBUSTROOT/Runtime/GenericHashtable.c $ROBUSTROOT/Runtime/object.c" if $DSMFLAG then EXTRAOPTIONS="$EXTRAOPTIONS -lpthread -DCOMPILER -DDSTM -I$DSMRUNTIME" -FILES="$FILES $DSMRUNTIME/trans.c $DSMRUNTIME/mcpileq.c $DSMRUNTIME/objstr.c $DSMRUNTIME/dstm.c $DSMRUNTIME/mlookup.c $DSMRUNTIME/clookup.c $DSMRUNTIME/llookup.c $DSMRUNTIME/dstmserver.c $DSMRUNTIME/plookup.c $DSMRUNTIME/ip.c $DSMRUNTIME/queue.c $DSMRUNTIME/prelookup.c $DSMRUNTIME/machinepile.c $DSMRUNTIME/localobjects.c" +FILES="$FILES $DSMRUNTIME/trans.c $DSMRUNTIME/mcpileq.c $DSMRUNTIME/objstr.c $DSMRUNTIME/dstm.c $DSMRUNTIME/mlookup.c $DSMRUNTIME/clookup.c $DSMRUNTIME/llookup.c $DSMRUNTIME/dstmserver.c $DSMRUNTIME/plookup.c $DSMRUNTIME/ip.c $DSMRUNTIME/queue.c $DSMRUNTIME/prelookup.c $DSMRUNTIME/machinepile.c $DSMRUNTIME/localobjects.c $ROBUSTROOT/Runtime/thread.c" fi if $RECOVERFLAG -- 2.34.1