Changed the top-level procedure for resolving a method call. When virtual
authorjjenista <jjenista>
Mon, 1 Sep 2008 21:13:56 +0000 (21:13 +0000)
committerjjenista <jjenista>
Mon, 1 Sep 2008 21:13:56 +0000 (21:13 +0000)
dispatch is possible, instead of merging together every potential callee
and then applying that result to the working graph, find the result of
applying each callee to a copy of the working graph, and merge all of those
results together.  This procedure is correct.

Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java
Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java

index 25c7b206dce6e36dc9375a1509fbd21aba3978e1..0e8d465ee39eb03bccf1a67b111216257df87a90 100644 (file)
@@ -457,11 +457,11 @@ public class OwnershipAnalysis {
       // 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:
@@ -521,43 +521,36 @@ public class OwnershipAnalysis {
       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:
index 95b7a18a9836683481ba28ec38bdbaa58fcbc5b3..bd9cba95c90828bc1a36a787a77e915d9641d67f 100644 (file)
@@ -887,7 +887,6 @@ public class OwnershipGraph {
                                 FlatMethod fm,
                                 OwnershipGraph ogCallee) {
 
-
     // define rewrite rules and other structures to organize
     // data by parameter/argument index
     Hashtable<Integer, ReachabilitySet> paramIndex2rewriteH =
@@ -1303,18 +1302,21 @@ public class OwnershipGraph {
            // 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;
              }
            }
 
@@ -2504,6 +2506,14 @@ public class OwnershipGraph {
 
     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 ) {