fix silly off-by-one bug
authorjjenista <jjenista>
Tue, 8 Nov 2011 22:14:12 +0000 (22:14 +0000)
committerjjenista <jjenista>
Tue, 8 Nov 2011 22:14:12 +0000 (22:14 +0000)
Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java
Robust/src/Analysis/Disjoint/DefiniteReachState.java
Robust/src/Analysis/Disjoint/DisjointAnalysis.java
Robust/src/Analysis/Disjoint/ReachGraph.java
Robust/src/Tests/disjoint/definite/test.java

index 2c57170ebcff782196ac5745ccf761a5db5c3f8a..00aa4d939bbbab2a2d3fcdccbbe3dc62b5cbc3c2 100644 (file)
@@ -41,9 +41,9 @@ public class DefiniteReachAnalysis {
                     TempDescriptor  y,
                     FieldDescriptor f,
                     Set<EdgeKey> edgeKeysForLoad ) {
+
     DefiniteReachState state = makeIn( fn );
     state.load( x, y, f, edgeKeysForLoad );
-    state.writeState( "YO" );
     fn2state.put( fn, state ); 
   }
 
@@ -53,6 +53,7 @@ public class DefiniteReachAnalysis {
                      TempDescriptor  y,
                      Set<EdgeKey> edgeKeysRemoved,
                      Set<EdgeKey> edgeKeysAdded ) {
+
     DefiniteReachState state = makeIn( fn );
     state.store( x, f, y, edgeKeysRemoved, edgeKeysAdded );
     fn2state.put( fn, state ); 
@@ -86,7 +87,7 @@ public class DefiniteReachAnalysis {
 
   // get the current state for just after the given
   // program point
-  private DefiniteReachState get( FlatNode fn ) {
+  public DefiniteReachState get( FlatNode fn ) {
     DefiniteReachState state = fn2state.get( fn );
     if( state == null ) {
       state = new DefiniteReachState();
@@ -98,8 +99,8 @@ public class DefiniteReachAnalysis {
   // get the current state for the program point just
   // before the given program point by merging the out
   // states of the predecessor statements
-  private DefiniteReachState makeIn( FlatNode fn ) {
-    if( fn.numPrev() <= 1 ) {
+  public DefiniteReachState makeIn( FlatNode fn ) {
+    if( fn.numPrev() == 0 ) {
       return new DefiniteReachState();
     }
 
@@ -109,6 +110,7 @@ public class DefiniteReachAnalysis {
     for( int i = 1; i < fn.numPrev(); ++i ) {
       stateIn.merge( get( fn.getPrev( i ) ) );
     }
+
     return stateIn;
   }
 }
index 67f545ce9973fd4cdb3acf7aefaa48559de5aafe..70711b19e7bb0251562896df46836d35e13eb6bb 100644 (file)
@@ -356,7 +356,6 @@ public class DefiniteReachState {
   }
 
 
-
   public String toString() {
     StringBuilder s = new StringBuilder();
 
index 37ea420590b6ced2845a2afcc3a1876f29aea3e4..c5d03684280c9e3a6aa926e132a6ea1a43114b46 100644 (file)
@@ -1312,13 +1312,11 @@ public class DisjointAnalysis implements HeapAnalysis {
     fn2rgAtEnter.put(fn, rgOnEnter);
 
 
-
     
     boolean didDefReachTransfer = false;    
 
 
 
-
     // use node type to decide what transfer function
     // to apply to the reachability graph
     switch( fn.kind() ) {
@@ -1953,7 +1951,6 @@ public class DisjointAnalysis implements HeapAnalysis {
 
 
 
-
     // dead variables were removed before the above transfer function
     // was applied, so eliminate heap regions and edges that are no
     // longer part of the abstractly-live heap graph, and sweep up
index d231593bfdbac6bfa5007405bb5e8f641464c697..69bece23aed3a63ce73a863132206d184b6a0e48 100644 (file)
@@ -718,6 +718,7 @@ public class ReachGraph {
           continue;
         }
 
+
         // for definite reach analysis only
         if( edgeKeysAdded != null ) {
           assert f != null;
@@ -725,6 +726,8 @@ public class ReachGraph {
                                           hrnY.getID(),
                                           f )
                              );
+
+          
         }
 
         // prepare the new reference edge hrnX.f -> hrnY
index cb4238bd7237a3da57d05851ddcabff9398672e8..5970eff5189c692518ca1f3639b8f167b81df45e 100644 (file)
@@ -8,6 +8,22 @@ public class Test {
   
 
   static public void main( String args[] ) {
+
+    Foo x = getFlagged();
+    Foo y = getUnflagged();
+
+    x.f = y;
+
+    gendefreach QWQ1; 
+
+    Foo z = x;
+    while( false ) {
+      z = z.f;
+    }
+
+    gendefreach QWQ2;
+
+    /*
     gendefreach yn1;    
 
     Foo x = getFlagged();
@@ -37,9 +53,9 @@ public class Test {
     // of objects y is reachable from.
     gendefreach y2;
     genreach y2;
+    */
 
-
-    System.out.println( x+","+y );
+    System.out.println( " "+x+y+z );
   }
 
   static public Foo getFlagged() {