interface to grab the conflict effect set for Stephen,
[IRC.git] / Robust / src / IR / Flat / BuildCode.java
index 240e6c5f5e4a3fe797ff425c14ca5507156b098d..5159f7ebbb051af5b165bed52e0f572ea66836b0 100644 (file)
@@ -19,16 +19,29 @@ import Analysis.TaskStateAnalysis.TaskIndex;
 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;
@@ -62,6 +75,7 @@ public class BuildCode {
   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); }";
@@ -69,25 +83,27 @@ public class BuildCode {
   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)
@@ -107,15 +123,15 @@ public class BuildCode {
     }
     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();
@@ -125,6 +141,7 @@ public class BuildCode {
   /** 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 */
@@ -140,6 +157,9 @@ public class BuildCode {
     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);
@@ -170,15 +190,22 @@ public class BuildCode {
     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>");
@@ -217,25 +244,62 @@ public class BuildCode {
       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);
       }
@@ -261,13 +325,13 @@ public class BuildCode {
       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();
@@ -275,7 +339,7 @@ public class BuildCode {
     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
@@ -285,15 +349,24 @@ public class BuildCode {
     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();");
     }
@@ -336,7 +409,7 @@ public class BuildCode {
        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
@@ -361,7 +434,8 @@ public class BuildCode {
     }
 
     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);");
@@ -370,9 +444,13 @@ public class BuildCode {
        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);");
@@ -386,10 +464,14 @@ public class BuildCode {
       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();");
     }
 
@@ -436,6 +518,9 @@ public class BuildCode {
     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\"");
@@ -456,13 +541,15 @@ public class BuildCode {
     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);
@@ -482,6 +569,7 @@ public class BuildCode {
        wb.analyze(lb);
        if (!md.getModifiers().isNative()) {
          generateFlatMethod(fm, lb, outmethod);
+      //System.out.println("fm= " + fm + " md= " + md);
        }
       }
     } else {
@@ -512,7 +600,7 @@ public class BuildCode {
     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\"");
     }
@@ -521,12 +609,23 @@ public class BuildCode {
      * 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 "+
@@ -582,6 +681,12 @@ public class BuildCode {
     //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;");
@@ -594,7 +699,7 @@ public class BuildCode {
       } else {
         outclassdefs.println("  int version;");
         outclassdefs.println("  int * lock;");  // lock entry for this obj
-        outclassdefs.println("  void * mutex;");  
+        outclassdefs.println("  int mutex;");  
         outclassdefs.println("  int lockcount;");
         if(state.MULTICOREGC) {
           outclassdefs.println("  int marked;");
@@ -607,8 +712,15 @@ public class BuildCode {
     }
     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");
@@ -896,9 +1008,13 @@ public class BuildCode {
       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;");
@@ -908,10 +1024,16 @@ public class BuildCode {
       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;
@@ -932,7 +1054,11 @@ public class BuildCode {
     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++) {
@@ -949,7 +1075,11 @@ public class BuildCode {
     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;
     }
 
@@ -972,7 +1102,7 @@ public class BuildCode {
     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)
@@ -1173,7 +1303,11 @@ public class BuildCode {
       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++) {
@@ -1195,7 +1329,7 @@ public class BuildCode {
       if (needcomma)
        output.println(", ");
       needcomma=true;
-      if (cn.hasFlags())
+      if ((cn != null) && (cn.hasFlags()))
        output.print("1");
       else
        output.print("0");
@@ -1212,7 +1346,7 @@ public class BuildCode {
       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
@@ -1292,6 +1426,12 @@ public class BuildCode {
     /* 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;");
@@ -1303,13 +1443,13 @@ public class BuildCode {
       if((!state.MULTICORE) || (cn.getSymbol().equals("TagDescriptor"))) {
        classdefout.println("  void * flagptr;");
       } else if (state.MULTICORE) {
-        if(state.MULTICOREGC) {
-          classdefout.println("  int marked;");
-        }
        classdefout.println("  int version;");
     classdefout.println("  int * lock;");  // lock entry for this obj
-    classdefout.println("  void * mutex;");  
+    classdefout.println("  int mutex;");  
     classdefout.println("  int lockcount;");
+    if(state.MULTICOREGC) {
+      classdefout.println("  int marked;");
+    }
       }
       if (state.OPTIONAL) {
        classdefout.println("  int numfses;");
@@ -1364,8 +1504,8 @@ public class BuildCode {
        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()+";");
@@ -1389,7 +1529,7 @@ public class BuildCode {
        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);
@@ -1467,8 +1607,7 @@ public class BuildCode {
       /* 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);
@@ -1484,7 +1623,7 @@ public class BuildCode {
       /* 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);
@@ -1516,6 +1655,8 @@ public class BuildCode {
   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());
@@ -1525,6 +1666,7 @@ public class BuildCode {
     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
@@ -1535,12 +1677,16 @@ public class BuildCode {
       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();
@@ -1564,6 +1710,7 @@ public class BuildCode {
          ar.liveout=liveout;
          ar.liveoutvirtualread=liveoutvirtualread;
 
+
          for(Iterator<TempDescriptor> it=liveinto.iterator(); it.hasNext();) {
            TempDescriptor tmp=it.next();
            //remove the pointers
@@ -1637,7 +1784,6 @@ public class BuildCode {
        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++)
@@ -1656,19 +1802,106 @@ public class BuildCode {
        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 if (this.state.MULTICOREGC) {
-      output.println("if(gcflag) gc("+localsprefixaddr+");");
-    } else
-         output.println("if (needtocollect) checkcollect("+localsprefixaddr+");");
+         output.println("if(gcflag) gc("+localsprefixaddr+");");
+       } else {
+         output.println("if (unlikely(needtocollect)) checkcollect("+localsprefixaddr+");");
+       }
       }
     }
 
@@ -1679,7 +1912,7 @@ public class BuildCode {
 
 
   protected void initializeSESE( FlatSESEEnterNode fsen ) {
-    
+
     FlatMethod       fm = fsen.getfmEnclosing();
     MethodDescriptor md = fm.getMethod();
     ClassDescriptor  cn = md.getClassDesc();
@@ -1720,17 +1953,19 @@ public class BuildCode {
     // 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);
+
+    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);
+         objecttemps.addPrim( temp );
        }
       }
     }
@@ -1743,20 +1978,26 @@ public class BuildCode {
                                     PrintWriter outputMethods
                                     ) {
 
-    ParamsObject objectparams = (ParamsObject) paramstable.get( fsen.getmdBogus() );
-                
-    TempObject objecttemps = (TempObject) tempstable.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("  INTPTR size;");
+    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("  struct "+
+                             temp.getType().getSafeSymbol()+" * "+
+                             temp.getSafeSymbol()+";");
     }
     outputStructs.println("};\n");
 
@@ -1770,25 +2011,12 @@ public class BuildCode {
     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>();
@@ -1810,7 +2038,9 @@ public class BuildCode {
     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++) {
@@ -1821,6 +2051,42 @@ public class BuildCode {
         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");
 
     
@@ -1857,7 +2123,7 @@ public class BuildCode {
     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("};");
@@ -1880,8 +2146,8 @@ public class BuildCode {
     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
@@ -1920,6 +2186,57 @@ public class BuildCode {
        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
@@ -1934,13 +2251,16 @@ public class BuildCode {
       
       // 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()+";");
 
@@ -1951,22 +2271,35 @@ public class BuildCode {
     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;" );
-      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() ) {
+       typeStr = "void*";
+      } else if( type.isClass() || type.isArray() ) {
+       typeStr = "struct "+type.getSafeSymbol()+"*";
+      } else {
+       typeStr = type.getSafeSymbol();
+      }
+      
       output.println("     "+generateTemp( fsen.getfmBogus(), temp, null )+
-                            " = *(("+temp.getType().toPrettyString()+"*) ("+
-                            paramsprefix+"->"+temp+"_srcSESE + "+
-                            paramsprefix+"->"+temp+"_srcOffset));");
+                    " = *(("+typeStr+"*) ("+
+                    paramsprefix+"->"+temp+"_srcSESE + "+
+                    paramsprefix+"->"+temp+"_srcOffset));");
 
       // or if the source was our parent, its in the record to grab
       output.println("   } else {");
@@ -1978,23 +2311,24 @@ public class BuildCode {
     // 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 (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");
+    
   }
 
 
@@ -2016,15 +2350,27 @@ public class BuildCode {
     // 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.getRootSESE() ) ) {
+      
+      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 );");
       }
 
@@ -2050,24 +2396,42 @@ public class BuildCode {
                               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 */
@@ -2108,13 +2472,24 @@ public class BuildCode {
            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);
@@ -2130,26 +2505,32 @@ public class BuildCode {
 
          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+" */");               
              }
            }
          }
@@ -2185,7 +2566,7 @@ public class BuildCode {
              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;
@@ -2227,7 +2608,100 @@ public class BuildCode {
     }
   }
 
-  /** 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);
   }
@@ -2280,7 +2754,6 @@ public class BuildCode {
     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();
     }
 
@@ -2298,9 +2771,15 @@ public class BuildCode {
   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();
@@ -2312,27 +2791,31 @@ public class BuildCode {
        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() ) {
            TempDescriptor td = tdItr.next();
-           output.println("       "+generateTemp( currentSESE.getfmBogus(), td, null )+
+           FlatMethod fmContext;
+           if( currentSESE.getIsCallerSESEplaceholder() ) {
+             fmContext = currentSESE.getfmEnclosing();
+           } else {
+             fmContext = currentSESE.getfmBogus();
+           }
+           output.println("       "+generateTemp( fmContext, td, null )+
                           " = child->"+vst.getAddrVar().getSafeSymbol()+";");
          }
 
@@ -2350,9 +2833,28 @@ public class BuildCode {
          output.println("     if( "+dynVar+"_srcSESE != NULL ) {");
          output.println("       SESEcommon* common = (SESEcommon*) "+dynVar+"_srcSESE;");
          output.println("       psem_take( &(common->stallSem) );");
-         output.println("       "+generateTemp( currentSESE.getfmBogus(), dynVar, null )+
-                                 " = *(("+dynVar.getType()+"*) ("+
-                                 dynVar+"_srcSESE + "+dynVar+"_srcOffset));");
+
+         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("   }");
        }
@@ -2367,6 +2869,93 @@ public class BuildCode {
          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("   }");
+                       }
+               }
+       }       
+       }
+
+       
       }     
     }
 
@@ -2452,14 +3041,21 @@ public class BuildCode {
       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 if(this.state.MULTICOREGC) {
-      output.println("if (gcflag) gc("+localsprefixaddr+");");
-    } else
-         output.println("if (needtocollect) checkcollect("+localsprefixaddr+");");
+         output.println("if (gcflag) gc("+localsprefixaddr+");");
+       } else {
+         output.println("if (unlikely(needtocollect)) checkcollect("+localsprefixaddr+");");
+       }
       } else
        output.println("/* nop */");
       break;
@@ -2484,13 +3080,15 @@ public class BuildCode {
       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) {
@@ -2673,19 +3271,23 @@ public class BuildCode {
     /* 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;");
@@ -2708,10 +3310,19 @@ public class BuildCode {
       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;
     }
 
@@ -2719,7 +3330,12 @@ public class BuildCode {
       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();) {
@@ -2766,9 +3382,15 @@ public class BuildCode {
     /******* 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()+"; }");
     }
@@ -2783,21 +3405,13 @@ public class BuildCode {
     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+") {");
@@ -2806,17 +3420,46 @@ public class BuildCode {
       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("}");
+      }
     }
   }
 
@@ -2825,68 +3468,136 @@ public class BuildCode {
                                         FlatSESEEnterNode fsen, 
                                         PrintWriter output 
                                       ) {
-    if( !state.MLP ) {
-      // SESE nodes can be parsed for normal compilation, just skip over them
+    // 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( fsen != mlpa.getRootSESE() ) {      
-      output.println("     pthread_mutex_lock( &("+paramsprefix+"->common.lock) );");
-      output.println("     ++("+paramsprefix+"->common.numRunningChildren);");
-      output.println("     pthread_mutex_unlock( &("+paramsprefix+"->common.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 );");
     output.println("     seseToIssue->common.numRunningChildren = 0;");
-
-    if( fsen != mlpa.getRootSESE() ) {
-      output.println("     seseToIssue->common.parent = (SESEcommon*) "+paramsprefix+";");
-    } else {
-      output.println("     seseToIssue->common.parent = NULL;");
-    }
+    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();
-      if( fsen != mlpa.getRootSESE() ) {
+
+      // 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( useParentContext ) {
        output.println("     seseToIssue->"+temp+" = "+
-                      generateTemp( fsen.getParent().getfmBogus(), temp, null )+";");
+                      generateTemp( fsen.getParent().getfmBogus(), temp, null )+";");   
       } else {
        output.println("     seseToIssue->"+temp+" = "+
-                      paramsprefix+"->"+temp+";");
+                      generateTemp( fsen.getfmEnclosing(), temp, null )+";");
       }
     }
-
+    
     // 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.getRootSESE() ) {
+//    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\");");
@@ -2894,7 +3605,8 @@ public class BuildCode {
        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("     }");
@@ -2903,7 +3615,7 @@ public class BuildCode {
        // 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();
@@ -2916,18 +3628,43 @@ public class BuildCode {
        // 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("         seseToIssue->"+dynInVar+"_srcOffset = "+dynInVar+"_srcOffset;");
        output.println("       } else {");
-       output.println("         seseToIssue->"+dynInVar+" = "+dynInVar+";");
+
+       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("     }");
        
@@ -2936,27 +3673,291 @@ public class BuildCode {
        output.println("     seseToIssue->"+dynInVar+"_srcSESE = "+dynInVar+"_srcSESE;");
       }
       
-      // maintain pointers for for finding dynamic SESE 
-      // instances from static names
-      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+";");
+      // 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();
+                       }
       }
-      SESEandAgePair p = new SESEandAgePair( fsen, 0 );
-      output.println("     "+p+" = 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("     pthread_mutex_unlock( &(seseToIssue->common.lock) );");
     output.println("   }");
-
+    
   }
 
   public void generateFlatSESEExitNode( FlatMethod fm,  
@@ -2964,33 +3965,92 @@ public class BuildCode {
                                        FlatSESEExitNode fsexn, 
                                        PrintWriter output
                                      ) {
-    if( !state.MLP ) {
-      // SESE nodes can be parsed for normal compilation, just skip over them
+
+    // 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;
+    }
+
+    // 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("   }");
-    //output.println("   pthread_mutex_unlock( &("+com+".lock) );");    
+
 
     // copy out-set from local temps into the sese record
-    Iterator<TempDescriptor> itr = fsexn.getFlatEnter().getOutVarSet().iterator();
+    Iterator<TempDescriptor> itr = fsen.getOutVarSet().iterator();
     while( itr.hasNext() ) {
-      TempDescriptor temp = itr.next();      
+      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()+
-                    " = "+temp.getSafeSymbol()+";" );
+                    " = "+from+";");
     }    
     
     // mark yourself done, your SESE data is now read-only
-    //output.println("   pthread_mutex_lock( &("+com+".lock) );");
     output.println("   "+com+".doneExecuting = TRUE;");
     output.println("   pthread_cond_signal( &("+com+".doneCond) );");
     output.println("   pthread_mutex_unlock( &("+com+".lock) );");
@@ -2998,75 +4058,116 @@ public class BuildCode {
     // 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( (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.getRootSESE() ) {
+    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()+");");
     }  
   }
 
@@ -3096,6 +4197,13 @@ public class BuildCode {
   }
 
   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();
@@ -3106,7 +4214,6 @@ public class BuildCode {
        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) {
@@ -3194,7 +4301,7 @@ public class BuildCode {
       needcomma=true;
     }
 
-    if (!GENERATEPRECISEGC) {
+    if (!GENERATEPRECISEGC && !this.state.MULTICOREGC) {
       if (fc.getThis()!=null) {
        TypeDescriptor ptd=md.getThis().getType();
        if (needcomma)
@@ -3231,7 +4338,7 @@ public class BuildCode {
       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))
@@ -3255,7 +4362,10 @@ public class BuildCode {
            (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) {
@@ -3280,7 +4390,8 @@ public class BuildCode {
          //} 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("}");
          //}
@@ -3295,6 +4406,7 @@ public class BuildCode {
          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()+";");
@@ -3308,8 +4420,12 @@ public class BuildCode {
        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()+";");
+    }
   }
 
 
@@ -3333,6 +4449,9 @@ public class BuildCode {
       }
       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()) {
@@ -3367,7 +4486,7 @@ public class BuildCode {
        /* 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+");");
@@ -3395,7 +4514,7 @@ public class BuildCode {
        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+");");
@@ -3403,6 +4522,10 @@ public class BuildCode {
        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)+";");
     }
   }
@@ -3417,29 +4540,36 @@ public class BuildCode {
       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)+"];");
@@ -3457,7 +4587,8 @@ public class BuildCode {
       } 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)+"];");
     }
   }
 
@@ -3474,7 +4605,7 @@ public class BuildCode {
       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();");
     }
 
@@ -3493,18 +4624,26 @@ public class BuildCode {
        } 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;");
@@ -3515,14 +4654,20 @@ public class BuildCode {
        /* 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+");");
        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);
@@ -3537,7 +4682,7 @@ public class BuildCode {
        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+");");
@@ -3545,6 +4690,7 @@ public class BuildCode {
        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)+";");
     }
   }
@@ -3579,7 +4725,12 @@ public class BuildCode {
       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)+");");
       }
@@ -3587,7 +4738,12 @@ public class BuildCode {
       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()+");");
       }
@@ -3624,16 +4780,20 @@ public class BuildCode {
          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)
@@ -3707,7 +4867,20 @@ public class BuildCode {
   }
 
   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) {
@@ -3748,12 +4921,6 @@ public class BuildCode {
     } else
       output.print(task.getSafeSymbol()+"(");
     
-    /*
-    if (addSESErecord) {
-      output.print("SESErecord* currentSESE, ");
-    }
-    */
-
     boolean printcomma=false;
     if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
       if (md!=null) {
@@ -3779,7 +4946,7 @@ public class BuildCode {
          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 */
@@ -4290,7 +5457,7 @@ public class BuildCode {
       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");
@@ -4323,6 +5490,93 @@ public class BuildCode {
 
   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;
+}
+
+
 }