// adding parameters labels to new heap regions
for( int i = 0; i < fm.numParameters(); ++i ) {
TempDescriptor tdParam = fm.getParameter(i);
+
og.assignTempEqualToParamAlloc(tdParam,
methodDesc instanceof TaskDescriptor,
new Integer(i) );
}
-
break;
case FKind.FlatOpNode:
FlatCall fc = (FlatCall) fn;
MethodDescriptor md = fc.getMethod();
FlatMethod flatm = state.getMethodFlat(md);
- OwnershipGraph ogAllPossibleCallees = new OwnershipGraph(allocationDepth);
+ OwnershipGraph ogMergeOfAllPossibleCalleeResults = new OwnershipGraph(allocationDepth);
if( md.isStatic() ) {
// a static method is simply always the same, makes life easy
OwnershipGraph onlyPossibleCallee = mapDescriptorToCompleteOwnershipGraph.get(md);
- ogAllPossibleCallees.merge(onlyPossibleCallee);
-
+ ogMergeOfAllPossibleCalleeResults = og;
+ ogMergeOfAllPossibleCalleeResults.resolveMethodCall(fc, md.isStatic(), flatm, onlyPossibleCallee);
} else {
// if the method descriptor is virtual, then there could be a
// set of possible methods that will actually be invoked, so
- // find all of them and merge all of their graphs together
+ // 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 );
+
OwnershipGraph ogPotentialCallee = mapDescriptorToCompleteOwnershipGraph.get(possibleMd);
- ogAllPossibleCallees.merge(ogPotentialCallee);
+ ogCopy.resolveMethodCall(fc, md.isStatic(), flatm, ogPotentialCallee );
+ ogMergeOfAllPossibleCalleeResults.merge( ogCopy );
}
}
- // Now we should have the following information to resolve this method call:
- //
- // 1. A FlatCall fc to query for the caller's context (argument labels, etc)
- //
- // 2. Whether the method is static; if not we need to deal with the "this" pointer
- //
- // *******************************************************************************************
- // 3. The original FlatMethod flatm to query for callee's context (paramter labels)
- // NOTE! I assume FlatMethod before virtual dispatch accurately describes all possible methods!
- // *******************************************************************************************
- //
- // 4. The OwnershipGraph ogAllPossibleCallees is a merge of every ownership graph of all the possible
- // methods to capture any possible references made.
- //
- og.resolveMethodCall(fc, md.isStatic(), flatm, ogAllPossibleCallees);
+ og = ogMergeOfAllPossibleCalleeResults;
break;
case FKind.FlatReturnNode:
FlatMethod fm,
OwnershipGraph ogCallee) {
-
// define rewrite rules and other structures to organize
// data by parameter/argument index
Hashtable<Integer, ReachabilitySet> paramIndex2rewriteH =
// it also has the appropriate field, otherwise prune this
AllocationSite asSrc = src.getAllocationSite();
if( asSrc != null ) {
- boolean foundField = false;
- Iterator fieldsSrcItr = asSrc.getType().getClassDesc().getFields();
- while( fieldsSrcItr.hasNext() ) {
- FieldDescriptor fd = (FieldDescriptor) fieldsSrcItr.next();
- if( fd == edgeCallee.getFieldDesc() ) {
- foundField = true;
- break;
+ boolean foundField = false;
+ TypeDescriptor tdSrc = asSrc.getType();
+ if( tdSrc != null && tdSrc.isClass() ) {
+ Iterator fieldsSrcItr = tdSrc.getClassDesc().getFields();
+ while( fieldsSrcItr.hasNext() ) {
+ FieldDescriptor fd = (FieldDescriptor) fieldsSrcItr.next();
+ if( fd == edgeCallee.getFieldDesc() ) {
+ foundField = true;
+ break;
+ }
+ }
+ if( !foundField ) {
+ // prune this source node possibility
+ continue;
}
- }
- if( !foundField ) {
- // prune this source node possibility
- continue;
}
}
bw.write(" graphTitle[label=\""+graphName+"\",shape=box];\n");
+ Set df = paramIndex2id.entrySet();
+ Iterator ih = df.iterator();
+ while( ih.hasNext() ) {
+ Map.Entry meh = (Map.Entry)ih.next();
+ Integer pi = (Integer) meh.getKey();
+ Integer id = (Integer) meh.getValue();
+ bw.write(" pindex"+pi+"[label=\""+pi+" to "+id+"\",shape=box];\n");
+ }
// then visit every label node, useful for debugging
if( writeLabels ) {