///////////////////////////////////////////
public HashSet<AllocationSite>
- getFlaggedAllocationSitesReachableFromTask( TaskDescriptor td ) {
- return getFlaggedAllocationSitesReachableFromTaskPRIVATE( td );
+ getFlaggedAllocationSitesReachableFromTask(TaskDescriptor td) {
+ return getFlaggedAllocationSitesReachableFromTaskPRIVATE(td);
}
- public AllocationSite getAllocationSiteFromFlatNew( FlatNew fn ) {
- return getAllocationSiteFromFlatNewPRIVATE( fn );
+ public AllocationSite getAllocationSiteFromFlatNew(FlatNew fn) {
+ return getAllocationSiteFromFlatNewPRIVATE(fn);
}
- public boolean createsPotentialAliases( Descriptor taskOrMethod,
- int paramIndex1,
- int paramIndex2 ) {
-
- OwnershipGraph og = mapDescriptorToCompleteOwnershipGraph.get( taskOrMethod );
- assert( og != null );
- return og.hasPotentialAlias( paramIndex1, paramIndex2 );
+ public boolean createsPotentialAliases(Descriptor taskOrMethod,
+ int paramIndex1,
+ int paramIndex2) {
+
+ OwnershipGraph og = mapDescriptorToCompleteOwnershipGraph.get(taskOrMethod);
+ assert(og != null);
+ return og.hasPotentialAlias(paramIndex1, paramIndex2);
}
- public boolean createsPotentialAliases( Descriptor taskOrMethod,
- int paramIndex,
- AllocationSite alloc ) {
-
- OwnershipGraph og = mapDescriptorToCompleteOwnershipGraph.get( taskOrMethod );
- assert( og != null );
- return og.hasPotentialAlias( paramIndex, alloc );
+ public boolean createsPotentialAliases(Descriptor taskOrMethod,
+ int paramIndex,
+ AllocationSite alloc) {
+
+ OwnershipGraph og = mapDescriptorToCompleteOwnershipGraph.get(taskOrMethod);
+ assert(og != null);
+ return og.hasPotentialAlias(paramIndex, alloc);
}
- public boolean createsPotentialAliases( Descriptor taskOrMethod,
- AllocationSite alloc,
- int paramIndex ) {
-
- OwnershipGraph og = mapDescriptorToCompleteOwnershipGraph.get( taskOrMethod );
- assert( og != null );
- return og.hasPotentialAlias( paramIndex, alloc );
+ public boolean createsPotentialAliases(Descriptor taskOrMethod,
+ AllocationSite alloc,
+ int paramIndex) {
+
+ OwnershipGraph og = mapDescriptorToCompleteOwnershipGraph.get(taskOrMethod);
+ assert(og != null);
+ return og.hasPotentialAlias(paramIndex, alloc);
}
- public boolean createsPotentialAliases( Descriptor taskOrMethod,
- AllocationSite alloc1,
- AllocationSite alloc2 ) {
-
- OwnershipGraph og = mapDescriptorToCompleteOwnershipGraph.get( taskOrMethod );
- assert( og != null );
- return og.hasPotentialAlias( alloc1, alloc2 );
+ public boolean createsPotentialAliases(Descriptor taskOrMethod,
+ AllocationSite alloc1,
+ AllocationSite alloc2) {
+
+ OwnershipGraph og = mapDescriptorToCompleteOwnershipGraph.get(taskOrMethod);
+ assert(og != null);
+ return og.hasPotentialAlias(alloc1, alloc2);
}
// use the methods given above to check every possible alias
Iterator taskItr = state.getTaskSymbolTable().getDescriptorsIterator();
while( taskItr.hasNext() ) {
TaskDescriptor td = (TaskDescriptor) taskItr.next();
-
- bw.write( "\n---------"+td+"--------\n" );
- HashSet<AllocationSite> allocSites = getFlaggedAllocationSitesReachableFromTask( td );
-
+ bw.write("\n---------"+td+"--------\n");
+
+ HashSet<AllocationSite> allocSites = getFlaggedAllocationSitesReachableFromTask(td);
+
// for each task parameter, check for aliases with
// other task parameters and every allocation site
// reachable from this task
boolean foundSomeAlias = false;
- FlatMethod fm = state.getMethodFlat( td );
+ FlatMethod fm = state.getMethodFlat(td);
for( int i = 0; i < fm.numParameters(); ++i ) {
// for the ith parameter check for aliases to all
// higher numbered parameters
for( int j = i + 1; j < fm.numParameters(); ++j ) {
- if( createsPotentialAliases( td, i, j ) ) {
+ if( createsPotentialAliases(td, i, j) ) {
foundSomeAlias = true;
- bw.write( "Potential alias between parameters "+i+" and "+j+".\n" );
+ bw.write("Potential alias between parameters "+i+" and "+j+".\n");
}
}
Iterator allocItr = allocSites.iterator();
while( allocItr.hasNext() ) {
AllocationSite as = (AllocationSite) allocItr.next();
- if( createsPotentialAliases( td, i, as ) ) {
+ if( createsPotentialAliases(td, i, as) ) {
foundSomeAlias = true;
- bw.write( "Potential alias between parameter "+i+" and "+as+".\n" );
+ bw.write("Potential alias between parameter "+i+" and "+as+".\n");
}
}
}
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" );
+ if( !outerChecked.contains(as2) &&
+ createsPotentialAliases(td, as1, as2) ) {
+ bw.write("Potential alias between "+as1+" and "+as2+".\n");
}
}
- outerChecked.add( as1 );
+ outerChecked.add(as1);
}
if( !foundSomeAlias ) {
- bw.write( "Task "+td+" contains no aliases between flagged objects.\n" );
+ bw.write("Task "+td+" contains no aliases between flagged objects.\n");
}
}
-
+
bw.close();
}
// a special field descriptor for all array elements
private static FieldDescriptor fdElement = new FieldDescriptor(new Modifiers(Modifiers.PUBLIC),
- new TypeDescriptor( "Array[]" ),
- "elements",
- null,
- false);
+ new TypeDescriptor("Array[]"),
+ "elements",
+ null,
+ false);
// this analysis generates an ownership graph for every task
// a method if the methods that it calls are updated
analyzeMethods();
- writeAllAliases( "identifiedAliases.txt" );
+ writeAllAliases("identifiedAliases.txt");
}
// called from the constructor to help initialize the set
rhs = fsfn.getSrc();
og.assignTempXFieldFEqualToTempY(lhs, fld, rhs);
break;
-
+
case FKind.FlatElementNode:
FlatElementNode fen = (FlatElementNode) fn;
lhs = fen.getDst();
// find all of them and merge all of their results together
TypeDescriptor typeDesc = fc.getThis().getType();
Set possibleCallees = callGraph.getMethods(md, typeDesc);
-
+
Iterator i = possibleCallees.iterator();
while( i.hasNext() ) {
MethodDescriptor possibleMd = (MethodDescriptor) i.next();
-
+
// don't alter the working graph (og) until we compute a result for every
// possible callee, merge them all together, then set og to that
OwnershipGraph ogCopy = new OwnershipGraph(allocationDepth);
- ogCopy.merge( og );
-
+ ogCopy.merge(og);
+
OwnershipGraph ogPotentialCallee = mapDescriptorToCompleteOwnershipGraph.get(possibleMd);
- ogCopy.resolveMethodCall(fc, md.isStatic(), flatm, ogPotentialCallee );
- ogMergeOfAllPossibleCalleeResults.merge( ogCopy );
+ ogCopy.resolveMethodCall(fc, md.isStatic(), flatm, ogPotentialCallee);
+ ogMergeOfAllPossibleCalleeResults.merge(ogCopy);
}
}
getHRNSetThatPossiblyMapToCalleeHRN(ogCallee,
edgeCallee.getDst(),
paramIndex2reachableCallerNodes);
-
+
// make every possible pair of {srcSet} -> {dstSet} edges in the caller
Iterator srcItr = possibleCallerSrcs.iterator();
// it also has the appropriate field, otherwise prune this
AllocationSite asSrc = src.getAllocationSite();
if( asSrc != null ) {
- boolean foundField = false;
+ boolean foundField = false;
TypeDescriptor tdSrc = asSrc.getType();
if( tdSrc != null && tdSrc.isClass() ) {
Iterator fieldsSrcItr = tdSrc.getClassDesc().getFields();
// if it matches the callee edge
AllocationSite asDst = dst.getAllocationSite();
if( asDst != null && edgeCallee.getFieldDesc() != null ) {
- if( asDst.getType() == null && edgeCallee.getFieldDesc().getType() != null ) { continue; }
- if( asDst.getType() != null && edgeCallee.getFieldDesc().getType() == null ) { continue; }
+ if( asDst.getType() == null && edgeCallee.getFieldDesc().getType() != null ) {
+ continue;
+ }
+ if( asDst.getType() != null && edgeCallee.getFieldDesc().getType() == null ) {
+ continue;
+ }
if( asDst.getType() != null && edgeCallee.getFieldDesc().getType() != null ) {
- if( !asDst.getType().equals( edgeCallee.getFieldDesc().getType() ) ) { continue; }
+ if( !asDst.getType().equals(edgeCallee.getFieldDesc().getType() ) ) {
+ continue;
+ }
}
- }
+ }
// otherwise the caller src and dst pair can match the edge, so make it
ReferenceEdge edgeNewInCaller = edgeNewInCallerTemplate.copy();
ReferenceEdge edgeCallee = edgeCalleeItr.next();
ReferenceEdge edgeNewInCallerTemplate = new ReferenceEdge(null,
- null,
- edgeCallee.getFieldDesc(),
- false,
- toShadowTokens(ogCallee, edgeCallee.getBeta() )
- );
+ null,
+ edgeCallee.getFieldDesc(),
+ false,
+ toShadowTokens(ogCallee, edgeCallee.getBeta() )
+ );
rewriteCallerEdgeBeta(fm.numParameters(),
- bogusIndex,
- edgeNewInCallerTemplate,
- paramIndex2rewriteJ,
- paramIndex2rewriteD,
- paramIndex2paramToken,
- paramIndex2paramTokenStar,
- false,
- null);
-
+ bogusIndex,
+ edgeNewInCallerTemplate,
+ paramIndex2rewriteJ,
+ paramIndex2rewriteD,
+ paramIndex2paramToken,
+ paramIndex2paramTokenStar,
+ false,
+ null);
+
edgeNewInCallerTemplate.applyBetaNew();
Iterator<HeapRegionNode> itrHrn = assignCallerRhs.iterator();
while( itrHrn.hasNext() ) {
HeapRegionNode hrnCaller = itrHrn.next();
-
+
// check if this dst node has a definite type and
// if it matches the callee edge
// check if this dst node has a definite type and
// if it matches the callee edge
AllocationSite asDst = hrnCaller.getAllocationSite();
if( asDst != null && edgeCallee.getFieldDesc() != null ) {
- if( asDst.getType() == null && edgeCallee.getFieldDesc().getType() != null ) { continue; }
- if( asDst.getType() != null && edgeCallee.getFieldDesc().getType() == null ) { continue; }
+ if( asDst.getType() == null && edgeCallee.getFieldDesc().getType() != null ) {
+ continue;
+ }
+ if( asDst.getType() != null && edgeCallee.getFieldDesc().getType() == null ) {
+ continue;
+ }
if( asDst.getType() != null && edgeCallee.getFieldDesc().getType() != null ) {
- if( !asDst.getType().equals( edgeCallee.getFieldDesc().getType() ) ) { continue; }
+ if( !asDst.getType().equals(edgeCallee.getFieldDesc().getType() ) ) {
+ continue;
+ }
}
- }
+ }
// otherwise caller node can match callee edge, so make it
ReferenceEdge edgeNewInCaller = edgeNewInCallerTemplate.copy();
} else {
// if it already exists, merge with it
edgeExisting.setBeta(edgeExisting.getBeta().union(edgeNewInCaller.getBeta() ) );
- }
+ }
}
}
}
}
- public boolean hasPotentialAlias( Integer paramIndex1, Integer paramIndex2 ) {
+ public boolean hasPotentialAlias(Integer paramIndex1, Integer paramIndex2) {
// get parameter's heap region
assert paramIndex2id.containsKey(paramIndex1);
// get tokens for this parameter
TokenTuple p1 = new TokenTuple(hrnParam1.getID(),
- true,
- TokenTuple.ARITY_ONE).makeCanonical();
+ true,
+ TokenTuple.ARITY_ONE).makeCanonical();
TokenTuple pStar1 = new TokenTuple(hrnParam1.getID(),
- true,
- TokenTuple.ARITY_MANY).makeCanonical();
+ true,
+ TokenTuple.ARITY_MANY).makeCanonical();
// get tokens for the other parameter
assert hrnParam2 != null;
TokenTuple p2 = new TokenTuple(hrnParam2.getID(),
- true,
- TokenTuple.ARITY_ONE).makeCanonical();
+ true,
+ TokenTuple.ARITY_ONE).makeCanonical();
TokenTuple pStar2 = new TokenTuple(hrnParam2.getID(),
- true,
- TokenTuple.ARITY_MANY).makeCanonical();
+ true,
+ TokenTuple.ARITY_MANY).makeCanonical();
// get special label p_q for first parameter
TempDescriptor tdParamQ1 = paramIndex2tdQ.get(paramIndex1);
- assert tdParamQ1 != null;
+ assert tdParamQ1 != null;
LabelNode lnParamQ1 = td2ln.get(tdParamQ1);
assert lnParamQ1 != null;
ReachabilitySet beta1 = edgeSpecialQ1.getBeta();
assert beta1 != null;
- if( beta1.containsTupleSetWithBoth( p1, p2 ) ) { return true; }
- if( beta1.containsTupleSetWithBoth( pStar1, p2 ) ) { return true; }
- if( beta1.containsTupleSetWithBoth( p1, pStar2 ) ) { return true; }
- if( beta1.containsTupleSetWithBoth( pStar1, pStar2 ) ) { return true; }
-
+ if( beta1.containsTupleSetWithBoth(p1, p2) ) {
+ return true;
+ }
+ if( beta1.containsTupleSetWithBoth(pStar1, p2) ) {
+ return true;
+ }
+ if( beta1.containsTupleSetWithBoth(p1, pStar2) ) {
+ return true;
+ }
+ if( beta1.containsTupleSetWithBoth(pStar1, pStar2) ) {
+ return true;
+ }
+
return false;
}
- public boolean hasPotentialAlias( Integer paramIndex, AllocationSite as ) {
+ public boolean hasPotentialAlias(Integer paramIndex, AllocationSite as) {
// get parameter's heap region
assert paramIndex2id.containsKey(paramIndex);
// get tokens for this parameter
TokenTuple p = new TokenTuple(hrnParam.getID(),
- true,
- TokenTuple.ARITY_ONE).makeCanonical();
+ true,
+ TokenTuple.ARITY_ONE).makeCanonical();
TokenTuple pStar = new TokenTuple(hrnParam.getID(),
- true,
- TokenTuple.ARITY_MANY).makeCanonical();
+ true,
+ TokenTuple.ARITY_MANY).makeCanonical();
// get special label p_q
TempDescriptor tdParamQ = paramIndex2tdQ.get(paramIndex);
- assert tdParamQ != null;
+ assert tdParamQ != null;
LabelNode lnParamQ = td2ln.get(tdParamQ);
assert lnParamQ != null;
// get tokens for summary node
TokenTuple gs = new TokenTuple(as.getSummary(),
- true,
- TokenTuple.ARITY_ONE).makeCanonical();
+ true,
+ TokenTuple.ARITY_ONE).makeCanonical();
TokenTuple gsStar = new TokenTuple(as.getSummary(),
- true,
- TokenTuple.ARITY_MANY).makeCanonical();
+ true,
+ TokenTuple.ARITY_MANY).makeCanonical();
- if( beta.containsTupleSetWithBoth( p, gs ) ) { return true; }
- if( beta.containsTupleSetWithBoth( pStar, gs ) ) { return true; }
- if( beta.containsTupleSetWithBoth( p, gsStar ) ) { return true; }
- if( beta.containsTupleSetWithBoth( pStar, gsStar ) ) { return true; }
+ if( beta.containsTupleSetWithBoth(p, gs) ) {
+ return true;
+ }
+ if( beta.containsTupleSetWithBoth(pStar, gs) ) {
+ return true;
+ }
+ if( beta.containsTupleSetWithBoth(p, gsStar) ) {
+ return true;
+ }
+ if( beta.containsTupleSetWithBoth(pStar, gsStar) ) {
+ return true;
+ }
// check for other nodes
for( int i = 0; i < as.getAllocationDepth(); ++i ) {
// the other nodes of an allocation site are single, no stars
TokenTuple gi = new TokenTuple(as.getIthOldest(i),
- false,
- TokenTuple.ARITY_ONE).makeCanonical();
+ false,
+ TokenTuple.ARITY_ONE).makeCanonical();
+
+ if( beta.containsTupleSetWithBoth(p, gi) ) {
+ return true;
+ }
+ if( beta.containsTupleSetWithBoth(pStar, gi) ) {
+ return true;
+ }
+ }
- if( beta.containsTupleSetWithBoth( p, gi ) ) { return true; }
- if( beta.containsTupleSetWithBoth( pStar, gi ) ) { return true; }
- }
-
return false;
}
- public boolean hasPotentialAlias( AllocationSite as1, AllocationSite as2 ) {
+ public boolean hasPotentialAlias(AllocationSite as1, AllocationSite as2) {
// get tokens for summary nodes
TokenTuple gs1 = new TokenTuple(as1.getSummary(),
- true,
- TokenTuple.ARITY_ONE).makeCanonical();
-
+ true,
+ TokenTuple.ARITY_ONE).makeCanonical();
+
TokenTuple gsStar1 = new TokenTuple(as1.getSummary(),
- true,
- TokenTuple.ARITY_MANY).makeCanonical();
-
+ true,
+ TokenTuple.ARITY_MANY).makeCanonical();
+
// get summary node's alpha
Integer idSum1 = as1.getSummary();
- assert id2hrn.containsKey( idSum1 );
- HeapRegionNode hrnSum1 = id2hrn.get( idSum1 );
+ 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();
-
+ true,
+ TokenTuple.ARITY_ONE).makeCanonical();
+
TokenTuple gsStar2 = new TokenTuple(as2.getSummary(),
- true,
- TokenTuple.ARITY_MANY).makeCanonical();
-
+ true,
+ TokenTuple.ARITY_MANY).makeCanonical();
+
// get summary node's alpha
Integer idSum2 = as2.getSummary();
- assert id2hrn.containsKey( idSum2 );
- HeapRegionNode hrnSum2 = id2hrn.get( idSum2 );
+ 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; }
+ 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; }
+ 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 id2hrn.containsKey(idI1);
+ HeapRegionNode hrnI1 = id2hrn.get(idI1);
assert hrnI1 != null;
ReachabilitySet alphaI1 = hrnI1.getAlpha();
assert alphaI1 != null;
// the other nodes of an allocation site are single, no stars
TokenTuple gi1 = new TokenTuple(as1.getIthOldest(i),
- false,
- TokenTuple.ARITY_ONE).makeCanonical();
+ false,
+ TokenTuple.ARITY_ONE).makeCanonical();
- if( alphaSum2.containsTuple( gi1 ) ) { return true; }
- if( alphaI1.containsTuple ( gs2 ) ) { return true; }
- if( alphaI1.containsTuple ( gsStar2 ) ) { return true; }
- }
+ if( alphaSum2.containsTuple(gi1) ) {
+ return true;
+ }
+ if( alphaI1.containsTuple(gs2) ) {
+ return true;
+ }
+ if( alphaI1.containsTuple(gsStar2) ) {
+ return true;
+ }
+ }
// 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 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();
+ false,
+ TokenTuple.ARITY_ONE).makeCanonical();
- if( alphaSum1.containsTuple( gi2 ) ) { return true; }
- if( alphaI2.containsTuple ( gs1 ) ) { return true; }
- if( alphaI2.containsTuple ( gsStar1 ) ) { return true; }
+ 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 ) {
+ 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; }
+ if( idI1 == idI2 ) {
+ continue;
+ }
- HeapRegionNode hrnI1 = id2hrn.get( idI1 );
+ 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; }
- }
+ false,
+ TokenTuple.ARITY_ONE).makeCanonical();
+ if( alphaI2.containsTuple(gi1) ) {
+ return true;
+ }
+ if( alphaI1.containsTuple(gi2) ) {
+ return true;
+ }
+ }
}
-
+
return false;
}