From fab04c072b2b3dc57e8c5ea894e0f872dc474d9a Mon Sep 17 00:00:00 2001 From: jjenista Date: Mon, 31 Mar 2008 20:47:54 +0000 Subject: [PATCH] Altered ownership graph to dot file by removing label nodes, marking allocation site nodes with the object type, numbering heap regions allocated for a parameter by the parameter index and tested that initial parameter relfexive edges get clobbered by code that introduces a self-reference. --- .../OwnershipAnalysis/AllocationSite.java | 10 +++++++-- .../OwnershipAnalysis/OwnershipAnalysis.java | 2 +- .../OwnershipAnalysis/OwnershipGraph.java | 19 ++++++++++------ .../test01/MAKESURETOTESTTHIS | 3 --- .../OwnershipAnalysisTest/test01/test01.java | 22 ++++++++++++------- .../OwnershipAnalysisTest/test02/test02.java | 7 +----- 6 files changed, 36 insertions(+), 27 deletions(-) delete mode 100644 Robust/src/Tests/OwnershipAnalysisTest/test01/MAKESURETOTESTTHIS diff --git a/Robust/src/Analysis/OwnershipAnalysis/AllocationSite.java b/Robust/src/Analysis/OwnershipAnalysis/AllocationSite.java index c98b6500..469fc425 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/AllocationSite.java +++ b/Robust/src/Analysis/OwnershipAnalysis/AllocationSite.java @@ -27,12 +27,14 @@ public class AllocationSite { protected int allocationDepth; protected Vector ithOldest; protected Integer summary; + protected TypeDescriptor type; - public AllocationSite( int allocationDepth ) { + public AllocationSite( int allocationDepth, TypeDescriptor type ) { assert allocationDepth >= 3; this.allocationDepth = allocationDepth; + this.type = type; ithOldest = new Vector( allocationDepth ); id = generateUniqueAllocationSiteID(); @@ -72,7 +74,11 @@ public class AllocationSite { return summary; } + public TypeDescriptor getType() { + return type; + } + public String toString() { - return "allocSite" + id; + return "allocSite" + id + "\\n" + type; } } diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java index 48664522..894674ec 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java @@ -379,7 +379,7 @@ public class OwnershipAnalysis { // return just the allocation site associated with one FlatNew node private AllocationSite getAllocationSiteFromFlatNew( FlatNew fn ) { if( !mapFlatNewToAllocationSite.containsKey( fn ) ) { - AllocationSite as = new AllocationSite( allocationDepth ); + AllocationSite as = new AllocationSite( allocationDepth, fn.getType() ); // the newest nodes are single objects for( int i = 0; i < allocationDepth; ++i ) { diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java index fc5cb76a..4e711b49 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java @@ -230,7 +230,7 @@ public class OwnershipGraph { false, isTask, false, - "param" ); + "param" + paramIndex ); // keep track of heap regions that were created for // parameter labels, the index of the parameter they @@ -318,7 +318,7 @@ public class OwnershipGraph { if( hrnSummary == null ) { hrnSummary = createNewHeapRegionNode( idSummary, false, - false, + as.getType().getClassDesc().hasFlags(), true, as + "\\nsummary" ); } @@ -332,7 +332,7 @@ public class OwnershipGraph { if( hrnK == null ) { hrnK = createNewHeapRegionNode( idK, true, - false, + as.getType().getClassDesc().hasFlags(), false, as + "\\noldest" ); } @@ -395,14 +395,14 @@ public class OwnershipGraph { if( hrnI == null ) { hrnI = createNewHeapRegionNode( idIth, true, - false, + as.getType().getClassDesc().hasFlags(), false, as + "\\n" + Integer.toString( i ) + "th" ); } if( hrnImin1 == null ) { hrnImin1 = createNewHeapRegionNode( idImin1th, true, - false, + as.getType().getClassDesc().hasFlags(), false, as + "\\n" + Integer.toString( i-1 ) + "th" ); } @@ -1087,16 +1087,19 @@ public class OwnershipGraph { - /* + // use this method to determine if two temp descriptors can possibly // access the same heap regions, which means there is a possible alias public boolean havePossibleAlias( TempDescriptor td1, TempDescriptor td2 ) { + LabelNode ln1 = getLabelNodeFromTemp( td1 ); + LabelNode ln2 = getLabelNodeFromTemp( td2 ); + return false; } - */ + // for writing ownership graphs to dot files @@ -1139,6 +1142,7 @@ public class OwnershipGraph { } // then visit every label node + /* s = td2ln.entrySet(); i = s.iterator(); while( i.hasNext() ) { @@ -1162,6 +1166,7 @@ public class OwnershipGraph { "\"];\n" ); } } + */ bw.write( "}\n" ); bw.close(); diff --git a/Robust/src/Tests/OwnershipAnalysisTest/test01/MAKESURETOTESTTHIS b/Robust/src/Tests/OwnershipAnalysisTest/test01/MAKESURETOTESTTHIS deleted file mode 100644 index 2fb91b11..00000000 --- a/Robust/src/Tests/OwnershipAnalysisTest/test01/MAKESURETOTESTTHIS +++ /dev/null @@ -1,3 +0,0 @@ -Make sure to test that an initial parameter has a special reflexive edge, but if you -actually remake that edge during the method analysis, it becomes a regular edge and -then will get picked up by the method call resolution! diff --git a/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java b/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java index 483c3e31..26050fc7 100644 --- a/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java +++ b/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java @@ -1,4 +1,4 @@ -/* + public class Parameter { flag w; int a, b; @@ -18,23 +18,22 @@ public class Penguin { public void bar() { x = 1; } } -*/ -/* public class Voo { - flag f; int x; Baw b; + flag f; int x; Baw b; Baw bb; public Voo() {} } public class Baw { flag g; int y; + Foo f; public Baw() {} public void doTheBaw( Voo v ) { v = new Voo(); } } -*/ + public class Foo { public Foo() {} @@ -65,7 +64,7 @@ task Startup( StartupObject s{ initialstate } ) { // be a heap region for the parameter, and several // heap regions for the allocation site, but the label // merely points to the newest region -/* + task NewObject( Voo v{ f } ) { Voo w = new Voo(); Baw b = new Baw(); @@ -90,13 +89,20 @@ task Branch( Voo v{ f } ) { } -task NewInLoop( Voo v{ f } ) { +task NoAliasNewInLoop( Voo v{ f } ) { Voo w = new Voo(); for( int i = 0; i < 10; ++i ) { w.b = new Baw(); + w.b.f = new Foo(); } taskexit( v{ !f } ); } -*/ + + +task ClobberInitParamReflex( Voo v{ f }, Voo w{ f } ) { + v.b = v.bb; + + taskexit( v{ !f }, w{ !f } ); +} \ No newline at end of file diff --git a/Robust/src/Tests/OwnershipAnalysisTest/test02/test02.java b/Robust/src/Tests/OwnershipAnalysisTest/test02/test02.java index 1e03e52c..118668d2 100644 --- a/Robust/src/Tests/OwnershipAnalysisTest/test02/test02.java +++ b/Robust/src/Tests/OwnershipAnalysisTest/test02/test02.java @@ -41,7 +41,7 @@ task Startup( StartupObject s{ initialstate } ) { taskexit( s{ !initialstate } ); } -/* + task aliasFromObjectAssignment ( Parameter p1{!w}, Parameter p2{!w} ) { @@ -103,9 +103,7 @@ task possibleAliasConditional taskexit( p1{w}, p2{w} ); } -*/ -/* task bunchOfPaths ( Parameter p1{!w}, Parameter p2{!w} ) { @@ -138,9 +136,7 @@ task bunchOfPaths taskexit( p1{w}, p2{w} ); } -*/ -/* task literalTest( Parameter p1{!w} ) { Parameter x = null; int y = 5; @@ -177,4 +173,3 @@ task newPossibleAlias taskexit( p1{w}, p2{w} ); } -*/ \ No newline at end of file -- 2.34.1