big fix for tracking latest ownership graph associated with a flat node during a...
authorjjenista <jjenista>
Tue, 9 Sep 2008 22:07:24 +0000 (22:07 +0000)
committerjjenista <jjenista>
Tue, 9 Sep 2008 22:07:24 +0000 (22:07 +0000)
Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java

index be78a4993d0ec1a5951efec6cd0d5245b9198a12..dbec6e31839bde5c2e4f2b6b57ef835ed7b9691e 100644 (file)
@@ -404,9 +404,11 @@ public class OwnershipAnalysis {
 
       // start by merging all node's parents' graphs
       for( int i = 0; i < fn.numPrev(); ++i ) {
-       FlatNode pn       = fn.getPrev(i);
-       OwnershipGraph ogParent = getGraphFromFlatNode(pn);
-       og.merge(ogParent);
+       FlatNode pn = fn.getPrev(i);    
+       if( mapFlatNodeToOwnershipGraph.containsKey(pn) ) {
+         OwnershipGraph ogParent = mapFlatNodeToOwnershipGraph.get(pn);
+         og.merge(ogParent);
+       }
       }
 
       // apply the analysis of the flat node to the
@@ -421,10 +423,9 @@ public class OwnershipAnalysis {
       // the current graph at this node, replace the graph
       // with the update and enqueue the children for
       // processing
-      OwnershipGraph ogPrev = getGraphFromFlatNode(fn);
-
+      OwnershipGraph ogPrev = mapFlatNodeToOwnershipGraph.get(fn);
       if( !og.equals(ogPrev) ) {
-       setGraphForFlatNode(fn, og);
+       mapFlatNodeToOwnershipGraph.put(fn, og);
 
        for( int i = 0; i < fn.numNext(); i++ ) {
          FlatNode nn = fn.getNext(i);
@@ -440,7 +441,8 @@ public class OwnershipAnalysis {
     Iterator retItr = returnNodesToCombineForCompleteOwnershipGraph.iterator();
     while( retItr.hasNext() ) {
       FlatReturnNode frn = (FlatReturnNode) retItr.next();
-      OwnershipGraph ogr = getGraphFromFlatNode(frn);
+      assert mapFlatNodeToOwnershipGraph.containsKey(frn);
+      OwnershipGraph ogr = mapFlatNodeToOwnershipGraph.get(frn);
       completeGraph.merge(ogr);
     }
     return completeGraph;
@@ -457,8 +459,6 @@ public class OwnershipAnalysis {
     TempDescriptor rhs;
     FieldDescriptor fld;
 
-    //System.out.println("  "+fn.kind());
-
     // use node type to decide what alterations to make
     // to the ownership graph
     switch( fn.kind() ) {
@@ -597,25 +597,37 @@ public class OwnershipAnalysis {
       break;
     }
 
+    return og;
+  }
+
 
-    /*
-    ++x;
-    if( x > 10000 ) {
-      og.writeGraph( String.format("test%04d",x-10000)+fn, true, true, true, false );
+  // insert a call to debugSnapshot() somewhere in the analysis to get
+  // successive captures of the analysis state
+  int debugCounter = 0;
+  int numIterationsIn = 30;
+  int numIterationsToCapture = 20;
+  void debugSnapshot( OwnershipGraph og, FlatNode fn ) {
+    ++debugCounter;
+    if( debugCounter > numIterationsIn ) {
+      System.out.println( "   @@@ capturing debug "+(debugCounter-numIterationsIn)+" @@@" );
+      String graphName = String.format("test%04d",debugCounter-numIterationsIn);
+      if( fn != null ) {
+       graphName = graphName+fn;
+      }
+      try {
+       og.writeGraph( graphName, true, true, true, false, false );
+      } catch( Exception e ) {
+       System.out.println( "Error writing debug capture." );
+       System.exit( 0 );       
+      }
     }
-    if( x == 10050 ) {
+    if( debugCounter == numIterationsIn + numIterationsToCapture ) {
+      System.out.println( "Stopping analysis after debug captures." );
       System.exit( 0 );
     }
-    */
-
-
-    return og;
   }
 
 
-  //int x = 0;
-
-
 
   // this method should generate integers strictly greater than zero!
   // special "shadow" regions are made from a heap region by negating
@@ -655,19 +667,6 @@ public class OwnershipAnalysis {
   }
 
 
-  private OwnershipGraph getGraphFromFlatNode(FlatNode fn) {
-    if( !mapFlatNodeToOwnershipGraph.containsKey(fn) ) {
-      mapFlatNodeToOwnershipGraph.put(fn, new OwnershipGraph(allocationDepth, typeUtil) );
-    }
-
-    return mapFlatNodeToOwnershipGraph.get(fn);
-  }
-
-  private void setGraphForFlatNode(FlatNode fn, OwnershipGraph og) {
-    mapFlatNodeToOwnershipGraph.put(fn, og);
-  }
-
-
   // return just the allocation site associated with one FlatNew node
   private AllocationSite getAllocationSiteFromFlatNewPRIVATE(FlatNew fn) {