From: jjenista Date: Wed, 28 Nov 2007 23:16:37 +0000 (+0000) Subject: Ownership analysis handles assignment, field setting and assignment X-Git-Tag: preEdgeChange~352 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=066848ace7309d22c0873edeea1d664709827a22;p=IRC.git Ownership analysis handles assignment, field setting and assignment to fields. The resulting condensed analysis identifies alias between task parameters, if any. --- diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java index bccf240a..3109b66f 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java @@ -15,7 +15,7 @@ public class OwnershipGraph { protected static int labelNodeIDs = 0; public Hashtable td2ln; - protected Vector analysisRegionLabels; + public Vector analysisRegionLabels; protected Hashtable linkedRegions; protected static final int VISIT_OHRN_WRITE_FULL = 0; @@ -259,6 +259,13 @@ public class OwnershipGraph { heapRoots.put( idA, ohrnB ); } } + + // also merge the analysis regions + for( int i = 0; i < og.analysisRegionLabels.size(); ++i ) { + if( !analysisRegionLabels.contains( og.analysisRegionLabels.get( i ) ) ) { + analysisRegionLabels.add( og.analysisRegionLabels.get( i ) ); + } + } } // see notes for merge() above about how to equate @@ -382,7 +389,7 @@ public class OwnershipGraph { } } - // finally check if the heapRoots are equivalent + // check if the heapRoots are equivalent sA = og.heapRoots.entrySet(); iA = sA.iterator(); while( iA.hasNext() ) { @@ -395,6 +402,17 @@ public class OwnershipGraph { } } + // check that the analysis regions are equivalent, note + // that they can be in a different order + if( og.analysisRegionLabels.size() != analysisRegionLabels.size() ) { + return false; + } + for( int i = 0; i < og.analysisRegionLabels.size(); ++i ) { + if( !analysisRegionLabels.contains( og.analysisRegionLabels.get( i ) ) ) { + return false; + } + } + return true; } @@ -436,19 +454,18 @@ public class OwnershipGraph { BufferedWriter bw = new BufferedWriter( new FileWriter( graphName+".dot" ) ); bw.write( "graph "+graphName+" {\n" ); - HashSet visited = new HashSet(); - // find linked regions for( int i = 0; i < analysisRegionLabels.size(); ++i ) { TempDescriptor td = analysisRegionLabels.get( i ); bw.write( " "+td.getSymbol()+";\n" ); OwnershipLabelNode oln = getLabelNodeFromTemp( td ); + HashSet visited = new HashSet(); + OwnershipHeapRegionNode ohrn = null; Iterator heapRegionsItr = oln.iteratorToReachableRegions(); while( heapRegionsItr.hasNext() ) { ohrn = (OwnershipHeapRegionNode)heapRegionsItr.next(); - traverseHeapNodes( VISIT_OHRN_WRITE_CONDENSED, ohrn, bw, td, visited ); } } @@ -467,17 +484,6 @@ public class OwnershipGraph { bw.close(); } - /* - protected void traverseHeapNodesTop( int mode, - OwnershipHeapRegionNode ohrn, - BufferedWriter bw, - TempDescriptor td - ) throws java.io.IOException { - HashSet visited = new HashSet(); - traverseHeapNodes( mode, ohrn, bw, td, visited ); - } - */ - protected void traverseHeapNodes( int mode, OwnershipHeapRegionNode ohrn, BufferedWriter bw, @@ -491,7 +497,28 @@ public class OwnershipGraph { bw.write( " "+ohrn.toString()+"[shape=box];\n" ); break; - case VISIT_OHRN_WRITE_CONDENSED: + case VISIT_OHRN_WRITE_CONDENSED: + Vector aliases = ohrn.getAnalysisRegionAliases(); + for( int i = 0; i < aliases.size(); ++i ) { + TempDescriptor tdn = aliases.get( i ); + + // only add a linked region if the td passed in and + // the td's aliased to this node haven't already been + // added as linked regions + TempDescriptor tdAlias = null; + if( linkedRegions.containsKey( td ) ) { + tdAlias = linkedRegions.get( td ); + } + + TempDescriptor tdnAlias = null; + if( linkedRegions.containsKey( tdn ) ) { + tdnAlias = linkedRegions.get( tdn ); + } + + if( tdn != tdAlias && td != tdnAlias ) { + linkedRegions.put( td, tdn ); + } + } ohrn.addAnalysisRegionAlias( td ); break; } @@ -505,29 +532,7 @@ public class OwnershipGraph { case VISIT_OHRN_WRITE_FULL: bw.write( " "+ohrn.toString()+" -> "+ohrnChild.toString()+";\n" ); break; - - case VISIT_OHRN_WRITE_CONDENSED: - Vector aliases = ohrnChild.getAnalysisRegionAliases(); - for( int i = 0; i < aliases.size(); ++i ) { - TempDescriptor tdn = aliases.get( i ); - - // only add this alias if it has not been already added - TempDescriptor tdAlias = null; - if( linkedRegions.containsKey( td ) ) { - tdAlias = linkedRegions.get( td ); - } - - TempDescriptor tdnAlias = null; - if( linkedRegions.containsKey( tdn ) ) { - tdnAlias = linkedRegions.get( tdn ); - } - - if( tdn != tdAlias && td != tdnAlias ) { - linkedRegions.put( td, tdn ); - } - } - break; - } + } if( !visited.contains( ohrnChild ) ) { traverseHeapNodes( mode, ohrnChild, bw, td, visited );