mapDescriptorToCompleteOwnershipGraph =
new Hashtable<Descriptor, OwnershipGraph>();
- // initialize methods to visit as the set of
- // all tasks
+ // initialize methods to visit as the set of all tasks
descriptorsToVisit = new HashSet<Descriptor>();
Iterator taskItr = state.getTaskSymbolTable().getDescriptorsIterator();
while( taskItr.hasNext() ) {
- descriptorsToVisit.add( (Descriptor) taskItr.next() );
+ Descriptor d = (Descriptor) taskItr.next();
+ descriptorsToVisit.add( d );
}
// as mentioned above, analyze methods one-by-one, possibly revisiting
}
private void analyzeMethods() throws java.io.IOException {
+
+ while( !descriptorsToVisit.isEmpty() ) {
+ Descriptor d = (Descriptor) descriptorsToVisit.iterator().next();
+ descriptorsToVisit.remove( d );
+
+ System.out.println( "Analyzing " + d );
+
+ // because the task or method descriptor just extracted
+ // in the "to visit" set it either hasn't been analyzed
+ // yet, or some method that it depends on has been
+ // updated. Recompute a complete ownership graph for
+ // this task/method and compare it to any previous result.
+ // If there is a change detected, add any methods/tasks
+ // that depend on this one to the "to visit" set.
+ OwnershipGraph og = new OwnershipGraph( allocationDepth );
+
+
+ OwnershipGraph ogPrev = mapDescriptorToCompleteOwnershipGraph.get( d );
+
+ if( !og.equals( ogPrev ) ) {
+
+ mapDescriptorToCompleteOwnershipGraph.put( d, og );
+
+ // only methods have dependents, tasks cannot
+ // be invoked by any user program calls
+ if( d instanceof MethodDescriptor ) {
+ MethodDescriptor md = (MethodDescriptor) d;
+ Set dependents = callGraph.getCallerSet( md );
+ descriptorsToVisit.addAll( dependents );
+ }
+ }
+ }
/*
protected int newDepthK;
public Hashtable<FlatNew, NewCluster> fn2nc;
-
+ */
public OwnershipGraph( int newDepthK ) {
+
+ /*
id2hrn = new Hashtable<Integer, HeapRegionNode>();
heapRoots = new Hashtable<Integer, HeapRegionNode>();
this.newDepthK = newDepthK;
fn2nc = new Hashtable<FlatNew, NewCluster>();
+ */
}
+ /*
protected void addReferenceEdge( OwnershipNode referencer,
HeapRegionNode referencee,
ReferenceEdgeProperties rep ) {
////////////////////////////////////////////////////
public void merge( OwnershipGraph og ) {
+
+ if( og == null ) {
+ return;
+ }
+
mergeOwnershipNodes ( og );
mergeReferenceEdges ( og );
mergeHeapRoots ( og );
}
}
}
-
+ */
// it is necessary in the equals() member functions
// are equally present is to iterate over both data
// structures and compare against the other graph.
public boolean equals( OwnershipGraph og ) {
+
+ if( og == null ) {
+ return false;
+ }
+ /*
if( !areHeapRegionNodesEqual( og ) ) {
return false;
}
if( !areNewClustersEqual( og ) ) {
return false;
}
+ */
return true;
}
+ /*
protected boolean areHeapRegionNodesEqual( OwnershipGraph og ) {
// check all nodes in A for presence in graph B
Set sA = og.id2hrn.entrySet();
public Parameter() {
a = 0; b = 0; f = null; g = null;
}
+
+ public void foo() { a = 1; }
}
task Startup( StartupObject s{ initialstate } ) {
taskexit( s{ !initialstate } );
}
+task DoStuff( Parameter p{!w} ) {
+ p.foo();
+
+ taskexit( p{w} );
+}
+
/*
task aliasFromObjectAssignment
( Parameter p1{!w}, Parameter p2{!w} ) {
}
*/
+/*
task newNoAlias
( Parameter p1{!w}, Parameter p2{!w} ) {
taskexit( p1{w}, p2{w} );
}
+*/