change in the multicore version runtime. now it is able to choose which cores to...
[IRC.git] / Robust / src / Main / Main.java
index 4e90919f2c07e745ed03697b1c2fe6ae08897b9c..748c0027fa06bdfcf33a21ecfae53e671574d0e8 100644 (file)
@@ -41,8 +41,11 @@ import Analysis.Locality.GenerateConversions;
 import Analysis.Prefetch.PrefetchAnalysis;
 import Analysis.FlatIRGraph.FlatIRGraph;
 import Analysis.OwnershipAnalysis.OwnershipAnalysis;
+import Analysis.Disjoint.DisjointAnalysis;
 import Analysis.MLP.MLPAnalysis;
 import Analysis.Loops.*;
+import Analysis.Liveness;
+import Analysis.ArrayReferencees;
 import IR.MethodDescriptor;
 import IR.Flat.FlatMethod;
 import Interface.*;
@@ -89,6 +92,9 @@ public class Main {
       } else if(option.equals("-numcore")) {
        ++i;
        state.CORENUM = Integer.parseInt(args[i]);
+      } else if(option.equals("-numcore4gc")) {
+        ++i;
+        state.CORENUM4GC = Integer.parseInt(args[i]);
       } else if (option.equals("-mainclass"))
        state.main=args[++i];
       else if (option.equals("-trueprob")) {
@@ -117,6 +123,14 @@ public class Main {
        state.TASKSTATE=true;
       else if (option.equals("-tagstate"))
        state.TAGSTATE=true;
+      else if (option.equals("-stmarray"))
+       state.STMARRAY=true;
+      else if (option.equals("-eventmonitor"))
+       state.EVENTMONITOR=true;
+      else if (option.equals("-dualview"))
+       state.DUALVIEW=true;
+      else if (option.equals("-hybrid"))
+       state.HYBRID=true;
       else if (option.equals("-flatirtasks")) {
        state.FLATIRGRAPH=true;
        state.FLATIRGRAPHTASKS=true;
@@ -139,8 +153,47 @@ public class Main {
        if (args[++i].equals("all")) {
          state.OWNERSHIPWRITEALL=true;
        }
-      } else if (option.equals("-ownaliasfile"))
+      } else if (option.equals("-ownaliasfile")) {
        state.OWNERSHIPALIASFILE=args[++i];
+      } else if (option.equals("-ownaliasfiletab")) {
+       state.OWNERSHIPALIASFILE=args[++i];
+        state.OWNERSHIPALIASTAB=true;      
+      } else if (option.equals("-owndebugcallee")) {
+       state.OWNERSHIPDEBUGCALLEE=args[++i];
+      } else if (option.equals("-owndebugcaller")) {
+       state.OWNERSHIPDEBUGCALLER=args[++i];
+      } else if (option.equals("-owndebugcallcount")) {
+       state.OWNERSHIPDEBUGCALLCOUNT=Integer.parseInt(args[++i]);
+      }
+      else if (option.equals("-disjoint"))
+       state.DISJOINT=true;
+      else if (option.equals("-disjoint-k")) {
+       state.DISJOINTALLOCDEPTH=Integer.parseInt(args[++i]);
+      } else if (option.equals("-disjoint-write-dots")) {
+       state.DISJOINTWRITEDOTS = true;
+        String arg = args[++i];
+       if( arg.equals("all") ) {
+         state.DISJOINTWRITEALL = true;
+       } else if( arg.equals("final") ) {
+          state.DISJOINTWRITEALL = false;
+        } else {
+          throw new Error("disjoint-write-dots requires argument <all/final>");
+        }
+      } else if (option.equals("-disjoint-alias-file")) {
+       state.DISJOINTALIASFILE = args[++i];
+        String arg = args[++i];
+       if( arg.equals("normal") ) {
+         state.DISJOINTALIASTAB = false;
+       } else if( arg.equals("tabbed") ) {
+          state.DISJOINTALIASTAB = true;
+        } else {
+          throw new Error("disjoint-alias-file requires arguments <filename> <normal/tabbed>");
+        }
+      } else if (option.equals("-disjoint-debug-callsite")) {
+       state.DISJOINTDEBUGCALLEE=args[++i];
+       state.DISJOINTDEBUGCALLER=args[++i];
+       state.DISJOINTDEBUGCALLCOUNT=Integer.parseInt(args[++i]);
+      }
       else if (option.equals("-optional"))
        state.OPTIONAL=true;
       else if (option.equals("-optimize"))
@@ -169,6 +222,10 @@ public class Main {
        state.THREAD=true;
       else if (option.equals("-dsm"))
        state.DSM=true;
+      else if (option.equals("-recoverystats"))
+  state.DSMRECOVERYSTATS=true;
+      else if (option.equals("-dsmtask"))
+  state.DSMTASK=true;
       else if (option.equals("-singleTM"))
        state.SINGLETM=true;
       else if (option.equals("-readset"))
@@ -240,7 +297,7 @@ public class Main {
        sourcefiles.add(args[i]);
       }
     }
-
+    
     //add default classpath
     if (state.classpath.size()==1)
       state.classpath.add(ClassLibraryPrefix);
@@ -333,9 +390,13 @@ public class Main {
     
     if (state.OWNERSHIP && !state.MLP) {
       CallGraph callGraph = new CallGraph(state);
+      Liveness liveness = new Liveness();
+      ArrayReferencees ar = new ArrayReferencees(state);
       OwnershipAnalysis oa = new OwnershipAnalysis(state,
                                                    tu,
                                                    callGraph,
+                                                  liveness,
+                                                   ar,
                                                    state.OWNERSHIPALLOCDEPTH,
                                                    state.OWNERSHIPWRITEDOTS,
                                                    state.OWNERSHIPWRITEALL,
@@ -345,9 +406,13 @@ public class Main {
 
     if (state.MLP) {
       CallGraph callGraph = new CallGraph(state);
+      Liveness liveness = new Liveness();
+      ArrayReferencees ar = new ArrayReferencees(state);
       OwnershipAnalysis oa = new OwnershipAnalysis(state,
                                                    tu,
                                                    callGraph,
+                                                  liveness,
+                                                   ar,
                                                   state.OWNERSHIPALLOCDEPTH,
                                                    state.OWNERSHIPWRITEDOTS,
                                                    state.OWNERSHIPWRITEALL,
@@ -359,6 +424,13 @@ public class Main {
                              oa);
     }    
 
+    if (state.DISJOINT) {
+      CallGraph        cg = new CallGraph(state);
+      Liveness         l  = new Liveness();
+      ArrayReferencees ar = new ArrayReferencees(state);
+      DisjointAnalysis oa = new DisjointAnalysis(state, tu, cg, l, ar);
+    }
+
     if (state.TAGSTATE) {
       CallGraph callgraph=new CallGraph(state);
       TagAnalysis taganalysis=new TagAnalysis(state, callgraph);
@@ -392,9 +464,13 @@ public class Main {
       if (state.SCHEDULING) {
        // Use ownership analysis to get alias information
        CallGraph callGraph = new CallGraph(state);
+       Liveness liveness = new Liveness();
+        ArrayReferencees ar = new ArrayReferencees(state);
        OwnershipAnalysis oa = new OwnershipAnalysis(state,
                                                     tu,
                                                     callGraph,
+                                                    liveness,
+                                                     ar,
                                                     state.OWNERSHIPALLOCDEPTH,
                                                     state.OWNERSHIPWRITEDOTS,
                                                     state.OWNERSHIPWRITEALL,
@@ -426,6 +502,7 @@ public class Main {
                                                              sa,
                                                              scheduling,
                                                              mcImplSynthesis.getCoreNum(),
+                                                  state.CORENUM4GC,
                                                              pa);
                bcm.setOwnershipAnalysis(oa);
                bcm.buildCode();
@@ -458,8 +535,18 @@ public class Main {
   }
 
   public static void loadClass(State state, BuildIR bir, String sourcefile) {
-    ParseNode pn=readSourceFile(state, sourcefile);
-    bir.buildtree(pn, null);
+    try {
+      ParseNode pn=readSourceFile(state, sourcefile);
+      bir.buildtree(pn, null);
+    } catch (Exception e) {
+      System.out.println("Error in sourcefile:"+sourcefile);
+      e.printStackTrace();
+      System.exit(-1);
+    } catch (Error e) {
+      System.out.println("Error in sourcefile:"+sourcefile);
+      e.printStackTrace();
+      System.exit(-1);
+    }
   }
 
   /** Reads in a source file and adds the parse tree to the state object. */