From: bdemsky Date: Mon, 20 Jul 2009 22:02:30 +0000 (+0000) Subject: bug fixes X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e2000b3281d0de997cc1d260097f56e2c39d4d08;p=IRC.git bug fixes --- diff --git a/Robust/src/Analysis/Locality/DelayComputation.java b/Robust/src/Analysis/Locality/DelayComputation.java index 011938a1..2216689d 100644 --- a/Robust/src/Analysis/Locality/DelayComputation.java +++ b/Robust/src/Analysis/Locality/DelayComputation.java @@ -509,15 +509,11 @@ public class DelayComputation { //See if flatnode is definitely no delay if (fn.kind()==FKind.FlatCall) { - isnodelay=true; - //Have to deal with fields/arrays FlatCall fcall=(FlatCall)fn; MethodDescriptor mdcall=fcall.getMethod(); - nodelayfieldwrset.addAll(gft.getFieldsAll(mdcall)); - nodelayarraywrset.addAll(typeanalysis.expandSet(gft.getArraysAll(mdcall))); - //Have to deal with field/array reads - nodelayfieldrdset.addAll(gft.getFieldsRdAll(mdcall)); - nodelayarrayrdset.addAll(typeanalysis.expandSet(gft.getArraysRdAll(mdcall))); + if (!mdcall.getClassDesc().getSymbol().equals("System")|| + (!mdcall.getSymbol().equals("println")&&!mdcall.getSymbol().equals("printString"))) + isnodelay=true; } //Delay branches if possible @@ -599,6 +595,18 @@ public class DelayComputation { //have to do expansion nodelayarrayrdset.addAll(typeanalysis.expand(((FlatElementNode)fn).getSrc().getType())); } + + //See if flatnode is definitely no delay + if (fn.kind()==FKind.FlatCall) { + //Have to deal with fields/arrays + FlatCall fcall=(FlatCall)fn; + MethodDescriptor mdcall=fcall.getMethod(); + nodelayfieldwrset.addAll(gft.getFieldsAll(mdcall)); + nodelayarraywrset.addAll(typeanalysis.expandSet(gft.getArraysAll(mdcall))); + //Have to deal with field/array reads + nodelayfieldrdset.addAll(gft.getFieldsRdAll(mdcall)); + nodelayarrayrdset.addAll(typeanalysis.expandSet(gft.getArraysRdAll(mdcall))); + } } else { //Need to know which objects to lock on switch(fn.kind()) { diff --git a/Robust/src/Analysis/Locality/LocalityAnalysis.java b/Robust/src/Analysis/Locality/LocalityAnalysis.java index 6a705e86..b4562ec4 100644 --- a/Robust/src/Analysis/Locality/LocalityAnalysis.java +++ b/Robust/src/Analysis/Locality/LocalityAnalysis.java @@ -504,8 +504,8 @@ public class LocalityAnalysis { } } else { Integer thistype=currtable.get(fc.getThis()); - if (!thistype.equals(NORMAL)) { - throw new Error("Called start on possible scratch object"); + if (!thistype.equals(NORMAL)&&!thistype.equals(STMEITHER)) { + throw new Error("Called start on possible scratch object"+thistype); } lb.setGlobal(0,currtable.get(fc.getThis())); } diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index e3d6bf1f..ffc2df2f 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -2676,11 +2676,11 @@ public class BuildCode { private void generateFlatCall(FlatMethod fm, LocalityBinding lb, FlatCall fc, PrintWriter output) { MethodDescriptor md=fc.getMethod(); - ParamsObject objectparams=(ParamsObject)paramstable.get(state.DSM||state.SINGLETM ? locality.getBinding(lb, fc) : md); + ParamsObject objectparams=(ParamsObject)paramstable.get(lb!=null ? locality.getBinding(lb, fc) : md); ClassDescriptor cn=md.getClassDesc(); output.println("{"); if (GENERATEPRECISEGC) { - if (state.DSM||state.SINGLETM) { + if (lb!=null) { LocalityBinding fclb=locality.getBinding(lb, fc); output.print(" struct "+cn.getSafeSymbol()+fclb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={"); } else @@ -2722,7 +2722,7 @@ public class BuildCode { /* Do we need to do virtual dispatch? */ if (md.isStatic()||md.getReturnType()==null||singleCall(fc.getThis().getType().getClassDesc(),md)) { //no - if (state.DSM||state.SINGLETM) { + if (lb!=null) { LocalityBinding fclb=locality.getBinding(lb, fc); output.print(cn.getSafeSymbol()+fclb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()); } else { @@ -2739,7 +2739,7 @@ public class BuildCode { boolean printcomma=false; if (GENERATEPRECISEGC) { - if (state.DSM||state.SINGLETM) { + if (lb!=null) { LocalityBinding fclb=locality.getBinding(lb, fc); output.print("struct "+cn.getSafeSymbol()+fclb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params * "); } else @@ -2759,7 +2759,7 @@ public class BuildCode { } - if (state.DSM||state.SINGLETM) { + if (lb!=null) { LocalityBinding fclb=locality.getBinding(lb, fc); output.print("))virtualtable["+generateTemp(fm,fc.getThis(),lb)+"->type*"+maxcount+"+"+virtualcalls.getLocalityNumber(fclb)+"])"); } else @@ -2900,6 +2900,7 @@ public class BuildCode { boolean srcptr=fsfn.getSrc().getType().isPtr(); String src=generateTemp(fm,fsfn.getSrc(),lb); String dst=generateTemp(fm,fsfn.getDst(),lb); + output.println("//"+srcptr+" "+fsfn.getSrc().getType().isNull()); if (srcptr&&!fsfn.getSrc().getType().isNull()) { output.println("{"); if ((dc==null)||dc.getNeedSrcTrans(lb, fsfn)&& diff --git a/Robust/src/Runtime/STM/stm.c b/Robust/src/Runtime/STM/stm.c index ac986758..2578796a 100644 --- a/Robust/src/Runtime/STM/stm.c +++ b/Robust/src/Runtime/STM/stm.c @@ -60,11 +60,32 @@ int typesCausingAbort[TOTALNUMCLASSANDARRAY]; #define DEBUGSTM(x...) #endif -#ifdef FASTMEMCPY -void * A_memcpy (void * dest, const void * src, size_t count); -#else -#define A_memcpy memcpy -#endif +//#ifdef FASTMEMCPY +//void * A_memcpy (void * dest, const void * src, size_t count); +//#else +//#define A_memcpy memcpy +//#endif + +void * A_memcpy (void * dest, const void * src, size_t count) { + int off=0; + INTPTR *desti=(INTPTR *)dest; + INTPTR *srci=(INTPTR *)src; + + //word copy + while(count>=sizeof(INTPTR)) { + desti[off]=srci[off]; + off+=1; + count-=sizeof(INTPTR); + } + off*=sizeof(INTPTR); + //byte copy + while(count>0) { + ((char *)dest)[off]=((char *)src)[off]; + off++; + count--; + } +} + extern void * curr_heapbase; extern void * curr_heapptr; @@ -256,7 +277,8 @@ void *objstrAlloc(unsigned int size) { * -copies the object into the transaction cache * ============================================================= */ -__attribute__ ((pure)) void *transRead(void * oid, void *gl) { +//__attribute__ ((pure)) +void *transRead(void * oid, void *gl) { objheader_t *tmp, *objheader; objheader_t *objcopy; int size; @@ -274,6 +296,7 @@ __attribute__ ((pure)) void *transRead(void * oid, void *gl) { } #endif A_memcpy(objcopy, header, size); + /* Insert into cache's lookup table */ STATUS(objcopy)=0; if (((unsigned INTPTR)oid)<((unsigned INTPTR ) curr_heapbase)|| ((unsigned INTPTR)oid) >((unsigned INTPTR) curr_heapptr)) @@ -615,6 +638,7 @@ int traverseCache() { objheader_t *header=oidrdlocked[i]; unsigned int version=oidrdversion[i]; if(header->lock>0) { //not write locked + CFENCE; if(version != header->version) { /* versions do not match */ #ifdef DELAYCOMP transAbortProcess(oidwrlocked, numoidwrtotal); @@ -912,7 +936,8 @@ int alttraverseCache() { for(i=0; ilock>=0) { + if(header->lock>0) { + CFENCE; if(version != header->version) { #ifdef DELAYCOMP transAbortProcess(oidwrlocked, numoidwrtotal); @@ -1137,12 +1162,8 @@ void transAbortProcess(void **oidwrlocked, int numoidwrlocked) { dst->___cachedCode___=src->___cachedCode___; dst->___cachedHash___=src->___cachedHash___; A_memcpy(&dst[1], &src[1], tmpsize-sizeof(struct ___Object___)); - __asm__ __volatile__("": : :"memory"); -#ifndef DELAYCOMP - header->version++; -#endif } - __asm__ __volatile__("": : :"memory"); + CFENCE; #ifdef DELAYCOMP // call commit method @@ -1159,9 +1180,7 @@ void transAbortProcess(void **oidwrlocked, int numoidwrlocked) { for(i=numoidwrlocked-1; i>=0; i--) { #endif header = (objheader_t *)oidwrlocked[i]; -#ifdef DELAYCOMP header->version++; -#endif write_unlock(&header->lock); } @@ -1328,7 +1347,7 @@ objheader_t * needLock(objheader_t *header, void *gl) { } else { //failed to get lock trec->blocked=1; //memory barrier - __asm__ __volatile__("":::"memory"); + CFENCE; //see if other thread is blocked if(ptr->blocked == 1) { //it might be block, so ignore lock and clear our blocked flag diff --git a/Robust/src/Runtime/STM/stmlock.c b/Robust/src/Runtime/STM/stmlock.c index 7da44b66..971f9026 100644 --- a/Robust/src/Runtime/STM/stmlock.c +++ b/Robust/src/Runtime/STM/stmlock.c @@ -18,6 +18,6 @@ int write_trylock(volatile unsigned int *lock) { */ void write_unlock(volatile unsigned int *lock) { - __asm __volatile__("movl $1, %0" : "+m" (*__xg(lock))::"memory"); + __asm __volatile__("movl $1, %0" : "+m" (*lock)::"memory"); } diff --git a/Robust/src/Runtime/STM/stmlock.h b/Robust/src/Runtime/STM/stmlock.h index 7b9c6d76..a396d8a5 100644 --- a/Robust/src/Runtime/STM/stmlock.h +++ b/Robust/src/Runtime/STM/stmlock.h @@ -3,6 +3,7 @@ #define RW_LOCK_BIAS 1 #define LOCK_UNLOCKED { LOCK_BIAS } +#define CFENCE asm volatile("":::"memory"); struct __xchg_dummy { unsigned long a[100]; @@ -23,7 +24,7 @@ static inline int write_trylock(volatile unsigned int *lock) { int retval=0; __asm__ __volatile__("xchgl %0,%1" : "=r"(retval) - : "m"(*__xg(lock)), "0"(retval) + : "m"(*lock), "0"(retval) : "memory"); return retval; }