From d28a31cc54990d5d134a5032953055c9b5f5424f Mon Sep 17 00:00:00 2001 From: jjenista Date: Mon, 7 Nov 2011 22:27:46 +0000 Subject: [PATCH] found a bug, results still empty --- .../Disjoint/DefiniteReachAnalysis.java | 21 +++++++++---------- .../Analysis/Disjoint/DefiniteReachState.java | 16 ++++++++++++++ Robust/src/Analysis/Disjoint/EdgeKey.java | 4 ++++ Robust/src/Tests/disjoint/definite/test.java | 8 +++++-- Robust/src/Util/MultiViewMap.java | 9 ++++++++ 5 files changed, 45 insertions(+), 13 deletions(-) diff --git a/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java b/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java index 97f2a416..2c57170e 100644 --- a/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java +++ b/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java @@ -1,6 +1,5 @@ package Analysis.Disjoint; -import java.io.*; import java.util.*; import IR.*; @@ -44,6 +43,7 @@ public class DefiniteReachAnalysis { Set edgeKeysForLoad ) { DefiniteReachState state = makeIn( fn ); state.load( x, y, f, edgeKeysForLoad ); + state.writeState( "YO" ); fn2state.put( fn, state ); } @@ -80,14 +80,7 @@ public class DefiniteReachAnalysis { public void writeState( FlatNode fn, String outputName ) { - DefiniteReachState state = makeIn( fn ); - try { - BufferedWriter bw = new BufferedWriter( new FileWriter( outputName+".txt" ) ); - bw.write( state.toString() ); - bw.close(); - } catch( IOException e ) { - System.out.println( "ERROR writing definite reachability state:\n "+e ); - } + makeIn( fn ).writeState( outputName ); } @@ -106,8 +99,14 @@ public class DefiniteReachAnalysis { // before the given program point by merging the out // states of the predecessor statements private DefiniteReachState makeIn( FlatNode fn ) { - DefiniteReachState stateIn = new DefiniteReachState(); - for( int i = 0; i < fn.numPrev(); ++i ) { + if( fn.numPrev() <= 1 ) { + return new DefiniteReachState(); + } + + DefiniteReachState stateIn = + new DefiniteReachState( get( fn.getPrev( 0 ) ) ); + + for( int i = 1; i < fn.numPrev(); ++i ) { stateIn.merge( get( fn.getPrev( i ) ) ); } return stateIn; diff --git a/Robust/src/Analysis/Disjoint/DefiniteReachState.java b/Robust/src/Analysis/Disjoint/DefiniteReachState.java index 7ab37d97..67f545ce 100644 --- a/Robust/src/Analysis/Disjoint/DefiniteReachState.java +++ b/Robust/src/Analysis/Disjoint/DefiniteReachState.java @@ -1,5 +1,6 @@ package Analysis.Disjoint; +import java.io.*; import java.util.*; import IR.*; @@ -82,11 +83,15 @@ public class DefiniteReachState { + public DefiniteReachState( DefiniteReachState toCopy ) { + this.R = toCopy.R.clone( RBuilder ); + } public DefiniteReachState() { R = RBuilder.build(); //Rs = new HashMap(); + //Fu = FuBuilder.build(); } @@ -340,6 +345,17 @@ public class DefiniteReachState { } + public void writeState( String outputName ) { + try { + BufferedWriter bw = new BufferedWriter( new FileWriter( "defReach-"+outputName+".txt" ) ); + bw.write( this.toString() ); + bw.close(); + } catch( IOException e ) { + System.out.println( "ERROR writing definite reachability state:\n "+e ); + } + } + + public String toString() { StringBuilder s = new StringBuilder(); diff --git a/Robust/src/Analysis/Disjoint/EdgeKey.java b/Robust/src/Analysis/Disjoint/EdgeKey.java index f4282bcc..b867d3ba 100644 --- a/Robust/src/Analysis/Disjoint/EdgeKey.java +++ b/Robust/src/Analysis/Disjoint/EdgeKey.java @@ -14,6 +14,10 @@ public class EdgeKey { this.f = f; } + public String toString() { + return "<"+srcId+", "+f+", "+dstId+">"; + } + public Integer getSrcId() { return srcId; } diff --git a/Robust/src/Tests/disjoint/definite/test.java b/Robust/src/Tests/disjoint/definite/test.java index e2f10cc0..cb4238bd 100644 --- a/Robust/src/Tests/disjoint/definite/test.java +++ b/Robust/src/Tests/disjoint/definite/test.java @@ -8,13 +8,15 @@ public class Test { static public void main( String args[] ) { - + gendefreach yn1; + Foo x = getFlagged(); Foo y = getUnflagged(); x.f = y; // x is flagged and y is reachable from // at most one object from that site + gendefreach y0; genreach y0; Foo t = getFlagged(); @@ -23,6 +25,7 @@ public class Test { // x is flagged and y is reachable from // at most one object from that site, even // though x is summarized now + gendefreach y1; genreach y1; x.g = y; @@ -32,8 +35,9 @@ public class Test { // from x, but we don't and x is summarized // so we conservatively increase the arity // of objects y is reachable from. - genreach y2; gendefreach y2; + genreach y2; + System.out.println( x+","+y ); } diff --git a/Robust/src/Util/MultiViewMap.java b/Robust/src/Util/MultiViewMap.java index 0a0b8878..c8482c91 100644 --- a/Robust/src/Util/MultiViewMap.java +++ b/Robust/src/Util/MultiViewMap.java @@ -79,6 +79,15 @@ public class MultiViewMap { } + public MultiViewMap clone( MultiViewMapBuilder builder ) { + MultiViewMap out = builder.build(); + for( Map.Entry entry : this.get().entrySet() ) { + out.put( entry.getKey(), entry.getValue() ); + } + return out; + } + + public boolean equals( Object o ) { if( this == o ) { return true; -- 2.34.1