From 039548bf0971a3c3f19e06dce396a6a1f8a6af1e Mon Sep 17 00:00:00 2001 From: jjenista Date: Wed, 14 Apr 2010 20:13:30 +0000 Subject: [PATCH] fixed a bug where retrieving the context contribution of a call site returns an empty graph instead of null, which erroneously matches a new context calculation that happens to be an empty graph--this doesn't fully solve the known bug though --- .../Analysis/Disjoint/DisjointAnalysis.java | 78 ++++++++++++------- Robust/src/Benchmarks/disjoint/makefile | 9 ++- Robust/src/IR/State.java | 16 ++-- Robust/src/Main/Main.java | 3 + 4 files changed, 72 insertions(+), 34 deletions(-) diff --git a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java index 49aebc74..20bbfdaa 100644 --- a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java +++ b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java @@ -320,6 +320,13 @@ public class DisjointAnalysis { // should attempt to be deterministic public static boolean determinismDesired; + // when we want to enforce determinism in the + // analysis we need to sort descriptors rather + // than toss them in efficient sets, use this + public static DescriptorComparator dComp = + new DescriptorComparator(); + + // data from the compiler public State state; public CallGraph callGraph; @@ -329,7 +336,8 @@ public class DisjointAnalysis { public int allocationDepth; // data structure for public interface - private Hashtable > mapDescriptorToAllocSiteSet; + private Hashtable< Descriptor, HashSet > + mapDescriptorToAllocSiteSet; // for public interface methods to warn that they @@ -468,9 +476,7 @@ public class DisjointAnalysis { if( determinismDesired ) { // use an ordered set - descriptorsToAnalyze - = new TreeSet( new DescriptorComparator() ); - + descriptorsToAnalyze = new TreeSet( dComp ); } else { // otherwise use a speedy hashset descriptorsToAnalyze = new HashSet(); @@ -623,6 +629,10 @@ public class DisjointAnalysis { writeFinalIHMs(); } + if( state.DISJOINTWRITEINITCONTEXTS ) { + writeInitialContexts(); + } + if( state.DISJOINTALIASFILE != null ) { if( state.TASK ) { writeAllSharing(state.DISJOINTALIASFILE, treport, justtime, state.DISJOINTALIASTAB, state.lines); @@ -794,18 +804,10 @@ public class DisjointAnalysis { if( state.DISJOINTDVISITSTACKEESONTOP ) { - if( state.DISJOINTDEBUGSCHEDULING ) { - System.out.println( " contexts changed, scheduling callees for analysis:" ); - } - depsItr = calleesToEnqueue.iterator(); while( depsItr.hasNext() ) { Descriptor dNext = depsItr.next(); enqueue( dNext ); - - if( state.DISJOINTDEBUGSCHEDULING ) { - System.out.println( " "+dNext ); - } } calleesToEnqueue.clear(); } @@ -1012,6 +1014,7 @@ public class DisjointAnalysis { rg.merge( rgContrib ); } + // additionally, we are enforcing STRICT MONOTONICITY for the // method's initial context, so grow the context by whatever // the previously computed context was, and put the most @@ -1179,15 +1182,14 @@ public class DisjointAnalysis { // and reschedule the callee for analysis addIHMcontribution( mdCallee, fc, heapForThisCall_cur ); + if( state.DISJOINTDEBUGSCHEDULING ) { + System.out.println( " context changed, scheduling callee: "+mdCallee ); + } + if( state.DISJOINTDVISITSTACKEESONTOP ) { calleesToEnqueue.add( mdCallee ); } else { enqueue( mdCallee ); - - if( state.DISJOINTDEBUGSCHEDULING ) { - System.out.println( " context changed, scheduling callee: "+mdCallee ); - } - } } @@ -1197,8 +1199,14 @@ public class DisjointAnalysis { // current heap abstraction with any effects from the callee, // or if the method is virtual, the effects from any possible // callees, so find the set of callees... - Set setPossibleCallees = - new HashSet(); + Set setPossibleCallees; + if( determinismDesired ) { + // use an ordered set + setPossibleCallees = new TreeSet( dComp ); + } else { + // otherwise use a speedy hashset + setPossibleCallees = new HashSet(); + } if( mdCallee.isStatic() ) { setPossibleCallees.add( mdCallee ); @@ -1234,11 +1242,12 @@ public class DisjointAnalysis { calleesToEnqueue.add( mdPossible ); } else { enqueue( mdPossible ); - - if( state.DISJOINTDEBUGSCHEDULING ) { - System.out.println( " callee hasn't been analyzed, scheduling: "+mdPossible ); - } } + + if( state.DISJOINTDEBUGSCHEDULING ) { + System.out.println( " callee hasn't been analyzed, scheduling: "+mdPossible ); + } + } else { rgCopy.resolveMethodCall( fc, @@ -1364,6 +1373,23 @@ public class DisjointAnalysis { } } } + + private void writeInitialContexts() { + Set entrySet = mapDescriptorToInitialContext.entrySet(); + Iterator itr = entrySet.iterator(); + while( itr.hasNext() ) { + Map.Entry me = (Map.Entry) itr.next(); + Descriptor d = (Descriptor) me.getKey(); + ReachGraph rg = (ReachGraph) me.getValue(); + + rg.writeGraph( "INITIAL"+d, + true, // write labels (variables) + true, // selectively hide intermediate temp vars + true, // prune unreachable heap regions + false, // hide subset reachability states + true ); // hide edge taints + } + } protected ReachGraph getPartial( Descriptor d ) { @@ -1505,9 +1531,7 @@ public class DisjointAnalysis { if( determinismDesired ) { // use an ordered set - discovered - = new TreeSet( new DescriptorComparator() ); - + discovered = new TreeSet( dComp ); } else { // otherwise use a speedy hashset discovered = new HashSet(); @@ -1644,7 +1668,7 @@ public class DisjointAnalysis { getIHMcontributions( d ); if( !heapsFromCallers.containsKey( fc ) ) { - heapsFromCallers.put( fc, new ReachGraph() ); + return null; } return heapsFromCallers.get( fc ); diff --git a/Robust/src/Benchmarks/disjoint/makefile b/Robust/src/Benchmarks/disjoint/makefile index fc58a826..9e4f5dae 100644 --- a/Robust/src/Benchmarks/disjoint/makefile +++ b/Robust/src/Benchmarks/disjoint/makefile @@ -18,6 +18,8 @@ BUILDSCRIPT=~/research/Robust/src/buildscript #DEBUGFLAGS= -disjoint-debug-callsite setPartial reduceOutput 1 20 false +#DEBUGFLAGS= -disjoint-debug-callsite close Transaction 1 20 false + ################################################# ## @@ -42,6 +44,9 @@ BUILDSCRIPT=~/research/Robust/src/buildscript #SNAPFLAGS= -disjoint-debug-snap-method setReduceFinish 5 50 true #SNAPFLAGS= -disjoint-debug-snap-method setPartial 1 50 true +#SNAPFLAGS= -disjoint-debug-snap-method Transaction 1 20 true +#SNAPFLAGS= -disjoint-debug-snap-method close 1 20 true + @@ -52,10 +57,10 @@ JAVAFLAGS= -mainclass test #VISITMODE= -disjoint-dvisit-pqueue VISITMODE= -disjoint-dvisit-stack-callees-on-top -DEBUGMODE= -enable-assertions -disjoint-write-dots final -disjoint-alias-file aliases.txt normal -disjoint-desire-determinism +DEBUGMODE= -enable-assertions -disjoint-write-dots final -disjoint-write-ihms -disjoint-write-initial-contexts -disjoint-alias-file aliases.txt normal -disjoint-desire-determinism #-disjoint-debug-scheduling RELEASEMODE= -disjoint-release-mode -disjoint-alias-file aliases.txt tabbed -BSFLAGS= -justanalyze -disjoint -disjoint-k 1 -flatirusermethods -flatirtasks +BSFLAGS= -justanalyze -disjoint -disjoint-k 1 #-flatirusermethods -flatirtasks all: echo 'pass another arg: ' diff --git a/Robust/src/IR/State.java b/Robust/src/IR/State.java index e12612dc..c29b0aa8 100644 --- a/Robust/src/IR/State.java +++ b/Robust/src/IR/State.java @@ -67,14 +67,23 @@ public class State { public int OWNERSHIPDEBUGCALLCOUNT=0; public String OWNERSHIPDEBUGCALLEE=null; public String OWNERSHIPDEBUGCALLER=null; + public boolean DISJOINT=false; + + public int DISJOINTALLOCDEPTH=1; public boolean DISJOINTRELEASEMODE=false; public boolean DISJOINTDETERMINISM=false; - public int DISJOINTALLOCDEPTH=3; + + public boolean DISJOINTDVISITSTACK=true; + public boolean DISJOINTDVISITPQUE=false; + public boolean DISJOINTDVISITSTACKEESONTOP=false; + public boolean DISJOINTWRITEDOTS=false; public boolean DISJOINTWRITEALL=false; public boolean DISJOINTWRITEIHMS=false; + public boolean DISJOINTWRITEINITCONTEXTS=false; + public String DISJOINTALIASFILE=null; public boolean DISJOINTALIASTAB=false; @@ -89,12 +98,9 @@ public class State { public int DISJOINTSNAPNUMVISITS=0; public boolean DISJOINTSNAPSTOPAFTER=false; - public boolean DISJOINTDVISITSTACK=true; - public boolean DISJOINTDVISITPQUE=false; - public boolean DISJOINTDVISITSTACKEESONTOP=false; - public boolean DISJOINTDEBUGSCHEDULING=false; + public boolean OPTIONAL=false; public boolean ARRAYPAD=false; public boolean THREAD=false; diff --git a/Robust/src/Main/Main.java b/Robust/src/Main/Main.java index 08e19581..ca305d16 100644 --- a/Robust/src/Main/Main.java +++ b/Robust/src/Main/Main.java @@ -185,6 +185,9 @@ public class Main { throw new Error("disjoint-write-dots requires argument "); } + } else if (option.equals("-disjoint-write-initial-contexts")) { + state.DISJOINTWRITEINITCONTEXTS = true; + } else if (option.equals("-disjoint-write-ihms")) { state.DISJOINTWRITEIHMS = true; -- 2.34.1