objecttemps.addPrim(tmp);
}
/* Create temp to hold revert table */
- if (lb.getHasAtomic()) {
+ if (lb.getHasAtomic()||lb.isAtomic()) {
TempDescriptor reverttmp=new TempDescriptor("revertlist", typeutil.getClass(TypeUtil.ObjectClass));
if (GENERATEPRECISEGC)
objecttemps.addPtr(reverttmp);
* multi-threaded program...*/
if ((state.THREAD||state.DSM)&&GENERATEPRECISEGC) {
- output.println("checkcollect(&"+localsprefix+");");
+ if (state.DSM&&lb.isAtomic())
+ output.println("checkcollect2(&"+localsprefix+",trans);");
+ else
+ output.println("checkcollect(&"+localsprefix+");");
}
/* Do the actual code generation */
return;
case FKind.FlatBackEdge:
if ((state.THREAD||state.DSM)&&GENERATEPRECISEGC) {
- output.println("checkcollect(&"+localsprefix+");");
+ if(state.DSM&&locality.getAtomic(lb).get(fn).intValue()>0) {
+ output.println("checkcollect2(&"+localsprefix+",trans);");
+ } else
+ output.println("checkcollect(&"+localsprefix+");");
} else
output.println("/* nop */");
return;
/** Check if we need to copy */
output.println("if(!"+dst+"->"+localcopystr+") {");
/* Link object into list */
- output.println(dst+"->"+nextobjstr+"=trans->revertlist;");
- output.println("trans->revertlist=(struct ___Object___ *)"+dst+";");
+ String revertptr=generateTemp(fm, reverttable.get(lb),lb);
+ output.println(revertptr+"=trans->revertlist;");
if (GENERATEPRECISEGC)
output.println("COPY_OBJ((struct garbagelist *)&"+localsprefix+",(struct ___Object___ *)"+dst+");");
else
output.println("COPY_OBJ("+dst+");");
+ output.println(dst+"->"+nextobjstr+"="+revertptr+";");
+ output.println("trans->revertlist=(struct ___Object___ *)"+dst+";");
output.println("}");
if (srcglobal)
output.println(dst+"->"+ fsfn.getField().getSafeSymbol()+"=srcoid;");
Integer statusdst=locality.getNodePreTempInfo(lb,fsen).get(fsen.getDst());
boolean srcglobal=statussrc==LocalityAnalysis.GLOBAL;
boolean dstglobal=statusdst==LocalityAnalysis.GLOBAL;
+ boolean dstlocal=statusdst==LocalityAnalysis.LOCAL;
+
if (dstglobal) {
output.println("*((unsigned int *)&("+generateTemp(fm,fsen.getDst(),lb)+"->___localcopy___))|=DIRTY;");
- }
+ } else if (dstlocal) {
+ /** Check if we need to copy */
+ String dst=generateTemp(fm, fsen.getDst(),lb);
+ output.println("if(!"+dst+"->"+localcopystr+") {");
+ /* Link object into list */
+ String revertptr=generateTemp(fm, reverttable.get(lb),lb);
+ output.println(revertptr+"=trans->revertlist;");
+ if (GENERATEPRECISEGC)
+ output.println("COPY_OBJ((struct garbagelist *)&"+localsprefix+",(struct ___Object___ *)"+dst+");");
+ else
+ output.println("COPY_OBJ("+dst+");");
+ output.println(dst+"->"+nextobjstr+"="+revertptr+";");
+
+ output.println("trans->revertlist=(struct ___Object___ *)"+dst+";");
+ output.println("}");
+ } else throw new Error("Unknown array type");
if (srcglobal) {
output.println("{");
String src=generateTemp(fm, fsen.getSrc(), lb);
}
private void generateFlatNew(FlatMethod fm, LocalityBinding lb, FlatNew fn, PrintWriter output) {
+ if (state.DSM && locality.getAtomic(lb).get(fn).intValue()>0&&!fn.isGlobal()) {
+ //Stash pointer in case of GC
+ String revertptr=generateTemp(fm, reverttable.get(lb),lb);
+ output.println(revertptr+"=trans->revertlist;");
+ }
if (fn.getType().isArray()) {
int arrayid=state.getArrayNumber(fn.getType())+state.numClasses();
if (fn.isGlobal()) {
output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new("+fn.getType().getClassDesc().getId()+");");
}
}
+ if (state.DSM && locality.getAtomic(lb).get(fn).intValue()>0&&!fn.isGlobal()) {
+ String revertptr=generateTemp(fm, reverttable.get(lb),lb);
+ output.println("trans->revertlist="+revertptr+";");
+ }
}
private void generateFlatTagDeclaration(FlatMethod fm, LocalityBinding lb, FlatTagDeclaration fn, PrintWriter output) {
output.println(generateTemp(fm, fln.getDst(),lb)+"=0;");
else if (fln.getType().getSymbol().equals(TypeUtil.StringClass)) {
if (GENERATEPRECISEGC) {
+ if (state.DSM && locality.getAtomic(lb).get(fln).intValue()>0) {
+ //Stash pointer in case of GC
+ String revertptr=generateTemp(fm, reverttable.get(lb),lb);
+ output.println(revertptr+"=trans->revertlist;");
+ }
output.println(generateTemp(fm, fln.getDst(),lb)+"=NewString(&"+localsprefix+", \""+FlatLiteralNode.escapeString((String)fln.getValue())+"\","+((String)fln.getValue()).length()+");");
+ if (state.DSM && locality.getAtomic(lb).get(fln).intValue()>0) {
+ //Stash pointer in case of GC
+ String revertptr=generateTemp(fm, reverttable.get(lb),lb);
+ output.println("trans->revertlist="+revertptr+";");
+ }
} else {
output.println(generateTemp(fm, fln.getDst(),lb)+"=NewString(\""+FlatLiteralNode.escapeString((String)fln.getValue())+"\","+((String)fln.getValue()).length()+");");
}
#ifdef DMALLOC
#include "dmalloc.h"
#endif
-
+#ifdef DSTM
+#include "dstm.h"
+#endif
#define NUMPTRS 100
if (pointer==0) {
/* Array of primitives */
/* Do nothing */
+#ifdef DSTM
+ struct ArrayObject *ao=(struct ArrayObject *) ptr;
+ struct ArrayObject *ao_cpy=(struct ArrayObject *) cpy;
+ ENQUEUE((void *)ao->___nextobject___, *((void **)&ao_cpy->___nextobject___));
+ ENQUEUE((void *)ao->___localcopy___, *((void **)&ao_cpy->___localcopy___));
+#endif
} else if (((int)pointer)==1) {
/* Array of pointers */
struct ArrayObject *ao=(struct ArrayObject *) ptr;
struct ArrayObject *ao_cpy=(struct ArrayObject *) cpy;
+#ifdef DSTM
+ ENQUEUE((void *)ao->___nextobject___, *((void **)&ao_cpy->___nextobject___));
+ ENQUEUE((void *)ao->___localcopy___, *((void **)&ao_cpy->___localcopy___));
+#endif
int length=ao->___length___;
int i;
for(i=0;i<length;i++) {
}
#if defined(THREADS)||defined(DSTM)
-
void checkcollect(void * ptr) {
if (needtocollect) {
struct listitem * tmp=stopforgc((struct garbagelist *)ptr);
}
}
+#ifdef DSTM
+void checkcollect2(void * ptr, transrecord_t *trans) {
+ if (needtocollect) {
+ int ptrarray[]={1, (int)ptr, (int) trans->revertlist};
+ struct listitem * tmp=stopforgc((struct garbagelist *)ptrarray);
+ pthread_mutex_lock(&gclock); // Wait for GC
+ restartaftergc(tmp);
+ pthread_mutex_unlock(&gclock);
+ trans->revertlist=(struct ___Object___*)ptrarray[2];
+ }
+}
+#endif
+
+
struct listitem * stopforgc(struct garbagelist * ptr) {
struct listitem * litem=malloc(sizeof(struct listitem));
litem->stackptr=ptr;