fix bug that a hrn ID integer and a boolean out-of-context --identify-- an out-of...
authorjjenista <jjenista>
Mon, 22 Mar 2010 23:02:03 +0000 (23:02 +0000)
committerjjenista <jjenista>
Mon, 22 Mar 2010 23:02:03 +0000 (23:02 +0000)
Robust/src/Analysis/Disjoint/DisjointAnalysis.java
Robust/src/Analysis/Disjoint/HeapRegionNode.java
Robust/src/Analysis/Disjoint/HrnIdOoc.java [new file with mode: 0644]
Robust/src/Analysis/Disjoint/ReachGraph.java
Robust/src/Benchmarks/disjoint/makefile

index 2c3b4d7342d9e7416b645b988323e16abf2c9caf..5b8cb1fd50c4673b99e90431d4b7f22d96613e59 100644 (file)
@@ -1808,7 +1808,7 @@ getFlaggedAllocationSitesReachableFromTaskPRIVATE(TaskDescriptor td) {
   
   // get successive captures of the analysis state
   boolean takeDebugSnapshots = false;
-  String descSymbolDebug = "addSomething";
+  String descSymbolDebug = "MDRunner";
   boolean stopAfterCapture = true;
 
   // increments every visit to debugSnapshot, don't fiddle with it
@@ -1819,13 +1819,13 @@ getFlaggedAllocationSitesReachableFromTaskPRIVATE(TaskDescriptor td) {
   int numStartCountReport = 0;
 
   // the frequency of debugCounter values to print out, 0 no report
-  int freqCountReport = 0;
+  int freqCountReport = 50;
 
   // the debugCounter value at which to start taking snapshots
-  int iterStartCapture = 25;
+  int iterStartCapture = 350;
 
   // the number of snapshots to take
-  int numIterToCapture = 300;
+  int numIterToCapture = 400;
 
 
   void debugSnapshot( ReachGraph rg, FlatNode fn, boolean in ) {
@@ -1839,7 +1839,8 @@ getFlaggedAllocationSitesReachableFromTaskPRIVATE(TaskDescriptor td) {
 
     if( debugCounter    > numStartCountReport &&
        freqCountReport > 0                   &&
-        debugCounter % freqCountReport == 0 
+        debugCounter % freqCountReport == 0   &&
+        in
         ) {
       System.out.println( "    @@@ debug counter = "+
                           debugCounter );
@@ -1847,15 +1848,15 @@ getFlaggedAllocationSitesReachableFromTaskPRIVATE(TaskDescriptor td) {
 
     if( debugCounter > iterStartCapture ) {
       System.out.println( "    @@@ capturing debug "+
-                          (debugCounter - iterStartCapture)+
+                          (debugCounter /*- iterStartCapture*/)+
                           " @@@" );
       String graphName;
       if( in ) {
         graphName = String.format( "snap%04din",
-                                   debugCounter - iterStartCapture );
+                                   debugCounter ); //- iterStartCapture );
       } else {
         graphName = String.format( "snap%04dout",
-                                   debugCounter - iterStartCapture );
+                                   debugCounter ); //- iterStartCapture );
       }
       if( fn != null ) {
        graphName = graphName + fn;
index 7ca1fdd2994331d24dffa73e18af073251f2db1a..392eefb2118682ca6ac3fdfacfd8801f4300f715 100644 (file)
@@ -250,6 +250,30 @@ public class HeapRegionNode extends RefSrcNode {
   }
 
 
+  // use this method to assert that an out-of-context
+  // heap region node has only out-of-context symbols
+  // in its reachability
+  public boolean reachHasOnlyOOC() {
+    assert isOutOfContext;
+
+    Iterator<ReachState> stateItr = alpha.iterator();
+    while( stateItr.hasNext() ) {
+      ReachState state = stateItr.next();
+
+      Iterator<ReachTuple> rtItr = state.iterator();
+      while( rtItr.hasNext() ) {
+        ReachTuple rt = rtItr.next();
+
+        if( !rt.isOutOfContext() ) {
+          return false;
+        }
+      }
+    }
+
+    return true;
+  }
+  
+
   public String getIDString() {
     String s;
 
diff --git a/Robust/src/Analysis/Disjoint/HrnIdOoc.java b/Robust/src/Analysis/Disjoint/HrnIdOoc.java
new file mode 100644 (file)
index 0000000..9239820
--- /dev/null
@@ -0,0 +1,61 @@
+package Analysis.Disjoint;
+
+import IR.*;
+import IR.Flat.*;
+import java.util.*;
+import java.io.*;
+
+// a heap region node has an integer ID, but heap regions can
+// also have reach tuples with the same ID but out-of-context
+// so 17 and 17? mean something different in reachability states
+public class HrnIdOoc {
+  protected Integer id;
+  protected Boolean ooc;
+
+  public HrnIdOoc( Integer id, Boolean ooc ) {
+    this.id  = id;
+    this.ooc = ooc;
+  }
+
+  public Integer getId() {
+    return id;
+  }
+
+  public Boolean getOoc() {
+    return ooc;
+  }
+
+  public boolean equals( Object o ) {
+    if( o == null ) {
+      return false;
+    }
+
+    if( !(o instanceof HrnIdOoc) ) {
+      return false;
+    }
+
+    HrnIdOoc hio = (HrnIdOoc) o;
+
+    return 
+      id.equals( hio.id )  &&
+      ooc.equals( hio.ooc );
+  }
+
+  public int hashCode() {
+    int hash = id.intValue();
+    if( ooc.booleanValue() ) {
+      hash = ~hash;
+    }
+    return hash;
+  }
+
+  public String toString() {
+    String s = id.toString();
+
+    if( ooc ) {
+      s += "?";
+    }
+
+    return s;
+  }
+}
index acb7e8fd32e8c9688e1a6796de6a703834c49d84..eaa55704f52581455db0a469a8d4e3590bcbda45 100644 (file)
@@ -1291,9 +1291,9 @@ public class ReachGraph {
 
   // used below to convert a ReachSet to its callee-context
   // equivalent with respect to allocation sites in this graph
-  protected ReachSet toCalleeContext( ReachSet        rs,
-                                      ExistPredSet    preds,
-                                      Set<ReachTuple> oocTuples
+  protected ReachSet toCalleeContext( ReachSet      rs,
+                                      ExistPredSet  preds,
+                                      Set<HrnIdOoc> oocHrnIdOoc2callee
                                       ) {
     ReachSet out = ReachSet.factory();
    
@@ -1314,7 +1314,10 @@ public class ReachGraph {
 
           // only translate this tuple if it is
           // in the out-callee-context bag
-          if( !oocTuples.contains( rt ) ) {
+          HrnIdOoc hio = new HrnIdOoc( rt.getHrnID(),
+                                       rt.isOutOfContext()
+                                       );
+          if( !oocHrnIdOoc2callee.contains( hio ) ) {
             stateNew = Canonical.add( stateNew, rt );
             continue;
           }
@@ -1518,9 +1521,10 @@ public class ReachGraph {
     } // end iterating over parameters as starting points
 
 
-    // now collect out-of-context reach tuples and 
-    // more out-of-context edges
-    Set<ReachTuple> oocTuples = new HashSet<ReachTuple>();
+    // now collect out-of-callee-context IDs and 
+    // map them to whether the ID is out of the caller
+    // context as well
+    Set<HrnIdOoc> oocHrnIdOoc2callee = new HashSet<HrnIdOoc>();
 
     Iterator<Integer> itrInContext = 
       callerNodeIDsCopiedToCallee.iterator();
@@ -1567,13 +1571,15 @@ public class ReachGraph {
           while( rtItr.hasNext() ) {
             ReachTuple rt = rtItr.next();
 
-            oocTuples.add( rt );
+            oocHrnIdOoc2callee.add( new HrnIdOoc( rt.getHrnID(),
+                                                  rt.isOutOfContext()
+                                                  )
+                                    );
           }
         }
       }
     }
 
-
     // the callee view is a new graph: DON'T MODIFY *THIS* graph
     ReachGraph rg = new ReachGraph();
 
@@ -1597,11 +1603,11 @@ public class ReachGraph {
                                   hrnCaller.getAllocSite(),
                                   toCalleeContext( hrnCaller.getInherent(),
                                                    preds,
-                                                   oocTuples 
+                                                   oocHrnIdOoc2callee 
                                                    ),
                                   toCalleeContext( hrnCaller.getAlpha(),
                                                    preds,
-                                                   oocTuples 
+                                                   oocHrnIdOoc2callee 
                                                    ),
                                   preds,
                                   hrnCaller.getDescription()
@@ -1646,7 +1652,7 @@ public class ReachGraph {
                      reArg.getField(),
                      toCalleeContext( reArg.getBeta(),
                                       preds,
-                                      oocTuples
+                                      oocHrnIdOoc2callee
                                       ),
                      preds
                      );
@@ -1692,7 +1698,7 @@ public class ReachGraph {
                      reCaller.getField(),
                      toCalleeContext( reCaller.getBeta(),
                                       preds,
-                                      oocTuples 
+                                      oocHrnIdOoc2callee 
                                       ),
                      preds
                      );
@@ -1789,11 +1795,11 @@ public class ReachGraph {
                                         null,  // alloc site, shouldn't be used
                                         toCalleeContext( oocReach,               
                                                          preds,
-                                                         oocTuples
+                                                         oocHrnIdOoc2callee
                                                          ),
                                         toCalleeContext( oocReach,
                                                          preds,
-                                                         oocTuples
+                                                         oocHrnIdOoc2callee
                                                          ),
                                         preds,
                                         "out-of-context"
@@ -1818,27 +1824,30 @@ public class ReachGraph {
                                           null,  // alloc site, shouldn't be used
                                           toCalleeContext( oocReach,
                                                            preds,
-                                                           oocTuples
+                                                           oocHrnIdOoc2callee
                                                            ),
                                           toCalleeContext( oocReach,
                                                            preds,
-                                                           oocTuples
+                                                           oocHrnIdOoc2callee
                                                            ),
                                           preds,
                                           "out-of-context"
                                           );       
+
           } else {
             // otherwise it is there, so merge reachability
             hrnCalleeAndOutContext.setAlpha( Canonical.unionORpreds( hrnCalleeAndOutContext.getAlpha(),
                                                                      toCalleeContext( oocReach,
                                                                                       preds,
-                                                                                      oocTuples
+                                                                                      oocHrnIdOoc2callee
                                                                                       )
                                                                      )
                                              );
           }
         }
 
+        assert hrnCalleeAndOutContext.reachHasOnlyOOC();
+
         rg.addRefEdge( hrnCalleeAndOutContext,
                        hrnDstCallee,
                        new RefEdge( hrnCalleeAndOutContext,
@@ -1847,7 +1856,7 @@ public class ReachGraph {
                                     reCaller.getField(),
                                     toCalleeContext( reCaller.getBeta(),
                                                      preds,
-                                                     oocTuples
+                                                     oocHrnIdOoc2callee
                                                      ),
                                     preds
                                     )
@@ -1858,7 +1867,7 @@ public class ReachGraph {
         oocEdgeExisting.setBeta( Canonical.unionORpreds( oocEdgeExisting.getBeta(),
                                                          toCalleeContext( reCaller.getBeta(),
                                                                           preds,
-                                                                          oocTuples
+                                                                          oocHrnIdOoc2callee
                                                                           )
                                                   )
                                  );         
@@ -1873,12 +1882,12 @@ public class ReachGraph {
         hrnCalleeAndOutContext.setAlpha( Canonical.unionORpreds( hrnCalleeAndOutContext.getAlpha(),
                                                                  toCalleeContext( oocReach,
                                                                                   preds,
-                                                                                  oocTuples
+                                                                                  oocHrnIdOoc2callee
                                                                                   )
                                                                  )
                                          );
         
-        
+        assert hrnCalleeAndOutContext.reachHasOnlyOOC();
       }                
     }
 
@@ -2885,10 +2894,13 @@ public class ReachGraph {
        assert rsetEmpty.equals( edge.getBetaNew() );
       }      
 
-      // calculate boldB for this flagged node, or out-of-context node
+      // make a mapping of IDs to heap regions they propagate from
       if( hrn.isFlagged() ) {
         assert !hrn.isOutOfContext();
         assert !icID2srcs.containsKey( hrn.getID() );
+
+        // in-context flagged node IDs simply propagate from the
+        // node they name
         Set<HeapRegionNode> srcs = new HashSet<HeapRegionNode>();
         srcs.add( hrn );
         icID2srcs.put( hrn.getID(), srcs );
@@ -2897,6 +2909,13 @@ public class ReachGraph {
       if( hrn.isOutOfContext() ) {
        assert !hrn.isFlagged();
 
+        // the reachability states on an out-of-context
+        // node are not really important (combinations of
+        // IDs or arity)--what matters is that the states
+        // specify which nodes this out-of-context node
+        // stands in for.  For example, if the state [17?, 19*]
+        // appears on the ooc node, it may serve as a source
+        // for node 17? and a source for node 19.
         Iterator<ReachState> stateItr = hrn.getAlpha().iterator();
         while( stateItr.hasNext() ) {
           ReachState state = stateItr.next();
index c6467d44377e5ebde072cc837aa5ae6281a3a0d4..f1964338a1370dca065aaf2571468b38f9ef5d0e 100644 (file)
@@ -1,9 +1,11 @@
 BUILDSCRIPT=~/research/Robust/src/buildscript
 
+#DEBUGFLAGS= -disjoint-debug-callsite MDRunner t3 100
+
 BSFLAGS= -recover -justanalyze -disjoint -disjoint-k 1 -disjoint-write-dots final -disjoint-alias-file aliases.txt normal -enable-assertions
 
 all:
-       $(BUILDSCRIPT) $(BSFLAGS) *.java
+       $(BUILDSCRIPT) $(BSFLAGS) $(DEBUGFLAGS) *.java
 
 clean:
        rm -f  *.bin