From: jjenista Date: Wed, 7 Apr 2010 18:13:39 +0000 (+0000) Subject: added compiler option to desire determinism, it currently has little effect on determ... X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=2a6c0c0bd5ee6e089c91b4dee85e3043a6500ab5;p=IRC.git added compiler option to desire determinism, it currently has little effect on determinism, though, so will get back to other bugs for now --- diff --git a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java index e8e6b296..bbd63083 100644 --- a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java +++ b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java @@ -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 flatNodesToVisit = new HashSet(); flatNodesToVisit.add( fm ); - Set debugVisited = new HashSet(); + // if determinism is desired by client, shadow the + // set with a queue to make visit order deterministic + Queue flatNodesToVisitQ = null; + if( determinismDesired ) { + flatNodesToVisitQ = new LinkedList(); + flatNodesToVisitQ.add( fm ); + } // mapping of current partial results Hashtable mapFlatNodeToReachGraph = @@ -784,10 +795,15 @@ public class DisjointAnalysis { HashSet setReturns = new HashSet(); 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 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 diff --git a/Robust/src/Benchmarks/disjoint/makefile b/Robust/src/Benchmarks/disjoint/makefile index 4c71c08e..107207c8 100644 --- a/Robust/src/Benchmarks/disjoint/makefile +++ b/Robust/src/Benchmarks/disjoint/makefile @@ -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 diff --git a/Robust/src/IR/State.java b/Robust/src/IR/State.java index 3248253f..ecada3b4 100644 --- a/Robust/src/IR/State.java +++ b/Robust/src/IR/State.java @@ -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; diff --git a/Robust/src/Main/Main.java b/Robust/src/Main/Main.java index 5d63f7b1..84a6302c 100644 --- a/Robust/src/Main/Main.java +++ b/Robust/src/Main/Main.java @@ -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;