added compiler option to desire determinism, it currently has little effect on determ...
authorjjenista <jjenista>
Wed, 7 Apr 2010 18:13:39 +0000 (18:13 +0000)
committerjjenista <jjenista>
Wed, 7 Apr 2010 18:13:39 +0000 (18:13 +0000)
Robust/src/Analysis/Disjoint/DisjointAnalysis.java
Robust/src/Benchmarks/disjoint/makefile
Robust/src/IR/State.java
Robust/src/Main/Main.java

index e8e6b29655ec7530ad8ab3b8ddf6eef58e2b4620..bbd63083e7009e3aff1e73fe0fb35f6b158dce47 100644 (file)
@@ -316,6 +316,10 @@ public class DisjointAnalysis {
   // run in faster mode, only when bugs wrung out!
   public static boolean releaseMode;
 
+  // use command line option to set this, analysis
+  // should attempt to be deterministic
+  public static boolean determinismDesired;
+
   // data from the compiler
   public State            state;
   public CallGraph        callGraph;
@@ -548,6 +552,7 @@ public class DisjointAnalysis {
     this.arrayReferencees        = arrayReferencees;
     this.allocationDepth         = state.DISJOINTALLOCDEPTH;
     this.releaseMode             = state.DISJOINTRELEASEMODE;
+    this.determinismDesired      = state.DISJOINTDETERMINISM;
 
     this.writeFinalDOTs          = state.DISJOINTWRITEDOTS && !state.DISJOINTWRITEALL;
     this.writeAllIncrementalDOTs = state.DISJOINTWRITEDOTS &&  state.DISJOINTWRITEALL;
@@ -773,7 +778,13 @@ public class DisjointAnalysis {
     Set<FlatNode> flatNodesToVisit = new HashSet<FlatNode>();
     flatNodesToVisit.add( fm );
 
-    Set<FlatNode> debugVisited = new HashSet<FlatNode>();
+    // if determinism is desired by client, shadow the
+    // set with a queue to make visit order deterministic
+    Queue<FlatNode> flatNodesToVisitQ = null;
+    if( determinismDesired ) {
+      flatNodesToVisitQ = new LinkedList<FlatNode>();
+      flatNodesToVisitQ.add( fm );
+    }
     
     // mapping of current partial results
     Hashtable<FlatNode, ReachGraph> mapFlatNodeToReachGraph =
@@ -784,10 +795,15 @@ public class DisjointAnalysis {
     HashSet<FlatReturnNode> setReturns = new HashSet<FlatReturnNode>();
 
     while( !flatNodesToVisit.isEmpty() ) {
-      FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next();
-      flatNodesToVisit.remove( fn );
 
-      debugVisited.add( fn );
+      FlatNode fn;      
+      if( determinismDesired ) {
+        assert !flatNodesToVisitQ.isEmpty();
+        fn = flatNodesToVisitQ.remove();
+      } else {
+        fn = flatNodesToVisit.iterator().next();
+      }
+      flatNodesToVisit.remove( fn );
 
       // effect transfer function defined by this node,
       // then compare it to the old graph at this node
@@ -843,42 +859,18 @@ public class DisjointAnalysis {
       if( !rg.equals( rgPrev ) ) {
        mapFlatNodeToReachGraph.put( fn, rg );
 
-       for( int i = 0; i < pm.numNext(fn); i++ ) {
-         FlatNode nn = pm.getNext(fn, i);
+       for( int i = 0; i < pm.numNext( fn ); i++ ) {
+         FlatNode nn = pm.getNext( fn, i );
+
          flatNodesToVisit.add( nn );
+          if( determinismDesired ) {
+            flatNodesToVisitQ.add( nn );
+          }
        }
       }
     }
 
 
-    // assert that the fixed-point results for each
-    // node in the method is no smaller than the last
-    // time this method was analyzed (monotonicity)
-    /*
-    Iterator<FlatNode> nItr = fm.getNodeSet().iterator();
-    while( nItr.hasNext() ) {
-      FlatNode   fn     = nItr.next();      
-      ReachGraph last   = fn2rg.get( fn );
-      ReachGraph newest = mapFlatNodeToReachGraph.get( fn );
-
-      if( newest == null ) {
-        System.out.println( "**********\nfn null result: "+fn+
-                            "\nnum visited="+debugVisited.size()+", num in set="+fm.getNodeSet().size()+
-                            "\nvisited:"+debugVisited );
-      }
-
-      assert newest != null;
-      if( last != null ) {
-        if( !ReachGraph.isNoSmallerThan( last, newest ) ) {
-          last.writeGraph( "last", true, false, false, true, true );
-          newest.writeGraph( "newest", true, false, false, true, true );
-          throw new Error( "transfer func for "+fn+" was not monotic" );
-        }
-      }
-      fn2rg.put( fn, newest );
-    }
-    */
-
     // end by merging all return nodes into a complete
     // reach graph that represents all possible heap
     // states after the flat method returns
index 4c71c08e39f73926f03bfda82c4404ab0a5638bb..107207c891cda1d5f6e580d34309ed6f061588fe 100644 (file)
@@ -9,7 +9,7 @@ BUILDSCRIPT=~/research/Robust/src/buildscript
 #################################################
 #DEBUGFLAGS= -disjoint-debug-callsite setClusters innerKMeansSetting 20
 #DEBUGFLAGS= -disjoint-debug-callsite ensureCapacity addElement 100
-#DEBUGFLAGS= -disjoint-debug-callsite setReduceFinish reduceOutput 100
+#DEBUGFLAGS= -disjoint-debug-callsite setPartial reduceOutput 100
 
 #################################################
 ##
@@ -24,20 +24,20 @@ BUILDSCRIPT=~/research/Robust/src/buildscript
 #################################################
 #SNAPFLAGS= -disjoint-debug-snap-method calcGoodFeatureTask 5 10 true
 #SNAPFLAGS= -disjoint-debug-snap-method calcGoodFeature 5 1 true
-#SNAPFLAGS= -disjoint-debug-snap-method t3 1 1 true
+SNAPFLAGS= -disjoint-debug-snap-method t6 20 5 true
 #SNAPFLAGS= -disjoint-debug-snap-method reduceOutput 5 50 true
 #SNAPFLAGS= -disjoint-debug-snap-method setReduceFinish 5 50 true
-
+#SNAPFLAGS= -disjoint-debug-snap-method setPartial 1 50 true
 
 
 BAMBOOFLAGS= -recover
 JAVAFLAGS= -mainclass test
 
 #VISITMODE= -disjoint-dvisit-stack
-#VISITMODE= -disjoint-dvisit-pqueue
-VISITMODE= -disjoint-dvisit-stack-callees-on-top
+VISITMODE= -disjoint-dvisit-pqueue
+#VISITMODE= -disjoint-dvisit-stack-callees-on-top
 
-DEBUGMODE= -enable-assertions -disjoint-write-dots final -disjoint-alias-file aliases.txt normal
+DEBUGMODE= -enable-assertions -disjoint-write-dots final -disjoint-alias-file aliases.txt normal -disjoint-desire-determinism
 RELEASEMODE= -disjoint-release-mode -disjoint-alias-file aliases.txt tabbed
 
 BSFLAGS= -justanalyze -disjoint -disjoint-k 1 -flatirusermethods
index 3248253fae67076cb6e4c8637fcb99c96d7b3f5d..ecada3b496e60b0e2b0830aefa0631f18d605f02 100644 (file)
@@ -70,6 +70,7 @@ public class State {
   
   public boolean DISJOINT=false;
   public boolean DISJOINTRELEASEMODE=false;
+  public boolean DISJOINTDETERMINISM=false;
   public int DISJOINTALLOCDEPTH=3;
   public boolean DISJOINTWRITEDOTS=false;
   public boolean DISJOINTWRITEALL=false;
index 5d63f7b134a6870d6b203f474b9c537190a016c1..84a6302ca4e0cbf95a0a2cb151f28f7b20f9c703 100644 (file)
@@ -220,6 +220,9 @@ public class Main {
       } else if( option.equals( "-disjoint-release-mode" ) ) {
         state.DISJOINTRELEASEMODE = true;        
 
+      } else if( option.equals( "-disjoint-desire-determinism" ) ) {
+        state.DISJOINTDETERMINISM = true;        
+
       } else if( option.equals( "-disjoint-dvisit-stack" ) ) {
         state.DISJOINTDVISITSTACK         = true;      
         state.DISJOINTDVISITPQUE          = false;