From 21df9e78ca2af4072431bfa3ed631cd4dee0827e Mon Sep 17 00:00:00 2001 From: jjenista Date: Tue, 1 Jul 2008 18:48:04 +0000 Subject: [PATCH] More reachability set functionality, but not all there yet --- .../OwnershipAnalysis/ChangeTuple.java | 7 +- .../OwnershipAnalysis/ChangeTupleSet.java | 4 ++ .../OwnershipAnalysis/ReachabilitySet.java | 69 +++++++++++++++++-- .../OwnershipAnalysis/TokenTuple.java | 14 ++-- .../OwnershipAnalysis/TokenTupleSet.java | 15 ++-- 5 files changed, 86 insertions(+), 23 deletions(-) diff --git a/Robust/src/Analysis/OwnershipAnalysis/ChangeTuple.java b/Robust/src/Analysis/OwnershipAnalysis/ChangeTuple.java index 06dac9fc..9a1f8bdf 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/ChangeTuple.java +++ b/Robust/src/Analysis/OwnershipAnalysis/ChangeTuple.java @@ -9,6 +9,9 @@ import java.io.*; // a change touple is a pair that indicates if the // first TokenTupleSet is found in a ReachabilitySet, // then the second TokenTupleSet should be added + +// THIS CLASS IS IMMUTABLE! + public class ChangeTuple { private TokenTupleSet toMatch; @@ -38,10 +41,6 @@ public class ChangeTuple return toMatch.hashCode() + toAdd.hashCode(); } - public ChangeTuple copy() { - return new ChangeTuple( toMatch, toAdd ); - } - public String toString() { return new String( "<"+toMatch+" -> "+toAdd+">" ); } diff --git a/Robust/src/Analysis/OwnershipAnalysis/ChangeTupleSet.java b/Robust/src/Analysis/OwnershipAnalysis/ChangeTupleSet.java index 650716bc..c0d90104 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/ChangeTupleSet.java +++ b/Robust/src/Analysis/OwnershipAnalysis/ChangeTupleSet.java @@ -23,6 +23,10 @@ public class ChangeTupleSet { changeTuples = (HashSet) cts.changeTuples.clone(); //COPY?! } + public Iterator iterator() { + return changeTuples.iterator(); + } + public ChangeTupleSet union( ChangeTupleSet ctsIn ) { ChangeTupleSet ctsOut = new ChangeTupleSet( this ); ctsOut.changeTuples.addAll( ctsIn.changeTuples ); diff --git a/Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java b/Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java index ecb52ea6..6f612414 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java +++ b/Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java @@ -18,6 +18,10 @@ public class ReachabilitySet { possibleReachabilities = (HashSet) rs.possibleReachabilities.clone(); // again, DEEP COPY?! } + public Iterator iterator() { + return possibleReachabilities.iterator(); + } + public ReachabilitySet union( ReachabilitySet rsIn ) { ReachabilitySet rsOut = new ReachabilitySet( this ); rsOut.possibleReachabilities.addAll( rsIn.possibleReachabilities ); @@ -27,7 +31,7 @@ public class ReachabilitySet { public ReachabilitySet intersection( ReachabilitySet rsIn ) { ReachabilitySet rsOut = new ReachabilitySet(); - Iterator i = this.possibleReachabilities.iterator(); + Iterator i = this.iterator(); while( i.hasNext() ) { TokenTupleSet tts = (TokenTupleSet) i.next(); if( rsIn.possibleReachabilities.contains( tts ) ) { @@ -38,9 +42,66 @@ public class ReachabilitySet { return rsOut; } - /* public ChangeTupleSet unionUpArity( ReachabilitySet rsIn ) { - + ChangeTupleSet ctsOut = new ChangeTupleSet(); + + Iterator itrO = this.iterator(); + while( itrO.hasNext() ) { + TokenTupleSet o = (TokenTupleSet) itrO.next(); + + Iterator itrR = rsIn.iterator(); + while( itrR.hasNext() ) { + TokenTupleSet r = (TokenTupleSet) itrR.next(); + + TokenTupleSet theUnion = new TokenTupleSet(); + + Iterator itrRelement = r.iterator(); + while( itrRelement.hasNext() ) { + TokenTuple e = (TokenTuple) itrRelement.next(); + + if( o.contains( e ) ) { + theUnion.union( new TokenTupleSet( e.increaseArity() ) ); + } + } + } + } + + return ctsOut; } - */ } + +/* +Set specialUnion( Set O, Set R ) { + Set C = {} + + foreach o in O { + foreach r in R { + + Set theUnion = {} + + foreach e in r { + if o.contains( e ) { + if e.isSummaryToken() { // wait, stronger condition? + theUnion.add( e.copy().increaseArity() ) + } else { + theUnion.add( e.copy() ) + } + } + } + + foreach e in o { + if !theUnion.contains( e ) { + theUnion.add( e.copy() ) + } + } + + if !theUnion.isEmpty() { + C.add( ) + } + + } + } + + return C +} +*/ diff --git a/Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java b/Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java index e9d3b400..4d496987 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java +++ b/Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java @@ -8,6 +8,9 @@ import java.io.*; // a token touple is a pair that indicates a // heap region node and an arity + +// THIS CLASS IS IMMUTABLE! + public class TokenTuple { private Integer token; @@ -35,10 +38,11 @@ public class TokenTuple public Integer getToken() { return token; } public int getArity() { return arity; } - public void increaseArity() { + public TokenTuple increaseArity() { if( isNewSummary ) { - arity = ARITY_MANY; + return new TokenTuple( token, isNewSummary, ARITY_MANY ); } + return this; } public boolean equals( Object o ) { @@ -56,12 +60,6 @@ public class TokenTuple return token.intValue(); } - public TokenTuple copy() { - return new TokenTuple( token, - isNewSummary, - arity ); - } - public String toString() { String s = ""; if( isNewSummary ) { diff --git a/Robust/src/Analysis/OwnershipAnalysis/TokenTupleSet.java b/Robust/src/Analysis/OwnershipAnalysis/TokenTupleSet.java index a78943c9..626e5327 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/TokenTupleSet.java +++ b/Robust/src/Analysis/OwnershipAnalysis/TokenTupleSet.java @@ -23,19 +23,20 @@ public class TokenTupleSet { tokenTuples = (HashSet) tts.tokenTuples.clone(); //COPY?! } + public Iterator iterator() { + return tokenTuples.iterator(); + } + public TokenTupleSet union( TokenTupleSet ttsIn ) { TokenTupleSet ttsOut = new TokenTupleSet( this ); ttsOut.tokenTuples.addAll( ttsIn.tokenTuples ); - /* - Iterator i = ttsIn.tokenTuples.iterator(); - while( i.hasNext() ) { - ttsOut.tokenTuples.add( (TokenTuple) i.next() ); - } - */ - return ttsOut; } + public boolean contains( TokenTuple tt ) { + return tokenTuples.contains( tt ); + } + public String toString() { return tokenTuples.toString(); } -- 2.34.1