From: jjenista Date: Tue, 8 Nov 2011 22:14:12 +0000 (+0000) Subject: fix silly off-by-one bug X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b0fdc59140f9146fc7cfcc318a3923086d82a54b;p=IRC.git fix silly off-by-one bug --- diff --git a/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java b/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java index 2c57170e..00aa4d93 100644 --- a/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java +++ b/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java @@ -41,9 +41,9 @@ public class DefiniteReachAnalysis { TempDescriptor y, FieldDescriptor f, Set edgeKeysForLoad ) { + DefiniteReachState state = makeIn( fn ); state.load( x, y, f, edgeKeysForLoad ); - state.writeState( "YO" ); fn2state.put( fn, state ); } @@ -53,6 +53,7 @@ public class DefiniteReachAnalysis { TempDescriptor y, Set edgeKeysRemoved, Set edgeKeysAdded ) { + DefiniteReachState state = makeIn( fn ); state.store( x, f, y, edgeKeysRemoved, edgeKeysAdded ); fn2state.put( fn, state ); @@ -86,7 +87,7 @@ public class DefiniteReachAnalysis { // get the current state for just after the given // program point - private DefiniteReachState get( FlatNode fn ) { + public DefiniteReachState get( FlatNode fn ) { DefiniteReachState state = fn2state.get( fn ); if( state == null ) { state = new DefiniteReachState(); @@ -98,8 +99,8 @@ public class DefiniteReachAnalysis { // get the current state for the program point just // before the given program point by merging the out // states of the predecessor statements - private DefiniteReachState makeIn( FlatNode fn ) { - if( fn.numPrev() <= 1 ) { + public DefiniteReachState makeIn( FlatNode fn ) { + if( fn.numPrev() == 0 ) { return new DefiniteReachState(); } @@ -109,6 +110,7 @@ public class DefiniteReachAnalysis { 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 67f545ce..70711b19 100644 --- a/Robust/src/Analysis/Disjoint/DefiniteReachState.java +++ b/Robust/src/Analysis/Disjoint/DefiniteReachState.java @@ -356,7 +356,6 @@ public class DefiniteReachState { } - public String toString() { StringBuilder s = new StringBuilder(); diff --git a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java index 37ea4205..c5d03684 100644 --- a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java +++ b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java @@ -1312,13 +1312,11 @@ public class DisjointAnalysis implements HeapAnalysis { fn2rgAtEnter.put(fn, rgOnEnter); - boolean didDefReachTransfer = false; - // use node type to decide what transfer function // to apply to the reachability graph switch( fn.kind() ) { @@ -1953,7 +1951,6 @@ public class DisjointAnalysis implements HeapAnalysis { - // dead variables were removed before the above transfer function // was applied, so eliminate heap regions and edges that are no // longer part of the abstractly-live heap graph, and sweep up diff --git a/Robust/src/Analysis/Disjoint/ReachGraph.java b/Robust/src/Analysis/Disjoint/ReachGraph.java index d231593b..69bece23 100644 --- a/Robust/src/Analysis/Disjoint/ReachGraph.java +++ b/Robust/src/Analysis/Disjoint/ReachGraph.java @@ -718,6 +718,7 @@ public class ReachGraph { continue; } + // for definite reach analysis only if( edgeKeysAdded != null ) { assert f != null; @@ -725,6 +726,8 @@ public class ReachGraph { hrnY.getID(), f ) ); + + } // prepare the new reference edge hrnX.f -> hrnY diff --git a/Robust/src/Tests/disjoint/definite/test.java b/Robust/src/Tests/disjoint/definite/test.java index cb4238bd..5970eff5 100644 --- a/Robust/src/Tests/disjoint/definite/test.java +++ b/Robust/src/Tests/disjoint/definite/test.java @@ -8,6 +8,22 @@ public class Test { static public void main( String args[] ) { + + Foo x = getFlagged(); + Foo y = getUnflagged(); + + x.f = y; + + gendefreach QWQ1; + + Foo z = x; + while( false ) { + z = z.f; + } + + gendefreach QWQ2; + + /* gendefreach yn1; Foo x = getFlagged(); @@ -37,9 +53,9 @@ public class Test { // of objects y is reachable from. gendefreach y2; genreach y2; + */ - - System.out.println( x+","+y ); + System.out.println( " "+x+y+z ); } static public Foo getFlagged() {