successfully keep def reach info just for the store transform
authorjjenista <jjenista>
Thu, 10 Nov 2011 00:16:50 +0000 (00:16 +0000)
committerjjenista <jjenista>
Thu, 10 Nov 2011 00:16:50 +0000 (00:16 +0000)
Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java
Robust/src/Analysis/Disjoint/DefiniteReachState.java
Robust/src/Analysis/Disjoint/DisjointAnalysis.java

index 8c1cf8b5e5af24a0e590f155360c4b37cb1a547e..f8a252ee37caa9bf9bbadd53540cf3265898b6c1 100644 (file)
@@ -13,26 +13,43 @@ public class DefiniteReachAnalysis {
   // every program point
   private Map<FlatNode, DefiniteReachState> fn2state;
 
-  private static PointerMethod pm;
+  // even though the above map has a set of nodes that
+  // have been analyzed, we need a per-intra pass set
+  // of nodes that have been analyzed, too, to filter
+  // out nodes that do not have a partial result yet
+  private Set<FlatNode> fnHasPartial;
 
-  public static void setPointerMethod( PointerMethod pm ) {
-    DefiniteReachAnalysis.pm = pm;
-  }
+
+  private static PointerMethod pm;
 
   
-  public DefiniteReachAnalysis() {
+  public DefiniteReachAnalysis( PointerMethod pm ) {
     // a class-wide initialization
     DefiniteReachState.initBuilders();
+    
+    DefiniteReachAnalysis.pm = pm;
 
-    fn2state = new HashMap<FlatNode, DefiniteReachState>();
+    fn2state     = new HashMap<FlatNode, DefiniteReachState>();
+    fnHasPartial = new HashSet<FlatNode>();
+  }
+
+
+  private void addPartialResult( FlatNode fn, DefiniteReachState state ) {
+    fn2state.put( fn, state );
+    fnHasPartial.add( fn );
   }
 
 
   public void methodEntry( FlatNode fn, 
                            Set<TempDescriptor> parameters ) {
+    // this should be called exactly once at the beginning
+    // of any intraprocedural pass, so clear partial result
+    // set
+    fnHasPartial.clear();
+
     DefiniteReachState state = makeIn( fn );
     state.methodEntry( parameters );
-    fn2state.put( fn, state );
+    addPartialResult( fn, state ); 
   }
 
   public void copy( FlatNode fn, 
@@ -40,7 +57,7 @@ public class DefiniteReachAnalysis {
                     TempDescriptor y ) {
     DefiniteReachState state = makeIn( fn );
     state.copy( x, y );
-    fn2state.put( fn, state ); 
+    addPartialResult( fn, state ); 
   }
 
   public void load( FlatNode fn, 
@@ -51,7 +68,7 @@ public class DefiniteReachAnalysis {
 
     DefiniteReachState state = makeIn( fn );
     state.load( x, y, f, edgeKeysForLoad );
-    fn2state.put( fn, state ); 
+    addPartialResult( fn, state ); 
   }
 
   public void store( FlatNode fn, 
@@ -63,14 +80,14 @@ public class DefiniteReachAnalysis {
 
     DefiniteReachState state = makeIn( fn );
     state.store( x, f, y, edgeKeysRemoved, edgeKeysAdded );
-    fn2state.put( fn, state ); 
+    addPartialResult( fn, state ); 
   }
 
   public void newObject( FlatNode fn, 
                          TempDescriptor x ) {
     DefiniteReachState state = makeIn( fn );
     state.newObject( x );
-    fn2state.put( fn, state ); 
+    addPartialResult( fn, state ); 
   }
 
   public void methodCall( FlatNode fn, 
@@ -79,11 +96,11 @@ public class DefiniteReachAnalysis {
     if( retVal != null ) {
       state.methodCall( retVal );
     }
-    fn2state.put( fn, state ); 
+    addPartialResult( fn, state ); 
   }
 
   public void otherStatement( FlatNode fn ) {
-    fn2state.put( fn, makeIn( fn ) ); 
+    addPartialResult( fn, makeIn( fn ) ); 
   }
 
 
@@ -103,10 +120,12 @@ public class DefiniteReachAnalysis {
     return state;
   }
 
+
   // get the current state for the program point just
   // before the given program point by merging the out
   // states of the predecessor statements
   public DefiniteReachState makeIn( FlatNode fn ) {
+
     if( pm.numPrev( fn ) == 0 ) {
       return new DefiniteReachState();
     }
@@ -114,8 +133,7 @@ public class DefiniteReachAnalysis {
     DefiniteReachState stateIn = null;
 
     for( int i = 0; i < pm.numPrev( fn ); ++i ) {
-
-      if( fn2state.containsKey( pm.getPrev( fn, i ) ) ) {
+      if( fnHasPartial.contains( pm.getPrev( fn, i ) ) ) {
         if( stateIn == null ) {
           // duplicate the first partial result we find
           stateIn = new DefiniteReachState( get( pm.getPrev( fn, i ) ) );
index 70711b19e7bb0251562896df46836d35e13eb6bb..e78ab4808b5b5e567afc65e7ce198cd6b2e9c63e 100644 (file)
@@ -188,14 +188,14 @@ public class DefiniteReachState {
 
 
   public void methodEntryR( Set<TempDescriptor> parameters ) {
-    R.clear();
+    //R.clear();
   }
 
   public void copyR( TempDescriptor x,
                      TempDescriptor y ) {
     // consider that x and y can be the same, so do the
     // parts of the update in the right order:
-
+    /*
     // first get all info for update
     MultiKey keyY = MultiKey.factory( y );
     Map<MultiKey, Object> mapY0 = R.get( viewR0, keyY );
@@ -219,12 +219,14 @@ public class DefiniteReachState {
                                             fullKeyY.get( 2 ) );
       R.put( fullKeyX, MultiViewMap.dummyValue );
     }
+    */
   }
   
   public void loadR( TempDescriptor x,
                      TempDescriptor y,
                      FieldDescriptor f,
                      Set<EdgeKey> edgeKeysForLoad ) {
+    /*
     // consider that x and y can be the same, so do the
     // parts of the update in the right order:
 
@@ -253,6 +255,7 @@ public class DefiniteReachState {
                MultiViewMap.dummyValue );
       }
     }
+    */
   }
 
   public void storeR( TempDescriptor x,
@@ -271,21 +274,29 @@ public class DefiniteReachState {
   }
   
   public void newObjectR( TempDescriptor x ) {
+    /*
     MultiKey keyX = MultiKey.factory( x );
     R.remove( viewR0, keyX );
     R.remove( viewR1, keyX );
+    */
   }
 
   public void methodCallR( TempDescriptor retVal ) {
+    /*
     MultiKey keyRetVal = MultiKey.factory( retVal );
     R.remove( viewR0, keyRetVal );
     R.remove( viewR1, keyRetVal );
+    */
   }
 
   public void mergeR( DefiniteReachState that ) {
     for( MultiKey key : this.R.get().keySet() ) {
       if( that.R.get( viewRfull, key ).isEmpty() ) {
         this.R.remove( viewRfull, key );
+      } else {
+        // if the key is in this and that, we should join the
+        // values using the R.joinOp which is currently has no
+        // public interface
       }
     }
   }
index a27d1df90a6bbadbf1d5b4271344251856ac0834..4b9b4f0dc79e2e1160701da4ca25a89e69c8fda2 100644 (file)
@@ -851,8 +851,7 @@ public class DisjointAnalysis implements HeapAnalysis {
 
     if( state.DO_DEFINITE_REACH_ANALYSIS ) {
       doDefiniteReachAnalysis = true;
-      DefiniteReachAnalysis.setPointerMethod( pm );
-      definiteReachAnalysis = new DefiniteReachAnalysis();
+      definiteReachAnalysis = new DefiniteReachAnalysis( pm );
     }