From 1fcd81450a20cad7c2e2d24d0225dc2034e30824 Mon Sep 17 00:00:00 2001 From: jjenista Date: Wed, 2 Jul 2008 18:37:05 +0000 Subject: [PATCH] Starting to integrate reachability classes into ownership. --- .../OwnershipAnalysis/HeapRegionNode.java | 27 ++++++++--- .../OwnershipAnalysis/OwnershipGraph.java | 45 ++++++++++++++----- .../OwnershipAnalysis/ReachabilitySet.java | 23 ++++++++-- .../OwnershipAnalysisTest/test01/makefile | 4 +- 4 files changed, 76 insertions(+), 23 deletions(-) diff --git a/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java b/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java index 55774b53..1e28f904 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java +++ b/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java @@ -17,21 +17,25 @@ public class HeapRegionNode extends OwnershipNode { protected AllocationSite allocSite; + protected ReachabilitySet alpha; + protected String description; - public HeapRegionNode( Integer id, - boolean isSingleObject, - boolean isFlagged, - boolean isNewSummary, - AllocationSite allocSite, - String description ) { + public HeapRegionNode( Integer id, + boolean isSingleObject, + boolean isFlagged, + boolean isNewSummary, + AllocationSite allocSite, + ReachabilitySet alpha, + String description ) { this.id = id; this.isSingleObject = isSingleObject; this.isFlagged = isFlagged; this.isNewSummary = isNewSummary; this.allocSite = allocSite; + this.alpha = alpha; this.description = description; referencers = new HashSet(); @@ -44,6 +48,7 @@ public class HeapRegionNode extends OwnershipNode { isFlagged, isNewSummary, allocSite, + alpha, description ); } @@ -110,10 +115,20 @@ public class HeapRegionNode extends OwnershipNode { return allocSite; } + + public ReachabilitySet getAlpha() { + return alpha; + } + + public String getIDString() { return id.toString(); } + public String getAlphaString() { + return alpha.toStringEscapeNewline(); + } + public String toString() { return "HRN"+getIDString(); } diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java index e58dff7f..39fa29d8 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java @@ -25,8 +25,8 @@ public class OwnershipGraph { public HashSet allocationSites; // CHANGE! Map HRN ID's to token sets (sets of IDs!) - public Hashtable< HeapRegionNode, HashSet< HashSet > > alpha; - //public Hashtable< touple< HRN, HRN >, HashSet< HashSet > > beta; + //public Hashtable< HeapRegionNode, HashSet< HashSet > > alpha; + //public Hashtable< touple< HRN, HRN >, HashSet< HashSet > > beta; public OwnershipGraph( int allocationDepth ) { @@ -39,7 +39,7 @@ public class OwnershipGraph { allocationSites = new HashSet (); - alpha = new Hashtable< HeapRegionNode, HashSet< HashSet > >(); + //alpha = new Hashtable< HeapRegionNode, HashSet< HashSet > >(); } @@ -67,22 +67,35 @@ public class OwnershipGraph { // in the merge() operation) or to create new heap // regions with a new unique ID. protected HeapRegionNode - createNewHeapRegionNode( Integer id, - boolean isSingleObject, - boolean isFlagged, - boolean isNewSummary, - AllocationSite allocSite, - String description ) { + createNewHeapRegionNode( Integer id, + boolean isSingleObject, + boolean isFlagged, + boolean isNewSummary, + boolean isParameter, + AllocationSite allocSite, + ReachabilitySet alpha, + String description ) { if( id == null ) { id = OwnershipAnalysis.generateUniqueHeapRegionNodeID(); } + if( alpha == null ) { + if( isFlagged || isParameter ) { + alpha = new ReachabilitySet( new TokenTuple( id, + isNewSummary, + TokenTuple.ARITY_ONE ) ); + } else { + alpha = new ReachabilitySet(); + } + } + HeapRegionNode hrn = new HeapRegionNode( id, isSingleObject, isFlagged, isNewSummary, allocSite, + alpha, description ); id2hrn.put( id, hrn ); return hrn; @@ -242,6 +255,8 @@ public class OwnershipGraph { false, isTask, false, + true, + null, null, "param" + paramIndex ); @@ -347,7 +362,9 @@ public class OwnershipGraph { false, hasFlags, true, + false, as, + null, as + "\\n" + as.getType() + "\\nsummary" ); for( int i = 0; i < as.getAllocationDepth(); ++i ) { @@ -357,7 +374,9 @@ public class OwnershipGraph { true, hasFlags, false, + false, as, + null, as + "\\n" + as.getType() + "\\n" + i + " oldest" ); } } @@ -650,7 +669,7 @@ public class OwnershipGraph { mergeReferenceEdges ( og ); mergeId2paramIndex ( og ); mergeAllocationSites( og ); - mergeTokenSets ( og ); + //mergeTokenSets ( og ); } protected void mergeOwnershipNodes( OwnershipGraph og ) { @@ -819,7 +838,7 @@ public class OwnershipGraph { - protected void mergeTokenSets( OwnershipGraph og ) { + //protected void mergeTokenSets( OwnershipGraph og ) { // alpha = new Hashtable< HeapRegionNode, HashSet< HashSet > >(); // if a key is in one or the other token set, @@ -844,7 +863,7 @@ public class OwnershipGraph { } } */ - } + //} @@ -1374,6 +1393,8 @@ public class OwnershipGraph { hrn.getID() + "\\n" + hrn.getDescription() + + "\\n" + + hrn.getAlphaString() + "\"]"; bw.write( " " + hrn.toString() + attributes + ";\n" ); diff --git a/Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java b/Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java index 83d6bfce..972e3d5b 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java +++ b/Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java @@ -19,6 +19,10 @@ public class ReachabilitySet { possibleReachabilities.add( tts ); } + public ReachabilitySet( TokenTuple tt ) { + this( new TokenTupleSet( tt ) ); + } + public ReachabilitySet( ReachabilitySet rs ) { possibleReachabilities = (HashSet) rs.possibleReachabilities.clone(); // again, DEEP COPY?! } @@ -82,9 +86,7 @@ public class ReachabilitySet { if( !theUnion.isEmpty() ) { ctsOut = ctsOut.union( - new ChangeTupleSet( - new ChangeTuple( o, theUnion ) - ) + new ChangeTupleSet( new ChangeTuple( o, theUnion ) ) ); } } @@ -93,6 +95,21 @@ public class ReachabilitySet { return ctsOut; } + + public String toStringEscapeNewline() { + String s = "["; + + Iterator i = this.iterator(); + while( i.hasNext() ) { + s += "\\n "+i.next(); + } + + s += "]"; + + return s; + } + + public String toString() { String s = "["; diff --git a/Robust/src/Tests/OwnershipAnalysisTest/test01/makefile b/Robust/src/Tests/OwnershipAnalysisTest/test01/makefile index 650e7e72..37e72086 100644 --- a/Robust/src/Tests/OwnershipAnalysisTest/test01/makefile +++ b/Robust/src/Tests/OwnershipAnalysisTest/test01/makefile @@ -9,10 +9,10 @@ BSFLAGS= -recover -flatirtasks -ownership -enable-assertions all: $(PROGRAM).bin view: PNGs - eog *flatIRGraph*.png & + #eog *flatIRGraph*.png & #eog *FN*.png & #eog *Ownership*.png & - eog *.png & + eog *COMPLETE*.png & printable: rm -f *Startup*.dot -- 2.34.1