From: jjenista Date: Sat, 30 Aug 2008 17:50:44 +0000 (+0000) Subject: Put the rest of the top-level interface together X-Git-Tag: buildscript^6~70 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=35bf2a72f898db3f2ad94eb9d3e7c32d0874dbb7;p=IRC.git Put the rest of the top-level interface together --- diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java index 181764b6..25c7b206 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java @@ -54,28 +54,14 @@ public class OwnershipAnalysis { return og.hasPotentialAlias( paramIndex, alloc ); } - /* public boolean createsPotentialAliases( Descriptor taskOrMethod, AllocationSite alloc1, AllocationSite alloc2 ) { OwnershipGraph og = mapDescriptorToCompleteOwnershipGraph.get( taskOrMethod ); assert( og != null ); - return createsPotentialAliases( og, - getHeapRegionIDset( alloc1 ), - getHeapRegionIDset( alloc2 ) ); + return og.hasPotentialAlias( alloc1, alloc2 ); } - - public boolean createsPotentialAliases( Descriptor taskOrMethod, - AllocationSite alloc, - HashSet allocSet ) { - OwnershipGraph og = mapDescriptorToCompleteOwnershipGraph.get( taskOrMethod ); - assert( og != null ); - return createsPotentialAliases( og, - getHeapRegionIDset( alloc ), - getHeapRegionIDset( allocSet ) ); - } - */ // use the methods given above to check every possible alias // between task parameters and flagged allocation sites reachable @@ -89,6 +75,8 @@ public class OwnershipAnalysis { while( taskItr.hasNext() ) { TaskDescriptor td = (TaskDescriptor) taskItr.next(); + bw.write( "\n---------"+td+"--------\n" ); + HashSet allocSites = getFlaggedAllocationSitesReachableFromTask( td ); // for each task parameter, check for aliases with @@ -104,7 +92,7 @@ public class OwnershipAnalysis { for( int j = i + 1; j < fm.numParameters(); ++j ) { if( createsPotentialAliases( td, i, j ) ) { foundSomeAlias = true; - bw.write( "Task "+td+" potentially aliases parameters "+i+" and "+j+".\n" ); + bw.write( "Potential alias between parameters "+i+" and "+j+".\n" ); } } @@ -116,23 +104,31 @@ public class OwnershipAnalysis { AllocationSite as = (AllocationSite) allocItr.next(); if( createsPotentialAliases( td, i, as ) ) { foundSomeAlias = true; - bw.write( "Task "+td+" potentially aliases parameter "+i+" and "+as+".\n" ); + bw.write( "Potential alias between parameter "+i+" and "+as+".\n" ); } } } - /* // for each allocation site check for aliases with // other allocation sites in the context of execution // of this task - Iterator allocItr = allocSites.iterator(); - while( allocItr.hasNext() ) { - AllocationSite as = (AllocationSite) allocItr.next(); - if( createsPotentialAliases( td, as, allocSites ) ) { - bw.write( "Task "+td+" potentially aliases "+as+" and the rest of the set.\n" ); + HashSet outerChecked = new HashSet(); + Iterator allocItr1 = allocSites.iterator(); + while( allocItr1.hasNext() ) { + AllocationSite as1 = (AllocationSite) allocItr1.next(); + + Iterator allocItr2 = allocSites.iterator(); + while( allocItr2.hasNext() ) { + AllocationSite as2 = (AllocationSite) allocItr2.next(); + + if( !outerChecked.contains( as2 ) && + createsPotentialAliases( td, as1, as2 ) ) { + bw.write( "Potential alias between "+as1+" and "+as2+".\n" ); + } } + + outerChecked.add( as1 ); } - */ if( !foundSomeAlias ) { bw.write( "Task "+td+" contains no aliases between flagged objects.\n" ); @@ -717,78 +713,4 @@ public class OwnershipAnalysis { return asSetTotal; } - - - - private HashSet getHeapRegionIDset(OwnershipGraph og, - int paramIndex) { - - assert og.paramIndex2id.containsKey(paramIndex); - Integer idParam = og.paramIndex2id.get(paramIndex); - - HashSet idSet = new HashSet(); - idSet.add(idParam); - - return idSet; - } - - - private HashSet getHeapRegionIDset(AllocationSite alloc) { - - HashSet idSet = new HashSet(); - - for( int i = 0; i < alloc.getAllocationDepth(); ++i ) { - Integer id = alloc.getIthOldest(i); - idSet.add(id); - } - - Integer idSummary = alloc.getSummary(); - idSet.add(idSummary); - - return idSet; - } - - private HashSet getHeapRegionIDset(HashSet allocSet) { - - HashSet idSet = new HashSet(); - - Iterator allocItr = allocSet.iterator(); - while( allocItr.hasNext() ) { - AllocationSite alloc = (AllocationSite) allocItr.next(); - - for( int i = 0; i < alloc.getAllocationDepth(); ++i ) { - Integer id = alloc.getIthOldest(i); - idSet.add(id); - } - - Integer idSummary = alloc.getSummary(); - idSet.add(idSummary); - } - - return idSet; - } - - private boolean createsPotentialAliases(OwnershipGraph og, - HashSet idSetA, - HashSet idSetB) { - boolean potentialAlias = false; - - /* - // first expand set B into the set of all heap region node ID's - // reachable from the nodes in set B - HashSet idSetReachableFromB = og.getReachableSet( idSetB ); - - // then see if anything in A can reach a node in the set reachable - // from B. If so, there is a potential alias. - Iterator i = idSetA.iterator(); - while( i.hasNext() ) { - Integer id = (Integer) i.next(); - if( og.canIdReachSet( id, idSetB ) ) { - return true; - } - } - */ - - return false; - } } diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java index 7e8783a0..95b7a18a 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java @@ -2327,105 +2327,110 @@ public class OwnershipGraph { } - /* - // given a set B of heap region node ID's, return the set of heap - // region node ID's that is reachable from B - public HashSet getReachableSet( HashSet idSetB ) { - - HashSet toVisit = new HashSet(); - HashSet visited = new HashSet(); - - // initial nodes to visit are from set B - Iterator initialItr = idSetB.iterator(); - while( initialItr.hasNext() ) { - Integer idInitial = (Integer) initialItr.next(); - assert id2hrn.contains( idInitial ); - HeapRegionNode hrnInitial = id2hrn.get( idInitial ); - toVisit.add( hrnInitial ); - } - - HashSet idSetReachableFromB = new HashSet(); - - // do a heap traversal - while( !toVisit.isEmpty() ) { - HeapRegionNode hrnVisited = (HeapRegionNode) toVisit.iterator().next(); - toVisit.remove( hrnVisited ); - visited.add ( hrnVisited ); - - // for every node visited, add it to the total - // reachable set - idSetReachableFromB.add( hrnVisited.getID() ); - - // find other reachable nodes - Iterator referenceeItr = hrnVisited.setIteratorToReferencedRegions(); - while( referenceeItr.hasNext() ) { - Map.Entry me = (Map.Entry) referenceeItr.next(); - HeapRegionNode hrnReferencee = (HeapRegionNode) me.getKey(); - ReferenceEdgeProperties rep = (ReferenceEdgeProperties) me.getValue(); - - if( !visited.contains( hrnReferencee ) ) { - toVisit.add( hrnReferencee ); - } - } - } - - return idSetReachableFromB; - } - - - // used to find if a heap region can possibly have a reference to - // any of the heap regions in the given set - // if the id supplied is in the set, then a self-referencing edge - // would return true, but that special case is specifically allowed - // meaning that it isn't an external alias - public boolean canIdReachSet( Integer id, HashSet idSet ) { - - assert id2hrn.contains( id ); - HeapRegionNode hrn = id2hrn.get( id ); - - - //HashSet hrnSet = new HashSet(); - - //Iterator i = idSet.iterator(); - //while( i.hasNext() ) { - // Integer idFromSet = (Integer) i.next(); - // assert id2hrn.contains( idFromSet ); - // hrnSet.add( id2hrn.get( idFromSet ) ); - //} - - - // do a traversal from hrn and see if any of the - // heap regions from the set come up during that - HashSet toVisit = new HashSet(); - HashSet visited = new HashSet(); - - toVisit.add( hrn ); - while( !toVisit.isEmpty() ) { - HeapRegionNode hrnVisited = (HeapRegionNode) toVisit.iterator().next(); - toVisit.remove( hrnVisited ); - visited.add ( hrnVisited ); + public boolean hasPotentialAlias( AllocationSite as1, AllocationSite as2 ) { - Iterator referenceeItr = hrnVisited.setIteratorToReferencedRegions(); - while( referenceeItr.hasNext() ) { - Map.Entry me = (Map.Entry) referenceeItr.next(); - HeapRegionNode hrnReferencee = (HeapRegionNode) me.getKey(); - ReferenceEdgeProperties rep = (ReferenceEdgeProperties) me.getValue(); + // get tokens for summary nodes + TokenTuple gs1 = new TokenTuple(as1.getSummary(), + true, + TokenTuple.ARITY_ONE).makeCanonical(); + + TokenTuple gsStar1 = new TokenTuple(as1.getSummary(), + true, + TokenTuple.ARITY_MANY).makeCanonical(); + + // get summary node's alpha + Integer idSum1 = as1.getSummary(); + assert id2hrn.containsKey( idSum1 ); + HeapRegionNode hrnSum1 = id2hrn.get( idSum1 ); + assert hrnSum1 != null; + ReachabilitySet alphaSum1 = hrnSum1.getAlpha(); + assert alphaSum1 != null; + + + // and for the other one + TokenTuple gs2 = new TokenTuple(as2.getSummary(), + true, + TokenTuple.ARITY_ONE).makeCanonical(); + + TokenTuple gsStar2 = new TokenTuple(as2.getSummary(), + true, + TokenTuple.ARITY_MANY).makeCanonical(); + + // get summary node's alpha + Integer idSum2 = as2.getSummary(); + assert id2hrn.containsKey( idSum2 ); + HeapRegionNode hrnSum2 = id2hrn.get( idSum2 ); + assert hrnSum2 != null; + ReachabilitySet alphaSum2 = hrnSum2.getAlpha(); + assert alphaSum2 != null; + + // does either one report reachability from the other tokens? + if( alphaSum1.containsTuple( gsStar2 ) ) { return true; } + if( alphaSum2.containsTuple( gsStar1 ) ) { return true; } + + // only check non-star token if they are different sites + if( as1 != as2 ) { + if( alphaSum1.containsTuple( gs2 ) ) { return true; } + if( alphaSum2.containsTuple( gs1 ) ) { return true; } + } + + + // check sum2 against alloc1 nodes + for( int i = 0; i < as1.getAllocationDepth(); ++i ) { + Integer idI1 = as1.getIthOldest(i); + assert id2hrn.containsKey( idI1 ); + HeapRegionNode hrnI1 = id2hrn.get( idI1 ); + assert hrnI1 != null; + ReachabilitySet alphaI1 = hrnI1.getAlpha(); + assert alphaI1 != null; - if( idSet.contains( hrnReferencee.getID() ) ) { - if( !id.equals( hrnReferencee.getID() ) ) { - return true; - } - } + // the other nodes of an allocation site are single, no stars + TokenTuple gi1 = new TokenTuple(as1.getIthOldest(i), + false, + TokenTuple.ARITY_ONE).makeCanonical(); - if( !visited.contains( hrnReferencee ) ) { - toVisit.add( hrnReferencee ); - } - } - } + if( alphaSum2.containsTuple( gi1 ) ) { return true; } + if( alphaI1.containsTuple ( gs2 ) ) { return true; } + if( alphaI1.containsTuple ( gsStar2 ) ) { return true; } + } - return false; - } - */ + // check sum1 against alloc2 nodes + for( int i = 0; i < as2.getAllocationDepth(); ++i ) { + Integer idI2 = as2.getIthOldest(i); + assert id2hrn.containsKey( idI2 ); + HeapRegionNode hrnI2 = id2hrn.get( idI2 ); + assert hrnI2 != null; + ReachabilitySet alphaI2 = hrnI2.getAlpha(); + assert alphaI2 != null; + + TokenTuple gi2 = new TokenTuple(as2.getIthOldest(i), + false, + TokenTuple.ARITY_ONE).makeCanonical(); + + if( alphaSum1.containsTuple( gi2 ) ) { return true; } + if( alphaI2.containsTuple ( gs1 ) ) { return true; } + if( alphaI2.containsTuple ( gsStar1 ) ) { return true; } + + // while we're at it, do an inner loop for alloc2 vs alloc1 nodes + for( int j = 0; j < as1.getAllocationDepth(); ++j ) { + Integer idI1 = as1.getIthOldest(j); + + // if these are the same site, don't look for the same token, no alias + // different tokens of the same site could alias together though + if( idI1 == idI2 ) { continue; } + + HeapRegionNode hrnI1 = id2hrn.get( idI1 ); + ReachabilitySet alphaI1 = hrnI1.getAlpha(); + TokenTuple gi1 = new TokenTuple(as1.getIthOldest(j), + false, + TokenTuple.ARITY_ONE).makeCanonical(); + if( alphaI2.containsTuple( gi1 ) ) { return true; } + if( alphaI1.containsTuple( gi2 ) ) { return true; } + } + } + + return false; + } // for writing ownership graphs to dot files diff --git a/Robust/src/Tests/OwnershipAnalysisTest/test02/makefile b/Robust/src/Tests/OwnershipAnalysisTest/test02/makefile index 4281e17d..c0b91f75 100644 --- a/Robust/src/Tests/OwnershipAnalysisTest/test02/makefile +++ b/Robust/src/Tests/OwnershipAnalysisTest/test02/makefile @@ -8,7 +8,7 @@ BSFLAGS= -recover -flatirtasks -ownership -enable-assertions all: $(PROGRAM).bin view: PNGs - eog *.png + eog *.png & PNGs: DOTs d2p *COMPLETE*.dot diff --git a/Robust/src/Tests/OwnershipAnalysisTest/test02/test02.java b/Robust/src/Tests/OwnershipAnalysisTest/test02/test02.java index 893927bc..ae7d234f 100644 --- a/Robust/src/Tests/OwnershipAnalysisTest/test02/test02.java +++ b/Robust/src/Tests/OwnershipAnalysisTest/test02/test02.java @@ -244,3 +244,13 @@ task AliasParamToNew( Voo v{ f }, Voo w{ f } ) { taskexit( v{ !f }, w{ !f } ); } + +task AliasNewToNew( Voo v{ f }, Voo w{ f } ) { + + Baw m = new Baw(); + + Voo x = new Voo(); + x.b = m; + + taskexit( v{ !f }, w{ !f } ); +}