From: bdemsky Date: Wed, 14 Oct 2009 20:38:04 +0000 (+0000) Subject: more work towards supporting arrays X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ad2e5de4cab4aeb38335bbe4377ef3df740eafd8;p=IRC.git more work towards supporting arrays --- diff --git a/Robust/src/Analysis/Liveness.java b/Robust/src/Analysis/Liveness.java index 2b10f739..0c62d0b5 100644 --- a/Robust/src/Analysis/Liveness.java +++ b/Robust/src/Analysis/Liveness.java @@ -7,12 +7,16 @@ import java.util.Set; import java.util.Iterator; import java.util.List; import java.util.Hashtable; +import Analysis.Locality.*; public class Liveness { /* This methods takes in a FlatMethod and returns a map from a * FlatNode to the set of temps that are live into the FlatNode.*/ public static Hashtable> computeLiveTemps(FlatMethod fm) { + return computeLiveTemps(fm, null); + } + public static Hashtable> computeLiveTemps(FlatMethod fm, LocalityBinding lb) { Hashtable> nodetotemps=new Hashtable>(); Set toprocess=fm.getNodeSet(); @@ -30,8 +34,11 @@ public class Liveness { if (nodetotemps.containsKey(fnnext)) tempset.addAll(nodetotemps.get(fnnext)); } - tempset.removeAll(writes); - tempset.addAll(reads); + if ((lb==null)||(!(fn instanceof FlatGlobalConvNode))|| + ((FlatGlobalConvNode)fn).getLocality()==lb) { + tempset.removeAll(writes); + tempset.addAll(reads); + } if (!nodetotemps.containsKey(fn)|| !nodetotemps.get(fn).equals(tempset)) { nodetotemps.put(fn, tempset); @@ -43,7 +50,11 @@ public class Liveness { } public static Hashtable> computeLiveOut(FlatMethod fm) { - Hashtable> liveinmap=computeLiveTemps(fm); + return computeLiveOut(fm, null); + } + + public static Hashtable> computeLiveOut(FlatMethod fm, LocalityBinding lb) { + Hashtable> liveinmap=computeLiveTemps(fm, lb); Hashtable> liveoutmap=new Hashtable>(); for(Iterator fnit=fm.getNodeSet().iterator(); fnit.hasNext();) { diff --git a/Robust/src/Analysis/ReachingDefs.java b/Robust/src/Analysis/ReachingDefs.java index f10f3f26..d0f3ebd2 100644 --- a/Robust/src/Analysis/ReachingDefs.java +++ b/Robust/src/Analysis/ReachingDefs.java @@ -5,6 +5,7 @@ import java.util.HashSet; import java.util.Set; import java.util.Iterator; import java.util.Hashtable; +import Analysis.Locality.*; public class ReachingDefs { /* This methods takes in a FlatMethod and returns a map from a @@ -13,6 +14,10 @@ public class ReachingDefs { /* liveintoset if true computes the reaching defs into the node and if false computes the reaching defs out of the node. */ public static Hashtable>> computeReachingDefs(FlatMethod fm, Hashtable> livemap, boolean liveintoset) { + return computeReachingDefs(fm, livemap, liveintoset, null); + } + + public static Hashtable>> computeReachingDefs(FlatMethod fm, Hashtable> livemap, boolean liveintoset, LocalityBinding lb) { Hashtable>> nodetotemps=new Hashtable>>(); Hashtable>> liveinto=liveintoset?new Hashtable>>():null; @@ -47,13 +52,15 @@ public class ReachingDefs { liveinto.put(fn, new Hashtable>(tempset)); } - TempDescriptor writes[]=fn.writesTemps(); - for(int i=0;i s=new HashSet(); - s.add(fn); - tempset.put(writes[i],s); + if (lb==null||(!(fn instanceof FlatGlobalConvNode))|| + ((FlatGlobalConvNode) fn).getLocality()==lb) { + TempDescriptor writes[]=fn.writesTemps(); + for(int i=0;i s=new HashSet(); + s.add(fn); + tempset.put(writes[i],s); + } } - if (!nodetotemps.containsKey(fn)|| !nodetotemps.get(fn).equals(tempset)) { nodetotemps.put(fn, tempset); @@ -63,5 +70,4 @@ public class ReachingDefs { } return liveintoset?liveinto:nodetotemps; } - } \ No newline at end of file diff --git a/Robust/src/Runtime/STM/commit.c b/Robust/src/Runtime/STM/commit.c index 912ceb38..bda2038f 100644 --- a/Robust/src/Runtime/STM/commit.c +++ b/Robust/src/Runtime/STM/commit.c @@ -238,6 +238,22 @@ int transCommit() { void * rdlockedarray[200]; \ void ** oidrdlockedarray; +#define ARRAYABORT \ + for(;j>=lowoffset;j--) { \ + GETLOCKVAL(status, transao, j); \ + if (status==STMDIRTY) { \ + GETLOCKPTR(lockptr, mainao,j); \ + write_unlock(lockptr); \ + } \ + } \ + transAbortProcess(oidwrlocked, numoidwrlocked); \ + freearrays; \ + if (softabort) \ + return TRANS_SOFT_ABORT; \ + else \ + return TRANS_ABORT; + + #define PROCESSARRAY \ int type=((int *)cachedobj)[0]; \ if (type>=NUMCLASSES) { \ @@ -261,14 +277,11 @@ int transCommit() { if (localversion == remoteversion) { \ addwrobject=1; \ } else { \ - dirwrlocked[numoidwrlocked++] = objptr; \ - transAbortProcess(oidwrlocked, numoidwrlocked); \ - freearrays; \ - if (softabort) \ - return TRANS_SOFT_ABORT; \ - else \ - return TRANS_ABORT; \ + ARRAYABORT; \ } \ + } else { \ + j--; \ + ARRAYABORT; \ } \ } else if (status==STMCLEAN) { \ addrdobject=1; \ @@ -278,7 +291,7 @@ int transCommit() { dirwrlocked[numoidwrlocked++] = objptr; \ } \ if (addrdobject) { \ - rdlockedarray[numoidrdlockedarray++]=objptr; \ + rdlockedarray[numoidrdlockedarray++]=objptr; \ } \ } else @@ -808,7 +821,28 @@ void transAbortProcess(struct garbagelist *oidwrlocked, int numoidwrlocked) { /* Release write locks */ for(i=numoidwrlocked-1; i>=0; i--) { /* Read from the main heap */ - header = &((objheader_t *)dirwrlocked[i])[-1]; + struct ___Object___ * dst=dirwrlocked[i]; + header = &((objheader_t *)dst)[-1]; +#ifdef STMARRAY + int type=dst->type; + if (type>=NUMCLASSES) { + //have array, do unlocking of bins + struct ArrayObject *src=(struct ArrayObject *)t_chashSearch(dst); + int lowoffset=(src->lowindex)>>INDEXSHIFT; + int highoffset=(src->highindex)>>INDEXSHIFT; + int j; + int addwrobject=0, addrdobject=0; + for(j=lowoffset; j<=highoffset;j++) { + int status; + GETLOCKVAL(status, src, j); + if (status==STMDIRTY) { + int *lockptr; + GETLOCKPTR(lockptr, ((struct ArrayObject *)dst), j); + write_unlock(lockptr); + } + } + } else +#endif write_unlock(&header->lock); } #ifdef STMSTATS @@ -860,7 +894,26 @@ void transCommitProcess(struct garbagelist * oidwrlocked, int numoidwrlocked) { struct ___Object___ *src=t_chashSearch(dst); dst->___cachedCode___=src->___cachedCode___; dst->___cachedHash___=src->___cachedHash___; - A_memcpy(&dst[1], &src[1], tmpsize-sizeof(struct ___Object___)); +#ifdef STMARRAY + int type=dst->type; + if (type>=NUMCLASSES) { + //have array, do copying of bins + int lowoffset=(((struct ArrayObject *)src)->lowindex)>>INDEXSHIFT; + int highoffset=(((struct ArrayObject *)src)->highindex)>>INDEXSHIFT; + int j; + int addwrobject=0, addrdobject=0; + int elementsize=classsize[type]; + int baseoffset=(lowoffset*elementsize)&HIGHMASK; + for(j=lowoffset; j<=highoffset;j++, baseoffset+=elementsize) { + int status; + GETLOCKVAL(status, ((struct ArrayObject *)src), j); + if (status==STMDIRTY) { + A_memcpy(((char *)&oid[1])+baseoffset, ((char *)&orig[1])+baseoffset, INDEXLENGTH); + } + } + } else +#endif + A_memcpy(&dst[1], &src[1], tmpsize-sizeof(struct ___Object___)); } CFENCE; @@ -879,9 +932,34 @@ void transCommitProcess(struct garbagelist * oidwrlocked, int numoidwrlocked) { /* Release write locks */ for(i=NUMWRTOTAL-1; i>=0; i--) { - header = &((objheader_t *)dirwrlocked[i])[-1]; - header->version++; - write_unlock(&header->lock); + struct ___Object___ * dst=dirwrlocked[i]; + header = &((objheader_t *)dst)[-1]; +#ifdef STMARRAY + int type=dst->type; + if (type>=NUMCLASSES) { + //have array, do unlocking of bins + struct ArrayObject *src=(struct ArrayObject *)t_chashSearch(dst); + int lowoffset=(src->lowindex)>>INDEXSHIFT; + int highoffset=(src->highindex)>>INDEXSHIFT; + int j; + int addwrobject=0, addrdobject=0; + for(j=lowoffset; j<=highoffset;j++) { + int status; + GETLOCKVAL(status, src, j); + if (status==STMDIRTY) { + int *ptr; + GETVERSIONPTR(intptr, ((struct ArrayObject *)dst), j); + (*intptr)++; + GETLOCKPTR(intptr, ((struct ArrayObject *)dst), j); + write_unlock(intptr); + } + } + } else +#endif + { + header->version++; + write_unlock(&header->lock); + } } #ifdef STMSTATS