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); }";
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.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 \"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);
}
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();");
}
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("#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();");
}
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);
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\"");
}
//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;");
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()];
/* 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;");
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()+";");
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);
/* Output parameter structure */
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) || (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);
ar.liveout=liveout;
ar.liveoutvirtualread=liveoutvirtualread;
+
for(Iterator<TempDescriptor> it=liveinto.iterator(); it.hasNext();) {
TempDescriptor tmp=it.next();
//remove the pointers
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++)
}
- if( state.MLP ) {
+ if( state.MLP || state.OOOJAVA ) {
if( fm.getNext(0) instanceof FlatSESEEnterNode ) {
FlatSESEEnterNode callerSESEplaceholder = (FlatSESEEnterNode) fm.getNext( 0 );
- if( callerSESEplaceholder != mlpa.getMainSESE() ) {
+ 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 p = pItr.next();
- output.println(" void* "+p+";");
+ SESEandAgePair pair = pItr.next();
+ output.println(" void* "+pair+";");
}
// declare variables for tracking dynamic sources
// set up related allocation sites's waiting queues
// eom
- output.println(" /* set up waiting queues */");
- ConflictGraph graph=null;
- graph=mlpa.getConflictGraphResults().get(fm);
- if(graph!=null){
- Set<Integer> allocSet=graph.getAllocationSiteIDSet();
-
- if(allocSet.size()>0){
- output.println(" int numRelatedAllocSites="+allocSet.size()+";");
- output.println(" seseCaller->numRelatedAllocSites=numRelatedAllocSites;");
- output.println(" seseCaller->allocSiteArray=mlpCreateAllocSiteArray(numRelatedAllocSites);");
- int idx=0;
- for (Iterator iterator = allocSet.iterator(); iterator.hasNext();) {
- Integer allocID = (Integer) iterator.next();
- output.println(" seseCaller->allocSiteArray["+idx+"].id="+allocID+";");
- idx++;
- }
- output.println();
- }
+ 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)) {
fsen.getmdBogus().getSafeSymbol()+"_"+
fsen.getmdBogus().getSafeMethodDescriptor()+
"_locals {");
- outputStructs.println(" INTPTR size;");
+ outputStructs.println(" int size;");
outputStructs.println(" void * next;");
for(int i=0; i<objecttemps.numPointers(); i++) {
TempDescriptor temp=objecttemps.getPointer(i);
- if( fsen.getPrettyIdentifier().equals( "calc" ) ) {
- System.out.println( " got a pointer "+temp );
- }
-
if (temp.getType().isNull())
outputStructs.println(" void * "+temp.getSafeSymbol()+";");
else
outputStructs.println(" SESEcommon common;");
// then garbage list stuff
- outputStructs.println(" INTPTR size;");
+ outputStructs.println(" int size;");
outputStructs.println(" void * next;");
- // 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+";");
- }
-
- // 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;");
- }
+ // DYNAMIC stuff was here
+
+ // invar source taking was here
// space for all in and out set primitives
Set<TempDescriptor> inSetAndOutSet = new HashSet<TempDescriptor>();
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()+";");
}
+ // 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(" 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");
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(" /* 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+";");
}
// declare variables for tracking dynamic sources
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
// can't grab something from this source until it is done
output.println(" {");
- 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) );");
+ /*
+ 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()+";");
// gotta wait until the source is done
output.println(" SESEcommon* com = (SESEcommon*)"+paramsprefix+"->"+temp+"_srcSESE;" );
- 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) );");
+ /*
+ 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() ) {
// Check to see if we need to do a GC if this is a
// multi-threaded program...
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)) {
- if(this.state.MULTICOREGC) {
- output.println("if(gcflag) gc("+localsprefixaddr+");");
- } else {
- output.println("if (unlikely(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
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( fsen.equals( mlpa.getMainSESE() ) ) {
+ 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 );");
}
output.println("primitives->"+tmp.getSafeSymbol()+"="+tmp.getSafeSymbol()+";");
}
}
- if (state.MLP && stopset!=null) {
+ if ((state.MLP || state.OOOJAVA) && stopset!=null) {
assert first.getPrev( 0 ) instanceof FlatSESEEnterNode;
assert current_node instanceof FlatSESEExitNode;
FlatSESEEnterNode fsen = (FlatSESEEnterNode) first.getPrev( 0 );
current_node=null;
} else if(current_node.numNext()==1) {
FlatNode nextnode;
- if (state.MLP &&
+ if ((state.MLP|| state.OOOJAVA) &&
current_node.kind()==FKind.FlatSESEEnterNode &&
!((FlatSESEEnterNode)current_node).getIsCallerSESEplaceholder()
) {
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();
while( vstItr.hasNext() ) {
VariableSourceToken vst = vstItr.next();
- SESEandAgePair p = new SESEandAgePair( vst.getSESE(), vst.getAge() );
+ SESEandAgePair pair = new SESEandAgePair( vst.getSESE(), vst.getAge() );
output.println(" {");
- output.println(" SESEcommon* common = (SESEcommon*) "+p+";");
+ 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) );");
-
- //output.println(" psem_take( &(common->stallSem) );");
// copy things we might have stalled for
- output.println(" "+p.getSESE().getSESErecordName()+"* child = ("+
- p.getSESE().getSESErecordName()+"*) "+p+";");
+ output.println(" "+pair.getSESE().getSESErecordName()+"* child = ("+
+ pair.getSESE().getSESErecordName()+"*) "+pair+";");
Iterator<TempDescriptor> tdItr = cp.getCopySet( vst ).iterator();
while( tdItr.hasNext() ) {
} 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 )+
- " = *(("+dynVar.getType()+"*) ("+
- dynVar+"_srcSESE + "+dynVar+"_srcOffset));");
+ " = *(("+typeStr+"*) ("+
+ dynVar+"_srcSESE + "+dynVar+"_srcOffset));");
output.println(" }");
output.println(" }");
// dynamic source vars to the current SESE
dynItr = cp.getDynAssignCurr().iterator();
while( dynItr.hasNext() ) {
- TempDescriptor dynVar = dynItr.next();
- output.println(" "+dynVar+"_srcSESE = NULL;");
+ 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(" }");
+ }
+ }
+ }
+ }
+
+
}
}
if (state.SINGLETM&&state.SANDBOX&&(locality.getAtomic(lb).get(fn).intValue()>0)) {
output.println("if (unlikely((--transaction_check_counter)<=0)) checkObjects();");
}
- if (((state.THREAD||state.DSM||state.SINGLETM)&&GENERATEPRECISEGC)
+ 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+");");
throw new Error();
}
- // insert post-node actions from the code-plan
- if( state.MLP ) {
+ // insert post-node actions from the code-plan
+ /*
+ if( state.MLP) {
CodePlan cp = mlpa.getCodePlan( fn );
if( cp != null ) {
}
- }
+ }
+ */
}
public void generateFlatOffsetNode(FlatMethod fm, LocalityBinding lb, FlatOffsetNode fofn, PrintWriter output) {
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 ) {
+ if( !(state.MLP || state.OOOJAVA) ) {
return;
}
-
// there may be an SESE in an unreachable method, skip over
- if( !mlpa.getAllSESEs().contains( fsen ) ) {
+ if( (state.MLP && !mlpa.getAllSESEs().contains( fsen )) ||
+ (state.OOOJAVA && !oooa.getAllSESEs().contains(fsen))
+ ) {
return;
}
output.println(" {");
// set up the parent
- if( fsen == mlpa.getMainSESE() ) {
+ if( (state.MLP && fsen == mlpa.getMainSESE()) ||
+ (state.OOOJAVA && fsen == oooa.getMainSESE())
+ ) {
output.println(" SESEcommon* parentCommon = NULL;");
} else {
if( fsen.getParent() == null ) {
}
// before doing anything, lock your own record and increment the running children
- if( fsen != mlpa.getMainSESE() ) {
- output.println(" pthread_mutex_lock( &(parentCommon->lock) );");
- output.println(" ++(parentCommon->numRunningChildren);");
- output.println(" pthread_mutex_unlock( &(parentCommon->lock) );");
+ 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()+" ) );");
+ //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___;");
+
// 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 = 0;");
+ 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 );");
// otherwise use the parent's enclosing method as the context
boolean useParentContext = false;
- if( fsen != mlpa.getMainSESE() ) {
+ if( (state.MLP && fsen != mlpa.getMainSESE()) ||
+ (state.OOOJAVA && fsen != oooa.getMainSESE())
+ ) {
assert fsen.getParent() != null;
if( !fsen.getParent().getIsCallerSESEplaceholder() ) {
useParentContext = true;
}
}
- // count up memory conflict dependencies,
- // eom
- ConflictGraph graph=null;
- FlatSESEEnterNode parent=fsen.getParent();
- if(parent!=null){
- if(parent.isCallerSESEplaceholder){
- graph=mlpa.getConflictGraphResults().get(parent.getfmEnclosing());
- }else{
- graph=mlpa.getConflictGraphResults().get(fsen);
- }
- }
- if (graph != null) {
- output.println();
- output.println(" /*add waiting queue element*/");
-
- Set<Integer> allocSet = graph.getAllocationSiteIDSetBySESEID(fsen
- .getIdentifier());
- if (allocSet.size() > 0) {
- output.println(" {");
- output
- .println(" pthread_mutex_lock( &(parentCommon->lock) );");
-
- for (Iterator iterator = allocSet.iterator(); iterator
- .hasNext();) {
- Integer allocID = (Integer) iterator.next();
- output
- .println(" addWaitingQueueElement(parentCommon->allocSiteArray,numRelatedAllocSites,"
- + allocID
- + ",seseToIssue);");
- output
- .println(" ++(seseToIssue->common.unresolvedDependencies);");
- }
- output
- .println(" pthread_mutex_unlock( &(parentCommon->lock) );");
- output.println(" }");
- }
-
- output.println(" /*decide whether it is runnable or not in regarding to memory conflicts*/");
- output.println(" {");
- output.println(" int idx;");
- output.println(" for(idx = 0 ; idx < numRelatedAllocSites ; idx++){");
- output.println(" SESEcommon* item=peekItem(seseCaller->allocSiteArray[idx].waitingQueue);");
- output.println(" if(item->classID==seseToIssue->common.classID){");
- output.println(" --(seseToIssue->common.unresolvedDependencies);");
- output.println(" }");
- output.println(" }");
- output.println(" }");
- output.println();
- }
-
// 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( fsen != mlpa.getMainSESE() ) {
+// 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(" }");
output.println(" if( !src->doneExecuting ) {");
output.println(" addNewItem( src->forwardList, seseToIssue );");
- output.println(" ++(seseToIssue->common.unresolvedDependencies);");
+// output.println(" ++(seseToIssue->common.unresolvedDependencies);");
+ output.println(" ++(localCount);");
output.println(" }");
output.println(" pthread_mutex_unlock( &(src->lock) );");
output.println(" }");
// 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();
// 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(" ++(seseToIssue->common.unresolvedDependencies);");
+ output.println(" ++(localCount);");
output.println(" }");
output.println(" }");
output.println(" pthread_mutex_unlock( &(src->lock) );");
output.println(" } else {");
boolean useParentContext = false;
- if( fsen != mlpa.getMainSESE() ) {
+ if( (state.MLP && fsen != mlpa.getMainSESE()) ||
+ (state.OOOJAVA && fsen != oooa.getMainSESE())
+ ) {
assert fsen.getParent() != null;
if( !fsen.getParent().getIsCallerSESEplaceholder() ) {
useParentContext = true;
output.println(" seseToIssue->"+dynInVar+"_srcSESE = "+dynInVar+"_srcSESE;");
}
- // maintain pointers for for finding dynamic SESE
+ // maintain pointers for finding dynamic SESE
// instances from static names
- SESEandAgePair p = new SESEandAgePair( fsen, 0 );
+ SESEandAgePair pair = new SESEandAgePair( fsen, 0 );
if( fsen.getParent() != null &&
//!fsen.getParent().getIsCallerSESEplaceholder() &&
- fsen.getParent().getNeededStaticNames().contains( p )
+ fsen.getParent().getNeededStaticNames().contains( pair )
) {
for( int i = fsen.getOldestAgeToTrack(); i > 0; --i ) {
- SESEandAgePair p1 = new SESEandAgePair( fsen, i );
- SESEandAgePair p2 = new SESEandAgePair( fsen, i-1 );
- output.println(" "+p1+" = "+p2+";");
+ SESEandAgePair pair1 = new SESEandAgePair( fsen, i );
+ SESEandAgePair pair2 = new SESEandAgePair( fsen, i-1 );
+ output.println(" "+pair1+" = "+pair2+";");
}
- output.println(" "+p+" = seseToIssue;");
+ 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();
+ }
+ }
+ ////////////////
}
-
+
+ // 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(" pthread_mutex_unlock( &(seseToIssue->common.lock) );");
output.println(" }");
}
// 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 ) {
+ if( ! (state.MLP || state.OOOJAVA) ) {
return;
}
FlatSESEEnterNode fsen = fsexn.getFlatEnter();
// there may be an SESE in an unreachable method, skip over
- if( !mlpa.getAllSESEs().contains( fsen ) ) {
+ if( (state.MLP && !mlpa.getAllSESEs().contains( fsen )) ||
+ (state.OOOJAVA && !oooa.getAllSESEs().contains( fsen ))
+ ) {
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
- if( !temp.getType().isPrimitive() ) {
+ // 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( fsen != mlpa.getMainSESE() ) {
+ if( (state.MLP &&fsen != mlpa.getMainSESE()) ||
+ (state.OOOJAVA &&fsen != oooa.getMainSESE())
+ ) {
assert fsen.getParent() != null;
if( !fsen.getParent().getIsCallerSESEplaceholder() ) {
useParentContext = true;
// 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(" pthread_mutex_lock( &(consumer->lock) );");
- output.println(" --(consumer->unresolvedDependencies);");
- output.println(" if( consumer->unresolvedDependencies == 0 ) {");
+
+
+ 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(" 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( fsen != mlpa.getMainSESE() ) {
- output.println();
- output.println(" /* check memory dependency*/");
- output.println(" {");
- output.println(" int idx;");
- output.println(" for(idx = 0 ; idx < ___params___->common.parent->numRelatedAllocSites ; idx++){");
- output.println(" SESEcommon* item=peekItem(___params___->common.parent->allocSiteArray[idx].waitingQueue);");
- output.println(" if( item->classID == ___params___->common.classID ){");
- output.println(" struct QueueItem* qItem=findItem(___params___->common.parent->allocSiteArray[idx].waitingQueue,item);");
- output.println(" removeItem(___params___->common.parent->allocSiteArray[idx].waitingQueue,qItem);");
- output.println(" if( !isEmpty(___params___->common.parent->allocSiteArray[idx].waitingQueue) ){");
- output.println(" SESEcommon* nextItem=peekItem(___params___->common.parent->allocSiteArray[idx].waitingQueue);");
- output.println(" pthread_mutex_lock( &(nextItem->lock) );");
- output.println(" --(nextItem->unresolvedDependencies);");
- output.println(" if( nextItem->unresolvedDependencies == 0){");
- output.println(" workScheduleSubmit( (void*)nextItem);");
- output.println(" }");
- output.println(" pthread_mutex_unlock( &(nextItem->lock) );");
- output.println(" }");
- output.println(" }");
- output.println(" }");
- output.println(" }");
+ 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( fsexn.getFlatEnter() != mlpa.getMainSESE() ) {
+ 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(" pthread_mutex_lock( &("+paramsprefix+"->common.parent->lock) );");
- output.println(" --("+paramsprefix+"->common.parent->numRunningChildren);");
- output.println(" pthread_cond_signal( &("+paramsprefix+"->common.parent->runningChildrenCond) );");
- output.println(" pthread_mutex_unlock( &("+paramsprefix+"->common.parent->lock) );");
- output.println(" }");
+ 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 ) {
+ 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, VariableSourceToken> writeDynamic =
- fwdvn.getVar2src();
+ 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();
- VariableSourceToken vst = (VariableSourceToken) me.getValue();
-
- FlatSESEEnterNode current = fwdvn.getEnclosingSESE();
+ 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;
}
+ */
- SESEandAgePair instance = new SESEandAgePair( vst.getSESE(), vst.getAge() );
-
- output.println(" {");
-
- if( current.equals( vst.getSESE() ) ) {
- // if the src comes from this SESE, it's a method local variable,
+ 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(" "+vst.getAddrVar()+"_srcSESE = NULL;");
-
- } else {
- // otherwise we track where it will come from
- output.println(" "+vst.getAddrVar()+"_srcSESE = "+instance+";");
- output.println(" "+vst.getAddrVar()+"_srcOffset = (int) &((("+
- vst.getSESE().getSESErecordName()+"*)0)->"+vst.getAddrVar()+");");
+ output.println(" "+refVar+"_srcSESE = NULL;");
+ continue;
}
- output.println(" }");
+ // 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 generateFlatCall(FlatMethod fm, LocalityBinding lb, FlatCall fc, PrintWriter output) {
- if( state.MLP && !nonSESEpass ) {
+ if( (state.MLP && !nonSESEpass) ||
+ (state.OOOJAVA && !nonSESEpass)
+ ) {
output.println(" seseCaller = (SESEcommon*)"+paramsprefix+";");
}
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.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()) {
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)+";");
}
}
} 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)+"];");
}
}
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)+";");
}
}
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) || (this.state.MULTICOREGC)) {
- output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray("+localsprefixaddr+", "+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");");
+ 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)+");");
}
if (fn.isGlobal()&&(state.DSM||state.SINGLETM)) {
output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newglobal("+fn.getType().getClassDesc().getId()+");");
} else if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
- output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new("+localsprefixaddr+", "+fn.getType().getClassDesc().getId()+");");
+ 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()+");");
}
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;
+}
+
+
}