change the debug mode for capturing null dereference to a global compilar option
[IRC.git] / Robust / src / IR / State.java
index 065c72c7f9695c6755e4b281741899d2b01daee7..a5d048b2632df9ed1105c165d342dfd019b2e984 100644 (file)
@@ -2,15 +2,34 @@ package IR;
 import IR.Tree.*;
 import IR.Flat.*;
 import IR.*;
+import Util.Lattice;
+
 import java.util.*;
 import Analysis.TaskStateAnalysis.*;
+import Analysis.CallGraph.CallGraph;
 
 public class State {
+  public static long startTime;
+  public static long lastTime;
+  public static void logEvent(String event) {
+    long currTime=System.nanoTime();
+    double delta=((double)(currTime-startTime))/1000000000;
+    double deltaLast=((double)(currTime-lastTime))/1000000000;
+    System.out.println("TLOG: Time of "+event+"="+delta);
+    System.out.println("TLOG: Elapsed time "+event+"="+deltaLast);
+    lastTime=currTime;
+  }
+
+  public static void initTimer() {
+    startTime=System.nanoTime();
+    lastTime=startTime;
+  }
 
-    public int lines;
+  public int lines;
   public State() {
     this.classes=new SymbolTable();
     this.tasks=new SymbolTable();
+    this.sclasses=new SymbolTable();
     this.treemethodmap=new Hashtable();
     this.flatmethodmap=new Hashtable();
     this.parsetrees=new HashSet();
@@ -20,6 +39,9 @@ public class State {
     this.selfloops=new HashSet();
     this.excprefetch=new HashSet();
     this.classpath=new Vector();
+    this.cd2locationOrderMap=new Hashtable();
+    this.cd2locationPropertyMap=new Hashtable();
+    this.fn2labelMap=new Hashtable();
     this.lines=0;
   }
 
@@ -47,6 +69,10 @@ public class State {
 
   /** Boolean flag which indicates whether compiler is compiling a task-based
    * program. */
+  public boolean JNI=false;
+  public boolean CAPTURE_NULL_DEREFERENCES=false;
+  public boolean POINTER=false;
+  public boolean COREPROF=false;
   public boolean WEBINTERFACE=false;
   public boolean MINIMIZE=false;
   public boolean TASK=false;
@@ -58,6 +84,7 @@ public class State {
   public boolean FLATIRGRAPHTASKS=false;
   public boolean FLATIRGRAPHUSERMETHODS=false;
   public boolean FLATIRGRAPHLIBMETHODS=false;
+  public boolean KEEP_RG_FOR_ALL_PROGRAM_POINTS=false;
   public boolean OWNERSHIP=false;
   public int OWNERSHIPALLOCDEPTH=3;
   public boolean OWNERSHIPWRITEDOTS=false;
@@ -67,38 +94,62 @@ public class State {
   public int OWNERSHIPDEBUGCALLCOUNT=0;
   public String OWNERSHIPDEBUGCALLEE=null;
   public String OWNERSHIPDEBUGCALLER=null;
-  
+
+
   public boolean DISJOINT=false;
+
+  public int DISJOINTALLOCDEPTH=1;
   public boolean DISJOINTRELEASEMODE=false;
-  public int DISJOINTALLOCDEPTH=3;
+  public boolean DISJOINTDETERMINISM=false;
+
+  public boolean DISJOINTDVISITSTACK=true;
+  public boolean DISJOINTDVISITPQUE=false;
+  public boolean DISJOINTDVISITSTACKEESONTOP=false;
+
   public boolean DISJOINTWRITEDOTS=false;
   public boolean DISJOINTWRITEALL=false;
   public boolean DISJOINTWRITEIHMS=false;
+  public boolean DISJOINTWRITEINITCONTEXTS=false;
+
   public String DISJOINTALIASFILE=null;
   public boolean DISJOINTALIASTAB=false;
-  public int DISJOINTDEBUGCALLCOUNT=0;
+
   public String DISJOINTDEBUGCALLEE=null;
   public String DISJOINTDEBUGCALLER=null;
+  public int DISJOINTDEBUGCALLVISITTOSTART=0;
+  public int DISJOINTDEBUGCALLNUMVISITS=0;
+  public boolean DISJOINTDEBUGCALLSTOPAFTER=false;
+
   public String DISJOINTSNAPSYMBOL=null;
   public int DISJOINTSNAPVISITTOSTART=0;
   public int DISJOINTSNAPNUMVISITS=0;
   public boolean DISJOINTSNAPSTOPAFTER=false;
-  public boolean DISJOINTDVISITSTACK=true;
-  public boolean DISJOINTDVISITPQUE=false;
+
+  public boolean DISJOINTDEBUGSCHEDULING=false;
+
+  public boolean OOOJAVA=false;
+  public boolean OOODEBUG=false;
+  public boolean RCR=false;
+  public boolean RCR_DEBUG=false;
+  public boolean RCR_DEBUG_VERBOSE=false;
+  public boolean NOSTALLTR=false;
+
+  //SSJava
+  public boolean SSJAVA=false;
+
 
   public boolean OPTIONAL=false;
+  public boolean NOLOOP=false;
   public boolean ARRAYPAD=false;
   public boolean THREAD=false;
   public boolean CONSCHECK=false;
   public boolean INSTRUCTIONFAILURE=false;
-  public boolean MLP=false;
-  public boolean MLPDEBUG=false;
-  public int MLP_NUMCORES=0;
-  public int MLP_MAXSESEAGE=0;
+  public int OOO_NUMCORES=0;
+  public int OOO_MAXSESEAGE=0;
   public boolean METHODEFFECTS=false;
   public static double TRUEPROB=0.8;
   public static boolean PRINTFLAT=false;
-  
+
   //DSM options
   public boolean DSM=false;
   public boolean DSMTASK=false;
@@ -116,7 +167,7 @@ public class State {
   public boolean DELAYCOMP=false;
   public boolean DUALVIEW=false;
   public boolean HYBRID=false;
-  
+
   // Bamboo options
   public boolean MULTICORE=false;
   public boolean MULTICOREGC=false;
@@ -132,6 +183,10 @@ public class State {
   public int CORENUM4GC = 0;
   public String profilename = null;
   public String outputdir = "/scratch/";
+  // MGC options
+  public boolean MGC=false;
+  public boolean OBJECTLOCKDEBUG=false;
+
   //Other options
   public String structfile;
   public String main;
@@ -142,15 +197,23 @@ public class State {
   public Vector classpath;
   public SymbolTable classes;
   public SymbolTable tasks;
+  public SymbolTable sclasses; // table of classes with static field/blocks
   public Set parsetrees;
   public Hashtable treemethodmap;
   public Hashtable flatmethodmap;
+  SymbolTable methods2gen;
   private HashSet arraytypes;
   public Hashtable arraytonumber;
   private int numclasses=1; // start from 1 instead of 0 for multicore gc
+  private int numinterfaces = 0;
   private int numtasks=0;
+  private int numstaticblocks=0;
   private int arraycount=0;
+  public Hashtable cd2locationOrderMap;
+  public Hashtable cd2locationPropertyMap;
+  public Hashtable fn2labelMap;
   public boolean OPTIMIZE=false;
+  public boolean LINENUM=false;
 
   private Hashtable<ClassDescriptor, Hashtable<OptionalTaskDescriptor, OptionalTaskDescriptor>> optionaltaskdescriptors;
   private Hashtable<ClassDescriptor, Hashtable<FlagState, Set<OptionalTaskDescriptor>>> analysisresults;
@@ -198,17 +261,37 @@ public class State {
     return td;
   }
 
+  public static TypeDescriptor getTypeDescriptor(String n) {
+    TypeDescriptor td=new TypeDescriptor(n);
+    return td;
+  }
+
   public void addClass(ClassDescriptor tdn) {
     if (classes.contains(tdn.getSymbol()))
       throw new Error("Class "+tdn.getSymbol()+" defined twice");
     classes.add(tdn);
-    numclasses++;
+    if(tdn.isInterface()) {
+      numinterfaces++;
+    } else {
+      numclasses++;
+    }
+    if((tdn.numstaticfields != 0) || (tdn.numstaticblocks != 0)) {
+      sclasses.add(tdn);
+    }
   }
 
   public int numClasses() {
     return numclasses;
   }
 
+  public int numInterfaces() {
+    return numinterfaces;
+  }
+
+  public int numStaticBlocks() {
+    return numstaticblocks;
+  }
+
   public BlockNode getMethodBody(MethodDescriptor md) {
     return (BlockNode)treemethodmap.get(md);
   }
@@ -225,6 +308,10 @@ public class State {
     return tasks;
   }
 
+  public SymbolTable getSClassSymbolTable() {
+    return sclasses;
+  }
+
   /** Returns Flat IR representation of MethodDescriptor md. */
 
   public FlatMethod getMethodFlat(MethodDescriptor md) {
@@ -272,4 +359,21 @@ public class State {
     tasks.add(td);
     numtasks++;
   }
+
+  public void addLocationOrder(ClassDescriptor cd, Lattice order) {
+    cd2locationOrderMap.put(cd,order);
+  }
+
+  public Hashtable getCd2LocationOrder() {
+    return cd2locationOrderMap;
+  }
+
+  public void addLocationPropertySet(ClassDescriptor cd, Set<String> set) {
+    cd2locationPropertyMap.put(cd,set);
+  }
+
+  public Hashtable getCd2LocationPropertyMap() {
+    return cd2locationPropertyMap;
+  }
+
 }