From 50854f5f52dc551953d88bc2b4fe8a1517367959 Mon Sep 17 00:00:00 2001 From: jjenista Date: Mon, 18 Aug 2008 23:48:43 +0000 Subject: [PATCH] Changed allocation depth to default to minimum possible so graphs are less cluttered during development. Other minor display changes, too. --- .../OwnershipAnalysis/AllocationSite.java | 2 +- .../OwnershipAnalysis/OwnershipAnalysis.java | 5 ++- .../OwnershipAnalysis/OwnershipGraph.java | 22 ++++++++---- .../OwnershipAnalysis/TokenTuple.java | 10 +++--- .../OwnershipAnalysisTest/test01/test01.java | 36 ++++++++++++++++++- 5 files changed, 60 insertions(+), 15 deletions(-) diff --git a/Robust/src/Analysis/OwnershipAnalysis/AllocationSite.java b/Robust/src/Analysis/OwnershipAnalysis/AllocationSite.java index fb02f461..c915bbd0 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/AllocationSite.java +++ b/Robust/src/Analysis/OwnershipAnalysis/AllocationSite.java @@ -35,7 +35,7 @@ public class AllocationSite { public AllocationSite( int allocationDepth, TypeDescriptor type ) { - assert allocationDepth >= 3; + assert allocationDepth >= 1; this.allocationDepth = allocationDepth; this.type = type; diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java index ae271ff8..24b3912b 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java @@ -194,6 +194,9 @@ public class OwnershipAnalysis { this.callGraph = callGraph; this.allocationDepth = allocationDepth; + // temporary for debugging + this.allocationDepth = 1; + descriptorsToVisit = new HashSet(); mapDescriptorToCompleteOwnershipGraph = @@ -310,7 +313,7 @@ public class OwnershipAnalysis { boolean pruneGarbage, boolean writeReferencers */ - og.writeGraph( d, true, true, false, false ); + og.writeGraph( d, true, true, true, false ); // only methods have dependents, tasks cannot // be invoked by any user program calls diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java index 334663ed..87052d0a 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java @@ -27,7 +27,7 @@ public class OwnershipGraph { public OwnershipGraph( int allocationDepth ) { this.allocationDepth = allocationDepth; - + id2hrn = new Hashtable(); td2ln = new Hashtable(); id2paramIndex = new Hashtable(); @@ -77,7 +77,7 @@ public class OwnershipGraph { if( alpha == null ) { if( isFlagged || isParameter ) { alpha = new ReachabilitySet( new TokenTuple( id, - isNewSummary, + !isSingleObject, TokenTuple.ARITY_ONE ) ).makeCanonical(); } else { @@ -418,6 +418,7 @@ public class OwnershipGraph { HeapRegionNode hrnY = edgeY.getDst(); ReachabilitySet O = edgeY.getBeta(); + // propagate tokens over nodes starting from hrnSrc, and it will // take care of propagating back up edges from any touched nodes ChangeTupleSet Cy = O.unionUpArityToChangeSet( R ); @@ -444,23 +445,29 @@ public class OwnershipGraph { nodesWithNewAlpha, edgesWithNewBeta ); - // finally, create the actual reference edge hrnX.f -> hrnY + + + //System.out.println( edgeY.getBetaNew() + "\nbeing pruned by\n" + hrnX.getAlpha() ); + + // create the actual reference edge hrnX.f -> hrnY ReferenceEdge edgeNew = new ReferenceEdge( hrnX, hrnY, f, false, edgeY.getBetaNew().pruneBy( hrnX.getAlpha() ) + //edgeY.getBeta().pruneBy( hrnX.getAlpha() ) ); + addReferenceEdge( hrnX, hrnY, edgeNew ); + + /* if( f != null ) { // we can do a strong update here if one of two cases holds // SAVE FOR LATER, WITHOUT STILL CORRECT - /* if( (hrnX.getNumReferencers() == 1) || ( lnX.getNumReferencees() == 1 && hrnX.isSingleObject() ) ) { clearReferenceEdgesFrom( hrnX, f, false ); - } - */ + } addReferenceEdge( hrnX, hrnY, edgeNew ); @@ -482,6 +489,7 @@ public class OwnershipGraph { addReferenceEdge( hrnX, hrnY, edgeNew ); } } + */ } } @@ -522,7 +530,7 @@ public class OwnershipGraph { paramIndex2id.put( paramIndex, newID ); ReachabilitySet beta = new ReachabilitySet( new TokenTuple( newID, - false, + true, TokenTuple.ARITY_ONE ) ); // heap regions for parameters are always multiple object (see above) diff --git a/Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java b/Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java index 99c4faed..93f6a6da 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java +++ b/Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java @@ -92,16 +92,16 @@ public class TokenTuple extends Canonical { public String toString() { - String s = ""; + String s = token.toString(); + if( isNewSummary ) { - s = "S"; + s += "S"; } - String t = ""; if( arity == ARITY_MANY ) { - t = "*"; + s += "*"; } - return new String( token+s+t ); + return s; } } diff --git a/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java b/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java index e380fb52..73256c19 100644 --- a/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java +++ b/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java @@ -1,3 +1,4 @@ +/* public class Parameter { flag w; int a, b; @@ -34,6 +35,7 @@ public class Baw { public void doTheBaw( Voo v ) { v = new Voo(); } } +*/ public class Foo { flag f; @@ -43,6 +45,7 @@ public class Foo { public Foo x; public Foo y; + /* public void ruinSomeFoos( Foo a, Foo b ) { a.x = b.x; } @@ -57,6 +60,7 @@ public class Foo { p1.x = f1; p1.x = f2; } + */ } @@ -68,7 +72,7 @@ task Startup( StartupObject s{ initialstate } ) { taskexit( s{ !initialstate } ); } - +/* task NewObjectA( Foo a{ f }, Foo b{ f } ) { Foo c = new Foo(); @@ -90,9 +94,15 @@ task NewObjectB( Foo a{ f }, Foo b{ f } ) { taskexit( a{ !f }, b{ !f } ); } +*/ +/* task NewObjectC( Foo a{ f }, Foo b{ f } ) { + Foo z = new Foo(); + a.x = z; + a.y = z; + Foo c; while( false ) { @@ -104,9 +114,32 @@ task NewObjectC( Foo a{ f }, Foo b{ f } ) { taskexit( a{ !f }, b{ !f } ); } +*/ + + +task forMethod( Foo p0{ f } ) { + + Foo a0; + Foo a1; + + while( false ) { + a1 = a0; + if( false ) { + a0 = new Foo(); + } + } + + Foo z = new Foo(); + a1.x = z; + z.x = a1; + + + taskexit( p0{ !f } ); +} +/* // this task allocates a new object, so there should // be a heap region for the parameter, and several // heap regions for the allocation site, but the label @@ -229,3 +262,4 @@ task methodTest( Foo p0{ f } ) { taskexit( p0{ !f } ); } +*/ -- 2.34.1