import Analysis.Locality.LocalityAnalysis;
import Analysis.Locality.LocalityBinding;
import Analysis.Locality.DiscoverConflicts;
+import Analysis.Locality.DCWrapper;
import Analysis.Locality.DelayComputation;
+import Analysis.Locality.BranchAnalysis;
import Analysis.CallGraph.CallGraph;
+import Analysis.Disjoint.Effect;
+import Analysis.Disjoint.ReachGraph;
+import Analysis.Disjoint.Taint;
+import Analysis.OoOJava.OoOJavaAnalysis;
import Analysis.Prefetch.*;
import Analysis.Loops.WriteBarrier;
import Analysis.Loops.GlobalFieldType;
import Analysis.Locality.TypeAnalysis;
+import Analysis.MLP.ConflictGraph;
+import Analysis.MLP.ConflictNode;
import Analysis.MLP.MLPAnalysis;
+import Analysis.MLP.ParentChildConflictsMap;
+import Analysis.MLP.SESELock;
+import Analysis.MLP.SESEWaitingQueue;
import Analysis.MLP.VariableSourceToken;
+import Analysis.MLP.VSTWrapper;
import Analysis.MLP.CodePlan;
import Analysis.MLP.SESEandAgePair;
+import Analysis.MLP.WaitingElement;
public class BuildCode {
State state;
SafetyAnalysis sa;
PrefetchAnalysis pa;
MLPAnalysis mlpa;
+ OoOJavaAnalysis oooa;
String mlperrstr = "if(status != 0) { "+
"sprintf(errmsg, \"MLP error at %s:%d\", __FILE__, __LINE__); "+
"perror(errmsg); exit(-1); }";
WriteBarrier wb;
DiscoverConflicts dc;
DiscoverConflicts recorddc;
- DelayComputation delaycomp;
+ DCWrapper delaycomp;
CallGraph callgraph;
+
public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, SafetyAnalysis sa, PrefetchAnalysis pa) {
- this(st, temptovar, typeutil, null, sa, pa, null);
+ this(st, temptovar, typeutil, null, sa, pa, null, null);
}
- public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, SafetyAnalysis sa, PrefetchAnalysis pa, MLPAnalysis mlpa) {
- this(st, temptovar, typeutil, null, sa, pa, mlpa);
+ public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, SafetyAnalysis sa, PrefetchAnalysis pa, MLPAnalysis mlpa, OoOJavaAnalysis oooa) {
+ this(st, temptovar, typeutil, null, sa, pa, mlpa, oooa);
}
- public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, LocalityAnalysis locality, PrefetchAnalysis pa, MLPAnalysis mlpa) {
- this(st, temptovar, typeutil, locality, null, pa, mlpa);
+ public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, LocalityAnalysis locality, PrefetchAnalysis pa, MLPAnalysis mlpa, OoOJavaAnalysis oooa) {
+ this(st, temptovar, typeutil, locality, null, pa, mlpa, oooa);
}
- public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, LocalityAnalysis locality, SafetyAnalysis sa, PrefetchAnalysis pa, MLPAnalysis mlpa) {
+ public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, LocalityAnalysis locality, SafetyAnalysis sa, PrefetchAnalysis pa, MLPAnalysis mlpa, OoOJavaAnalysis oooa) {
this.sa=sa;
this.pa=pa;
this.mlpa=mlpa;
+ this.oooa=oooa;
state=st;
callgraph=new CallGraph(state);
if (state.SINGLETM)
}
if (state.SINGLETM&&state.DCOPTS) {
TypeAnalysis typeanalysis=new TypeAnalysis(locality, st, typeutil,callgraph);
- this.dc=new DiscoverConflicts(locality, st, typeanalysis, null);
+ GlobalFieldType gft=new GlobalFieldType(callgraph, st, typeutil.getMain());
+ this.dc=new DiscoverConflicts(locality, st, typeanalysis, gft);
dc.doAnalysis();
}
if (state.DELAYCOMP) {
//TypeAnalysis typeanalysis=new TypeAnalysis(locality, st, typeutil,callgraph);
TypeAnalysis typeanalysis=new TypeAnalysis(locality, st, typeutil,callgraph);
GlobalFieldType gft=new GlobalFieldType(callgraph, st, typeutil.getMain());
- delaycomp=new DelayComputation(locality, st, typeanalysis, gft);
- delaycomp.doAnalysis();
+ delaycomp=new DCWrapper(locality, st, typeanalysis, gft);
dc=delaycomp.getConflicts();
recorddc=new DiscoverConflicts(locality, st, typeanalysis, delaycomp.getCannotDelayMap(), true, true, null);
recorddc.doAnalysis();
/** The buildCode method outputs C code for all the methods. The Flat
* versions of the methods must already be generated and stored in
* the State object. */
+ PrintWriter outsandbox=null;
public void buildCode() {
/* Create output streams to write to */
PrintWriter optionalheaders=null;
try {
+ if (state.SANDBOX) {
+ outsandbox=new PrintWriter(new FileOutputStream(PREFIX+"sandboxdefs.c"), true);
+ }
outstructs=new PrintWriter(new FileOutputStream(PREFIX+"structdefs.h"), true);
outmethodheader=new PrintWriter(new FileOutputStream(PREFIX+"methodheaders.h"), true);
outclassdefs=new PrintWriter(new FileOutputStream(PREFIX+"classdefs.h"), true);
outmethodheader.println("#include \"structdefs.h\"");
if (state.DSM)
outmethodheader.println("#include \"dstm.h\"");
+ if (state.SANDBOX) {
+ outmethodheader.println("#include \"sandbox.h\"");
+ }
+ if (state.EVENTMONITOR) {
+ outmethodheader.println("#include \"monitor.h\"");
+ }
if (state.SINGLETM) {
outmethodheader.println("#include \"tm.h\"");
outmethodheader.println("#include \"delaycomp.h\"");
+ outmethodheader.println("#include \"inlinestm.h\"");
}
if (state.ABORTREADERS) {
outmethodheader.println("#include \"abortreaders.h\"");
outmethodheader.println("#include <setjmp.h>");
}
- if (state.MLP) {
+ if (state.MLP || state.OOOJAVA) {
outmethodheader.println("#include <stdlib.h>");
outmethodheader.println("#include <stdio.h>");
outmethodheader.println("#include <string.h>");
outputTaskTypes(outtask);
}
- if( state.MLP ) {
+ if( state.MLP || state.OOOJAVA) {
// have to initialize some SESE compiler data before
// analyzing normal methods, which must happen before
// generating SESE internal code
- for(Iterator<FlatSESEEnterNode> seseit=mlpa.getAllSESEs().iterator();seseit.hasNext();) {
- FlatSESEEnterNode fsen = seseit.next();
- initializeSESE( fsen );
+
+ Iterator<FlatSESEEnterNode> seseit;
+ if(state.MLP){
+ seseit=mlpa.getAllSESEs().iterator();
+ }else{
+ seseit=oooa.getAllSESEs().iterator();
+ }
+ while(seseit.hasNext()){
+ FlatSESEEnterNode fsen = seseit.next();
+ initializeSESE( fsen );
+
+ /*
+ if(state.RCR){
+ if(!fsen.getIsCallerSESEplaceholder() && fsen.getParent()!=null){
+
+ FlatMethod fm=fsen.getfmEnclosing();
+
+ //reach graph
+ ReachGraph rg=oooa.getDisjointAnalysis().getReachGraph(fm.getMethod());
+
+ //get effect set
+ Hashtable<Taint, Set<Effect>> effects=oooa.getDisjointAnalysis().getEffectsAnalysis().get(fsen);
+
+ //get conflict set
+ Analysis.OoOJava.ConflictGraph conflictGraph=oooa.getConflictGraph(fsen.getParent());
+ Hashtable<Taint, Set<Effect>> conflicts=conflictGraph.getConflictEffectSet(fsen);
+ }
+ }
+ */
}
+
}
/* Build the actual methods */
outputMethods(outmethod);
// Output function prototypes and structures for SESE's and code
- if( state.MLP ) {
+ if( state.MLP || state.OOOJAVA ) {
+
+ // used to differentiate, during code generation, whether we are
+ // passing over SESE body code, or non-SESE code
nonSESEpass = false;
- // first generate code for each sese's internals
- for(Iterator<FlatSESEEnterNode> seseit=mlpa.getAllSESEs().iterator();seseit.hasNext();) {
+ // first generate code for each sese's internals
+ Iterator<FlatSESEEnterNode> seseit;
+ if(state.MLP){
+ seseit=mlpa.getAllSESEs().iterator();
+ }else{
+ seseit=oooa.getAllSESEs().iterator();
+ }
+
+ while(seseit.hasNext()) {
FlatSESEEnterNode fsen = seseit.next();
generateMethodSESE(fsen, null, outstructs, outmethodheader, outmethod);
}
generateOptionalArrays(outoptionalarrays, optionalheaders, state.getAnalysisResult(), state.getOptionalTaskDescriptors());
outoptionalarrays.close();
}
-
+
/* Output structure definitions for repair tool */
if (state.structfile!=null) {
buildRepairStructs(outrepairstructs);
outrepairstructs.close();
}
-
+
/* Close files */
outmethodheader.println("#endif");
outmethodheader.close();
outstructs.println("#endif");
outstructs.close();
}
-
+
/* This code just generates the main C method for java programs.
* The main C method packs up the arguments into a string array
outmethod.println("int main(int argc, const char *argv[]) {");
outmethod.println(" int i;");
- if (state.MLP) {
+ if (state.MLP || state.OOOJAVA) {
+ //outmethod.println(" pthread_once( &mlpOnceObj, mlpInitOncePerThread );");
+
outmethod.println(" workScheduleInit( "+state.MLP_NUMCORES+", invokeSESEmethod );");
}
if (state.DSM) {
- outmethod.println("#ifdef TRANSSTATS \n");
- outmethod.println("handle();\n");
- outmethod.println("#endif\n");
+ if (state.DSMRECOVERYSTATS) {
+ outmethod.println("#ifdef RECOVERYSTATS \n");
+ outmethod.println("handle();\n");
+ outmethod.println("#endif\n");
+ } else {
+ outmethod.println("#if defined(TRANSSTATS) || defined(RECOVERYSTATS) \n");
+ outmethod.println("handle();\n");
+ outmethod.println("#endif\n");
+ }
}
+
if (state.THREAD||state.DSM||state.SINGLETM) {
outmethod.println("initializethreads();");
}
if (state.DSM) {
outmethod.println("if (dstmStartup(argv[1])) {");
- if (GENERATEPRECISEGC) {
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
outmethod.println(" struct ArrayObject * stringarray=allocate_newarray(NULL, STRINGARRAYTYPE, argc-2);");
} else {
outmethod.println(" struct ArrayObject * stringarray=allocate_newarray(STRINGARRAYTYPE, argc-2);");
}
} else {
- if (GENERATEPRECISEGC) {
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
outmethod.println(" struct ArrayObject * stringarray=allocate_newarray(NULL, STRINGARRAYTYPE, argc-1);");
} else {
outmethod.println(" struct ArrayObject * stringarray=allocate_newarray(STRINGARRAYTYPE, argc-1);");
} else
outmethod.println(" for(i=1;i<argc;i++) {");
outmethod.println(" int length=strlen(argv[i]);");
- if (GENERATEPRECISEGC) {
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
outmethod.println(" struct ___String___ *newstring=NewString(NULL, argv[i], length);");
} else {
outmethod.println(" struct ___String___ *newstring=NewString(argv[i], length);");
ClassDescriptor cd=typeutil.getMainClass();
outmethod.println(" {");
- if (GENERATEPRECISEGC) {
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
if (state.DSM||state.SINGLETM) {
outmethod.print(" struct "+cd.getSafeSymbol()+locality.getMain().getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={");
} else
outmethod.print(" struct "+cd.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={");
- outmethod.println("1, NULL,"+"stringarray};");
+ outmethod.println("1, NULL,"+"stringarray};");
if (state.DSM||state.SINGLETM)
outmethod.println(" "+cd.getSafeSymbol()+locality.getMain().getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"(& __parameterlist__);");
else
}
if (state.DSM||state.SINGLETM) {
- outmethod.println("#ifdef TRANSSTATS \n");
+ //outmethod.println("#if defined(TRANSSTATS) || defined(RECOVERYSTATS) \n");
+ outmethod.println("#if defined(TRANSSTATS) \n");
outmethod.println("printf(\"****** Transaction Stats ******\\n\");");
outmethod.println("printf(\"numTransCommit= %d\\n\", numTransCommit);");
outmethod.println("printf(\"numTransAbort= %d\\n\", numTransAbort);");
outmethod.println("printf(\"nchashSearch= %d\\n\", nchashSearch);");
outmethod.println("printf(\"nmhashSearch= %d\\n\", nmhashSearch);");
outmethod.println("printf(\"nprehashSearch= %d\\n\", nprehashSearch);");
+ outmethod.println("printf(\"ndirtyCacheObj= %d\\n\", ndirtyCacheObj);");
outmethod.println("printf(\"nRemoteReadSend= %d\\n\", nRemoteSend);");
outmethod.println("printf(\"bytesSent= %d\\n\", bytesSent);");
outmethod.println("printf(\"bytesRecv= %d\\n\", bytesRecv);");
+ outmethod.println("printf(\"totalObjSize= %d\\n\", totalObjSize);");
+ outmethod.println("printf(\"sendRemoteReq= %d\\n\", sendRemoteReq);");
+ outmethod.println("printf(\"getResponse= %d\\n\", getResponse);");
} else if (state.SINGLETM) {
outmethod.println("printf(\"nSoftAbortAbort= %d\\n\", nSoftAbortAbort);");
outmethod.println("printf(\"nSoftAbortCommit= %d\\n\", nSoftAbortCommit);");
outmethod.println("#endif\n");
}
+ if (state.EVENTMONITOR) {
+ outmethod.println("dumpdata();");
+ }
+
if (state.THREAD||state.SINGLETM)
outmethod.println("pthread_exit(NULL);");
- if (state.MLP) {
+ if (state.MLP || state.OOOJAVA ) {
outmethod.println(" workScheduleBegin();");
}
outmethod.println("#include \"methodheaders.h\"");
outmethod.println("#include \"virtualtable.h\"");
outmethod.println("#include \"runtime.h\"");
+ if (state.SANDBOX) {
+ outmethod.println("#include \"sandboxdefs.c\"");
+ }
if (state.DSM) {
outmethod.println("#include \"addPrefetchEnhance.h\"");
outmethod.println("#include \"localobjects.h\"");
if (state.CONSCHECK) {
outmethod.println("#include \"checkers.h\"");
}
- if (state.MLP) {
+ if (state.MLP || state.OOOJAVA ) {
outmethod.println("#include <stdlib.h>");
outmethod.println("#include <stdio.h>");
outmethod.println("#include \"mlp_runtime.h\"");
outmethod.println("#include \"psemaphore.h\"");
}
-
+ if (state.COREPROF) {
+ outmethod.println("#include \"coreprof\\coreprof.h\"");
+ }
//Store the sizes of classes & array elements
generateSizeArray(outmethod);
wb.analyze(lb);
if (!md.getModifiers().isNative()) {
generateFlatMethod(fm, lb, outmethod);
+ //System.out.println("fm= " + fm + " md= " + md);
}
}
} else {
outstructs.println("#define INTPTR int");
outstructs.println("#endif");
outstructs.println("#endif");
- if( state.MLP ) {
+ if( state.MLP || state.OOOJAVA ) {
+ outstructs.println("#include \"mlp_runtime.h\"");
outstructs.println("#include \"psemaphore.h\"");
}
* numbers for various objects it needs */
outstructs.println("#define MAXCOUNT "+maxcount);
if (state.DSM||state.SINGLETM) {
- LocalityBinding lb=new LocalityBinding(typeutil.getRun(), false);
- if (state.DSM)
- lb.setGlobalThis(LocalityAnalysis.GLOBAL);
- else if (state.SINGLETM)
- lb.setGlobalThis(LocalityAnalysis.NORMAL);
- outstructs.println("#define RUNMETHOD "+virtualcalls.getLocalityNumber(lb));
+ LocalityBinding lbrun=new LocalityBinding(typeutil.getRun(), false);
+ if (state.DSM) {
+ lbrun.setGlobalThis(LocalityAnalysis.GLOBAL);
+ }
+ else if (state.SINGLETM) {
+ lbrun.setGlobalThis(LocalityAnalysis.NORMAL);
+ }
+ outstructs.println("#define RUNMETHOD "+virtualcalls.getLocalityNumber(lbrun));
+ }
+
+ if (state.DSMTASK) {
+ LocalityBinding lbexecute = new LocalityBinding(typeutil.getExecute(), false);
+ if(state.DSM)
+ lbexecute.setGlobalThis(LocalityAnalysis.GLOBAL);
+ else if( state.SINGLETM)
+ lbexecute.setGlobalThis(LocalityAnalysis.NORMAL);
+ outstructs.println("#define EXECUTEMETHOD " + virtualcalls.getLocalityNumber(lbexecute));
}
outstructs.println("#define STRINGARRAYTYPE "+
//Print out definition for array type
outclassdefs.println("struct "+arraytype+" {");
outclassdefs.println(" int type;");
+ if(state.MLP || state.OOOJAVA ){
+ outclassdefs.println(" int oid;");
+ }
+ if (state.EVENTMONITOR) {
+ outclassdefs.println(" int objuid;");
+ }
if (state.THREAD) {
outclassdefs.println(" pthread_t tid;");
outclassdefs.println(" void * lockentry;");
if(!state.MULTICORE) {
outclassdefs.println(" void * flagptr;");
} else {
- outclassdefs.println(" int version;");
- outclassdefs.println(" struct ___Object___ * original;");
- //outclassdefs.println(" int numlocks;"); // array for locks
- outclassdefs.println(" int * lock;");
+ outclassdefs.println(" int version;");
+ outclassdefs.println(" int * lock;"); // lock entry for this obj
+ outclassdefs.println(" int mutex;");
+ outclassdefs.println(" int lockcount;");
+ if(state.MULTICOREGC) {
+ outclassdefs.println(" int marked;");
+ }
}
if(state.OPTIONAL) {
outclassdefs.println(" int numfses;");
}
printClassStruct(typeutil.getClass(TypeUtil.ObjectClass), outclassdefs);
+ if (state.STMARRAY) {
+ outclassdefs.println(" int lowindex;");
+ outclassdefs.println(" int highindex;");
+ }
if (state.ARRAYPAD)
outclassdefs.println(" int paddingforarray;");
+ if (state.DUALVIEW) {
+ outclassdefs.println(" int arrayversion;");
+ }
outclassdefs.println(" int ___length___;");
outclassdefs.println("};\n");
outclassdefs.print("extern int nchashSearch;\n");
outclassdefs.print("extern int nmhashSearch;\n");
outclassdefs.print("extern int nprehashSearch;\n");
+ outclassdefs.print("extern int ndirtyCacheObj;\n");
outclassdefs.print("extern int nRemoteSend;\n");
+ outclassdefs.print("extern int sendRemoteReq;\n");
+ outclassdefs.print("extern int getResponse;\n");
outclassdefs.print("extern int bytesSent;\n");
outclassdefs.print("extern int bytesRecv;\n");
+ outclassdefs.print("extern int totalObjSize;\n");
outclassdefs.print("extern void handle();\n");
} else if (state.SINGLETM) {
outclassdefs.println("extern int nSoftAbortAbort;");
outclassdefs.println("#endif\n");
}
outclassdefs.print("#endif\n");
+
outclassdefs.print("int numprefetchsites = " + pa.prefetchsiteid + ";\n");
+ if(this.state.MLP || state.OOOJAVA ){
+ outclassdefs.print("extern __thread int oid;\n");
+ outclassdefs.print("extern int numWorkers;\n");
+ }
Iterator it=state.getClassSymbolTable().getDescriptorsIterator();
cdarray=new ClassDescriptor[state.numClasses()];
+ cdarray[0] = null;
while(it.hasNext()) {
ClassDescriptor cd=(ClassDescriptor)it.next();
cdarray[cd.getId()]=cd;
outclassdefs.println("/* ");
for(int i=0; i<state.numClasses(); i++) {
ClassDescriptor cd=cdarray[i];
- outclassdefs.println(cd +" "+i);
+ if(cd == null) {
+ outclassdefs.println("NULL " + i);
+ } else {
+ outclassdefs.println(cd +" "+i);
+ }
}
for(int i=0; i<state.numArrays(); i++) {
for(int i=0; i<state.numClasses(); i++) {
if (needcomma)
outclassdefs.print(", ");
- outclassdefs.print("sizeof(struct "+cdarray[i].getSafeSymbol()+")");
+ if(i>0) {
+ outclassdefs.print("sizeof(struct "+cdarray[i].getSafeSymbol()+")");
+ } else {
+ outclassdefs.print("0");
+ }
needcomma=true;
}
outclassdefs.print("int typearray[]={");
for(int i=0; i<state.numClasses(); i++) {
ClassDescriptor cd=cdarray[i];
- ClassDescriptor supercd=cd.getSuperDesc();
+ ClassDescriptor supercd=i>0?cd.getSuperDesc():null;
if (needcomma)
outclassdefs.print(", ");
if (supercd==null)
for(int i=0; i<fm.numParameters(); i++) {
TempDescriptor temp=fm.getParameter(i);
TypeDescriptor type=temp.getType();
- if (type.isPtr()&&GENERATEPRECISEGC)
+ if (type.isPtr()&&((GENERATEPRECISEGC) || (this.state.MULTICOREGC)))
objectparams.addPtr(temp);
else
objectparams.addPrim(temp);
for(int i=0; i<fm.numTags(); i++) {
TempDescriptor temp=fm.getTag(i);
- if (GENERATEPRECISEGC)
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC))
objectparams.addPtr(temp);
else
objectparams.addPrim(temp);
for(int i=0; i<writes.length; i++) {
TempDescriptor temp=writes[i];
TypeDescriptor type=temp.getType();
- if (type.isPtr()&&GENERATEPRECISEGC)
+ if (type.isPtr()&&((GENERATEPRECISEGC) || (this.state.MULTICOREGC)))
objecttemps.addPtr(temp);
else
objecttemps.addPrim(temp);
for(Iterator<TempDescriptor> tmpit=backuptable.get(lb).values().iterator(); tmpit.hasNext();) {
TempDescriptor tmp=tmpit.next();
TypeDescriptor type=tmp.getType();
- if (type.isPtr()&&GENERATEPRECISEGC)
+ if (type.isPtr()&&((GENERATEPRECISEGC) || (this.state.MULTICOREGC)))
objecttemps.addPtr(tmp);
else
objecttemps.addPrim(tmp);
/* Create temp to hold revert table */
if (state.DSM&&(lb.getHasAtomic()||lb.isAtomic())) {
TempDescriptor reverttmp=new TempDescriptor("revertlist", typeutil.getClass(TypeUtil.ObjectClass));
- if (GENERATEPRECISEGC)
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC))
objecttemps.addPtr(reverttmp);
else
objecttemps.addPrim(reverttmp);
if (needcomma)
output.println(",");
needcomma=true;
- output.print(cn.getSafeSymbol()+"_pointers");
+ if(cn != null) {
+ output.print(cn.getSafeSymbol()+"_pointers");
+ } else {
+ output.print("NULL");
+ }
}
for(int i=0; i<state.numArrays(); i++) {
if (needcomma)
output.println(", ");
needcomma=true;
- if (cn.hasFlags())
+ if ((cn != null) && (cn.hasFlags()))
output.print("1");
else
output.print("0");
if (needcomma)
output.println(",");
needcomma=true;
- if (cn.getSuperDesc()!=null) {
+ if ((cn != null) && (cn.getSuperDesc()!=null)) {
ClassDescriptor cdsuper=cn.getSuperDesc();
output.print(cdsuper.getId());
} else
/* Output class structure */
classdefout.println("struct "+cn.getSafeSymbol()+" {");
classdefout.println(" int type;");
+ if(state.MLP || state.OOOJAVA){
+ classdefout.println(" int oid;");
+ }
+ if (state.EVENTMONITOR) {
+ classdefout.println(" int objuid;");
+ }
if (state.THREAD) {
classdefout.println(" pthread_t tid;");
classdefout.println(" void * lockentry;");
classdefout.println(" void * flagptr;");
} else if (state.MULTICORE) {
classdefout.println(" int version;");
- classdefout.println(" struct ___Object___ * original;");
- //classdefout.println(" int numlocks;"); // array for locks
- classdefout.println(" int * lock;");
+ classdefout.println(" int * lock;"); // lock entry for this obj
+ classdefout.println(" int mutex;");
+ classdefout.println(" int lockcount;");
+ if(state.MULTICOREGC) {
+ classdefout.println(" int marked;");
+ }
}
if (state.OPTIONAL) {
classdefout.println(" int numfses;");
private void generateMethodParam(ClassDescriptor cn, MethodDescriptor md, LocalityBinding lb, PrintWriter output) {
/* Output parameter structure */
- if (GENERATEPRECISEGC) {
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
ParamsObject objectparams=(ParamsObject) paramstable.get(lb!=null ? lb : md);
if ((state.DSM||state.SINGLETM)&&lb!=null)
output.println("struct "+cn.getSafeSymbol()+lb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params {");
else
output.println("struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params {");
- output.println(" INTPTR size;");
- output.println(" void * next;");
+ output.println(" int size;");
+ output.println(" void * next;");
for(int i=0; i<objectparams.numPointers(); i++) {
TempDescriptor temp=objectparams.getPointer(i);
output.println(" struct "+temp.getType().getSafeSymbol()+" * "+temp.getSafeSymbol()+";");
generateMethodParam(cn, md, lb, output);
/* Output temp structure */
- if (GENERATEPRECISEGC) {
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
if (state.DSM||state.SINGLETM)
output.println("struct "+cn.getSafeSymbol()+lb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals {");
else
output.println("struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals {");
- output.println(" INTPTR size;");
+ output.println(" int size;");
output.println(" void * next;");
for(int i=0; i<objecttemps.numPointers(); i++) {
TempDescriptor temp=objecttemps.getPointer(i);
headersout.print(cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"(");
}
boolean printcomma=false;
- if (GENERATEPRECISEGC) {
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
if (state.DSM||state.SINGLETM) {
headersout.print("struct "+cn.getSafeSymbol()+lb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params * "+paramsprefix);
} else
TempObject objecttemps=(TempObject) tempstable.get(task);
/* Output parameter structure */
- if (GENERATEPRECISEGC) {
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
output.println("struct "+task.getSafeSymbol()+"_params {");
-
- output.println(" INTPTR size;");
+ output.println(" int size;");
output.println(" void * next;");
for(int i=0; i<objectparams.numPointers(); i++) {
TempDescriptor temp=objectparams.getPointer(i);
}
/* Output temp structure */
- if (GENERATEPRECISEGC) {
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
output.println("struct "+task.getSafeSymbol()+"_locals {");
- output.println(" INTPTR size;");
+ output.println(" int size;");
output.println(" void * next;");
for(int i=0; i<objecttemps.numPointers(); i++) {
TempDescriptor temp=objecttemps.getPointer(i);
headersout.print("void " + task.getSafeSymbol()+"(");
boolean printcomma=false;
- if (GENERATEPRECISEGC) {
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
headersout.print("struct "+task.getSafeSymbol()+"_params * "+paramsprefix);
} else
headersout.print("void * parameterarray[]");
Hashtable<FlatAtomicEnterNode, AtomicRecord> atomicmethodmap;
static int atomicmethodcount=0;
+
+ BranchAnalysis branchanalysis;
private void generateFlatMethod(FlatMethod fm, LocalityBinding lb, PrintWriter output) {
if (State.PRINTFLAT)
System.out.println(fm.printMethod());
ParamsObject objectparams=(ParamsObject)paramstable.get(lb!=null ? lb : md!=null ? md : task);
HashSet<AtomicRecord> arset=null;
+ branchanalysis=null;
if (state.DELAYCOMP&&!lb.isAtomic()&&lb.getHasAtomic()) {
//create map
localsprefixaddr=localsprefix;
localsprefixderef=localsprefix+"->";
arset=new HashSet<AtomicRecord>();
+
+ //build branchanalysis
+ branchanalysis=new BranchAnalysis(locality, lb, delaycomp.getNotReady(lb), delaycomp.livecode(lb), state);
//Generate commit methods here
for(Iterator<FlatNode> fnit=fm.getNodeSet().iterator();fnit.hasNext();) {
FlatNode fn=fnit.next();
if (fn.kind()==FKind.FlatAtomicEnterNode&&
- locality.getAtomic(lb).get(fn.getPrev(0)).intValue()==0) {
+ locality.getAtomic(lb).get(fn.getPrev(0)).intValue()==0&&
+ delaycomp.needsFission(lb, (FlatAtomicEnterNode) fn)) {
//We have an atomic enter
FlatAtomicEnterNode faen=(FlatAtomicEnterNode) fn;
Set<FlatNode> exitset=faen.getExits();
ar.liveout=liveout;
ar.liveoutvirtualread=liveoutvirtualread;
+
for(Iterator<TempDescriptor> it=liveinto.iterator(); it.hasNext();) {
TempDescriptor tmp=it.next();
//remove the pointers
}
}
- if (GENERATEPRECISEGC) {
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
if (md!=null&&(state.DSM||state.SINGLETM))
output.print(" struct "+cn.getSafeSymbol()+lb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals "+localsprefix+"={");
else if (md!=null&&!(state.DSM||state.SINGLETM))
output.print(" struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals "+localsprefix+"={");
else
output.print(" struct "+task.getSafeSymbol()+"_locals "+localsprefix+"={");
-
output.print(objecttemp.numPointers()+",");
output.print(paramsprefix);
for(int j=0; j<objecttemp.numPointers(); j++)
output.println(" "+type.getSafeSymbol()+" "+td.getSafeSymbol()+";");
}
+
+ if( state.MLP || state.OOOJAVA ) {
+ if( fm.getNext(0) instanceof FlatSESEEnterNode ) {
+ FlatSESEEnterNode callerSESEplaceholder = (FlatSESEEnterNode) fm.getNext( 0 );
+ if( (state.MLP && callerSESEplaceholder != mlpa.getMainSESE()) ||
+ (state.OOOJAVA && callerSESEplaceholder != oooa.getMainSESE())
+ ) {
+ // declare variables for naming static SESE's
+ output.println(" /* static SESE names */");
+ Iterator<SESEandAgePair> pItr = callerSESEplaceholder.getNeededStaticNames().iterator();
+ while( pItr.hasNext() ) {
+ SESEandAgePair pair = pItr.next();
+ output.println(" void* "+pair+";");
+ }
+
+ // declare variables for tracking dynamic sources
+ output.println(" /* dynamic variable sources */");
+ Iterator<TempDescriptor> dynSrcItr = callerSESEplaceholder.getDynamicVarSet().iterator();
+ while( dynSrcItr.hasNext() ) {
+ TempDescriptor dynSrcVar = dynSrcItr.next();
+ output.println(" void* "+dynSrcVar+"_srcSESE;");
+ output.println(" int "+dynSrcVar+"_srcOffset;");
+ }
+ }
+ }
+
+ // set up related allocation sites's waiting queues
+ // eom
+ if(state.MLP){
+ ConflictGraph graph = null;
+ graph = mlpa.getConflictGraphResults().get(fm);
+ if (graph != null && graph.hasConflictEdge()) {
+ output.println(" /* set up waiting queues */");
+ output.println(" int numMemoryQueue=0;");
+ output.println(" int memoryQueueItemID=0;");
+ HashSet<SESELock> lockSet = mlpa.getConflictGraphLockMap().get(
+ graph);
+ System.out.println("#lockSet="+lockSet.hashCode());
+ System.out.println("lockset="+lockSet);
+ for (Iterator iterator = lockSet.iterator(); iterator.hasNext();) {
+ SESELock seseLock = (SESELock) iterator.next();
+ System.out.println("id="+seseLock.getID());
+ System.out.println("#="+seseLock);
+ }
+ System.out.println("size="+lockSet.size());
+ if (lockSet.size() > 0) {
+ output.println(" numMemoryQueue=" + lockSet.size() + ";");
+ output
+ .println(" seseCaller->numMemoryQueue=numMemoryQueue;");
+ output
+ .println(" seseCaller->memoryQueueArray=mlpCreateMemoryQueueArray(numMemoryQueue);");
+ output.println();
+ }
+ }
+ }else{
+ FlatSESEEnterNode callerSESEplaceholder = (FlatSESEEnterNode) fm.getNext( 0 );
+ if(callerSESEplaceholder!= oooa.getMainSESE()){
+ Analysis.OoOJava.ConflictGraph graph = oooa.getConflictGraph(callerSESEplaceholder);
+ if (graph != null && graph.hasConflictEdge()) {
+ output.println(" // set up waiting queues ");
+ output.println(" int numMemoryQueue=0;");
+ output.println(" int memoryQueueItemID=0;");
+ Set<Analysis.OoOJava.SESELock> lockSet = oooa.getLockMappings(graph);
+ System.out.println("#lockSet="+lockSet.hashCode());
+ System.out.println("lockset="+lockSet);
+ for (Iterator iterator = lockSet.iterator(); iterator.hasNext();) {
+ Analysis.OoOJava.SESELock seseLock = (Analysis.OoOJava.SESELock) iterator.next();
+ System.out.println("id="+seseLock.getID());
+ System.out.println("#="+seseLock);
+ }
+ System.out.println("size="+lockSet.size());
+ if (lockSet.size() > 0) {
+ output.println(" numMemoryQueue=" + lockSet.size() + ";");
+ output
+ .println(" seseCaller->numMemoryQueue=numMemoryQueue;");
+ output
+ .println(" seseCaller->memoryQueueArray=mlpCreateMemoryQueueArray(numMemoryQueue);");
+ output.println();
+ }
+ }
+ }
+ }
+
+ }
+
+
/* Check to see if we need to do a GC if this is a
* multi-threaded program...*/
- if ((state.THREAD||state.DSM||state.SINGLETM)&&GENERATEPRECISEGC) {
+ if (((state.MLP||state.OOOJAVA||state.THREAD||state.DSM||state.SINGLETM)&&GENERATEPRECISEGC)
+ || this.state.MULTICOREGC) {
//Don't bother if we aren't in recursive methods...The loops case will catch it
if (callgraph.getAllMethods(md).contains(md)) {
if (state.DSM&&lb.isAtomic())
output.println("if (needtocollect) checkcollect2("+localsprefixaddr+");");
- else
- output.println("if (needtocollect) checkcollect("+localsprefixaddr+");");
+ else if (this.state.MULTICOREGC) {
+ output.println("if(gcflag) gc("+localsprefixaddr+");");
+ } else {
+ output.println("if (unlikely(needtocollect)) checkcollect("+localsprefixaddr+");");
+ }
}
}
protected void initializeSESE( FlatSESEEnterNode fsen ) {
-
+
FlatMethod fm = fsen.getfmEnclosing();
MethodDescriptor md = fm.getMethod();
ClassDescriptor cn = md.getClassDesc();
TypeDescriptor type = temp.getType();
if( type.isPtr() ) {
objectparams.addPtr( temp );
+ } else {
+ objectparams.addPrim( temp );
}
}
// Build normal temp object for bogus method descriptor
TempObject objecttemps = new TempObject( objectparams, mdBogus, tag++ );
tempstable.put( mdBogus, objecttemps );
-
- for(Iterator nodeit=fsen.getNodeSet().iterator(); nodeit.hasNext();) {
- FlatNode fn=(FlatNode)nodeit.next();
- TempDescriptor[] writes=fn.writesTemps();
- for(int i=0; i<writes.length; i++) {
- TempDescriptor temp=writes[i];
- TypeDescriptor type=temp.getType();
- if (type.isPtr()&&GENERATEPRECISEGC)
- objecttemps.addPtr(temp);
- else
- objecttemps.addPrim(temp);
+
+ for( Iterator nodeit = fsen.getNodeSet().iterator(); nodeit.hasNext(); ) {
+ FlatNode fn = (FlatNode)nodeit.next();
+ TempDescriptor[] writes = fn.writesTemps();
+
+ for( int i = 0; i < writes.length; i++ ) {
+ TempDescriptor temp = writes[i];
+ TypeDescriptor type = temp.getType();
+
+ if( type.isPtr() ) {
+ objecttemps.addPtr( temp );
+ } else {
+ objecttemps.addPrim( temp );
+ }
}
}
}
PrintWriter outputMethods
) {
- ParamsObject objectparams = (ParamsObject) paramstable.get( fsen.getmdBogus() );
+ ParamsObject objectparams = (ParamsObject) paramstable.get( fsen.getmdBogus() );
+ TempObject objecttemps = (TempObject) tempstable .get( fsen.getmdBogus() );
+ // generate locals structure
+ outputStructs.println("struct "+
+ fsen.getcdEnclosing().getSafeSymbol()+
+ fsen.getmdBogus().getSafeSymbol()+"_"+
+ fsen.getmdBogus().getSafeMethodDescriptor()+
+ "_locals {");
+ outputStructs.println(" int size;");
+ outputStructs.println(" void * next;");
+ for(int i=0; i<objecttemps.numPointers(); i++) {
+ TempDescriptor temp=objecttemps.getPointer(i);
+
+ if (temp.getType().isNull())
+ outputStructs.println(" void * "+temp.getSafeSymbol()+";");
+ else
+ outputStructs.println(" struct "+
+ temp.getType().getSafeSymbol()+" * "+
+ temp.getSafeSymbol()+";");
+ }
+ outputStructs.println("};\n");
+
+
+ // generate the SESE record structure
+ outputStructs.println(fsen.getSESErecordName()+" {");
+
+ // data common to any SESE, and it must be placed first so
+ // a module that doesn't know what kind of SESE record this
+ // is can cast the pointer to a common struct
+ outputStructs.println(" SESEcommon common;");
+
+ // then garbage list stuff
+ outputStructs.println(" int size;");
+ outputStructs.println(" void * next;");
+
+ // DYNAMIC stuff was here
+
+ // invar source taking was here
+
+ // space for all in and out set primitives
Set<TempDescriptor> inSetAndOutSet = new HashSet<TempDescriptor>();
inSetAndOutSet.addAll( fsen.getInVarSet() );
inSetAndOutSet.addAll( fsen.getOutVarSet() );
inSetAndOutSetPrims.add( temp );
}
}
-
- TempObject objecttemps = (TempObject) tempstable.get( fsen.getmdBogus() );
-
-
- // generate the SESE record structure
- outputStructs.println(fsen.getSESErecordName()+" {");
-
- // SESE's static class ID
- outputStructs.println(" int classID;");
-
- // child is issued with this locked, and it
- // unlocks it when it completes
- outputStructs.println(" psemaphore stallSem;");
-
- // then garbage list stuff
- outputStructs.println(" INTPTR size;");
- outputStructs.println(" void * next;");
- // in-set source pointers
- Iterator<TempDescriptor> itrInSet = fsen.getInVarSet().iterator();
- while( itrInSet.hasNext() ) {
- TempDescriptor temp = itrInSet.next();
- outputStructs.println(" INTPTR "+temp.getSafeSymbol()+"__srcAddr_;");
- }
-
- // all in and out set primitives
Iterator<TempDescriptor> itrPrims = inSetAndOutSetPrims.iterator();
while( itrPrims.hasNext() ) {
TempDescriptor temp = itrPrims.next();
TypeDescriptor type = temp.getType();
- outputStructs.println(" "+temp.getType().getSafeSymbol()+" "+temp.getSafeSymbol()+";");
+ if(!type.isPrimitive()){
+ outputStructs.println(" "+temp.getType().getSafeSymbol()+" "+temp.getSafeSymbol()+";");
+ }
}
for(int i=0; i<objectparams.numPointers(); i++) {
outputStructs.println(" struct "+temp.getType().getSafeSymbol()+" * "+temp.getSafeSymbol()+";");
}
- outputStructs.println("};\n");
-
- // generate locals structure
- outputStructs.println("struct "+fsen.getcdEnclosing().getSafeSymbol()+fsen.getmdBogus().getSafeSymbol()+"_"+fsen.getmdBogus().getSafeMethodDescriptor()+"_locals {");
- outputStructs.println(" INTPTR size;");
- outputStructs.println(" void * next;");
- for(int i=0; i<objecttemps.numPointers(); i++) {
- TempDescriptor temp=objecttemps.getPointer(i);
- if (temp.getType().isNull())
- outputStructs.println(" void * "+temp.getSafeSymbol()+";");
- else
- outputStructs.println(" struct "+temp.getType().getSafeSymbol()+" * "+temp.getSafeSymbol()+";");
+ // DYNAMIC stuff needs a source SESE ptr and offset
+ Iterator<TempDescriptor> itrDynInVars = fsen.getDynamicInVarSet().iterator();
+ while( itrDynInVars.hasNext() ) {
+ TempDescriptor dynInVar = itrDynInVars.next();
+// outputStructs.println(" void* "+dynInVar+"_srcSESE;");
+ outputStructs.println(" int "+dynInVar+"_srcOffset;");
+ }
+
+ itrPrims = inSetAndOutSetPrims.iterator();
+ while( itrPrims.hasNext() ) {
+ TempDescriptor temp = itrPrims.next();
+ TypeDescriptor type = temp.getType();
+ if(type.isPrimitive()){
+ outputStructs.println(" "+temp.getType().getSafeSymbol()+" "+temp.getSafeSymbol()+";");
+ }
}
- outputStructs.println("};\n");
+ outputStructs.println(" int prevSESECount;");
+
+ // DYNAMIC stuff needs a source SESE ptr and offset
+ itrDynInVars = fsen.getDynamicInVarSet().iterator();
+ while( itrDynInVars.hasNext() ) {
+ TempDescriptor dynInVar = itrDynInVars.next();
+ outputStructs.println(" void* "+dynInVar+"_srcSESE;");
+// outputStructs.println(" int "+dynInVar+"_srcOffset;");
+ }
+
+ // in-set source tracking
+ // in-vars that are READY come from parent, don't need anything
+ // stuff STATIC needs a custom SESE pointer for each age pair
+ Iterator<SESEandAgePair> itrStaticInVarSrcs = fsen.getStaticInVarSrcs().iterator();
+ while( itrStaticInVarSrcs.hasNext() ) {
+ SESEandAgePair srcPair = itrStaticInVarSrcs.next();
+ outputStructs.println(" "+srcPair.getSESE().getSESErecordName()+"* "+srcPair+";");
+ }
+
+ outputStructs.println("};\n");
+
// write method declaration to header file
outputMethHead.print("void ");
outputMethHead.print(fsen.getSESEmethodName()+"(");
outputMethHead.print(fsen.getSESErecordName()+"* "+paramsprefix);
-
- /*
- boolean printcomma=false;
- if (GENERATEPRECISEGC) {
- outputMethHead.print("struct "+cn.getSafeSymbol()+
- bogusmd.getSafeSymbol()+"_"+
- bogusmd.getSafeMethodDescriptor()+"_params * "+paramsprefix);
- printcomma=true;
- }
- // Output parameter list
- for(int i=0; i<objectparams.numPrimitives(); i++) {
- TempDescriptor temp=objectparams.getPrimitive(i);
- if (printcomma)
- outputMethHead.print(", ");
- printcomma=true;
- if (temp.getType().isClass()||temp.getType().isArray())
- outputMethHead.print("struct " + temp.getType().getSafeSymbol()+" * "+temp.getSafeSymbol());
- else
- outputMethHead.print(temp.getType().getSafeSymbol()+" "+temp.getSafeSymbol());
- }
- */
-
outputMethHead.println(");\n");
+
generateFlatMethodSESE( fsen.getfmBogus(),
fsen.getcdEnclosing(),
fsen,
MethodDescriptor md=fm.getMethod();
- //generateHeader(fm, null, md, output, true);
-
output.print("void ");
output.print(fsen.getSESEmethodName()+"(");
output.print(fsen.getSESErecordName()+"* "+paramsprefix);
TempObject objecttemp=(TempObject) tempstable.get(md);
- if (GENERATEPRECISEGC) {
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
output.print(" struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals "+localsprefix+"={");
output.print(objecttemp.numPointers()+",");
- output.print("(void*) &("+paramsprefix+"->size)");
+ output.print("&(((SESEcommon*)(___params___))[1])");
for(int j=0; j<objecttemp.numPointers(); j++)
output.print(", NULL");
output.println("};");
}
+ output.println(" /* regular local primitives */");
for(int i=0; i<objecttemp.numPrimitives(); i++) {
TempDescriptor td=objecttemp.getPrimitive(i);
TypeDescriptor type=td.getType();
}
- // declare variables for naming SESE's
+ // declare variables for naming static SESE's
+ output.println(" /* static SESE names */");
Iterator<SESEandAgePair> pItr = fsen.getNeededStaticNames().iterator();
while( pItr.hasNext() ) {
- SESEandAgePair p = pItr.next();
- output.println(" void* "+p+";");
+ SESEandAgePair pair = pItr.next();
+ output.println(" void* "+pair+";");
}
- // copy in-set into place
+ // declare variables for tracking dynamic sources
+ output.println(" /* dynamic variable sources */");
+ Iterator<TempDescriptor> dynSrcItr = fsen.getDynamicVarSet().iterator();
+ while( dynSrcItr.hasNext() ) {
+ TempDescriptor dynSrcVar = dynSrcItr.next();
+ output.println(" void* "+dynSrcVar+"_srcSESE;");
+ output.println(" int "+dynSrcVar+"_srcOffset;");
+ }
+
+ // declare local temps for in-set primitives, and if it is
+ // a ready-source variable, get the value from the record
+ output.println(" /* local temps for in-set primitives */");
Iterator<TempDescriptor> itrInSet = fsen.getInVarSet().iterator();
while( itrInSet.hasNext() ) {
TempDescriptor temp = itrInSet.next();
TypeDescriptor type = temp.getType();
+ if( !type.isPtr() ) {
+ if( fsen.getReadyInVarSet().contains( temp ) ) {
+ output.println(" "+type+" "+temp+" = "+paramsprefix+"->"+temp+";");
+ } else {
+ output.println(" "+type+" "+temp+";");
+ }
+ }
+ }
- output.println(" memcpy( "+
- "(void*) &("+paramsprefix+"->"+temp.getSafeSymbol()+"), "+ // to
- "(void*) ("+paramsprefix+"->"+temp.getSafeSymbol()+"__srcAddr_),"+ // from
- " sizeof( "+paramsprefix+"->"+temp.getSafeSymbol()+" ) );"); // size
+ // declare local temps for out-set primitives if its not already
+ // in the in-set, and it's value will get written so no problem
+ output.println(" /* local temp for out-set prim, not already in the in-set */");
+ Iterator<TempDescriptor> itrOutSet = fsen.getOutVarSet().iterator();
+ while( itrOutSet.hasNext() ) {
+ TempDescriptor temp = itrOutSet.next();
+ TypeDescriptor type = temp.getType();
+ if( !type.isPtr() && !fsen.getInVarSet().contains( temp ) ) {
+ output.println(" "+type+" "+temp+";");
+ }
+ }
+
+ // setup memory queue
+ // eom
+ if(state.OOOJAVA){
+ output.println(" // set up memory queues ");
+ output.println(" int numMemoryQueue=0;");
+ output.println(" int memoryQueueItemID=0;");
+ Analysis.OoOJava.ConflictGraph graph = oooa.getConflictGraph(fsen);
+ if (graph != null && graph.hasConflictEdge()) {
+ output.println(" {");
+ output
+ .println(" SESEcommon* parentCommon = &(___params___->common);");
+ Set<Analysis.OoOJava.SESELock> lockSet = oooa.getLockMappings(graph);
+ System.out.println("#lockSet="+lockSet);
+ if (lockSet.size() > 0) {
+ output.println(" numMemoryQueue=" + lockSet.size() + ";");
+ output
+ .println(" parentCommon->numMemoryQueue=numMemoryQueue;");
+ output
+ .println(" parentCommon->memoryQueueArray=mlpCreateMemoryQueueArray(numMemoryQueue);");
+ output.println();
+ }
+ output.println(" }");
+ }
+ }else{
+ output.println(" // set up memory queues ");
+ output.println(" int numMemoryQueue=0;");
+ output.println(" int memoryQueueItemID=0;");
+ ConflictGraph graph = null;
+ graph = mlpa.getConflictGraphResults().get(fsen);
+ if (graph != null && graph.hasConflictEdge()) {
+ output.println(" {");
+ output
+ .println(" SESEcommon* parentCommon = &(___params___->common);");
+ HashSet<SESELock> lockSet = mlpa.getConflictGraphLockMap().get(
+ graph);
+ System.out.println("#lockSet="+lockSet);
+
+ if (lockSet.size() > 0) {
+ output.println(" numMemoryQueue=" + lockSet.size() + "; ");
+ output
+ .println(" parentCommon->numMemoryQueue=numMemoryQueue;");
+ output
+ .println(" parentCommon->memoryQueueArray=mlpCreateMemoryQueueArray(numMemoryQueue);");
+ output.println();
+ }
+ output.println(" }");
+ }
+
+ }
+
+
+ // copy in-set into place, ready vars were already
+ // copied when the SESE was issued
+ Iterator<TempDescriptor> tempItr;
+
+ // static vars are from a known SESE
+ tempItr = fsen.getStaticInVarSet().iterator();
+ while( tempItr.hasNext() ) {
+ TempDescriptor temp = tempItr.next();
+ VariableSourceToken vst = fsen.getStaticInVarSrc( temp );
+ SESEandAgePair srcPair = new SESEandAgePair( vst.getSESE(), vst.getAge() );
- // make a deep copy of objects
- //if( type.isPtr() ) {
- // deep copy
- //} else {
- // shallow copy
- //}
+ // can't grab something from this source until it is done
+ output.println(" {");
+ /*
+ If we are running, everything is done. This check is redundant.
+
+ output.println(" SESEcommon* com = (SESEcommon*)"+paramsprefix+"->"+srcPair+";" );
+ output.println(" pthread_mutex_lock( &(com->lock) );");
+ output.println(" while( com->doneExecuting == FALSE ) {");
+ output.println(" pthread_cond_wait( &(com->doneCond), &(com->lock) );");
+ output.println(" }");
+ output.println(" pthread_mutex_unlock( &(com->lock) );");
+ */
+ output.println(" "+generateTemp( fsen.getfmBogus(), temp, null )+
+ " = "+paramsprefix+"->"+srcPair+"->"+vst.getAddrVar()+";");
+
+ output.println(" }");
+ }
+
+ // dynamic vars come from an SESE and src
+ tempItr = fsen.getDynamicInVarSet().iterator();
+ while( tempItr.hasNext() ) {
+ TempDescriptor temp = tempItr.next();
+ TypeDescriptor type = temp.getType();
+
+ // go grab it from the SESE source
+ output.println(" if( "+paramsprefix+"->"+temp+"_srcSESE != NULL ) {");
+
+ // gotta wait until the source is done
+ output.println(" SESEcommon* com = (SESEcommon*)"+paramsprefix+"->"+temp+"_srcSESE;" );
+ /*
+ If we are running, everything is done!
+ output.println(" pthread_mutex_lock( &(com->lock) );");
+ output.println(" while( com->doneExecuting == FALSE ) {");
+ output.println(" pthread_cond_wait( &(com->doneCond), &(com->lock) );");
+ output.println(" }");
+ output.println(" pthread_mutex_unlock( &(com->lock) );");
+ */
+
+ String typeStr;
+ if( type.isNull() ) {
+ typeStr = "void*";
+ } else if( type.isClass() || type.isArray() ) {
+ typeStr = "struct "+type.getSafeSymbol()+"*";
+ } else {
+ typeStr = type.getSafeSymbol();
+ }
+
+ output.println(" "+generateTemp( fsen.getfmBogus(), temp, null )+
+ " = *(("+typeStr+"*) ("+
+ paramsprefix+"->"+temp+"_srcSESE + "+
+ paramsprefix+"->"+temp+"_srcOffset));");
+
+ // or if the source was our parent, its in the record to grab
+ output.println(" } else {");
+ output.println(" "+generateTemp( fsen.getfmBogus(), temp, null )+
+ " = "+paramsprefix+"->"+temp+";");
+ output.println(" }");
}
// Check to see if we need to do a GC if this is a
// multi-threaded program...
- if (GENERATEPRECISEGC) {
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
+ output.println("if (unlikely(needtocollect)) checkcollect("+localsprefixaddr+");");
//Don't bother if we aren't in recursive methods...The loops case will catch it
- if (callgraph.getAllMethods(md).contains(md)) {
- output.println("if (needtocollect) checkcollect("+localsprefixaddr+");");
- }
+// if (callgraph.getAllMethods(md).contains(md)) {
+// if(this.state.MULTICOREGC) {
+// output.println("if(gcflag) gc("+localsprefixaddr+");");
+// } else {
+// output.println("if (unlikely(needtocollect)) checkcollect("+localsprefixaddr+");");
+// }
+// }
}
+ // initialize thread-local var to a non-zero, invalid address
+ output.println(" seseCaller = (SESEcommon*) 0x2;");
HashSet<FlatNode> exitset=new HashSet<FlatNode>();
- exitset.add(seseExit);
+ exitset.add(seseExit);
generateCode(fsen.getNext(0), fm, null, exitset, output, true);
-
output.println("}\n\n");
+
}
// generate a case for each SESE class that can be invoked
outmethod.println( " switch( *((int*)seseRecord) ) {");
outmethod.println( " ");
- for(Iterator<FlatSESEEnterNode> seseit=mlpa.getAllSESEs().iterator();seseit.hasNext();) {
+ Iterator<FlatSESEEnterNode> seseit;
+ if(state.MLP){
+ seseit=mlpa.getAllSESEs().iterator();
+ }else{
+ seseit=oooa.getAllSESEs().iterator();
+ }
+ while(seseit.hasNext()){
FlatSESEEnterNode fsen = seseit.next();
outmethod.println( " /* "+fsen.getPrettyIdentifier()+" */");
outmethod.println( " case "+fsen.getIdentifier()+":");
outmethod.println( " "+fsen.getSESEmethodName()+"( seseRecord );");
+
+ if( (state.MLP && fsen.equals( mlpa.getMainSESE() )) ||
+ (state.OOOJAVA && fsen.equals( oooa.getMainSESE() ))
+ ) {
+ outmethod.println( " /* work scheduler works forever, explicitly exit */");
+ if (state.COREPROF) {
+ outmethod.println("EXITPROFILER();");
+ outmethod.println("DUMPPROFILER();");
+ }
+ outmethod.println( " exit( 0 );");
+ }
+
outmethod.println( " break;");
outmethod.println( "");
}
PrintWriter output, boolean firstpass) {
/* Assign labels to FlatNode's if necessary.*/
- Hashtable<FlatNode, Integer> nodetolabel=assignLabels(first, stopset);
+ Hashtable<FlatNode, Integer> nodetolabel;
+
+ if (state.DELAYCOMP&&!firstpass)
+ nodetolabel=dcassignLabels(first, stopset);
+ else
+ nodetolabel=assignLabels(first, stopset);
+
Set<FlatNode> storeset=null;
HashSet<FlatNode> genset=null;
+ HashSet<FlatNode> refset=null;
Set<FlatNode> unionset=null;
if (state.DELAYCOMP&&!lb.isAtomic()&&lb.getHasAtomic()) {
storeset=delaycomp.livecode(lb);
genset=new HashSet<FlatNode>();
+ if (state.STMARRAY&&!state.DUALVIEW) {
+ refset=new HashSet<FlatNode>();
+ refset.addAll(delaycomp.getDeref(lb));
+ refset.removeAll(delaycomp.getCannotDelay(lb));
+ refset.removeAll(delaycomp.getOther(lb));
+ }
if (firstpass) {
genset.addAll(delaycomp.getCannotDelay(lb));
genset.addAll(delaycomp.getOther(lb));
} else {
genset.addAll(delaycomp.getNotReady(lb));
+ if (state.STMARRAY&&!state.DUALVIEW) {
+ genset.removeAll(refset);
+ }
}
unionset=new HashSet<FlatNode>();
unionset.addAll(storeset);
unionset.addAll(genset);
+ if (state.STMARRAY&&!state.DUALVIEW)
+ unionset.addAll(refset);
}
/* Do the actual code generation */
output.println("primitives->"+tmp.getSafeSymbol()+"="+tmp.getSafeSymbol()+";");
}
}
+ if ((state.MLP || state.OOOJAVA) && stopset!=null) {
+ assert first.getPrev( 0 ) instanceof FlatSESEEnterNode;
+ assert current_node instanceof FlatSESEExitNode;
+ FlatSESEEnterNode fsen = (FlatSESEEnterNode) first.getPrev( 0 );
+ FlatSESEExitNode fsxn = (FlatSESEExitNode) current_node;
+ assert fsen.getFlatExit().equals( fsxn );
+ assert fsxn.getFlatEnter().equals( fsen );
+ }
if (current_node.kind()!=FKind.FlatReturnNode) {
output.println(" return;");
}
current_node=null;
} else if(current_node.numNext()==1) {
FlatNode nextnode;
- if (state.MLP && current_node.kind()==FKind.FlatSESEEnterNode) {
+ if ((state.MLP|| state.OOOJAVA) &&
+ current_node.kind()==FKind.FlatSESEEnterNode &&
+ !((FlatSESEEnterNode)current_node).getIsCallerSESEplaceholder()
+ ) {
FlatSESEEnterNode fsen = (FlatSESEEnterNode)current_node;
generateFlatNode(fm, lb, current_node, output);
nextnode=fsen.getFlatExit().getNext(0);
if (genset==null||genset.contains(current_node)||specialprimitive)
generateFlatNode(fm, lb, current_node, output);
+ if (state.STMARRAY&&!state.DUALVIEW&&refset!=null&&refset.contains(current_node)) {
+ //need to acquire lock
+ handleArrayDeref(fm, lb, current_node, output, firstpass);
+ }
if (storeset!=null&&storeset.contains(current_node)&&!specialprimitive) {
TempDescriptor wrtmp=current_node.writesTemps()[0];
if (firstpass) {
//need to store value written by previous node
if (wrtmp.getType().isPtr()) {
//only lock the objects that may actually need locking
- if (recorddc.getNeedTrans(lb, current_node)) {
- output.println("STOREPTR("+generateTemp(fm, wrtmp,lb)+");");
+ if (recorddc.getNeedTrans(lb, current_node)&&
+ (!state.STMARRAY||state.DUALVIEW||!wrtmp.getType().isArray()||
+ wrtmp.getType().getSymbol().equals(TypeUtil.ObjectClass))) {
+ output.println("STOREPTR("+generateTemp(fm, wrtmp,lb)+");/* "+current_node.nodeid+" */");
} else {
- output.println("STOREPTRNOLOCK("+generateTemp(fm, wrtmp,lb)+");");
+ output.println("STOREPTRNOLOCK("+generateTemp(fm, wrtmp,lb)+");/* "+current_node.nodeid+" */");
}
} else {
- output.println("STORE"+wrtmp.getType().getSafeDescriptor()+"("+generateTemp(fm, wrtmp, lb)+");");
+ output.println("STORE"+wrtmp.getType().getSafeDescriptor()+"("+generateTemp(fm, wrtmp, lb)+");/* "+current_node.nodeid+" */");
}
} else {
//need to read value read by previous node
if (wrtmp.getType().isPtr()) {
- output.println("RESTOREPTR("+generateTemp(fm, wrtmp,lb)+");");
+ output.println("RESTOREPTR("+generateTemp(fm, wrtmp,lb)+");/* "+current_node.nodeid+" */");
} else {
- output.println("RESTORE"+wrtmp.getType().getSafeDescriptor()+"("+generateTemp(fm, wrtmp, lb)+");");
+ output.println("RESTORE"+wrtmp.getType().getSafeDescriptor()+"("+generateTemp(fm, wrtmp, lb)+"); /* "+current_node.nodeid+" */");
}
}
}
generateFlatCondBranch(fm, lb, (FlatCondBranch)current_node, "L"+nodetolabel.get(current_node.getNext(1)), output);
} else if (storeset.contains(current_node)) {
//need to do branch
- output.println("RESTOREANDBRANCH(L"+nodetolabel.get(current_node.getNext(1))+");");
+ branchanalysis.generateGroupCode(current_node, output, nodetolabel);
} else {
//which side to execute
computeside=true;
}
}
- /** This method assigns labels to FlatNodes */
+ protected void handleArrayDeref(FlatMethod fm, LocalityBinding lb, FlatNode fn, PrintWriter output, boolean firstpass) {
+ if (fn.kind()==FKind.FlatSetElementNode) {
+ FlatSetElementNode fsen=(FlatSetElementNode) fn;
+ String dst=generateTemp(fm, fsen.getDst(), lb);
+ String src=generateTemp(fm, fsen.getSrc(), lb);
+ String index=generateTemp(fm, fsen.getIndex(), lb);
+ TypeDescriptor elementtype=fsen.getDst().getType().dereference();
+ String type="";
+ if (elementtype.isArray()||elementtype.isClass())
+ type="void *";
+ else
+ type=elementtype.getSafeSymbol()+" ";
+ if (firstpass) {
+ output.println("STOREARRAY("+dst+","+index+","+type+")");
+ } else {
+ output.println("{");
+ output.println(" struct ArrayObject *array;");
+ output.println(" int index;");
+ output.println(" RESTOREARRAY(array,index);");
+ output.println(" (("+type+"*)(((char *)&array->___length___)+sizeof(int)))[index]="+src+";");
+ output.println("}");
+ }
+ } else if (fn.kind()==FKind.FlatElementNode) {
+ FlatElementNode fen=(FlatElementNode) fn;
+ String src=generateTemp(fm, fen.getSrc(), lb);
+ String index=generateTemp(fm, fen.getIndex(), lb);
+ TypeDescriptor elementtype=fen.getSrc().getType().dereference();
+ String dst=generateTemp(fm, fen.getDst(), lb);
+ String type="";
+ if (elementtype.isArray()||elementtype.isClass())
+ type="void *";
+ else
+ type=elementtype.getSafeSymbol()+" ";
+ if (firstpass) {
+ output.println("STOREARRAY("+src+","+index+","+type+")");
+ } else {
+ output.println("{");
+ output.println(" struct ArrayObject *array;");
+ output.println(" int index;");
+ output.println(" RESTOREARRAY(array,index);");
+ output.println(" "+dst+"=(("+type+"*)(((char *)&array->___length___)+sizeof(int)))[index];");
+ output.println("}");
+ }
+ }
+ }
+ /** Special label assignment for delaycomputation */
+ protected Hashtable<FlatNode, Integer> dcassignLabels(FlatNode first, Set<FlatNode> lastset) {
+ HashSet tovisit=new HashSet();
+ HashSet visited=new HashSet();
+ int labelindex=0;
+ Hashtable<FlatNode, Integer> nodetolabel=new Hashtable<FlatNode, Integer>();
+
+ //Label targets of branches
+ Set<FlatNode> targets=branchanalysis.getTargets();
+ for(Iterator<FlatNode> it=targets.iterator();it.hasNext();) {
+ nodetolabel.put(it.next(), new Integer(labelindex++));
+ }
+
+
+ tovisit.add(first);
+ /*Assign labels first. A node needs a label if the previous
+ * node has two exits or this node is a join point. */
+
+ while(!tovisit.isEmpty()) {
+ FlatNode fn=(FlatNode)tovisit.iterator().next();
+ tovisit.remove(fn);
+ visited.add(fn);
+
+
+ if(lastset!=null&&lastset.contains(fn)) {
+ // if last is not null and matches, don't go
+ // any further for assigning labels
+ continue;
+ }
+
+ for(int i=0; i<fn.numNext(); i++) {
+ FlatNode nn=fn.getNext(i);
+
+ if(i>0) {
+ //1) Edge >1 of node
+ nodetolabel.put(nn,new Integer(labelindex++));
+ }
+ if (!visited.contains(nn)&&!tovisit.contains(nn)) {
+ tovisit.add(nn);
+ } else {
+ //2) Join point
+ nodetolabel.put(nn,new Integer(labelindex++));
+ }
+ }
+ }
+ return nodetolabel;
+
+ }
+
protected Hashtable<FlatNode, Integer> assignLabels(FlatNode first) {
return assignLabels(first, null);
}
TempObject objecttemps=(TempObject) tempstable.get(lb!=null ? lb : md!=null ? md : task);
if (objecttemps.isLocalPrim(td)||objecttemps.isParamPrim(td)) {
- //System.out.println("generateTemp returns " + td.getSafeSymbol());
return td.getSafeSymbol();
}
protected void generateFlatNode(FlatMethod fm, LocalityBinding lb, FlatNode fn, PrintWriter output) {
// insert pre-node actions from the code plan
- if( state.MLP ) {
+ if( state.MLP|| state.OOOJAVA ) {
- CodePlan cp = mlpa.getCodePlan( fn );
+ CodePlan cp;
+ if(state.MLP){
+ cp = mlpa.getCodePlan( fn );
+ }else{
+ cp = oooa.getCodePlan(fn);
+ }
+
if( cp != null ) {
+ FlatSESEEnterNode currentSESE = cp.getCurrentSESE();
+
// for each sese and age pair that this parent statement
// must stall on, take that child's stall semaphore, the
// copying of values comes after the statement
- Iterator<SESEandAgePair> pItr = cp.getStallPairs().iterator();
- while( pItr.hasNext() ) {
- SESEandAgePair p = pItr.next();
+ Iterator<VariableSourceToken> vstItr = cp.getStallTokens().iterator();
+ while( vstItr.hasNext() ) {
+ VariableSourceToken vst = vstItr.next();
+
+ SESEandAgePair pair = new SESEandAgePair( vst.getSESE(), vst.getAge() );
+
output.println(" {");
- output.println(" SESErecord* child = (SESErecord*) "+p+";");
- output.println(" psem_take( &(child->stallSem) );");
+ output.println(" SESEcommon* common = (SESEcommon*) "+pair+";");
+
+ output.println(" pthread_mutex_lock( &(common->lock) );");
+ output.println(" while( common->doneExecuting == FALSE ) {");
+ output.println(" pthread_cond_wait( &(common->doneCond), &(common->lock) );");
+ output.println(" }");
+ output.println(" pthread_mutex_unlock( &(common->lock) );");
+
+ // copy things we might have stalled for
+ output.println(" "+pair.getSESE().getSESErecordName()+"* child = ("+
+ pair.getSESE().getSESErecordName()+"*) "+pair+";");
+
+ Iterator<TempDescriptor> tdItr = cp.getCopySet( vst ).iterator();
+ while( tdItr.hasNext() ) {
+ TempDescriptor td = tdItr.next();
+ FlatMethod fmContext;
+ if( currentSESE.getIsCallerSESEplaceholder() ) {
+ fmContext = currentSESE.getfmEnclosing();
+ } else {
+ fmContext = currentSESE.getfmBogus();
+ }
+ output.println(" "+generateTemp( fmContext, td, null )+
+ " = child->"+vst.getAddrVar().getSafeSymbol()+";");
+ }
+
+ output.println(" }");
+ }
+
+ // for each variable with a dynamic source, stall just for that variable
+ Iterator<TempDescriptor> dynItr = cp.getDynamicStallSet().iterator();
+ while( dynItr.hasNext() ) {
+ TempDescriptor dynVar = dynItr.next();
+
+ // only stall if the dynamic source is not yourself, denoted by src==NULL
+ // otherwise the dynamic write nodes will have the local var up-to-date
+ output.println(" {");
+ output.println(" if( "+dynVar+"_srcSESE != NULL ) {");
+ output.println(" SESEcommon* common = (SESEcommon*) "+dynVar+"_srcSESE;");
+ output.println(" psem_take( &(common->stallSem) );");
+
+ FlatMethod fmContext;
+ if( currentSESE.getIsCallerSESEplaceholder() ) {
+ fmContext = currentSESE.getfmEnclosing();
+ } else {
+ fmContext = currentSESE.getfmBogus();
+ }
+
+ TypeDescriptor type=dynVar.getType();
+ String typeStr;
+ if( type.isNull() ) {
+ typeStr = "void*";
+ } else if( type.isClass() || type.isArray() ) {
+ typeStr = "struct "+type.getSafeSymbol()+"*";
+ } else {
+ typeStr = type.getSafeSymbol();
+ }
+
+ output.println(" "+generateTemp( fmContext, dynVar, null )+
+ " = *(("+typeStr+"*) ("+
+ dynVar+"_srcSESE + "+dynVar+"_srcOffset));");
+
+ output.println(" }");
output.println(" }");
}
+
+ // for each assignment of a variable to rhs that has a dynamic source,
+ // copy the dynamic sources
+ Iterator dynAssignItr = cp.getDynAssigns().entrySet().iterator();
+ while( dynAssignItr.hasNext() ) {
+ Map.Entry me = (Map.Entry) dynAssignItr.next();
+ TempDescriptor lhs = (TempDescriptor) me.getKey();
+ TempDescriptor rhs = (TempDescriptor) me.getValue();
+ output.println(" "+lhs+"_srcSESE = "+rhs+"_srcSESE;");
+ output.println(" "+lhs+"_srcOffset = "+rhs+"_srcOffset;");
+ }
+
+ // for each lhs that is dynamic from a non-dynamic source, set the
+ // dynamic source vars to the current SESE
+ dynItr = cp.getDynAssignCurr().iterator();
+ while( dynItr.hasNext() ) {
+ TempDescriptor dynVar = dynItr.next();
+ assert currentSESE.getDynamicVarSet().contains( dynVar );
+ output.println(" "+dynVar+"_srcSESE = NULL;");
+ }
+
+ // eom
+ // handling stall site
+ if (state.OOOJAVA) {
+ Analysis.OoOJava.ConflictGraph graph = oooa.getConflictGraph(currentSESE);
+ if(graph!=null){
+ Set<Analysis.OoOJava.SESELock> seseLockSet = oooa.getLockMappings(graph);
+ Set<Analysis.OoOJava.WaitingElement> waitingElementSet =
+ graph.getStallSiteWaitingElementSet(fn, seseLockSet);
+
+ if(waitingElementSet.size()>0){
+ output.println("// stall on parent's stall sites ");
+ output.println(" {");
+ output.println(" REntry* rentry;");
+
+ for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) {
+ Analysis.OoOJava.WaitingElement waitingElement = (Analysis.OoOJava.WaitingElement) iterator.next();
+
+ if( waitingElement.getStatus() >= ConflictNode.COARSE ){
+ output.println(" rentry=mlpCreateREntry("+ waitingElement.getStatus()+ ", seseCaller);");
+ }else{
+ output.println(" rentry=mlpCreateFineREntry("+ waitingElement.getStatus()+ ", seseCaller, (void*)&" +generateTemp(fm,waitingElement.getTempDesc(),lb)+ ");");
+ }
+ output.println(" psem_init( &(rentry->parentStallSem) );");
+ output.println(" rentry->queue=seseCaller->memoryQueueArray["+ waitingElement.getQueueID()+ "];");
+ output
+ .println(" if(ADDRENTRY(seseCaller->memoryQueueArray["+ waitingElement.getQueueID()
+ + "],rentry)==NOTREADY){");
+ output.println(" psem_take( &(rentry->parentStallSem) );");
+ output.println(" } ");
+ }
+ output.println(" }");
+ }
+ }
+ }else{
+ ParentChildConflictsMap conflictsMap = mlpa.getConflictsResults().get(fn);
+ if (conflictsMap != null) {
+ Set<Long> allocSet = conflictsMap.getAllocationSiteIDSetofStallSite();
+ if (allocSet.size() > 0) {
+ FlatNode enclosingFlatNode=null;
+ if( currentSESE.getIsCallerSESEplaceholder() && currentSESE.getParent()==null){
+ enclosingFlatNode=currentSESE.getfmEnclosing();
+ }else{
+ enclosingFlatNode=currentSESE;
+ }
+ ConflictGraph graph=mlpa.getConflictGraphResults().get(enclosingFlatNode);
+ HashSet<SESELock> seseLockSet=mlpa.getConflictGraphLockMap().get(graph);
+ Set<WaitingElement> waitingElementSet=graph.getStallSiteWaitingElementSet(conflictsMap, seseLockSet);
+
+ if(waitingElementSet.size()>0){
+ output.println("// stall on parent's stall sites ");
+ output.println(" {");
+ output.println(" REntry* rentry;");
+
+ for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) {
+ WaitingElement waitingElement = (WaitingElement) iterator.next();
+
+ if( waitingElement.getStatus() >= ConflictNode.COARSE ){
+ output.println(" rentry=mlpCreateREntry("+ waitingElement.getStatus()+ ", seseCaller);");
+ }else{
+ output.println(" rentry=mlpCreateFineREntry("+ waitingElement.getStatus()+ ", seseCaller, (void*)&___locals___."+ waitingElement.getDynID() + ");");
+ // output.println(" rentry=mlpCreateFineREntry("+ waitingElement.getStatus()+ ", seseCaller, ___locals___."+ waitingElement.getDynID() + "->oid);");
+ }
+ output.println(" psem_init( &(rentry->parentStallSem) );");
+ output.println(" rentry->queue=seseCaller->memoryQueueArray["+ waitingElement.getQueueID()+ "];");
+ output
+ .println(" if(ADDRENTRY(seseCaller->memoryQueueArray["+ waitingElement.getQueueID()
+ + "],rentry)==NOTREADY){");
+ output.println(" psem_take( &(rentry->parentStallSem) );");
+ output.println(" } ");
+ }
+ output.println(" }");
+ }
+ }
+ }
+ }
+
+
}
}
case FKind.FlatSESEExitNode:
generateFlatSESEExitNode(fm, lb, (FlatSESEExitNode)fn, output);
break;
+
+ case FKind.FlatWriteDynamicVarNode:
+ generateFlatWriteDynamicVarNode(fm, lb, (FlatWriteDynamicVarNode)fn, output);
+ break;
case FKind.FlatGlobalConvNode:
generateFlatGlobalConvNode(fm, lb, (FlatGlobalConvNode) fn, output);
break;
case FKind.FlatBackEdge:
- if ((state.THREAD||state.DSM||state.SINGLETM)&&GENERATEPRECISEGC) {
+ if (state.SINGLETM&&state.SANDBOX&&(locality.getAtomic(lb).get(fn).intValue()>0)) {
+ output.println("if (unlikely((--transaction_check_counter)<=0)) checkObjects();");
+ }
+ if(state.DSM&&state.SANDBOX&&(locality.getAtomic(lb).get(fn).intValue()>0)) {
+ output.println("if (unlikely((--transaction_check_counter)<=0)) checkObjects();");
+ }
+ if (((state.MLP|| state.OOOJAVA||state.THREAD||state.DSM||state.SINGLETM)&&GENERATEPRECISEGC)
+ || (this.state.MULTICOREGC)) {
if(state.DSM&&locality.getAtomic(lb).get(fn).intValue()>0) {
output.println("if (needtocollect) checkcollect2("+localsprefixaddr+");");
- } else
- output.println("if (needtocollect) checkcollect("+localsprefixaddr+");");
+ } else if(this.state.MULTICOREGC) {
+ output.println("if (gcflag) gc("+localsprefixaddr+");");
+ } else {
+ output.println("if (unlikely(needtocollect)) checkcollect("+localsprefixaddr+");");
+ }
} else
output.println("/* nop */");
break;
// insert post-node actions from the code-plan
/*
- if( state.MLP ) {
+ if( state.MLP) {
CodePlan cp = mlpa.getCodePlan( fn );
+
if( cp != null ) {
- Set<VariableSourceToken> writeDynamic = cp.getWriteToDynamicSrc();
- if( writeDynamic != null ) {
- Iterator<VariableSourceToken> vstItr = writeDynamic.iterator();
- while( vstItr.hasNext() ) {
- VariableSourceToken vst = vstItr.next();
-
- }
- }
}
}
*/
/* Have to generate flat globalconv */
if (fgcn.getMakePtr()) {
if (state.DSM) {
- output.println("TRANSREAD("+generateTemp(fm, fgcn.getSrc(),lb)+", (unsigned int) "+generateTemp(fm, fgcn.getSrc(),lb)+");");
+ //DEBUG: output.println("TRANSREAD("+generateTemp(fm, fgcn.getSrc(),lb)+", (unsigned int) "+generateTemp(fm, fgcn.getSrc(),lb)+",\" "+fm+":"+fgcn+"\");");
+ output.println("TRANSREAD("+generateTemp(fm, fgcn.getSrc(),lb)+", (unsigned int) "+generateTemp(fm, fgcn.getSrc(),lb)+");");
} else {
if ((dc==null)||!state.READSET&&dc.getNeedTrans(lb, fgcn)||state.READSET&&dc.getNeedWriteTrans(lb, fgcn)) {
//need to do translation
output.println("TRANSREAD("+generateTemp(fm, fgcn.getSrc(),lb)+", "+generateTemp(fm, fgcn.getSrc(),lb)+", (void *)("+localsprefixaddr+"));");
} else if (state.READSET&&dc.getNeedTrans(lb, fgcn)) {
- output.println("TRANSREADRD("+generateTemp(fm, fgcn.getSrc(),lb)+", "+generateTemp(fm, fgcn.getSrc(),lb)+");");
+ if (state.HYBRID&&delaycomp.getConv(lb).contains(fgcn)) {
+ output.println("TRANSREADRDFISSION("+generateTemp(fm, fgcn.getSrc(),lb)+", "+generateTemp(fm, fgcn.getSrc(),lb)+");");
+ } else
+ output.println("TRANSREADRD("+generateTemp(fm, fgcn.getSrc(),lb)+", "+generateTemp(fm, fgcn.getSrc(),lb)+");");
}
}
} else {
/* Need to convert to OID */
if ((dc==null)||dc.getNeedSrcTrans(lb,fgcn)) {
- if (fgcn.doConvert()||(delaycomp!=null&&atomicmethodmap.get(fgcn.getAtomicEnter()).reallivein.contains(fgcn.getSrc()))) {
+ if (fgcn.doConvert()||(delaycomp!=null&&delaycomp.needsFission(lb, fgcn.getAtomicEnter())&&atomicmethodmap.get(fgcn.getAtomicEnter()).reallivein.contains(fgcn.getSrc()))) {
output.println(generateTemp(fm, fgcn.getSrc(),lb)+"=(void *)COMPOID("+generateTemp(fm, fgcn.getSrc(),lb)+");");
} else {
output.println(generateTemp(fm, fgcn.getSrc(),lb)+"=NULL;");
output.println(generateTemp(fm, fion.getDst(), lb)+"=instanceof("+generateTemp(fm,fion.getSrc(),lb)+","+type+");");
}
+ int sandboxcounter=0;
public void generateFlatAtomicEnterNode(FlatMethod fm, LocalityBinding lb, FlatAtomicEnterNode faen, PrintWriter output) {
/* Check to see if we need to generate code for this atomic */
if (locality==null) {
- output.println("pthread_mutex_lock(&atomiclock);");
+ if (GENERATEPRECISEGC) {
+ output.println("if (pthread_mutex_trylock(&atomiclock)!=0) {");
+ output.println("stopforgc((struct garbagelist *) &___locals___);");
+ output.println("pthread_mutex_lock(&atomiclock);");
+ output.println("restartaftergc();");
+ output.println("}");
+ } else {
+ output.println("pthread_mutex_lock(&atomiclock);");
+ }
return;
}
return;
- if (state.DELAYCOMP) {
+ if (state.SANDBOX) {
+ outsandbox.println("int atomiccounter"+sandboxcounter+"=LOW_CHECK_FREQUENCY;");
+ output.println("counter_reset_pointer=&atomiccounter"+sandboxcounter+";");
+ }
+
+ if (state.DELAYCOMP&&delaycomp.needsFission(lb, faen)) {
AtomicRecord ar=atomicmethodmap.get(faen);
//copy in
for(Iterator<TempDescriptor> tmpit=ar.livein.iterator();tmpit.hasNext();) {
/******* Tell the runtime to start the transaction *******/
output.println("transstart"+faen.getIdentifier()+":");
+ if (state.SANDBOX) {
+ output.println("transaction_check_counter=*counter_reset_pointer;");
+ sandboxcounter++;
+ }
output.println("transStart();");
- if (state.ABORTREADERS) {
+ if (state.ABORTREADERS||state.SANDBOX) {
+ if (state.SANDBOX)
+ output.println("abortenabled=1;");
output.println("if (_setjmp(aborttrans)) {");
output.println(" goto transretry"+faen.getIdentifier()+"; }");
}
if (locality.getAtomic(lb).get(faen).intValue()>0)
return;
//store the revert list before we lose the transaction object
- String revertptr=null;
+
if (state.DSM) {
- revertptr=generateTemp(fm, reverttable.get(lb),lb);
+ String revertptr=generateTemp(fm, reverttable.get(lb),lb);
output.println(revertptr+"=revertlist;");
- }
- if (state.DELAYCOMP) {
- AtomicRecord ar=atomicmethodmap.get(faen.getAtomicEnter());
-
- //do call
- output.println("if (transCommit((void (*)(void *, void *, void *))&"+ar.name+", &primitives_"+ar.name+", &"+localsprefix+", "+paramsprefix+")) {");
- } else
output.println("if (transCommit()) {");
- /* Transaction aborts if it returns true */
- output.println("goto transretry"+faen.getAtomicEnter().getIdentifier()+";");
- if (state.DSM) {
+ output.println("if (unlikely(needtocollect)) checkcollect("+localsprefixaddr+");");
+ output.println("goto transretry"+faen.getAtomicEnter().getIdentifier()+";");
output.println("} else {");
/* Need to commit local object store */
output.println("while ("+revertptr+") {");
output.println("COMMIT_OBJ("+revertptr+");");
output.println(revertptr+"=tmpptr;");
output.println("}");
+ output.println("}");
+ return;
}
- output.println("}");
- if (state.DELAYCOMP) {
- //copy out
- AtomicRecord ar=atomicmethodmap.get(faen.getAtomicEnter());
- output.println("else {");
- for(Iterator<TempDescriptor> tmpit=ar.liveout.iterator();tmpit.hasNext();) {
- TempDescriptor tmp=tmpit.next();
- output.println(tmp.getSafeSymbol()+"=primitives_"+ar.name+"."+tmp.getSafeSymbol()+";");
- }
+
+ if (!state.DELAYCOMP) {
+ //Normal STM stuff
+ output.println("if (transCommit()) {");
+ /* Transaction aborts if it returns true */
+ output.println("if (unlikely(needtocollect)) checkcollect("+localsprefixaddr+");");
+ output.println("goto transretry"+faen.getAtomicEnter().getIdentifier()+";");
output.println("}");
+ } else {
+ if (delaycomp.optimizeTrans(lb, faen.getAtomicEnter())&&(!state.STMARRAY||state.DUALVIEW)) {
+ AtomicRecord ar=atomicmethodmap.get(faen.getAtomicEnter());
+ output.println("LIGHTWEIGHTCOMMIT("+ar.name+", &primitives_"+ar.name+", &"+localsprefix+", "+paramsprefix+", transretry"+faen.getAtomicEnter().getIdentifier()+");");
+ //copy out
+ for(Iterator<TempDescriptor> tmpit=ar.liveout.iterator();tmpit.hasNext();) {
+ TempDescriptor tmp=tmpit.next();
+ output.println(tmp.getSafeSymbol()+"=primitives_"+ar.name+"."+tmp.getSafeSymbol()+";");
+ }
+ } else if (delaycomp.needsFission(lb, faen.getAtomicEnter())) {
+ AtomicRecord ar=atomicmethodmap.get(faen.getAtomicEnter());
+ //do call
+ output.println("if (transCommit((void (*)(void *, void *, void *))&"+ar.name+", &primitives_"+ar.name+", &"+localsprefix+", "+paramsprefix+")) {");
+ output.println("if (unlikely(needtocollect)) checkcollect("+localsprefixaddr+");");
+ output.println("goto transretry"+faen.getAtomicEnter().getIdentifier()+";");
+ output.println("}");
+ //copy out
+ output.println("else {");
+ for(Iterator<TempDescriptor> tmpit=ar.liveout.iterator();tmpit.hasNext();) {
+ TempDescriptor tmp=tmpit.next();
+ output.println(tmp.getSafeSymbol()+"=primitives_"+ar.name+"."+tmp.getSafeSymbol()+";");
+ }
+ output.println("}");
+ } else {
+ output.println("if (transCommit(NULL, NULL, NULL, NULL)) {");
+ output.println("if (unlikely(needtocollect)) checkcollect("+localsprefixaddr+");");
+ output.println("goto transretry"+faen.getAtomicEnter().getIdentifier()+";");
+ output.println("}");
+ }
}
}
- public void generateFlatSESEEnterNode(FlatMethod fm, LocalityBinding lb, FlatSESEEnterNode fsen, PrintWriter output) {
- if( !state.MLP ) {
- // SESE nodes can be parsed for normal compilation, just skip over them
+ public void generateFlatSESEEnterNode( FlatMethod fm,
+ LocalityBinding lb,
+ FlatSESEEnterNode fsen,
+ PrintWriter output
+ ) {
+ // if MLP flag is off, okay that SESE nodes are in IR graph,
+ // just skip over them and code generates exactly the same
+ if( !(state.MLP || state.OOOJAVA) ) {
return;
}
+ // there may be an SESE in an unreachable method, skip over
+ if( (state.MLP && !mlpa.getAllSESEs().contains( fsen )) ||
+ (state.OOOJAVA && !oooa.getAllSESEs().contains(fsen))
+ ) {
+ return;
+ }
+
+ // also, if we have encountered a placeholder, just skip it
+ if( fsen.getIsCallerSESEplaceholder() ) {
+ return;
+ }
+
output.println(" {");
+
+ // set up the parent
+ if( (state.MLP && fsen == mlpa.getMainSESE()) ||
+ (state.OOOJAVA && fsen == oooa.getMainSESE())
+ ) {
+ output.println(" SESEcommon* parentCommon = NULL;");
+ } else {
+ if( fsen.getParent() == null ) {
+ System.out.println( "in "+fm+", "+fsen+" has null parent" );
+ }
+ assert fsen.getParent() != null;
+ if( !fsen.getParent().getIsCallerSESEplaceholder() ) {
+ output.println(" SESEcommon* parentCommon = &("+paramsprefix+"->common);");
+ } else {
+ //output.println(" SESEcommon* parentCommon = (SESEcommon*) peekItem( seseCallStack );");
+ output.println(" SESEcommon* parentCommon = seseCaller;");
+ }
+ }
+
+ // before doing anything, lock your own record and increment the running children
+ if( (state.MLP && fsen != mlpa.getMainSESE()) ||
+ (state.OOOJAVA && fsen != oooa.getMainSESE())
+ ) {
+ output.println(" atomic_inc(&parentCommon->numRunningChildren);");
+ }
+
+ // just allocate the space for this record
output.println(" "+fsen.getSESErecordName()+"* seseToIssue = ("+
fsen.getSESErecordName()+"*) mlpAllocSESErecord( sizeof( "+
fsen.getSESErecordName()+" ) );");
- output.println(" seseToIssue->classID = "+fsen.getIdentifier()+";");
- output.println(" psem_init( &(seseToIssue->stallSem) );");
+ //eomgc need to set next, size
+// output.println(" struct garbagelist * gl= (struct garbagelist *)&(((SESEcommon*)(seseToIssue))[1]);");
+ output.println(" struct garbagelist * gl= (struct garbagelist *)&(((SESEcommon*)(seseToIssue))[1]);");
+ // sizeof(int)*2 + sizeof(void*)*calculateSizeOfSESEParamList(fsen)
+ //output.println(" // sizeof(int)*2+sizeof(void*)*"+calculateSizeOfSESEParamList(fsen));
+ //output.println(" // blah="+calculateSizeOfSESEParamSize(fsen));
+ output.println(" (seseToIssue->common).offsetsize=sizeof(int)+sizeof(void*)+sizeof(void*)*"+calculateSizeOfSESEParamList(fsen)+calculateSizeOfSESEParamSize(fsen)+";");
+ output.println(" gl->size="+calculateSizeOfSESEParamList(fsen)+";");
+// output.println(" gl->next = (struct garbagelist *)&___locals___;");
+ output.println(" seseToIssue->prevSESECount="+calculatePrevSESECount(fsen)+";");
+// output.println(" seseToIssue->prevSESECount=50;");
+ output.println(" gl->next = NULL;");
+// output.println(" seseToIssue->size = "+calculateSizeOfSESEParamList(fsen)+";");
+// output.println(" seseToIssue->next = &___locals___;");
+
- // give pointers to in-set variables, when this SESE is ready to
- // execute it should copy values from the pointers because they
- // will be guaranteed to be ready for consumption then
- Iterator<TempDescriptor> itr = fsen.getInVarSet().iterator();
- while( itr.hasNext() ) {
- TempDescriptor temp = itr.next();
- output.print(" seseToIssue->"+temp.getSafeSymbol()+"__srcAddr_ = ");
+ // and keep the thread-local sese stack up to date
+ //output.println(" addNewItem( seseCallStack, (void*) seseToIssue);");
+
+ // fill in common data
+ output.println(" int localCount=0;");
+ output.println(" seseToIssue->common.classID = "+fsen.getIdentifier()+";");
+ output.println(" psem_init( &(seseToIssue->common.stallSem) );");
+
+ output.println(" seseToIssue->common.forwardList = createQueue();");
+ output.println(" seseToIssue->common.unresolvedDependencies = 10000;");
+ output.println(" pthread_cond_init( &(seseToIssue->common.doneCond), NULL );");
+ output.println(" seseToIssue->common.doneExecuting = FALSE;");
+ output.println(" pthread_cond_init( &(seseToIssue->common.runningChildrenCond), NULL );");
+ output.println(" seseToIssue->common.numRunningChildren = 0;");
+ output.println(" seseToIssue->common.parent = parentCommon;");
+
+ // all READY in-vars should be copied now and be done with it
+ Iterator<TempDescriptor> tempItr = fsen.getReadyInVarSet().iterator();
+ while( tempItr.hasNext() ) {
+ TempDescriptor temp = tempItr.next();
+
+ // when we are issuing the main SESE or an SESE with placeholder
+ // caller SESE as parent, generate temp child child's eclosing method,
+ // otherwise use the parent's enclosing method as the context
+ boolean useParentContext = false;
+
+ if( (state.MLP && fsen != mlpa.getMainSESE()) ||
+ (state.OOOJAVA && fsen != oooa.getMainSESE())
+ ) {
+ assert fsen.getParent() != null;
+ if( !fsen.getParent().getIsCallerSESEplaceholder() ) {
+ useParentContext = true;
+ }
+ }
- if( fsen.getParent() == null ||
- fsen.getParent().getInVarSet().contains( temp ) ||
- fsen.getParent().getOutVarSet().contains( temp )
- ) {
- output.println("(INTPTR) &("+paramsprefix+"->"+temp.getSafeSymbol()+");");
+ if( useParentContext ) {
+ output.println(" seseToIssue->"+temp+" = "+
+ generateTemp( fsen.getParent().getfmBogus(), temp, null )+";");
} else {
- output.println("(INTPTR) &("+temp.getSafeSymbol()+");");
+ output.println(" seseToIssue->"+temp+" = "+
+ generateTemp( fsen.getfmEnclosing(), temp, null )+";");
}
}
-
- // for finding dynamic SESE instances from static names
- if( fsen != mlpa.getRootSESE() ) {
- SESEandAgePair p = new SESEandAgePair( fsen, 0 );
- output.println(" "+p+" = seseToIssue;");
+
+ // before potentially adding this SESE to other forwarding lists,
+ // create it's lock and take it immediately
+ output.println(" pthread_mutex_init( &(seseToIssue->common.lock), NULL );");
+// output.println(" pthread_mutex_lock( &(seseToIssue->common.lock) );");
+
+ if( (state.MLP && fsen != mlpa.getMainSESE()) ||
+ (state.OOOJAVA && fsen != oooa.getMainSESE())
+ ) {
+ // count up outstanding dependencies, static first, then dynamic
+ Iterator<SESEandAgePair> staticSrcsItr = fsen.getStaticInVarSrcs().iterator();
+ while( staticSrcsItr.hasNext() ) {
+ SESEandAgePair srcPair = staticSrcsItr.next();
+ output.println(" {");
+ output.println(" SESEcommon* src = (SESEcommon*)"+srcPair+";");
+ //eomgc
+ if(GENERATEPRECISEGC){
+ output.println(" stopforgc((struct garbagelist *)&___locals___);");
+ }
+ output.println(" pthread_mutex_lock( &(src->lock) );");
+ if(GENERATEPRECISEGC){
+ output.println(" restartaftergc();");
+ }
+ output.println(" if( !isEmpty( src->forwardList ) &&");
+ output.println(" seseToIssue == peekItem( src->forwardList ) ) {");
+ output.println(" printf( \"This shouldnt already be here\\n\");");
+ output.println(" exit( -1 );");
+ output.println(" }");
+ output.println(" if( !src->doneExecuting ) {");
+ output.println(" addNewItem( src->forwardList, seseToIssue );");
+// output.println(" ++(seseToIssue->common.unresolvedDependencies);");
+ output.println(" ++(localCount);");
+ output.println(" }");
+ output.println(" pthread_mutex_unlock( &(src->lock) );");
+ output.println(" }");
+
+ // whether or not it is an outstanding dependency, make sure
+ // to pass the static name to the child's record
+ output.println(" seseToIssue->"+srcPair+" = "+srcPair+";");
+ }
+
+ // dynamic sources might already be accounted for in the static list,
+ // so only add them to forwarding lists if they're not already there
+ Iterator<TempDescriptor> dynVarsItr = fsen.getDynamicInVarSet().iterator();
+ while( dynVarsItr.hasNext() ) {
+ TempDescriptor dynInVar = dynVarsItr.next();
+ output.println(" {");
+ output.println(" SESEcommon* src = (SESEcommon*)"+dynInVar+"_srcSESE;");
+
+ // the dynamic source is NULL if it comes from your own space--you can't pass
+ // the address off to the new child, because you're not done executing and
+ // might change the variable, so copy it right now
+ output.println(" if( src != NULL ) {");
+ //eomgc
+ if(GENERATEPRECISEGC){
+ output.println(" stopforgc((struct garbagelist *)&___locals___);");
+ }
+ output.println(" pthread_mutex_lock( &(src->lock) );");
+ if(GENERATEPRECISEGC){
+ output.println(" restartaftergc();");
+ }
+ output.println(" if( isEmpty( src->forwardList ) ||");
+ output.println(" seseToIssue != peekItem( src->forwardList ) ) {");
+ output.println(" if( !src->doneExecuting ) {");
+ output.println(" addNewItem( src->forwardList, seseToIssue );");
+// output.println(" ++(seseToIssue->common.unresolvedDependencies);");
+ output.println(" ++(localCount);");
+ output.println(" }");
+ output.println(" }");
+ output.println(" pthread_mutex_unlock( &(src->lock) );");
+ output.println(" seseToIssue->"+dynInVar+"_srcOffset = "+dynInVar+"_srcOffset;");
+ output.println(" } else {");
+
+ boolean useParentContext = false;
+ if( (state.MLP && fsen != mlpa.getMainSESE()) ||
+ (state.OOOJAVA && fsen != oooa.getMainSESE())
+ ) {
+ assert fsen.getParent() != null;
+ if( !fsen.getParent().getIsCallerSESEplaceholder() ) {
+ useParentContext = true;
+ }
+ }
+ if( useParentContext ) {
+ output.println(" seseToIssue->"+dynInVar+" = "+
+ generateTemp( fsen.getParent().getfmBogus(), dynInVar, null )+";");
+ } else {
+ output.println(" seseToIssue->"+dynInVar+" = "+
+ generateTemp( fsen.getfmEnclosing(), dynInVar, null )+";");
+ }
+
+ output.println(" }");
+ output.println(" }");
+
+ // even if the value is already copied, make sure your NULL source
+ // gets passed so child knows it already has the dynamic value
+ output.println(" seseToIssue->"+dynInVar+"_srcSESE = "+dynInVar+"_srcSESE;");
+ }
+
+ // maintain pointers for finding dynamic SESE
+ // instances from static names
+ SESEandAgePair pair = new SESEandAgePair( fsen, 0 );
+ if( fsen.getParent() != null &&
+ //!fsen.getParent().getIsCallerSESEplaceholder() &&
+ fsen.getParent().getNeededStaticNames().contains( pair )
+ ) {
+
+ for( int i = fsen.getOldestAgeToTrack(); i > 0; --i ) {
+ SESEandAgePair pair1 = new SESEandAgePair( fsen, i );
+ SESEandAgePair pair2 = new SESEandAgePair( fsen, i-1 );
+ output.println(" "+pair1+" = "+pair2+";");
+ }
+ output.println(" "+pair+" = seseToIssue;");
+ }
+
+ ////////////////
+ // count up memory conflict dependencies,
+ // eom
+ if(state.OOOJAVA){
+
+ FlatSESEEnterNode parent = fsen.getParent();
+ Analysis.OoOJava.ConflictGraph graph = oooa.getConflictGraph(parent);
+ if (graph != null && graph.hasConflictEdge()) {
+ Set<Analysis.OoOJava.SESELock> seseLockSet = oooa.getLockMappings(graph);
+ output.println();
+ output.println(" //add memory queue element");
+ Analysis.OoOJava.SESEWaitingQueue seseWaitingQueue=
+ graph.getWaitingElementSetBySESEID(fsen.getIdentifier(), seseLockSet);
+ if(seseWaitingQueue.getWaitingElementSize()>0){
+ output.println(" {");
+ output.println(" REntry* rentry=NULL;");
+ output.println(" INTPTR* pointer=NULL;");
+ output.println(" seseToIssue->common.rentryIdx=0;");
+
+ Set<Integer> queueIDSet=seseWaitingQueue.getQueueIDSet();
+ for (Iterator iterator = queueIDSet.iterator(); iterator
+ .hasNext();) {
+ Integer key = (Integer) iterator.next();
+ int queueID=key.intValue();
+ Set<Analysis.OoOJava.WaitingElement> waitingQueueSet =
+ seseWaitingQueue.getWaitingElementSet(queueID);
+ int enqueueType=seseWaitingQueue.getType(queueID);
+ if(enqueueType==SESEWaitingQueue.EXCEPTION){
+ output.println(" INITIALIZEBUF(parentCommon->memoryQueueArray["
+ + queueID+ "]);");
+ }
+ for (Iterator iterator2 = waitingQueueSet.iterator(); iterator2
+ .hasNext();) {
+ Analysis.OoOJava.WaitingElement waitingElement
+ = (Analysis.OoOJava.WaitingElement) iterator2.next();
+ if (waitingElement.getStatus() >= ConflictNode.COARSE) {
+ output.println(" rentry=mlpCreateREntry("
+ + waitingElement.getStatus()
+ + ", seseToIssue);");
+ } else {
+ TempDescriptor td = waitingElement
+ .getTempDesc();
+ // decide whether waiting element is dynamic or static
+ if (fsen.getDynamicInVarSet().contains(td)) {
+ // dynamic in-var case
+ output.println(" pointer=seseToIssue->"
+ + waitingElement.getDynID()
+ + "_srcSESE+seseToIssue->"
+ + waitingElement.getDynID()
+ + "_srcOffset;");
+ output
+ .println(" rentry=mlpCreateFineREntry("
+ + waitingElement
+ .getStatus()
+ + ", seseToIssue, pointer );");
+ } else if (fsen.getStaticInVarSet()
+ .contains(td)) {
+ // static in-var case
+ VariableSourceToken vst = fsen
+ .getStaticInVarSrc(td);
+ if (vst != null) {
+
+ String srcId = "SESE_"
+ + vst.getSESE()
+ .getPrettyIdentifier()
+ + vst.getSESE().getIdentifier()
+ + "_" + vst.getAge();
+ output
+ .println(" pointer=(void*)&seseToIssue->"
+ + srcId
+ + "->"
+ + waitingElement
+ .getDynID()
+ + ";");
+ output
+ .println(" rentry=mlpCreateFineREntry("
+ + waitingElement
+ .getStatus()
+ + ", seseToIssue, pointer );");
+
+ }
+ } else {
+ output
+ .println(" rentry=mlpCreateFineREntry("
+ + waitingElement
+ .getStatus()
+ + ", seseToIssue, (void*)&seseToIssue->"
+ + waitingElement.getDynID()
+ + ");");
+ }
+ }
+ output
+ .println(" rentry->queue=parentCommon->memoryQueueArray["
+ + waitingElement.getQueueID()
+ + "];");
+
+ if(enqueueType==SESEWaitingQueue.NORMAL){
+ output
+ .println(" seseToIssue->common.rentryArray[seseToIssue->common.rentryIdx++]=rentry;");
+ output
+ .println(" if(ADDRENTRY(parentCommon->memoryQueueArray["
+ + waitingElement.getQueueID()
+ + "],rentry)==NOTREADY){");
+ output.println(" ++(localCount);");
+ output.println(" }");
+ }else{
+ output
+ .println(" ADDRENTRYTOBUF(parentCommon->memoryQueueArray["
+ + waitingElement.getQueueID()
+ + "],rentry);");
+ }
+ }
+ if(enqueueType!=SESEWaitingQueue.NORMAL){
+ output.println(" localCount+=RESOLVEBUF(parentCommon->memoryQueueArray["
+ + queueID+ "],&seseToIssue->common);");
+ }
+ }
+ output.println(" }");
+ }
+ output.println();
+ }
+
+ }else{
+ ConflictGraph graph = null;
+ FlatSESEEnterNode parent = fsen.getParent();
+ if (parent != null) {
+ if (parent.isCallerSESEplaceholder) {
+ graph = mlpa.getConflictGraphResults().get(parent.getfmEnclosing());
+ } else {
+ graph = mlpa.getConflictGraphResults().get(parent);
+ }
+ }
+ if (graph != null && graph.hasConflictEdge()) {
+ HashSet<SESELock> seseLockSet = mlpa.getConflictGraphLockMap()
+ .get(graph);
+ output.println();
+ output.println(" //add memory queue element");
+ SESEWaitingQueue seseWaitingQueue=graph.getWaitingElementSetBySESEID(fsen.getIdentifier(),
+ seseLockSet);
+ if(seseWaitingQueue.getWaitingElementSize()>0){
+ output.println(" {");
+ output.println(" REntry* rentry=NULL;");
+ output.println(" INTPTR* pointer=NULL;");
+ output.println(" seseToIssue->common.rentryIdx=0;");
+
+ Set<Integer> queueIDSet=seseWaitingQueue.getQueueIDSet();
+ for (Iterator iterator = queueIDSet.iterator(); iterator
+ .hasNext();) {
+ Integer key = (Integer) iterator.next();
+ int queueID=key.intValue();
+ Set<WaitingElement> waitingQueueSet = seseWaitingQueue.getWaitingElementSet(queueID);
+ int enqueueType=seseWaitingQueue.getType(queueID);
+ if(enqueueType==SESEWaitingQueue.EXCEPTION){
+ output.println(" INITIALIZEBUF(parentCommon->memoryQueueArray["
+ + queueID+ "]);");
+ }
+ for (Iterator iterator2 = waitingQueueSet.iterator(); iterator2
+ .hasNext();) {
+ WaitingElement waitingElement = (WaitingElement) iterator2
+ .next();
+ if (waitingElement.getStatus() >= ConflictNode.COARSE) {
+ output.println(" rentry=mlpCreateREntry("
+ + waitingElement.getStatus()
+ + ", seseToIssue);");
+ } else {
+ TempDescriptor td = waitingElement
+ .getTempDesc();
+ // decide whether waiting element is dynamic or
+ // static
+ if (fsen.getDynamicInVarSet().contains(td)) {
+ // dynamic in-var case
+ output.println(" pointer=seseToIssue->"
+ + waitingElement.getDynID()
+ + "_srcSESE+seseToIssue->"
+ + waitingElement.getDynID()
+ + "_srcOffset;");
+ output
+ .println(" rentry=mlpCreateFineREntry("
+ + waitingElement
+ .getStatus()
+ + ", seseToIssue, pointer );");
+ } else if (fsen.getStaticInVarSet()
+ .contains(td)) {
+ // static in-var case
+ VariableSourceToken vst = fsen
+ .getStaticInVarSrc(td);
+ if (vst != null) {
+
+ String srcId = "SESE_"
+ + vst.getSESE()
+ .getPrettyIdentifier()
+ + vst.getSESE().getIdentifier()
+ + "_" + vst.getAge();
+ output
+ .println(" pointer=(void*)&seseToIssue->"
+ + srcId
+ + "->"
+ + waitingElement
+ .getDynID()
+ + ";");
+ output
+ .println(" rentry=mlpCreateFineREntry("
+ + waitingElement
+ .getStatus()
+ + ", seseToIssue, pointer );");
+
+ }
+ } else {
+ output
+ .println(" rentry=mlpCreateFineREntry("
+ + waitingElement
+ .getStatus()
+ + ", seseToIssue, (void*)&seseToIssue->"
+ + waitingElement.getDynID()
+ + ");");
+ }
+ }
+ output
+ .println(" rentry->queue=parentCommon->memoryQueueArray["
+ + waitingElement.getQueueID()
+ + "];");
+
+ if(enqueueType==SESEWaitingQueue.NORMAL){
+ output
+ .println(" seseToIssue->common.rentryArray[seseToIssue->common.rentryIdx++]=rentry;");
+ output
+ .println(" if(ADDRENTRY(parentCommon->memoryQueueArray["
+ + waitingElement.getQueueID()
+ + "],rentry)==NOTREADY){");
+ output.println(" ++(localCount);");
+ output.println(" } ");
+ }else{
+ output
+ .println(" ADDRENTRYTOBUF(parentCommon->memoryQueueArray["
+ + waitingElement.getQueueID()
+ + "],rentry);");
+ }
+ }
+ if(enqueueType!=SESEWaitingQueue.NORMAL){
+ output.println(" localCount+=RESOLVEBUF(parentCommon->memoryQueueArray["
+ + queueID+ "],&seseToIssue->common);");
+ }
+ }
+ output.println(" }");
+ }
+ output.println();
+ }
+ }
+ ////////////////
}
- // submit the SESE as work
- output.println(" workScheduleSubmit( (void*) seseToIssue );");
+ // release this SESE for siblings to update its dependencies or,
+ // eventually, for it to mark itself finished
+ // output.println(" pthread_mutex_unlock( &(seseToIssue->common.lock) );");
+
+ // if there were no outstanding dependencies, issue here
+ output.println(" if( atomic_sub_and_test(10000-localCount,&(seseToIssue->common.unresolvedDependencies) ) ) {");
+ output.println(" workScheduleSubmit( (void*)seseToIssue );");
+ output.println(" }");
+ /*
+ output.println(" if( seseToIssue->common.unresolvedDependencies == 0 ) {");
+ output.println(" workScheduleSubmit( (void*)seseToIssue );");
+ output.println(" }");
+ */
+ // release this SESE for siblings to update its dependencies or,
+ // eventually, for it to mark itself finished
+// output.println(" pthread_mutex_unlock( &(seseToIssue->common.lock) );");
output.println(" }");
+
}
- public void generateFlatSESEExitNode(FlatMethod fm, LocalityBinding lb, FlatSESEExitNode fsexn, PrintWriter output) {
- if( !state.MLP ) {
- // SESE nodes can be parsed for normal compilation, just skip over them
+ public void generateFlatSESEExitNode( FlatMethod fm,
+ LocalityBinding lb,
+ FlatSESEExitNode fsexn,
+ PrintWriter output
+ ) {
+
+ // if MLP flag is off, okay that SESE nodes are in IR graph,
+ // just skip over them and code generates exactly the same
+ if( ! (state.MLP || state.OOOJAVA) ) {
return;
}
- if( fsexn.getFlatEnter() != mlpa.getRootSESE() ) {
- output.println(" {");
- output.println(" psem_give( &("+paramsprefix+"->stallSem) );");
- output.println(" }");
+ // get the enter node for this exit that has meta data embedded
+ FlatSESEEnterNode fsen = fsexn.getFlatEnter();
+
+ // there may be an SESE in an unreachable method, skip over
+ if( (state.MLP && !mlpa.getAllSESEs().contains( fsen )) ||
+ (state.OOOJAVA && !oooa.getAllSESEs().contains( fsen ))
+ ) {
+ return;
+ }
+
+ // also, if we have encountered a placeholder, just jump it
+ if( fsen.getIsCallerSESEplaceholder() ) {
+ return;
+ }
+
+ output.println(" /* SESE exiting */");
+
+ String com = paramsprefix+"->common";
+
+ // this SESE cannot be done until all of its children are done
+ // so grab your own lock with the condition variable for watching
+ // that the number of your running children is greater than zero
+ if (GENERATEPRECISEGC){
+ output.println(" stopforgc((struct garbagelist *)&___locals___);");
+ }
+ output.println(" pthread_mutex_lock( &("+com+".lock) );");
+ if (GENERATEPRECISEGC){
+ output.println(" restartaftergc();");
+ }
+ output.println(" while( "+com+".numRunningChildren > 0 ) {");
+ if (GENERATEPRECISEGC){
+// output.println(" stopforgc((struct garbagelist *)&(((SESEcommon*)(___params___))[1]));");
+ output.println(" stopforgc((struct garbagelist *)&___locals___);");
+ }
+ output.println(" pthread_cond_wait( &("+com+".runningChildrenCond), &("+com+".lock) );");
+ if (GENERATEPRECISEGC){
+ output.println(" restartaftergc();");
+ }
+ output.println(" }");
+
+
+ // copy out-set from local temps into the sese record
+ Iterator<TempDescriptor> itr = fsen.getOutVarSet().iterator();
+ while( itr.hasNext() ) {
+ TempDescriptor temp = itr.next();
+
+ // only have to do this for primitives non-arrays
+ if( !(
+ temp.getType().isPrimitive() && !temp.getType().isArray()
+ )
+ ) {
+ continue;
+ }
+
+ // have to determine the context enclosing this sese
+ boolean useParentContext = false;
+
+ if( (state.MLP &&fsen != mlpa.getMainSESE()) ||
+ (state.OOOJAVA &&fsen != oooa.getMainSESE())
+ ) {
+ assert fsen.getParent() != null;
+ if( !fsen.getParent().getIsCallerSESEplaceholder() ) {
+ useParentContext = true;
+ }
+ }
+
+ String from;
+ if( useParentContext ) {
+ from = generateTemp( fsen.getParent().getfmBogus(), temp, null );
+ } else {
+ from = generateTemp( fsen.getfmEnclosing(), temp, null );
+ }
+
+ output.println(" "+paramsprefix+
+ "->"+temp.getSafeSymbol()+
+ " = "+from+";");
+ }
+
+ // mark yourself done, your SESE data is now read-only
+ output.println(" "+com+".doneExecuting = TRUE;");
+ output.println(" pthread_cond_signal( &("+com+".doneCond) );");
+ output.println(" pthread_mutex_unlock( &("+com+".lock) );");
+
+ // decrement dependency count for all SESE's on your forwarding list
+ output.println(" while( !isEmpty( "+com+".forwardList ) ) {");
+ output.println(" SESEcommon* consumer = (SESEcommon*) getItem( "+com+".forwardList );");
+
+
+ output.println(" if(consumer->rentryIdx>0){");
+ output.println(" // resolved null pointer");
+ output.println(" int idx;");
+ output.println(" for(idx=0;idx<consumer->rentryIdx;idx++){");
+ output.println(" resolvePointer(consumer->rentryArray[idx]);");
+ output.println(" }");
+ output.println(" }");
+
+
+// output.println(" pthread_mutex_lock( &(consumer->lock) );");
+// output.println(" --(consumer->unresolvedDependencies);");
+// output.println(" if( consumer->unresolvedDependencies == 0 ) {");
+ output.println(" if( atomic_sub_and_test(1, &(consumer->unresolvedDependencies)) ){");
+ output.println(" workScheduleSubmit( (void*)consumer );");
+ output.println(" }");
+// output.println(" pthread_mutex_unlock( &(consumer->lock) );");
+ output.println(" }");
+
+
+ // eom
+ // clean up its lock element from waiting queue, and decrement dependency count for next SESE block
+ if( (state.MLP && fsen != mlpa.getMainSESE()) ||
+ (state.OOOJAVA && fsen != oooa.getMainSESE())
+ ) {
+
+ output.println();
+ output.println(" /* check memory dependency*/");
+ output.println(" {");
+ output.println(" int idx;");
+ output.println(" for(idx=0;idx<___params___->common.rentryIdx;idx++){");
+ output.println(" REntry* re=___params___->common.rentryArray[idx];");
+ output.println(" RETIRERENTRY(re->queue,re);");
+ output.println(" }");
+ output.println(" }");
+
}
+
+ // if parent is stalling on you, let them know you're done
+ if( (state.MLP && fsexn.getFlatEnter() != mlpa.getMainSESE()) ||
+ (state.OOOJAVA && fsexn.getFlatEnter() != oooa.getMainSESE())
+ ) {
+ output.println(" psem_give( &("+paramsprefix+"->common.stallSem) );");
+ }
+
+ // last of all, decrement your parent's number of running children
+ output.println(" if( "+paramsprefix+"->common.parent != NULL ) {");
+ output.println(" if (atomic_sub_and_test(1, &"+paramsprefix+"->common.parent->numRunningChildren)) {");
+ if (GENERATEPRECISEGC){
+ output.println(" stopforgc((struct garbagelist *)&___locals___);");
+ }
+ output.println(" pthread_mutex_lock( &("+paramsprefix+"->common.parent->lock) );");
+ if (GENERATEPRECISEGC){
+ output.println(" restartaftergc();");
+ }
+ output.println(" pthread_cond_signal( &("+paramsprefix+"->common.parent->runningChildrenCond) );");
+ output.println(" pthread_mutex_unlock( &("+paramsprefix+"->common.parent->lock) );");
+ output.println(" }");
+ output.println(" }");
+
+ // this is a thread-only variable that can be handled when critical sese-to-sese
+ // data has been taken care of--set sese pointer to remember self over method
+ // calls to a non-zero, invalid address
+ output.println(" seseCaller = (SESEcommon*) 0x1;");
+
+ }
+
+ public void generateFlatWriteDynamicVarNode( FlatMethod fm,
+ LocalityBinding lb,
+ FlatWriteDynamicVarNode fwdvn,
+ PrintWriter output
+ ) {
+ if( !(state.MLP || state.OOOJAVA) ) {
+ // should node should not be in an IR graph if the
+ // MLP flag is not set
+ throw new Error("Unexpected presence of FlatWriteDynamicVarNode");
+ }
+
+ Hashtable<TempDescriptor, VSTWrapper> writeDynamic = fwdvn.getVar2src();
+
+ assert writeDynamic != null;
+
+ Iterator wdItr = writeDynamic.entrySet().iterator();
+ while( wdItr.hasNext() ) {
+ Map.Entry me = (Map.Entry) wdItr.next();
+ TempDescriptor refVar = (TempDescriptor) me.getKey();
+ VSTWrapper vstW = (VSTWrapper) me.getValue();
+ VariableSourceToken vst = vstW.vst;
+
+ /*
+ // only do this if the variable in question should be tracked,
+ // meaning that it was explicitly added to the dynamic var set
+ if( !current.getDynamicVarSet().contains( vst.getAddrVar() ) ) {
+ continue;
+ }
+ */
+
+ if( vst == null ) {
+ // if there is no given source, this variable is ready so
+ // mark src pointer NULL to signify that the var is up-to-date
+ output.println(" "+refVar+"_srcSESE = NULL;");
+ continue;
+ }
+
+ // otherwise we track where it will come from
+ SESEandAgePair instance = new SESEandAgePair( vst.getSESE(), vst.getAge() );
+ output.println(" "+refVar+"_srcSESE = "+instance+";");
+ output.println(" "+refVar+"_srcOffset = (int) &((("+
+ vst.getSESE().getSESErecordName()+"*)0)->"+vst.getAddrVar()+");");
+ }
}
+
private void generateFlatCheckNode(FlatMethod fm, LocalityBinding lb, FlatCheckNode fcn, PrintWriter output) {
if (state.CONSCHECK) {
String specname=fcn.getSpec();
}
private void generateFlatCall(FlatMethod fm, LocalityBinding lb, FlatCall fc, PrintWriter output) {
+
+ if( (state.MLP && !nonSESEpass) ||
+ (state.OOOJAVA && !nonSESEpass)
+ ) {
+ output.println(" seseCaller = (SESEcommon*)"+paramsprefix+";");
+ }
+
MethodDescriptor md=fc.getMethod();
ParamsObject objectparams=(ParamsObject)paramstable.get(lb!=null ? locality.getBinding(lb, fc) : md);
ClassDescriptor cn=md.getClassDesc();
output.println("{");
- if (GENERATEPRECISEGC) {
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
if (lb!=null) {
LocalityBinding fclb=locality.getBinding(lb, fc);
output.print(" struct "+cn.getSafeSymbol()+fclb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={");
} else
output.print(" struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={");
-
output.print(objectparams.numPointers());
output.print(", "+localsprefixaddr);
if (md.getThis()!=null) {
output.print("(*)(");
boolean printcomma=false;
- if (GENERATEPRECISEGC) {
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
if (lb!=null) {
LocalityBinding fclb=locality.getBinding(lb, fc);
output.print("struct "+cn.getSafeSymbol()+fclb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params * ");
output.print("(");
boolean needcomma=false;
- if (GENERATEPRECISEGC) {
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
output.print("&__parameterlist__");
needcomma=true;
}
- if (!GENERATEPRECISEGC) {
+ if (!GENERATEPRECISEGC && !this.state.MULTICOREGC) {
if (fc.getThis()!=null) {
TypeDescriptor ptd=md.getThis().getType();
if (needcomma)
return true;
for(Iterator classit=subclasses.iterator(); classit.hasNext();) {
ClassDescriptor cd=(ClassDescriptor)classit.next();
- Set possiblematches=cd.getMethodTable().getSet(md.getSymbol());
+ Set possiblematches=cd.getMethodTable().getSetFromSameScope(md.getSymbol());
for(Iterator matchit=possiblematches.iterator(); matchit.hasNext();) {
MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
if (md.matches(matchmd))
(state.READSET&&dc.getNeedWriteTrans(lb, ffn))) {
output.println("TRANSREAD("+dst+", "+dst+", (void *) (" + localsprefixaddr + "));");
} else if (state.READSET&&dc.getNeedTrans(lb, ffn)) {
- output.println("TRANSREADRD("+dst+", "+dst+");");
+ if (state.HYBRID&&delaycomp.getConv(lb).contains(ffn)) {
+ output.println("TRANSREADRDFISSION("+dst+", "+dst+");");
+ } else
+ output.println("TRANSREADRD("+dst+", "+dst+");");
}
}
} else if (state.DSM) {
//} else {
output.println(dst+"="+ src +"->"+field+ ";");
//output.println("if ("+dst+"&0x1) {");
- output.println("TRANSREAD("+dst+", (unsigned int) "+dst+");");
+ //DEBUG: output.println("TRANSREAD("+dst+", (unsigned int) "+dst+",\""+fm+":"+ffn+"\");");
+ output.println("TRANSREAD("+dst+", (unsigned int) "+dst+");");
//output.println(src+"->"+field+"="+src+"->"+field+";");
//output.println("}");
//}
String dst=generateTemp(fm, ffn.getDst(),lb);
output.println(dst+"="+ src +"->"+field+ ";");
if (locality.getAtomic(lb).get(ffn).intValue()>0)
+ //DEBUG: output.println("TRANSREAD("+dst+", (unsigned int) "+dst+",\""+fm+":"+ffn+"\");");
output.println("TRANSREAD("+dst+", (unsigned int) "+dst+");");
} else
output.println(generateTemp(fm, ffn.getDst(),lb)+"="+ generateTemp(fm,ffn.getSrc(),lb)+"->"+ ffn.getField().getSafeSymbol()+";");
output.println(generateTemp(fm, ffn.getDst(),lb)+"="+ generateTemp(fm,ffn.getSrc(),lb)+"->"+ ffn.getField().getSafeSymbol()+";");
} else
throw new Error("Read from non-global/non-local in:"+lb.getExplanation());
- } else
+ } else{
+// DEBUG if(!ffn.getDst().getType().isPrimitive()){
+// DEBUG output.println("within((void*)"+generateTemp(fm,ffn.getSrc(),lb)+"->"+ ffn.getField().getSafeSymbol()+");");
+// DEBUG }
output.println(generateTemp(fm, ffn.getDst(),lb)+"="+ generateTemp(fm,ffn.getSrc(),lb)+"->"+ ffn.getField().getSafeSymbol()+";");
+ }
}
}
if (wb.needBarrier(fsfn)&&
locality.getNodePreTempInfo(lb, fsfn).get(fsfn.getDst())!=LocalityAnalysis.SCRATCH) {
+ if (state.EVENTMONITOR) {
+ output.println("if ("+dst+"->___objstatus___&DIRTY) EVLOGEVENTOBJ(EV_WRITE,"+dst+"->objuid)");
+ }
output.println("*((unsigned int *)&("+dst+"->___objstatus___))|=DIRTY;");
}
if (srcptr&!fsfn.getSrc().getType().isNull()) {
/* Link object into list */
String revertptr=generateTemp(fm, reverttable.get(lb),lb);
output.println(revertptr+"=revertlist;");
- if (GENERATEPRECISEGC)
+ if (GENERATEPRECISEGC || this.state.MULTICOREGC)
output.println("COPY_OBJ((struct garbagelist *)"+localsprefixaddr+",(struct ___Object___ *)"+dst+");");
else
output.println("COPY_OBJ("+dst+");");
String dst=generateTemp(fm, fsfn.getDst(),lb);
output.println("if(!"+dst+"->"+localcopystr+") {");
/* Link object into list */
- if (GENERATEPRECISEGC)
+ if (GENERATEPRECISEGC || this.state.MULTICOREGC)
output.println("COPY_OBJ((struct garbagelist *)"+localsprefixaddr+",(struct ___Object___ *)"+dst+");");
else
output.println("COPY_OBJ("+dst+");");
output.println(fcrevert+"=(struct ___Object___ *)"+dst+";");
output.println("}");
}
+
+// DEBUG if(!fsfn.getField().getType().isPrimitive()){
+// DEBUG output.println("within((void*)"+generateTemp(fm,fsfn.getSrc(),lb)+");");
+// DEBUG }
output.println(generateTemp(fm, fsfn.getDst(),lb)+"->"+ fsfn.getField().getSafeSymbol()+"="+ generateTemp(fm,fsfn.getSrc(),lb)+";");
}
}
type=elementtype.getSafeSymbol()+" ";
if (this.state.ARRAYBOUNDARYCHECK && fen.needsBoundsCheck()) {
- output.println("if ("+generateTemp(fm, fen.getIndex(),lb)+"< 0 | "+generateTemp(fm, fen.getIndex(),lb)+" >= "+generateTemp(fm,fen.getSrc(),lb) + "->___length___)");
+ output.println("if (unlikely(((unsigned int)"+generateTemp(fm, fen.getIndex(),lb)+") >= "+generateTemp(fm,fen.getSrc(),lb) + "->___length___))");
output.println("failedboundschk();");
}
if (state.SINGLETM) {
//Single machine transaction case
String dst=generateTemp(fm, fen.getDst(),lb);
- output.println(dst +"=(("+ type+"*)(((char *) &("+ generateTemp(fm,fen.getSrc(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fen.getIndex(),lb)+"];");
+ if ((!state.STMARRAY)||(!wb.needBarrier(fen))||locality.getNodePreTempInfo(lb, fen).get(fen.getSrc())==LocalityAnalysis.SCRATCH||locality.getAtomic(lb).get(fen).intValue()==0||(state.READSET&&!dc.getNeedGet(lb, fen))) {
+ output.println(dst +"=(("+ type+"*)(((char *) &("+ generateTemp(fm,fen.getSrc(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fen.getIndex(),lb)+"];");
+ } else {
+ output.println("STMGETARRAY("+dst+", "+ generateTemp(fm,fen.getSrc(),lb)+", "+generateTemp(fm, fen.getIndex(),lb)+", "+type+");");
+ }
if (elementtype.isPtr()&&locality.getAtomic(lb).get(fen).intValue()>0&&
locality.getNodePreTempInfo(lb, fen).get(fen.getSrc())!=LocalityAnalysis.SCRATCH) {
if ((dc==null)||!state.READSET&&dc.getNeedTrans(lb, fen)||state.READSET&&dc.getNeedWriteTrans(lb, fen)) {
output.println("TRANSREAD("+dst+", "+dst+", (void *)(" + localsprefixaddr+"));");
} else if (state.READSET&&dc.getNeedTrans(lb, fen)) {
- output.println("TRANSREADRD("+dst+", "+dst+");");
+ if (state.HYBRID&&delaycomp.getConv(lb).contains(fen)) {
+ output.println("TRANSREADRDFISSION("+dst+", "+dst+");");
+ } else
+ output.println("TRANSREADRD("+dst+", "+dst+");");
}
}
} else if (state.DSM) {
Integer status=locality.getNodePreTempInfo(lb,fen).get(fen.getSrc());
if (status==LocalityAnalysis.GLOBAL) {
String dst=generateTemp(fm, fen.getDst(),lb);
-
if (elementtype.isPtr()) {
output.println(dst +"=(("+ type+"*)(((char *) &("+ generateTemp(fm,fen.getSrc(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fen.getIndex(),lb)+"];");
+ //DEBUG: output.println("TRANSREAD("+dst+", "+dst+",\""+fm+":"+fen+"\");");
output.println("TRANSREAD("+dst+", "+dst+");");
} else {
output.println(dst +"=(("+ type+"*)(((char *) &("+ generateTemp(fm,fen.getSrc(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fen.getIndex(),lb)+"];");
} else
throw new Error("Read from non-global/non-local in:"+lb.getExplanation());
} else {
- output.println(generateTemp(fm, fen.getDst(),lb)+"=(("+ type+"*)(((char *) &("+ generateTemp(fm,fen.getSrc(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fen.getIndex(),lb)+"];");
+// DEBUG output.println("within((void*)"+generateTemp(fm,fen.getSrc(),lb)+");");
+ output.println(generateTemp(fm, fen.getDst(),lb)+"=(("+ type+"*)(((char *) &("+ generateTemp(fm,fen.getSrc(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fen.getIndex(),lb)+"];");
}
}
type=elementtype.getSafeSymbol()+" ";
if (this.state.ARRAYBOUNDARYCHECK && fsen.needsBoundsCheck()) {
- output.println("if ("+generateTemp(fm, fsen.getIndex(),lb)+"< 0 | "+generateTemp(fm, fsen.getIndex(),lb)+" >= "+generateTemp(fm,fsen.getDst(),lb) + "->___length___)");
+ output.println("if (unlikely(((unsigned int)"+generateTemp(fm, fsen.getIndex(),lb)+") >= "+generateTemp(fm,fsen.getDst(),lb) + "->___length___))");
output.println("failedboundschk();");
}
} else {
output.println("INTPTR srcoid=(INTPTR)"+src+";");
}
- output.println("((INTPTR*)(((char *) &("+ generateTemp(fm,fsen.getDst(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fsen.getIndex(),lb)+"]=srcoid;");
+ if (state.STMARRAY&&locality.getNodePreTempInfo(lb, fsen).get(fsen.getDst())!=LocalityAnalysis.SCRATCH&&wb.needBarrier(fsen)&&locality.getAtomic(lb).get(fsen).intValue()>0) {
+ output.println("STMSETARRAY("+generateTemp(fm, fsen.getDst(),lb)+", "+generateTemp(fm, fsen.getIndex(),lb)+", srcoid, INTPTR);");
+ } else {
+ output.println("((INTPTR*)(((char *) &("+ generateTemp(fm,fsen.getDst(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fsen.getIndex(),lb)+"]=srcoid;");
+ }
output.println("}");
} else {
- output.println("(("+type +"*)(((char *) &("+ generateTemp(fm,fsen.getDst(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fsen.getIndex(),lb)+"]="+generateTemp(fm,fsen.getSrc(),lb)+";");
+ if (state.STMARRAY&&locality.getNodePreTempInfo(lb, fsen).get(fsen.getDst())!=LocalityAnalysis.SCRATCH&&wb.needBarrier(fsen)&&locality.getAtomic(lb).get(fsen).intValue()>0) {
+ output.println("STMSETARRAY("+generateTemp(fm, fsen.getDst(),lb)+", "+generateTemp(fm, fsen.getIndex(),lb)+", "+ generateTemp(fm, fsen.getSrc(), lb) +", "+type+");");
+ } else {
+ output.println("(("+type +"*)(((char *) &("+ generateTemp(fm,fsen.getDst(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fsen.getIndex(),lb)+"]="+generateTemp(fm,fsen.getSrc(),lb)+";");
+ }
}
} else if (state.DSM && locality.getAtomic(lb).get(fsen).intValue()>0) {
Integer statussrc=locality.getNodePreTempInfo(lb,fsen).get(fsen.getSrc());
Integer statusdst=locality.getNodePreTempInfo(lb,fsen).get(fsen.getDst());
boolean srcglobal=statussrc==LocalityAnalysis.GLOBAL;
boolean dstglobal=statusdst==LocalityAnalysis.GLOBAL;
- boolean dstlocal=statusdst==LocalityAnalysis.LOCAL;
-
+ boolean dstlocal=(statusdst==LocalityAnalysis.LOCAL)||(statusdst==LocalityAnalysis.EITHER);
+
if (dstglobal) {
if (wb.needBarrier(fsen))
output.println("*((unsigned int *)&("+generateTemp(fm,fsen.getDst(),lb)+"->___localcopy___))|=DIRTY;");
/* Link object into list */
String revertptr=generateTemp(fm, reverttable.get(lb),lb);
output.println(revertptr+"=revertlist;");
- if (GENERATEPRECISEGC)
- output.println("COPY_OBJ((struct garbagelist *)"+localsprefixaddr+",(struct ___Object___ *)"+dst+");");
+ if ((GENERATEPRECISEGC) || this.state.MULTICOREGC)
+ output.println("COPY_OBJ((struct garbagelist *)"+localsprefixaddr+",(struct ___Object___ *)"+dst+");");
else
output.println("COPY_OBJ("+dst+");");
output.println(dst+"->"+nextobjstr+"="+revertptr+";");
output.println("revertlist=(struct ___Object___ *)"+dst+";");
output.println("}");
- } else throw new Error("Unknown array type");
+ } else {
+ System.out.println("Node: "+fsen);
+ System.out.println(lb);
+ System.out.println("statusdst="+statusdst);
+ System.out.println(fm.printMethod());
+ throw new Error("Unknown array type");
+ }
if (srcglobal) {
output.println("{");
String src=generateTemp(fm, fsen.getSrc(), lb);
String dst=generateTemp(fm, fsen.getDst(),lb);
output.println("if(!"+dst+"->"+localcopystr+") {");
/* Link object into list */
- if (GENERATEPRECISEGC)
+ if (GENERATEPRECISEGC || this.state.MULTICOREGC)
output.println("COPY_OBJ((struct garbagelist *)"+localsprefixaddr+",(struct ___Object___ *)"+dst+");");
else
output.println("COPY_OBJ("+dst+");");
output.println(fcrevert+"=(struct ___Object___ *)"+dst+";");
output.println("}");
}
+// DEBUG output.println("within((void*)"+generateTemp(fm,fsen.getDst(),lb)+");");
output.println("(("+type +"*)(((char *) &("+ generateTemp(fm,fsen.getDst(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fsen.getIndex(),lb)+"]="+generateTemp(fm,fsen.getSrc(),lb)+";");
}
}
int arrayid=state.getArrayNumber(fn.getType())+state.numClasses();
if (fn.isGlobal()&&(state.DSM||state.SINGLETM)) {
output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarrayglobal("+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");");
- } else if (GENERATEPRECISEGC) {
- output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray("+localsprefixaddr+", "+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");");
+ } else if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
+ if(this.state.MLP || state.OOOJAVA){
+ output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray_oid("+localsprefixaddr+", "+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+", oid);");
+ output.println(" oid += numWorkers;");
+ }else{
+ output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray("+localsprefixaddr+", "+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");");
+ }
} else {
output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray("+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");");
}
} else {
if (fn.isGlobal()&&(state.DSM||state.SINGLETM)) {
output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newglobal("+fn.getType().getClassDesc().getId()+");");
- } else if (GENERATEPRECISEGC) {
- output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new("+localsprefixaddr+", "+fn.getType().getClassDesc().getId()+");");
+ } else if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
+ if (this.state.MLP || state.OOOJAVA){
+ output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new_oid("+localsprefixaddr+", "+fn.getType().getClassDesc().getId()+", oid);");
+ output.println(" oid += numWorkers;");
+ } else {
+ output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new("+localsprefixaddr+", "+fn.getType().getClassDesc().getId()+");");
+ }
} else {
output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new("+fn.getType().getClassDesc().getId()+");");
}
}
private void generateFlatTagDeclaration(FlatMethod fm, LocalityBinding lb, FlatTagDeclaration fn, PrintWriter output) {
- if (GENERATEPRECISEGC) {
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_tag("+localsprefixaddr+", "+state.getTagId(fn.getType())+");");
} else {
output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_tag("+state.getTagId(fn.getType())+");");
output.println(generateTemp(fm, fon.getDest(),lb)+" = ((unsigned int)"+generateTemp(fm, fon.getLeft(),lb)+")>>"+generateTemp(fm,fon.getRight(),lb)+";");
} else if (dc!=null) {
- output.print(generateTemp(fm, fon.getDest(),lb)+" = ");
+ output.print(generateTemp(fm, fon.getDest(),lb)+" = (");
+ if (fon.getLeft().getType().isPtr()&&(fon.getOp().getOp()==Operation.EQUAL||fon.getOp().getOp()==Operation.NOTEQUAL))
+ output.print("(void *)");
if (dc.getNeedLeftSrcTrans(lb, fon))
output.print("("+generateTemp(fm, fon.getLeft(),lb)+"!=NULL?"+generateTemp(fm, fon.getLeft(),lb)+"->"+oidstr+":NULL)");
else
output.print(generateTemp(fm, fon.getLeft(),lb));
- output.print(fon.getOp().toString());
+ output.print(")"+fon.getOp().toString()+"(");
+ if (fon.getRight().getType().isPtr()&&(fon.getOp().getOp()==Operation.EQUAL||fon.getOp().getOp()==Operation.NOTEQUAL))
+ output.print("(void *)");
if (dc.getNeedRightSrcTrans(lb, fon))
- output.println("("+generateTemp(fm, fon.getRight(),lb)+"!=NULL?"+generateTemp(fm, fon.getRight(),lb)+"->"+oidstr+":NULL);");
+ output.println("("+generateTemp(fm, fon.getRight(),lb)+"!=NULL?"+generateTemp(fm, fon.getRight(),lb)+"->"+oidstr+":NULL));");
else
- output.println(generateTemp(fm,fon.getRight(),lb)+";");
+ output.println(generateTemp(fm,fon.getRight(),lb)+");");
} else
output.println(generateTemp(fm, fon.getDest(),lb)+" = "+generateTemp(fm, fon.getLeft(),lb)+fon.getOp().toString()+generateTemp(fm,fon.getRight(),lb)+";");
} else if (fon.getOp().getOp()==Operation.ASSIGN)
if (fln.getValue()==null)
output.println(generateTemp(fm, fln.getDst(),lb)+"=0;");
else if (fln.getType().getSymbol().equals(TypeUtil.StringClass)) {
- if (GENERATEPRECISEGC) {
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
if (state.DSM && locality.getAtomic(lb).get(fln).intValue()>0) {
//Stash pointer in case of GC
String revertptr=generateTemp(fm, reverttable.get(lb),lb);
}
protected void generateStoreFlatCondBranch(FlatMethod fm, LocalityBinding lb, FlatCondBranch fcb, String label, PrintWriter output) {
- output.println("STOREANDBRANCH(!"+generateTemp(fm, fcb.getTest(),lb)+", "+label+");");
+ int left=-1;
+ int right=-1;
+ //only record if this group has more than one exit
+ if (branchanalysis.numJumps(fcb)>1) {
+ left=branchanalysis.jumpValue(fcb, 0);
+ right=branchanalysis.jumpValue(fcb, 1);
+ }
+ output.println("if (!"+generateTemp(fm, fcb.getTest(),lb)+") {");
+ if (right!=-1)
+ output.println("STOREBRANCH("+right+");");
+ output.println("goto "+label+";");
+ output.println("}");
+ if (left!=-1)
+ output.println("STOREBRANCH("+left+");");
}
protected void generateFlatCondBranch(FlatMethod fm, LocalityBinding lb, FlatCondBranch fcb, String label, PrintWriter output) {
} else
output.print(task.getSafeSymbol()+"(");
- /*
- if (addSESErecord) {
- output.print("SESErecord* currentSESE, ");
- }
- */
-
boolean printcomma=false;
- if (GENERATEPRECISEGC) {
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
if (md!=null) {
if (state.DSM||state.SINGLETM) {
output.print("struct "+cn.getSafeSymbol()+lb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params * "+paramsprefix);
output.print(temp.getType().getSafeSymbol()+" "+temp.getSafeSymbol());
}
output.println(") {");
- } else if (!GENERATEPRECISEGC) {
+ } else if (!GENERATEPRECISEGC && !this.state.MULTICOREGC) {
/* Imprecise Task */
output.println("void * parameterarray[]) {");
/* Unpack variables */
Iterator tagit=tagtmps.iterator();
while(tagit.hasNext()) {
TempDescriptor tagtmp=(TempDescriptor)tagit.next();
- if (GENERATEPRECISEGC)
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC))
output.println("tagclear("+localsprefixaddr+", (struct ___Object___ *)"+generateTemp(fm, temp,lb)+", "+generateTemp(fm,tagtmp,lb)+");");
else
output.println("tagclear((struct ___Object___ *)"+generateTemp(fm, temp,lb)+", "+generateTemp(fm,tagtmp,lb)+");");
Iterator tagit=tagtmps.iterator();
while(tagit.hasNext()) {
TempDescriptor tagtmp=(TempDescriptor)tagit.next();
- if (GENERATEPRECISEGC)
+ if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC))
output.println("tagset("+localsprefixaddr+", (struct ___Object___ *)"+generateTemp(fm, temp,lb)+", "+generateTemp(fm,tagtmp,lb)+");");
else
output.println("tagset((struct ___Object___ *)"+generateTemp(fm, temp, lb)+", "+generateTemp(fm,tagtmp, lb)+");");
ClassDescriptor cn=cdarray[i];
if (i>0)
output.print(", ");
- if (processedcd.contains(cn))
+ if ((cn != null) && (processedcd.contains(cn)))
output.print("&classanalysiswrapper_"+cn.getSafeSymbol());
else
output.print("NULL");
protected void outputTransCode(PrintWriter output) {
}
+
+ private int calculateSizeOfSESEParamList(FlatSESEEnterNode fsen){
+
+ Set<TempDescriptor> tdSet=new HashSet<TempDescriptor>();
+
+ for (Iterator iterator = fsen.getInVarSet().iterator(); iterator.hasNext();) {
+ TempDescriptor tempDescriptor = (TempDescriptor) iterator.next();
+ if(!tempDescriptor.getType().isPrimitive() || tempDescriptor.getType().isArray()){
+ tdSet.add(tempDescriptor);
+ }
+ }
+
+ for (Iterator iterator = fsen.getOutVarSet().iterator(); iterator.hasNext();) {
+ TempDescriptor tempDescriptor = (TempDescriptor) iterator.next();
+ if(!tempDescriptor.getType().isPrimitive() || tempDescriptor.getType().isArray()){
+ tdSet.add(tempDescriptor);
+ }
+ }
+
+ return tdSet.size();
+ }
+
+private String calculateSizeOfSESEParamSize(FlatSESEEnterNode fsen){
+ HashMap <String,Integer> map=new HashMap();
+ HashSet <TempDescriptor> processed=new HashSet<TempDescriptor>();
+ String rtr="";
+
+ // space for all in and out set primitives
+ Set<TempDescriptor> inSetAndOutSet = new HashSet<TempDescriptor>();
+ inSetAndOutSet.addAll( fsen.getInVarSet() );
+ inSetAndOutSet.addAll( fsen.getOutVarSet() );
+
+ Set<TempDescriptor> inSetAndOutSetPrims = new HashSet<TempDescriptor>();
+
+ Iterator<TempDescriptor> itr = inSetAndOutSet.iterator();
+ while( itr.hasNext() ) {
+ TempDescriptor temp = itr.next();
+ TypeDescriptor type = temp.getType();
+ if( !type.isPtr() ) {
+ inSetAndOutSetPrims.add( temp );
+ }
+ }
+
+ Iterator<TempDescriptor> itrPrims = inSetAndOutSetPrims.iterator();
+ while( itrPrims.hasNext() ) {
+ TempDescriptor temp = itrPrims.next();
+ TypeDescriptor type = temp.getType();
+ if(type.isPrimitive()){
+ Integer count=map.get(type.getSymbol());
+ if(count==null){
+ count=new Integer(1);
+ map.put(type.getSymbol(), count);
+ }else{
+ map.put(type.getSymbol(), new Integer(count.intValue()+1));
+ }
+ }
+ }
+
+ Set<String> keySet=map.keySet();
+ for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
+ String key = (String) iterator.next();
+ rtr+="+sizeof("+key+")*"+map.get(key);
+ }
+ return rtr;
+}
+
+private int calculatePrevSESECount(FlatSESEEnterNode fsen){
+ int count=0;
+
+ // dynamic stuff
+ Iterator<TempDescriptor>itrDynInVars = fsen.getDynamicInVarSet().iterator();
+ while( itrDynInVars.hasNext() ) {
+ TempDescriptor dynInVar = itrDynInVars.next();
+ count++;
+ }
+
+ // in-set source tracking
+ Iterator<SESEandAgePair> itrStaticInVarSrcs = fsen.getStaticInVarSrcs().iterator();
+ while( itrStaticInVarSrcs.hasNext() ) {
+ SESEandAgePair srcPair = itrStaticInVarSrcs.next();
+ count++;
+ }
+
+ return count;
+}
+
+
}