alias query for param to alloc site
authorjjenista <jjenista>
Sat, 30 Aug 2008 00:30:17 +0000 (00:30 +0000)
committerjjenista <jjenista>
Sat, 30 Aug 2008 00:30:17 +0000 (00:30 +0000)
Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java
Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java
Robust/src/Tests/OwnershipAnalysisTest/test02/test02.java

index dedc6ad513172c883a243d3b5088a187e97ddd74..181764b635a07f873f86f73890671b5334eda44a 100644 (file)
@@ -33,38 +33,28 @@ public class OwnershipAnalysis {
     
     OwnershipGraph og = mapDescriptorToCompleteOwnershipGraph.get( taskOrMethod );
     assert( og != null );    
-
     return og.hasPotentialAlias( paramIndex1, paramIndex2 );
-    /*
-    return createsPotentialAliases( og,
-                                   getHeapRegionIDset( og, paramIndex1 ),
-                                   getHeapRegionIDset( og, paramIndex2 ) );
-    */
   }
 
-  /*
   public boolean createsPotentialAliases( Descriptor     taskOrMethod,
                                           int            paramIndex,
                                           AllocationSite alloc ) {
     
     OwnershipGraph og = mapDescriptorToCompleteOwnershipGraph.get( taskOrMethod );
     assert( og != null );    
-    return createsPotentialAliases( og,
-                                   getHeapRegionIDset( og, paramIndex ),
-                                   getHeapRegionIDset( alloc ) );
+    return og.hasPotentialAlias( paramIndex, alloc );
   }
-  
+
   public boolean createsPotentialAliases( Descriptor     taskOrMethod,
                                           AllocationSite alloc,
                                           int            paramIndex ) {
     
     OwnershipGraph og = mapDescriptorToCompleteOwnershipGraph.get( taskOrMethod );
     assert( og != null );    
-    return createsPotentialAliases( og,
-                                   getHeapRegionIDset( og, paramIndex ),
-                                   getHeapRegionIDset( alloc ) );
+    return og.hasPotentialAlias( paramIndex, alloc );
   }
-  
+
+  /*
   public boolean createsPotentialAliases( Descriptor     taskOrMethod,
                                           AllocationSite alloc1,
                                           AllocationSite alloc2 ) {
@@ -99,7 +89,7 @@ public class OwnershipAnalysis {
     while( taskItr.hasNext() ) {
       TaskDescriptor td = (TaskDescriptor) taskItr.next();
       
-      //HashSet<AllocationSite> allocSites = getFlaggedAllocationSitesReachableFromTask( td );
+      HashSet<AllocationSite> allocSites = getFlaggedAllocationSitesReachableFromTask( td );
       
       // for each task parameter, check for aliases with
       // other task parameters and every allocation site
@@ -118,7 +108,6 @@ public class OwnershipAnalysis {
          }
        }
 
-       /*
        // for the ith parameter, check for aliases against
        // the set of allocation sites reachable from this
        // task context
@@ -126,10 +115,10 @@ public class OwnershipAnalysis {
        while( allocItr.hasNext() ) {
          AllocationSite as = (AllocationSite) allocItr.next();
          if( createsPotentialAliases( td, i, as ) ) {
+           foundSomeAlias = true;
            bw.write( "Task "+td+" potentially aliases parameter "+i+" and "+as+".\n" );
          }
        }
-       */
       }
 
       /*
index fee59db06b06710f97cd60e2d4f4a4b6073aa23d..7e8783a0f995b9fce35b1231d33a29ab8b2fb42f 100644 (file)
@@ -2263,6 +2263,70 @@ public class OwnershipGraph {
   }
 
 
+  public boolean hasPotentialAlias( Integer paramIndex, AllocationSite as ) {
+
+    // get parameter's heap region
+    assert paramIndex2id.containsKey(paramIndex);
+    Integer idParam = paramIndex2id.get(paramIndex);
+
+    assert id2hrn.containsKey(idParam);
+    HeapRegionNode hrnParam = id2hrn.get(idParam);
+    assert hrnParam != null;
+
+    // get tokens for this parameter
+    TokenTuple p = new TokenTuple(hrnParam.getID(),
+                                 true,
+                                 TokenTuple.ARITY_ONE).makeCanonical();
+
+    TokenTuple pStar = new TokenTuple(hrnParam.getID(),
+                                     true,
+                                     TokenTuple.ARITY_MANY).makeCanonical();    
+
+    // get special label p_q
+    TempDescriptor tdParamQ = paramIndex2tdQ.get(paramIndex);
+    assert tdParamQ != null;    
+    LabelNode lnParamQ = td2ln.get(tdParamQ);
+    assert lnParamQ != null;
+
+    // then get the edge from label q to parameter's hrn
+    ReferenceEdge edgeSpecialQ = lnParamQ.getReferenceTo(hrnParam, null);
+    assert edgeSpecialQ != null;
+
+    // look through this beta set for potential aliases
+    ReachabilitySet beta = edgeSpecialQ.getBeta();
+    assert beta != null;
+
+
+    // get tokens for summary node
+    TokenTuple gs = new TokenTuple(as.getSummary(),
+                                 true,
+                                 TokenTuple.ARITY_ONE).makeCanonical();
+
+    TokenTuple gsStar = new TokenTuple(as.getSummary(),
+                                      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; }
+
+    // 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();
+
+      if( beta.containsTupleSetWithBoth( p,     gi     ) ) { return true; }
+      if( beta.containsTupleSetWithBoth( pStar, gi     ) ) { return true; }
+    }    
+    
+    return false;
+  }
+
+
   /*
      // given a set B of heap region node ID's, return the set of heap
      // region node ID's that is reachable from B
index 4ce1063734759fa03839d10ae28c9ffae8f5b6c5..893927bcd17d500fe31f2c78829a2bdd9a705354 100644 (file)
@@ -232,3 +232,15 @@ task NoAliasNewInLoopAnotherWay( Voo v{ f } ) {
   
   taskexit( v{ !f } );
 }
+
+
+task AliasParamToNew( Voo v{ f }, Voo w{ f } ) {
+  
+  Baw m = new Baw();
+  w.b = m;
+
+  Voo x = new Voo();
+  x.b = m;
+
+  taskexit( v{ !f }, w{ !f } );
+}