From: jjenista Date: Tue, 20 Oct 2009 21:34:42 +0000 (+0000) Subject: revert alias set computation changes, stick with old way X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ab917e0ed8637fcee7deae5910355634db95b88c;p=IRC.git revert alias set computation changes, stick with old way --- diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java index ee9954b7..f7ff02f6 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java @@ -977,7 +977,7 @@ public class OwnershipAnalysis { ogMergeOfAllPossibleCalleeResults = og; Set aliasedParamIndices = - ogMergeOfAllPossibleCalleeResults.calculateAliasedParamSet(fc, flatm); + ogMergeOfAllPossibleCalleeResults.calculateAliasedParamSet(fc, md.isStatic(), flatm); MethodContext mcNew = new MethodContext( md, aliasedParamIndices ); Set contexts = mapDescriptorToAllMethodContexts.get( md ); @@ -1023,7 +1023,7 @@ public class OwnershipAnalysis { ogCopy.merge(og); Set aliasedParamIndices = - ogCopy.calculateAliasedParamSet(fc, pflatm); + ogCopy.calculateAliasedParamSet(fc, possibleMd.isStatic(), pflatm); MethodContext mcNew = new MethodContext( possibleMd, aliasedParamIndices ); Set contexts = mapDescriptorToAllMethodContexts.get( md ); @@ -1516,7 +1516,7 @@ public class OwnershipAnalysis { MethodDescriptor md=fc.getMethod(); FlatMethod flatm = state.getMethodFlat(md); - Set aliasedParamIndices = mergeOG.calculateAliasedParamSet(fc, flatm); + Set aliasedParamIndices = mergeOG.calculateAliasedParamSet(fc, md.isStatic(), flatm); MethodContext calleeMC = new MethodContext( md, aliasedParamIndices ); return calleeMC; diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java index c61a9ea4..f2d1263e 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java @@ -530,8 +530,6 @@ public class OwnershipGraph { } - - // the parameter model is to use a single-object heap region // for the primary parameter, and a multiple-object heap // region for the secondary objects reachable through the @@ -931,24 +929,6 @@ public class OwnershipGraph { LabelNode lnParamI = getLabelNodeFromTemp( tdParamI ); Integer idPrimaryI = paramIndex2idPrimary.get( i ); - - /* - if( idPrimaryI == null ) { - try { - writeGraph( "debugalias", - true, // write labels (variables) - true, // selectively hide intermediate temp vars - true, // prune unreachable heap regions - false, // show back edges to confirm graph validity - false, // show parameter indices (unmaintained!) - true, // hide subset reachability states - true); // hide edge taints - } catch( Exception e ) {} - System.out.println( "FlatMethod="+fm+"\nalias set="+aliasedParamIndices+ - "\nindex bad="+i); - } - */ - assert idPrimaryI != null; HeapRegionNode primaryI = id2hrn.get( idPrimaryI ); assert primaryI != null; @@ -1676,117 +1656,94 @@ public class OwnershipGraph { public Set calculateAliasedParamSet( FlatCall fc, + boolean isStatic, FlatMethod fm ) { - // to decide if two parameters are aliased, look - // at the caller graph (this graph) and if these - // two conditions are met, they may be aliased: - // 1. The argument labels reference a shared node - // 2. The edges to that shared node have a common - // reachability state. - - Set aliasedIndices = new HashSet(); + Hashtable paramIndex2ln = + new Hashtable(); - //System.out.println("Aliases for "+fm+" at "+fc); - + Hashtable > paramIndex2reachableCallerNodes = + new Hashtable >(); for( int i = 0; i < fm.numParameters(); ++i ) { - for( int j = 0; j < i; ++j ) { - - TempDescriptor argTemp_i = fc.getArgMatchingParamIndex( fm, i ); - LabelNode argLabel_i = getLabelNodeFromTemp( argTemp_i ); - - TempDescriptor argTemp_j = fc.getArgMatchingParamIndex( fm, j ); - LabelNode argLabel_j = getLabelNodeFromTemp( argTemp_j ); + Integer paramIndex = new Integer( i ); + TempDescriptor tdParam = fm.getParameter( i ); + TypeDescriptor typeParam = tdParam.getType(); - /* - System.out.println(" "+argTemp_i.getType()+" "+argTemp_i+" and "+ - argTemp_j.getType()+" "+argTemp_j+" aliased?"); - */ - - // first condition--do these arguments - // reference any common nodes? - Iterator edgeItr; + if( typeParam.isImmutable() && !typeParam.isArray() ) { + // don't bother with this primitive parameter, it + // cannot affect reachability + continue; + } - Set hrnSetI = new HashSet(); - edgeItr = argLabel_i.iteratorToReferencees(); - while( edgeItr.hasNext() ) { - hrnSetI.add( edgeItr.next().getDst() ); - } + // now depending on whether the callee is static or not + // we need to account for a "this" argument in order to + // find the matching argument in the caller context + TempDescriptor argTemp_i = fc.getArgMatchingParamIndex( fm, paramIndex ); - Set hrnSetJ = new HashSet(); - edgeItr = argLabel_j.iteratorToReferencees(); - while( edgeItr.hasNext() ) { - hrnSetJ.add( edgeItr.next().getDst() ); - } + LabelNode argLabel_i = getLabelNodeFromTemp(argTemp_i); + paramIndex2ln.put(paramIndex, argLabel_i); + } - Set intersection = - new HashSet( hrnSetI ); - intersection.retainAll( hrnSetJ ); + Iterator lnArgItr = paramIndex2ln.entrySet().iterator(); + while( lnArgItr.hasNext() ) { + Map.Entry me = (Map.Entry)lnArgItr.next(); + Integer index = (Integer) me.getKey(); + LabelNode lnArg_i = (LabelNode) me.getValue(); - // condition two--for each shared node, do the reference - // edges to it from arguments have a common reachability - // state that is *ALSO* on the shared node? - boolean foundAlias = false; + HashSet reachableNodes = new HashSet(); + HashSet todoNodes = new HashSet(); - Iterator hrnItr = intersection.iterator(); - while( hrnItr.hasNext() ) { - HeapRegionNode hrn = hrnItr.next(); + // to find all reachable nodes, start with label referencees + Iterator edgeArgItr = lnArg_i.iteratorToReferencees(); + while( edgeArgItr.hasNext() ) { + ReferenceEdge edge = edgeArgItr.next(); + todoNodes.add( edge.getDst() ); + } - ReferenceEdge ei = argLabel_i.getReferenceTo( hrn, - argTemp_i.getType(), - null ); + // then follow links until all reachable nodes have been found + while( !todoNodes.isEmpty() ) { + HeapRegionNode hrn = todoNodes.iterator().next(); + todoNodes.remove(hrn); + reachableNodes.add(hrn); - ReferenceEdge ej = argLabel_j.getReferenceTo( hrn, - argTemp_j.getType(), - null ); - assert ei != null; - assert ej != null; + Iterator edgeItr = hrn.iteratorToReferencees(); + while( edgeItr.hasNext() ) { + ReferenceEdge edge = edgeItr.next(); - ReachabilitySet allStatesForParamI = - ei.getBeta().intersection( hrn.getAlpha() ); + if( !reachableNodes.contains(edge.getDst() ) ) { + todoNodes.add(edge.getDst() ); + } + } + } - ReachabilitySet allStatesForParamJ = - ej.getBeta().intersection( hrn.getAlpha() ); + // save for later + paramIndex2reachableCallerNodes.put(index, reachableNodes); + } - ReachabilitySet commonStates = - allStatesForParamI.intersection( allStatesForParamJ ); + Set aliasedIndices = new HashSet(); - if( !commonStates.isEmpty() ) { - foundAlias = true; - aliasedIndices.add( new Integer( i ) ); - aliasedIndices.add( new Integer( j ) ); + // check for arguments that are aliased + for( int i = 0; i < fm.numParameters(); ++i ) { + for( int j = 0; j < i; ++j ) { + HashSet s1 = paramIndex2reachableCallerNodes.get( i ); + HashSet s2 = paramIndex2reachableCallerNodes.get( j ); - //System.out.println( " yes!" ); - } + // some parameters are immutable or primitive, so skip em + if( s1 == null || s2 == null ) { + continue; } - // as soon as we detect one possible way to alias - // these parameters, skip on to another pair - if( foundAlias ) { - continue; + Set intersection = new HashSet(s1); + intersection.retainAll(s2); + + if( !intersection.isEmpty() ) { + aliasedIndices.add( new Integer( i ) ); + aliasedIndices.add( new Integer( j ) ); } } } - if( !aliasedIndices.isEmpty() ) { - try { - writeGraph( "foundaliases", - true, // write labels (variables) - true, // selectively hide intermediate temp vars - true, // prune unreachable heap regions - false, // show back edges to confirm graph validity - false, // show parameter indices (unmaintained!) - true, // hide subset reachability states - true); // hide edge taints - } catch( Exception e ) {} - /* - System.out.println("FlatCall="+fc+ - "\nflat method="+fm+ - "\nAliases="+aliasedIndices ); - */ - } - return aliasedIndices; } @@ -2059,7 +2016,6 @@ public class OwnershipGraph { assert hrnSecondary != null; paramIndex2rewriteH_s.put( paramIndex, toShadowTokens( ogCallee, hrnSecondary.getAlpha() ) ); - // setup J (secondary->X) Iterator s2xItr = hrnSecondary.iteratorToReferencees(); while( s2xItr.hasNext() ) { @@ -4527,120 +4483,7 @@ public class OwnershipGraph { return intersection; } - - /* - // for writing ownership graphs to dot files - public void writeGraph(MethodContext mc, - FlatNode fn, - boolean writeLabels, - boolean labelSelect, - boolean pruneGarbage, - boolean writeReferencers, - boolean writeParamMappings - ) throws java.io.IOException { - writeGraph( - mc.toString() + - fn.toString(), - writeLabels, - labelSelect, - pruneGarbage, - writeReferencers, - writeParamMappings - ); - } - - public void writeGraph(MethodContext mc, - boolean writeLabels, - boolean labelSelect, - boolean pruneGarbage, - boolean writeReferencers, - boolean writeParamMappings - ) throws java.io.IOException { - - writeGraph(mc+"COMPLETE", - writeLabels, - labelSelect, - pruneGarbage, - writeReferencers, - writeParamMappings - ); - } - - public void writeGraph(MethodContext mc, - boolean writeLabels, - boolean labelSelect, - boolean pruneGarbage, - boolean writeReferencers, - boolean writeParamMappings, - boolean hideSubsetReachability - ) throws java.io.IOException { - - writeGraph(mc+"COMPLETE", - writeLabels, - labelSelect, - pruneGarbage, - writeReferencers, - writeParamMappings, - hideSubsetReachability - ); - } - - public void writeGraph(MethodContext mc, - Integer numUpdate, - boolean writeLabels, - boolean labelSelect, - boolean pruneGarbage, - boolean writeReferencers, - boolean writeParamMappings - ) throws java.io.IOException { - - writeGraph(mc+"COMPLETE"+String.format("%05d", numUpdate), - writeLabels, - labelSelect, - pruneGarbage, - writeReferencers, - writeParamMappings - ); - } - - public void writeGraph(MethodContext mc, - Integer numUpdate, - boolean writeLabels, - boolean labelSelect, - boolean pruneGarbage, - boolean writeReferencers, - boolean writeParamMappings, - boolean hideSubsetReachability - ) throws java.io.IOException { - - writeGraph(mc+"COMPLETE"+String.format("%05d", numUpdate), - writeLabels, - labelSelect, - pruneGarbage, - writeReferencers, - writeParamMappings, - hideSubsetReachability - ); - } - - public void writeGraph(String graphName, - boolean writeLabels, - boolean labelSelect, - boolean pruneGarbage, - boolean writeReferencers, - boolean writeParamMappings - ) throws java.io.IOException { - writeGraph(graphName, - writeLabels, - labelSelect, - pruneGarbage, - writeReferencers, - writeParamMappings, - false - ); - } - */ - + public void writeGraph(String graphName, boolean writeLabels, boolean labelSelect,