// traversing the call graph
HashSet<Descriptor> calleesScheduled = new HashSet<Descriptor>();
+
// initialize methods to visit as the set of all tasks in the
// program and then any method that could be called starting
// from those tasks
scheduleAllCallees( calleesScheduled, d );
}
+ // before beginning analysis, initialize every scheduled method
+ // with an ownership graph that has populated parameter index tables
+ // by analyzing the first node which is always a FlatMethod node
+ Iterator<Descriptor> dItr = calleesScheduled.iterator();
+ while( dItr.hasNext() ) {
+ Descriptor d = dItr.next();
+ OwnershipGraph og = new OwnershipGraph( allocationDepth );
+
+ FlatMethod fm;
+ if( d instanceof MethodDescriptor ) {
+ fm = state.getMethodFlat( (MethodDescriptor) d );
+ } else {
+ assert d instanceof TaskDescriptor;
+ fm = state.getMethodFlat( (TaskDescriptor) d );
+ }
+
+ analyzeFlatNode( d, fm, null, og );
+ mapDescriptorToCompleteOwnershipGraph.put( d, og );
+ }
+
// as mentioned above, analyze methods one-by-one, possibly revisiting
// a method if the methods that it calls are updated
analyzeMethods();
// the final ownership graph result to return as an empty set
returnNodesToCombineForCompleteOwnershipGraph = new HashSet<FlatReturnNode>();
-
- // DEBUG
- //int x = 0;
-
-
while( !flatNodesToVisit.isEmpty() ) {
FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next();
flatNodesToVisit.remove( fn );
if( !og.equals( ogPrev ) ) {
setGraphForFlatNode( fn, og );
- // DEBUG
- /*
- ++x;
-
- if( x > 5000 ) {
- String s = String.format( "%04d", x );
- og.writeGraph( "debug"+s, false, false );
- }
-
- if( x == 5020 ) {
- System.exit( -1 );
- }
- */
-
for( int i = 0; i < fn.numNext(); i++ ) {
FlatNode nn = fn.getNext( i );
flatNodesToVisit.add( nn );
// verify the existence of allocation sites and their
// shadows from the callee in the context of this caller graph
- Iterator<AllocationSite> i = ogCallee.allocationSites.iterator();
- while( i.hasNext() ) {
- AllocationSite allocSite = i.next();
+ Iterator<AllocationSite> asItr = ogCallee.allocationSites.iterator();
+ while( asItr.hasNext() ) {
+ AllocationSite allocSite = asItr.next();
HeapRegionNode hrnSummary = getSummaryNode ( allocSite );
HeapRegionNode hrnShadowSummary = getShadowSummaryNode( allocSite );
}
assert fc.numArgs() + 1 == fm.numParameters();
}
+ // make a change set to translate callee tokens into caller tokens
+ ChangeTupleSet C = new ChangeTupleSet().makeCanonical();
+
+ for( int i = 0; i < fm.numParameters(); ++i ) {
+
+ Integer indexParam = new Integer( i );
+
+ System.out.println( "In method "+fm+ " on param "+indexParam );
+
+ assert ogCallee.paramIndex2id.containsKey( indexParam );
+ Integer idParam = ogCallee.paramIndex2id.get( indexParam );
+
+ assert ogCallee.id2hrn.containsKey( idParam );
+ HeapRegionNode hrnParam = ogCallee.id2hrn.get( idParam );
+ assert hrnParam != null;
+
+ TokenTupleSet calleeTokenToMatch =
+ new TokenTupleSet( new TokenTuple( hrnParam ) ).makeCanonical();
+
+
+ // 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;
+ if( isStatic ) {
+ argTemp = fc.getArg( indexParam );
+ } else {
+ if( indexParam == 0 ) {
+ argTemp = fc.getThis();
+ } else {
+ argTemp = fc.getArg( indexParam - 1 );
+ }
+ }
+
+ LabelNode argLabel = getLabelNodeFromTemp( argTemp );
+ Iterator argHeapRegionsItr = argLabel.setIteratorToReferencedRegions();
+ while( argHeapRegionsItr.hasNext() ) {
+ Map.Entry meArg = (Map.Entry) argHeapRegionsItr.next();
+ HeapRegionNode argHeapRegion = (HeapRegionNode) meArg.getKey();
+ ReferenceEdgeProperties repArg = (ReferenceEdgeProperties) meArg.getValue();
+
+ Iterator<TokenTupleSet> ttsItr = repArg.getBeta().iterator();
+ while( ttsItr.hasNext() ) {
+ TokenTupleSet callerTokensToReplace = ttsItr.next();
+
+ ChangeTuple ct = new ChangeTuple( calleeTokenToMatch,
+ callerTokensToReplace ).makeCanonical();
+
+ C = C.union( ct );
+ }
+ }
+ }
+
+ System.out.println( "Applying method call "+fm );
+ System.out.println( " Change: "+C );
+
+
// the heap regions represented by the arguments (caller graph)
// and heap regions for the parameters (callee graph)
// don't correspond to each other by heap region ID. In fact,
mergeOwnershipNodes ( og );
mergeReferenceEdges ( og );
- mergeId2paramIndex ( og );
+ mergeId2paramIndex ( og );
mergeAllocationSites( og );
}