public HeapRegionNode( Integer id,
boolean isSingleObject,
boolean isFlagged,
- boolean isNewSummary ) {
+ boolean isNewSummary,
+ String description ) {
this.id = id;
this.isSingleObject = isSingleObject;
this.isFlagged = isFlagged;
this.isNewSummary = isNewSummary;
+ this.description = description;
referencers = new HashSet<OwnershipNode>();
//analysisRegionAliases = new HashSet<TempDescriptor>();
return new HeapRegionNode( id,
isSingleObject,
isFlagged,
- isNewSummary );
+ isNewSummary,
+ description );
}
return id.equals( hrn.getID() ) &&
isSingleObject == hrn.isSingleObject() &&
isFlagged == hrn.isFlagged() &&
- isNewSummary == hrn.isNewSummary();
+ isNewSummary == hrn.isNewSummary() &&
+ description.equals( hrn.getDescription() );
}
/////////////////
// end equality
// for writing out
+ String description;
+
public String getIDString() {
return id.toString();
}
public String toString() {
return "HRN"+getIDString();
}
+
+ public String getDescription() {
+ return description;
+ }
}
createNewHeapRegionNode( Integer id,
boolean isSingleObject,
boolean isFlagged,
- boolean isNewSummary ) {
+ boolean isNewSummary,
+ String description ) {
if( id == null ) {
id = OwnershipAnalysis.generateUniqueHeapRegionNodeID();
HeapRegionNode hrn = new HeapRegionNode( id,
isSingleObject,
isFlagged,
- isNewSummary );
+ isNewSummary,
+ description );
id2hrn.put( id, hrn );
return hrn;
}
assert td != null;
LabelNode lnParam = getLabelNodeFromTemp( td );
- HeapRegionNode hrn = createNewHeapRegionNode( null, false, isTask, false );
- heapRoots.put( hrn.getID(), hrn );
+ HeapRegionNode hrn = createNewHeapRegionNode( null, false, isTask, false, "param" );
+ //heapRoots.put( hrn.getID(), hrn );
addReferenceEdge( lnParam, hrn, new ReferenceEdgeProperties( false ) );
addReferenceEdge( hrn, hrn, new ReferenceEdgeProperties( false ) );
// in different ownership graphs that represents the same part of an
// allocation site
if( hrnSummary == null ) {
- hrnSummary = createNewHeapRegionNode( idSummary, false, false, true );
+ hrnSummary = createNewHeapRegionNode( idSummary, false, false, true, "summary" );
}
// first transfer the references out of alpha_k to alpha_s
// see comment above about needing to allocate a heap region
// for the context of this ownership graph
if( hrnK == null ) {
- hrnK = createNewHeapRegionNode( idK, true, false, false );
+ hrnK = createNewHeapRegionNode( idK, true, false, false, "alpha" );
}
HeapRegionNode hrnReferencee = null;
// see comment above about needing to allocate a heap region
// for the context of this ownership graph
if( hrnI == null ) {
- hrnI = createNewHeapRegionNode( idIth, true, false, false );
+ hrnI = createNewHeapRegionNode( idIth, true, false, false, "alpha" );
}
if( hrnImin1 == null ) {
- hrnImin1 = createNewHeapRegionNode( idImin1th, true, false, false );
+ hrnImin1 = createNewHeapRegionNode( idImin1th, true, false, false, "alpha" );
}
// clear references in and out of node i
mergeOwnershipNodes ( og );
mergeReferenceEdges ( og );
- mergeHeapRoots ( og );
+ //mergeHeapRoots ( og );
//mergeAnalysisRegions( og );
//mergeNewClusters ( og );
}
}
}
+ /*
protected void mergeHeapRoots( OwnershipGraph og ) {
Set sA = og.heapRoots.entrySet();
Iterator iA = sA.iterator();
}
}
}
+ */
/*
protected void mergeAnalysisRegions( OwnershipGraph og ) {
return false;
}
+ /*
if( !areHeapRootsEqual( og ) ) {
return false;
}
+ */
/*
if( !areAnalysisRegionLabelsEqual( og ) ) {
return true;
}
+ /*
protected boolean areHeapRootsEqual( OwnershipGraph og ) {
if( og.heapRoots.size() != heapRoots.size() ) {
return false;
return true;
}
+ */
+
/*
protected boolean areAnalysisRegionLabelsEqual( OwnershipGraph og ) {
// then visit every heap region node
HashSet<HeapRegionNode> visited = new HashSet<HeapRegionNode>();
- Set s = heapRoots.entrySet();
+ //Set s = heapRoots.entrySet();
+ Set s = id2hrn.entrySet();
Iterator i = s.iterator();
while( i.hasNext() ) {
Map.Entry me = (Map.Entry) i.next();
HeapRegionNode hrn = (HeapRegionNode) me.getValue();
- traverseHeapRegionNodes( VISIT_HRN_WRITE_FULL, hrn, bw, null, visited );
+ if( !visited.contains( hrn ) ) {
+ traverseHeapRegionNodes( VISIT_HRN_WRITE_FULL, hrn, bw, null, visited );
+ }
}
// then visit every label node
switch( mode ) {
case VISIT_HRN_WRITE_FULL:
- String isSingleObjectStr = "isSingleObject";
+ String isSingleObjectStr = "Single";
if( !hrn.isSingleObject() ) {
- isSingleObjectStr = "!isSingleObject";
+ isSingleObjectStr = "!Single";
}
- String isFlaggedStr = "isFlagged";
+ String isFlaggedStr = "Flagged";
if( !hrn.isFlagged() ) {
- isFlaggedStr = "!isFlagged";
+ isFlaggedStr = "!Flagged";
}
- String isNewSummaryStr = "isNewSummary";
+ String isNewSummaryStr = "Summary";
if( !hrn.isNewSummary() ) {
- isNewSummaryStr = "!isNewSummary";
+ isNewSummaryStr = "!Summary";
}
- bw.write( " " + hrn.toString() +
- "[shape=box,label=\"" + isFlaggedStr +
- "\\n" + isSingleObjectStr +
- "\\n" + isNewSummaryStr +
+ bw.write( " " + hrn.toString() +
+ "[shape=box,label=\"" + hrn.getDescription() +
+ "\\n" + isFlaggedStr +
+ "\\n" + isSingleObjectStr +
+ "\\n" + isNewSummaryStr +
"\"];\n" );
break;
*/
}
+ /*
OwnershipNode onRef = null;
Iterator refItr = hrn.iteratorToReferencers();
while( refItr.hasNext() ) {
break;
}
}
-
+ */
HeapRegionNode hrnChild = null;
Iterator childRegionsItr = hrn.setIteratorToReferencedRegions();
--- /dev/null
+test01
+ This test program contains many tasks that
+individually illustrate the correctness of different
+ownership analysis elements. The program source code
+includes comments that describe what the final ownership
+graphs for each task should be. These are sort of like
+unit tests for the individual operations performed during
+ownership analysis.
+
+test02
+ This test program contains many tasks that are
+named to indicate whether they purposefully create aliases
+or not. This test comes from the top-down approach to see
+that the individual operations of the ownership analysis
+work together to produce the correct results.
+
+testGraph
+ This test program puts some ownership graph
+objects and some supporting data in a vacuum to test
+the critical merge() and equals() members.
all: $(PROGRAM).bin
view: PNGs
- #eog *flatIRGraph*.png &
+ eog *flatIRGraph*.png &
#eog *FN*.png &
#eog *Ownership*.png &
eog *.png &
rm -f *FlatCall*.dot
rm -f *Parameter*.dot
rm -f *Penguin*.dot
+ rm -f *Voo*.dot
+ rm -f *Baw*.dot
d2p *.dot
DOTs: $(PROGRAM).bin
+/*
public class Parameter {
flag w;
int a, b;
public void bar() { x = 1; }
}
+*/
-task Startup( StartupObject s{ initialstate } ) {
-
- /*
- Parameter p = new Parameter(){!w};
- p.foo();
-
- Penguin g = new Penguin();
- g.bar();
- */
-
- Parameter p;
-
- for( int i = 0; i < 3; ++i ) {
- p = new Parameter();
- p.penguin = new Penguin();
- p.penguin.bar();
- }
-
- p = null;
-
- taskexit( s{ !initialstate } );
-}
-
-/*
-task aliasFromObjectAssignment
- ( Parameter p1{!w}, Parameter p2{!w} ) {
-
- p1.f = p2.g;
-
- taskexit( p1{w}, p2{w} );
-}
-
-task noAliasFromPrimitiveAssignment
- ( Parameter p1{!w}, Parameter p2{!w} ) {
-
- p1.a = p2.b;
+public class Voo {
+ flag f; int x; Baw b;
- taskexit( p1{w}, p2{w} );
+ public Voo() {}
}
-task aliasWithTwoLinks
- ( Parameter p1{!w}, Parameter p2{!w} ) {
-
- Parameter j = p1.f;
- p2.f = j;
+public class Baw {
+ flag g; int y;
- taskexit( p1{w}, p2{w} );
+ public Baw() {}
}
-task aliasWithThreeLinks
- ( Parameter p1{!w}, Parameter p2{!w} ) {
-
- Parameter j = p1.f;
- Parameter k = j;
- p2.f = k;
- taskexit( p1{w}, p2{w} );
+// this empty task should still create a non-empty
+// ownership graph showing parameter allocation
+// look for the parameter s as a label referencing
+// a heap region that is multi-object, flagged, not summary
+task Startup( StartupObject s{ initialstate } ) {
+ taskexit( s{ !initialstate } );
}
-task noAliasBreakLinks
- ( Parameter p1{!w}, Parameter p2{!w} ) {
-
- Parameter j = p1.f;
- Parameter k = j;
- k = p2.f;
- p2.f = k;
+// 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
+// merely points to the newest region
+task NewObject( Voo v{ f } ) {
+ Voo w = new Voo();
- taskexit( p1{w}, p2{w} );
+ taskexit( v{ !f } );
}
-task possibleAliasConditional
- ( Parameter p1{!w}, Parameter p2{!w} ) {
-
- Parameter y;
+// this task
+task Branch( Voo v{ f } ) {
+ Voo w = new Voo();
+ Baw j = new Baw();
+ Baw k = new Baw();
- if( p1.a == 0 ) {
- y = p1.f;
+ if( v.x == 0 ) {
+ w.b = j;
} else {
- y = p2.f;
- }
-
- p2.g = y;
-
- taskexit( p1{w}, p2{w} );
-}
-*/
-
-/*
-task bunchOfPaths
- ( Parameter p1{!w}, Parameter p2{!w} ) {
-
- Parameter y;
-
- for( int i =0; i < 100; ++i ) {
-
- if( y == p1 ) {
- Parameter z;
-
- for( int j = 0; i < 50; ++j ) {
- if( z == y ) {
- p1.f = y;
- } else {
- z = p2.g;
- }
-
- p1.f = z;
- }
-
- y = p1.g;
- } else {
-
- p2.f = y;
- }
+ w.b = k;
}
- p1.f = p2.g;
-
-
- taskexit( p1{w}, p2{w} );
+ taskexit( v{ !f } );
}
-*/
-
-/*
-task literalTest( Parameter p1{!w} ) {
- Parameter x = null;
- int y = 5;
- String s = "Dude";
- taskexit( p1{w} );
-}
-task newNoAlias
- ( Parameter p1{!w}, Parameter p2{!w} ) {
+task NewInLoop( Voo v{ f } ) {
+ Voo w = new Voo();
- for( int i = 0; i < 1; ++i ) {
- p1.f = new Parameter();
+ for( int i = 0; i < 10; ++i ) {
+ w.b = new Baw();
}
- taskexit( p1{w}, p2{w} );
-}
-
-task newPossibleAlias
- ( Parameter p1{!w}, Parameter p2{!w} ) {
-
- Parameter x, y;
-
- for( int i = 0; i < 1; ++i ) {
- p1.f = new Parameter();
- if( true ) {
- x = p1.f;
- } else {
- y = p1.f;
- }
- }
-
- p2.f = y;
-
- taskexit( p1{w}, p2{w} );
+ taskexit( v{ !f } );
}
-*/
\ No newline at end of file
--- /dev/null
+PROGRAM=test02
+
+SOURCE_FILES=test02.java
+
+BUILDSCRIPT=~/research/Robust/src/buildscript
+BSFLAGS= -recover -flatirtasks -ownership -enable-assertions
+#BSFLAGS= -recover -ownership -enable-assertions
+
+all: $(PROGRAM).bin
+
+view: PNGs
+ #eog *flatIRGraph*.png &
+ #eog *FN*.png &
+ #eog *Ownership*.png &
+ eog *.png &
+
+PNGs: DOTs
+ #rm -f *Startup*.dot
+ rm -f *FlatMethod*.dot
+ rm -f *FlatOpNode*.dot
+ rm -f *FlatFieldNode*.dot
+ rm -f *FlatSetFieldNode*.dot
+ rm -f *FlatCall*.dot
+ rm -f *Parameter*.dot
+ rm -f *Penguin*.dot
+ d2p *.dot
+
+DOTs: $(PROGRAM).bin
+
+$(PROGRAM).bin: $(SOURCE_FILES)
+ $(BUILDSCRIPT) $(BSFLAGS) -o $(PROGRAM) $(SOURCE_FILES)
+
+clean:
+ rm -f $(PROGRAM).bin
+ rm -fr tmpbuilddirectory
+ rm -f *~
+ rm -f *.dot
+ rm -f *.png
--- /dev/null
+public class Parameter {
+ flag w;
+ int a, b;
+ Parameter f, g;
+ Penguin penguin;
+
+ public Parameter() { a = 0; b = 0; f = null; g = null; }
+
+ public void bar() { foo(); }
+ public void foo() { bar(); }
+}
+
+public class Penguin {
+ int x, y;
+
+ public Penguin() { x = 0; y = 0; }
+
+ public void bar() { x = 1; }
+}
+
+task Startup( StartupObject s{ initialstate } ) {
+
+ /*
+ Parameter p = new Parameter(){!w};
+ p.foo();
+
+ Penguin g = new Penguin();
+ g.bar();
+ */
+
+ Parameter p;
+
+ for( int i = 0; i < 3; ++i ) {
+ p = new Parameter();
+ p.penguin = new Penguin();
+ p.penguin.bar();
+ }
+
+ p = null;
+
+ taskexit( s{ !initialstate } );
+}
+
+/*
+task aliasFromObjectAssignment
+ ( Parameter p1{!w}, Parameter p2{!w} ) {
+
+ p1.f = p2.g;
+
+ taskexit( p1{w}, p2{w} );
+}
+
+task noAliasFromPrimitiveAssignment
+ ( Parameter p1{!w}, Parameter p2{!w} ) {
+
+ p1.a = p2.b;
+
+ taskexit( p1{w}, p2{w} );
+}
+
+task aliasWithTwoLinks
+ ( Parameter p1{!w}, Parameter p2{!w} ) {
+
+ Parameter j = p1.f;
+ p2.f = j;
+
+ taskexit( p1{w}, p2{w} );
+}
+
+task aliasWithThreeLinks
+ ( Parameter p1{!w}, Parameter p2{!w} ) {
+
+ Parameter j = p1.f;
+ Parameter k = j;
+ p2.f = k;
+
+ taskexit( p1{w}, p2{w} );
+}
+
+task noAliasBreakLinks
+ ( Parameter p1{!w}, Parameter p2{!w} ) {
+
+ Parameter j = p1.f;
+ Parameter k = j;
+ k = p2.f;
+ p2.f = k;
+
+ taskexit( p1{w}, p2{w} );
+}
+
+task possibleAliasConditional
+ ( Parameter p1{!w}, Parameter p2{!w} ) {
+
+ Parameter y;
+
+ if( p1.a == 0 ) {
+ y = p1.f;
+ } else {
+ y = p2.f;
+ }
+
+ p2.g = y;
+
+ taskexit( p1{w}, p2{w} );
+}
+*/
+
+/*
+task bunchOfPaths
+ ( Parameter p1{!w}, Parameter p2{!w} ) {
+
+ Parameter y;
+
+ for( int i =0; i < 100; ++i ) {
+
+ if( y == p1 ) {
+ Parameter z;
+
+ for( int j = 0; i < 50; ++j ) {
+ if( z == y ) {
+ p1.f = y;
+ } else {
+ z = p2.g;
+ }
+
+ p1.f = z;
+ }
+
+ y = p1.g;
+ } else {
+
+ p2.f = y;
+ }
+ }
+
+ p1.f = p2.g;
+
+
+ taskexit( p1{w}, p2{w} );
+}
+*/
+
+/*
+task literalTest( Parameter p1{!w} ) {
+ Parameter x = null;
+ int y = 5;
+ String s = "Dude";
+
+ taskexit( p1{w} );
+}
+
+task newNoAlias
+ ( Parameter p1{!w}, Parameter p2{!w} ) {
+
+ for( int i = 0; i < 1; ++i ) {
+ p1.f = new Parameter();
+ }
+
+ taskexit( p1{w}, p2{w} );
+}
+
+task newPossibleAlias
+ ( Parameter p1{!w}, Parameter p2{!w} ) {
+
+ Parameter x, y;
+
+ for( int i = 0; i < 1; ++i ) {
+ p1.f = new Parameter();
+ if( true ) {
+ x = p1.f;
+ } else {
+ y = p1.f;
+ }
+ }
+
+ p2.f = y;
+
+ taskexit( p1{w}, p2{w} );
+}
+*/
\ No newline at end of file