From: jjenista Date: Thu, 10 Nov 2011 00:16:50 +0000 (+0000) Subject: successfully keep def reach info just for the store transform X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=d2e1a91b7fdd988114055a8c961ffb11bfa5f276;p=IRC.git successfully keep def reach info just for the store transform --- diff --git a/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java b/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java index 8c1cf8b5..f8a252ee 100644 --- a/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java +++ b/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java @@ -13,26 +13,43 @@ public class DefiniteReachAnalysis { // every program point private Map 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 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(); + fn2state = new HashMap(); + fnHasPartial = new HashSet(); + } + + + private void addPartialResult( FlatNode fn, DefiniteReachState state ) { + fn2state.put( fn, state ); + fnHasPartial.add( fn ); } public void methodEntry( FlatNode fn, Set 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 ) ) ); diff --git a/Robust/src/Analysis/Disjoint/DefiniteReachState.java b/Robust/src/Analysis/Disjoint/DefiniteReachState.java index 70711b19..e78ab480 100644 --- a/Robust/src/Analysis/Disjoint/DefiniteReachState.java +++ b/Robust/src/Analysis/Disjoint/DefiniteReachState.java @@ -188,14 +188,14 @@ public class DefiniteReachState { public void methodEntryR( Set 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 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 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 } } } diff --git a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java index a27d1df9..4b9b4f0d 100644 --- a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java +++ b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java @@ -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 ); }