def reach has to use PointerMethod to detect CFG edges that the analysis cares about
authorjjenista <jjenista>
Wed, 9 Nov 2011 00:34:10 +0000 (00:34 +0000)
committerjjenista <jjenista>
Wed, 9 Nov 2011 00:34:10 +0000 (00:34 +0000)
Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java
Robust/src/Analysis/Disjoint/DisjointAnalysis.java
Robust/src/Tests/disjoint/definite/makefile
Robust/src/Tests/disjoint/definite/test.java

index 00aa4d939bbbab2a2d3fcdccbbe3dc62b5cbc3c2..8c1cf8b5e5af24a0e590f155360c4b37cb1a547e 100644 (file)
@@ -12,6 +12,13 @@ public class DefiniteReachAnalysis {
   // keep a state of definite reachability analysis for
   // every program point
   private Map<FlatNode, DefiniteReachState> fn2state;
+
+  private static PointerMethod pm;
+
+  public static void setPointerMethod( PointerMethod pm ) {
+    DefiniteReachAnalysis.pm = pm;
+  }
+
   
   public DefiniteReachAnalysis() {
     // a class-wide initialization
@@ -23,7 +30,7 @@ public class DefiniteReachAnalysis {
 
   public void methodEntry( FlatNode fn, 
                            Set<TempDescriptor> parameters ) {
-    DefiniteReachState state = get( fn );
+    DefiniteReachState state = makeIn( fn );
     state.methodEntry( parameters );
     fn2state.put( fn, state );
   }
@@ -100,17 +107,27 @@ public class DefiniteReachAnalysis {
   // before the given program point by merging the out
   // states of the predecessor statements
   public DefiniteReachState makeIn( FlatNode fn ) {
-    if( fn.numPrev() == 0 ) {
+    if( pm.numPrev( fn ) == 0 ) {
       return new DefiniteReachState();
     }
 
-    DefiniteReachState stateIn = 
-      new DefiniteReachState( get( fn.getPrev( 0 ) ) );
+    DefiniteReachState stateIn = null;
 
-    for( int i = 1; i < fn.numPrev(); ++i ) {
-      stateIn.merge( get( fn.getPrev( i ) ) );
-    }
+    for( int i = 0; i < pm.numPrev( fn ); ++i ) {
 
+      if( fn2state.containsKey( pm.getPrev( fn, i ) ) ) {
+        if( stateIn == null ) {
+          // duplicate the first partial result we find
+          stateIn = new DefiniteReachState( get( pm.getPrev( fn, i ) ) );
+        } else {
+          // merge other partial results into the rest
+          stateIn.merge( get( pm.getPrev( fn, i ) ) );
+        }
+      }
+    }
+      
+    // at least one predecessor was analyzed before this
+    assert( stateIn != null );
     return stateIn;
   }
 }
index c5d03684280c9e3a6aa926e132a6ea1a43114b46..a27d1df90a6bbadbf1d5b4271344251856ac0834 100644 (file)
@@ -726,8 +726,6 @@ public class DisjointAnalysis implements HeapAnalysis {
     mapDescriptorToReachGraph =
       new Hashtable<Descriptor, ReachGraph>();
 
-    pm = new PointerMethod();
-
     fc2enclosing = new Hashtable<FlatCall, Descriptor>();
   }
 
@@ -849,8 +847,11 @@ public class DisjointAnalysis implements HeapAnalysis {
     ReachGraph.debugCallSiteVisitCounter
       = 0; // count visits from 1, is incremented before first visit    
 
+    pm = new PointerMethod();
+
     if( state.DO_DEFINITE_REACH_ANALYSIS ) {
       doDefiniteReachAnalysis = true;
+      DefiniteReachAnalysis.setPointerMethod( pm );
       definiteReachAnalysis = new DefiniteReachAnalysis();
     }
 
index 7cebad31ae9bb3351d67d6874a1350f5ad43460c..462f41d4916fe10d42cf6a945a930ae16dfab82b 100644 (file)
@@ -6,7 +6,7 @@ BUILDSCRIPT=../../../buildscript
 
 DISJOINT= -disjoint -disjoint-k 1 -enable-assertions -do-definite-reach-analysis
 
-BSFLAGS= -justanalyze -mainclass $(PROGRAM) -heapsize-mb 1024 -noloop -joptimize -debug
+BSFLAGS= -justanalyze -mainclass $(PROGRAM) -heapsize-mb 1024 -noloop -joptimize -debug #-flatirusermethods
 
 
 all:
index 5970eff5189c692518ca1f3639b8f167b81df45e..e3ef1b1fafb186e930b6be8a45b4c288608b39d4 100644 (file)
@@ -18,10 +18,11 @@ public class Test {
 
     Foo z = x;
     while( false ) {
+      gendefreach QWQ2; 
       z = z.f;
     }
 
-    gendefreach QWQ2;
+    gendefreach QWQ3;
 
     /*
     gendefreach yn1;