compiler options for call map debugging
authorjjenista <jjenista>
Fri, 16 Oct 2009 17:57:13 +0000 (17:57 +0000)
committerjjenista <jjenista>
Fri, 16 Oct 2009 17:57:13 +0000 (17:57 +0000)
Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java
Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java
Robust/src/Analysis/OwnershipAnalysis/ParameterDecomposition.java
Robust/src/IR/State.java
Robust/src/Main/Main.java

index c28f264cd1c73972f9416abb497ea177b05bcdd1..87d53ba8d82e13b74ef9b12d0dfa8cebc20d1dab 100644 (file)
@@ -76,7 +76,7 @@ public class OwnershipAnalysis {
 
     assert d != null;
 
-    OwnershipGraph og = new OwnershipGraph( allocationDepth, typeUtil );
+    OwnershipGraph og = new OwnershipGraph();
 
     assert mapDescriptorToAllMethodContexts.containsKey( d );
     HashSet<MethodContext> contexts = mapDescriptorToAllMethodContexts.get( d );
@@ -454,6 +454,17 @@ public class OwnershipAnalysis {
            this.writeDOTs       = writeDOTs;
            this.writeAllDOTs    = writeAllDOTs;
 
+           // set some static configuration for OwnershipGraphs
+           OwnershipGraph.allocationDepth   = allocationDepth;
+           OwnershipGraph.typeUtil          = typeUtil;
+           OwnershipGraph.debugCallMapCount = state.OWNERSHIPDEBUGCALLCOUNT;
+           OwnershipGraph.debugCallee       = state.OWNERSHIPDEBUGCALLEE;
+           OwnershipGraph.debugCaller       = state.OWNERSHIPDEBUGCALLER;
+           if( OwnershipGraph.debugCallee != null &&
+               OwnershipGraph.debugCaller != null ) {
+             OwnershipGraph.debugCallMap = true;
+           }
+
            descriptorsToAnalyze = new HashSet<Descriptor>();
 
            mapMethodContextToInitialParamAllocGraph =
@@ -517,7 +528,7 @@ public class OwnershipAnalysis {
            Iterator<Descriptor> dItr = descriptorsToAnalyze.iterator();
            while( dItr.hasNext() ) {
              Descriptor d  = dItr.next();
-             OwnershipGraph og = new OwnershipGraph(allocationDepth, typeUtil);
+             OwnershipGraph og = new OwnershipGraph();
 
              FlatMethod fm;
              if( d instanceof MethodDescriptor ) {
@@ -709,7 +720,7 @@ public class OwnershipAnalysis {
       // perform this node's contributions to the ownership
       // graph on a new copy, then compare it to the old graph
       // at this node to see if anything was updated.
-      OwnershipGraph og = new OwnershipGraph(allocationDepth, typeUtil);
+      OwnershipGraph og = new OwnershipGraph();
 
       // start by merging all node's parents' graphs
       for( int i = 0; i < fn.numPrev(); ++i ) {
@@ -756,7 +767,7 @@ public class OwnershipAnalysis {
     // end by merging all return nodes into a complete
     // ownership graph that represents all possible heap
     // states after the flat method returns
-    OwnershipGraph completeGraph = new OwnershipGraph(allocationDepth, typeUtil);
+    OwnershipGraph completeGraph = new OwnershipGraph();
     Iterator retItr = returnNodesToCombineForCompleteOwnershipGraph.iterator();
     while( retItr.hasNext() ) {
       FlatReturnNode frn = (FlatReturnNode) retItr.next();
@@ -844,7 +855,7 @@ public class OwnershipAnalysis {
        og.prepareParamTokenMaps( fm );
 
        // cache the graph
-       OwnershipGraph ogResult = new OwnershipGraph(allocationDepth, typeUtil);
+       OwnershipGraph ogResult = new OwnershipGraph();
        ogResult.merge(og);
        mapMethodContextToInitialParamAllocGraph.put(mc, ogResult);
 
@@ -960,7 +971,7 @@ public class OwnershipAnalysis {
       FlatCall fc = (FlatCall) fn;
       MethodDescriptor md = fc.getMethod();
       FlatMethod flatm = state.getMethodFlat(md);
-      OwnershipGraph ogMergeOfAllPossibleCalleeResults = new OwnershipGraph(allocationDepth, typeUtil);
+      OwnershipGraph ogMergeOfAllPossibleCalleeResults = new OwnershipGraph();
 
       if( md.isStatic() ) {
        // a static method is simply always the same, makes life easy
@@ -1009,7 +1020,7 @@ public class OwnershipAnalysis {
 
          // don't alter the working graph (og) until we compute a result for every
          // possible callee, merge them all together, then set og to that
-         OwnershipGraph ogCopy = new OwnershipGraph(allocationDepth, typeUtil);
+         OwnershipGraph ogCopy = new OwnershipGraph();
          ogCopy.merge(og);
 
          Set<Integer> aliasedParamIndices = 
@@ -1494,7 +1505,7 @@ public class OwnershipAnalysis {
          Hashtable<FlatNode, OwnershipGraph> table=mapMethodContextToFlatNodeOwnershipGraph.get(callerMC);
          
          // merge previous ownership graph to calculate corresponding method context
-         OwnershipGraph mergeOG = new OwnershipGraph( allocationDepth, typeUtil );
+         OwnershipGraph mergeOG = new OwnershipGraph();
          
          for(int i=0;i<fc.numPrev();i++){
                  FlatNode prevNode=fc.getPrev(i);
index 5a5717abda80a765d0fd3f3a902807ab840a819c..cf17e071a1b12f8439893cb5ddf57d17bda3b6ed 100644 (file)
@@ -11,9 +11,12 @@ public class OwnershipGraph {
   protected static final boolean DISABLE_STRONG_UPDATES = false;
   protected static final boolean DISABLE_GLOBAL_SWEEP   = false;
 
-
-  private int allocationDepth;
-  private TypeUtil typeUtil;
+  protected static int      allocationDepth   = -1;
+  protected static TypeUtil typeUtil          = null;
+  protected static boolean  debugCallMap      = false;
+  protected static int      debugCallMapCount = 0;
+  protected static String   debugCallee       = null;
+  protected static String   debugCaller       = null;
 
   // there was already one other very similar reason
   // for traversing heap nodes that is no longer needed
@@ -72,9 +75,7 @@ public class OwnershipGraph {
   public Hashtable<Integer, TokenTuple> paramIndex2paramTokenSecondaryStar;
 
 
-  public OwnershipGraph(int allocationDepth, TypeUtil typeUtil) {
-    this.allocationDepth = allocationDepth;
-    this.typeUtil        = typeUtil;
+  public OwnershipGraph() {
 
     id2hrn                    = new Hashtable<Integer,        HeapRegionNode>();
     td2ln                     = new Hashtable<TempDescriptor, LabelNode     >();
@@ -1891,19 +1892,10 @@ public class OwnershipGraph {
                                ParameterDecomposition pd // if this is not null, we're calling after analysis
                                ) {
 
-
-    // this debug snippet is harmless for regular use and INVALUABLE at debug time
-    // to see what potentially goes wrong when a specific method calls another
-    String debugCaller = "foo";
-    String debugCallee = "bar";
-    //String debugCaller = "StandardEngine";
-    //String debugCaller = "register_by_type";
-    //String debugCaller = "register_by_type_front";
-    //String debugCaller = "addFirst";
-    //String debugCallee = "LinkedListElement";
-
-    if( mc.getDescriptor().getSymbol().equals( debugCaller ) &&
-       fm.getMethod().getSymbol().equals( debugCallee ) ) {
+    if( debugCallMap &&
+       mc.getDescriptor().getSymbol().equals( debugCaller ) &&
+       fm.getMethod().getSymbol().equals( debugCallee ) 
+       ) {
 
       try {
        writeGraph("debug1BeforeCall",
@@ -2965,8 +2957,11 @@ public class OwnershipGraph {
     }
 
 
-    if( mc.getDescriptor().getSymbol().equals( debugCaller ) &&
-       fm.getMethod().getSymbol().equals( debugCallee ) ) {
+    if( debugCallMap &&
+       mc.getDescriptor().getSymbol().equals( debugCaller ) &&
+       fm.getMethod().getSymbol().equals( debugCallee ) 
+       ) {
+
       try {
        writeGraph("debug7JustBeforeMergeToKCapacity",
                   true,  // write labels (variables)
@@ -3048,8 +3043,11 @@ public class OwnershipGraph {
     }
 
 
-    if( mc.getDescriptor().getSymbol().equals( debugCaller ) &&
-       fm.getMethod().getSymbol().equals( debugCallee ) ) {
+    if( debugCallMap &&
+       mc.getDescriptor().getSymbol().equals( debugCaller ) &&
+       fm.getMethod().getSymbol().equals( debugCallee ) 
+       ) {
+
       try {
        writeGraph( "debug8JustBeforeSweep",
                    true,  // write labels (variables)
@@ -3069,8 +3067,11 @@ public class OwnershipGraph {
     }
 
 
-    if( mc.getDescriptor().getSymbol().equals( debugCaller ) &&
-       fm.getMethod().getSymbol().equals( debugCallee ) ) {
+    if( debugCallMap &&
+       mc.getDescriptor().getSymbol().equals( debugCaller ) &&
+       fm.getMethod().getSymbol().equals( debugCallee ) 
+       ) {
+      
       try {
        writeGraph( "debug9endResolveCall",
                    true,  // write labels (variables)
@@ -3083,7 +3084,7 @@ public class OwnershipGraph {
       } catch( IOException e ) {}
       System.out.println( "  "+mc+" done calling "+fm );      
       ++x;
-      if( x > 2 ) {
+      if( x == debugCallMapCount ) {
        System.exit( -1 );   
       }
     }
index 2015f367eda79028b8cdf258a79a101361d1c54a..5707abab4a33a2ce9019ed68af3ec75565cd24ba 100644 (file)
@@ -58,10 +58,10 @@ public class ParameterDecomposition {
 
     // make copies of the graphs so that resolveMethodCall can
     // destroy the graph while calculating the stuff we want
-    this.ogCallee = new OwnershipGraph( oa.allocationDepth, oa.typeUtil );
+    this.ogCallee = new OwnershipGraph();
     this.ogCallee.merge( cee );
 
-    this.ogCaller = new OwnershipGraph( oa.allocationDepth, oa.typeUtil );
+    this.ogCaller = new OwnershipGraph();
     this.ogCaller.merge( cer );
 
     allocOutputStructs();
index 6eadf3edc4b6d227c887a4e6669967ee954260c0..2e4c037c926c64f4b2eb457cdea3eae69d11697b 100644 (file)
@@ -66,6 +66,9 @@ public class State {
   public boolean OWNERSHIPWRITEALL=false;
   public String OWNERSHIPALIASFILE=null;
   public boolean OWNERSHIPALIASTAB=false;
+  public int OWNERSHIPDEBUGCALLCOUNT=0;
+  public String OWNERSHIPDEBUGCALLEE=null;
+  public String OWNERSHIPDEBUGCALLER=null;
   public boolean OPTIONAL=false;
   public boolean ARRAYBOUNDARYCHECK=true;
   public boolean RAW=false;
index c5f146563337a1d4b07b91386c3ff43a5c577751..4ee1bcd2cdf12b582efed37753488808d016a80b 100644 (file)
@@ -145,7 +145,13 @@ public class Main {
        state.OWNERSHIPALIASFILE=args[++i];
       } else if (option.equals("-ownaliasfiletab")) {
        state.OWNERSHIPALIASFILE=args[++i];
-        state.OWNERSHIPALIASTAB=true;
+        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("-optional"))
        state.OPTIONAL=true;