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<FlatNode, Set<TempDescriptor>> computeLiveTemps(FlatMethod fm) {
+ return computeLiveTemps(fm, null);
+ }
+ public static Hashtable<FlatNode, Set<TempDescriptor>> computeLiveTemps(FlatMethod fm, LocalityBinding lb) {
Hashtable<FlatNode, Set<TempDescriptor>> nodetotemps=new Hashtable<FlatNode, Set<TempDescriptor>>();
Set<FlatNode> toprocess=fm.getNodeSet();
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);
}
public static Hashtable<FlatNode, Set<TempDescriptor>> computeLiveOut(FlatMethod fm) {
- Hashtable<FlatNode, Set<TempDescriptor>> liveinmap=computeLiveTemps(fm);
+ return computeLiveOut(fm, null);
+ }
+
+ public static Hashtable<FlatNode, Set<TempDescriptor>> computeLiveOut(FlatMethod fm, LocalityBinding lb) {
+ Hashtable<FlatNode, Set<TempDescriptor>> liveinmap=computeLiveTemps(fm, lb);
Hashtable<FlatNode, Set<TempDescriptor>> liveoutmap=new Hashtable<FlatNode, Set<TempDescriptor>>();
for(Iterator<FlatNode> fnit=fm.getNodeSet().iterator(); fnit.hasNext();) {
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
/* liveintoset if true computes the reaching defs into the node and if false computes the reaching defs out of the node. */
public static Hashtable<FlatNode, Hashtable<TempDescriptor, Set<FlatNode>>> computeReachingDefs(FlatMethod fm, Hashtable<FlatNode, Set<TempDescriptor>> livemap, boolean liveintoset) {
+ return computeReachingDefs(fm, livemap, liveintoset, null);
+ }
+
+ public static Hashtable<FlatNode, Hashtable<TempDescriptor, Set<FlatNode>>> computeReachingDefs(FlatMethod fm, Hashtable<FlatNode, Set<TempDescriptor>> livemap, boolean liveintoset, LocalityBinding lb) {
Hashtable<FlatNode, Hashtable<TempDescriptor, Set<FlatNode>>> nodetotemps=new Hashtable<FlatNode, Hashtable<TempDescriptor,Set<FlatNode>>>();
Hashtable<FlatNode, Hashtable<TempDescriptor, Set<FlatNode>>> liveinto=liveintoset?new Hashtable<FlatNode, Hashtable<TempDescriptor,Set<FlatNode>>>():null;
liveinto.put(fn, new Hashtable<TempDescriptor, Set<FlatNode>>(tempset));
}
- TempDescriptor writes[]=fn.writesTemps();
- for(int i=0;i<writes.length;i++) {
- HashSet<FlatNode> s=new HashSet<FlatNode>();
- 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<writes.length;i++) {
+ HashSet<FlatNode> s=new HashSet<FlatNode>();
+ s.add(fn);
+ tempset.put(writes[i],s);
+ }
}
-
if (!nodetotemps.containsKey(fn)||
!nodetotemps.get(fn).equals(tempset)) {
nodetotemps.put(fn, tempset);
}
return liveintoset?liveinto:nodetotemps;
}
-
}
\ No newline at end of file
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) { \
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; \
dirwrlocked[numoidwrlocked++] = objptr; \
} \
if (addrdobject) { \
- rdlockedarray[numoidrdlockedarray++]=objptr; \
+ rdlockedarray[numoidrdlockedarray++]=objptr; \
} \
} else
/* 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
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;
/* 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