for method calls, all reachability sets brought into the caller need to have a callee...
authorjjenista <jjenista>
Mon, 25 Aug 2008 20:05:04 +0000 (20:05 +0000)
committerjjenista <jjenista>
Mon, 25 Aug 2008 20:05:04 +0000 (20:05 +0000)
Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java
Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java
Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java
Robust/src/Analysis/OwnershipAnalysis/TokenTupleSet.java

index 96a85dc943b2ef0c1ac2e6ded5a45dba60ba1e1a..82fde7882d49b81704c96787f8e94485fb5f64a8 100644 (file)
@@ -860,14 +860,6 @@ public class OwnershipGraph {
     hrn.setAlpha(hrn.getAlpha().ageTokens(as) );
   }
 
-  protected void majorAgeTokens(AllocationSite as, ReferenceEdge edge) {
-    //edge.setBeta( edge.getBeta().majorAgeTokens( as ) );
-  }
-
-  protected void majorAgeTokens(AllocationSite as, HeapRegionNode hrn) {
-    //hrn.setAlpha( hrn.getAlpha().majorAgeTokens( as ) );
-  }
-
 
   public void resolveMethodCall(FlatCall fc,
                                 boolean isStatic,
@@ -935,11 +927,15 @@ public class OwnershipGraph {
       assert ogCallee.id2hrn.containsKey( idParam );
       HeapRegionNode hrnParam = ogCallee.id2hrn.get( idParam );
       assert hrnParam != null;
-      paramIndex2rewriteH.put( paramIndex, hrnParam.getAlpha() );
+      paramIndex2rewriteH.put( paramIndex,
+                              toShadowTokens( ogCallee, hrnParam.getAlpha() )
+                              );
 
       ReferenceEdge edgeReflexive_i = hrnParam.getReferenceTo( hrnParam, null );
       assert edgeReflexive_i != null;
-      paramIndex2rewriteJ.put( paramIndex, edgeReflexive_i.getBeta() );
+      paramIndex2rewriteJ.put( paramIndex, 
+                              toShadowTokens( ogCallee, edgeReflexive_i.getBeta() )
+                              );
 
       TempDescriptor tdParamQ = ogCallee.paramIndex2tdQ.get( paramIndex );
       assert tdParamQ != null;
@@ -947,7 +943,9 @@ public class OwnershipGraph {
       assert lnParamQ != null;
       ReferenceEdge edgeSpecialQ_i = lnParamQ.getReferenceTo( hrnParam, null );
       assert edgeSpecialQ_i != null;
-      paramIndex2rewriteK.put( paramIndex, edgeSpecialQ_i.getBeta() );
+      paramIndex2rewriteK.put( paramIndex, 
+                              toShadowTokens( ogCallee, edgeSpecialQ_i.getBeta() )
+                              );
 
       TokenTuple p_i = new TokenTuple( hrnParam.getID(),
                                       true,
@@ -1164,7 +1162,7 @@ public class OwnershipGraph {
       // then bring g_ij onto g'_ij and rewrite
       transferOnto( hrnSummary, hrnShadowSummary );
 
-      // TODO REPLACE NORMAL TOKEN WITH SHADOW TOKEN BEFORE PROCEEDING!!
+      hrnShadowSummary.setAlpha( toShadowTokens( ogCallee, hrnShadowSummary.getAlpha() ) );
 
       // shadow nodes only are touched by a rewrite one time,
       // so rewrite and immediately commit--and they don't belong
@@ -1191,6 +1189,8 @@ public class OwnershipGraph {
        assert hrnIthShadow.getNumReferencees() == 0;
 
        transferOnto( hrnIth, hrnIthShadow );
+       
+       hrnIthShadow.setAlpha( toShadowTokens( ogCallee, hrnIthShadow.getAlpha() ) );
 
        rewriteCallerNodeAlpha( fm.numParameters(),
                                bogusIndex,
@@ -1235,7 +1235,8 @@ public class OwnershipGraph {
                                                                     null,
                                                                     edgeCallee.getFieldDesc(),
                                                                     false,
-                                                                    edgeCallee.getBeta() );
+                                                                    toShadowTokens( ogCallee, edgeCallee.getBeta() )
+                                                                    );
          rewriteCallerEdgeBeta( fm.numParameters(),
                                 bogusIndex,
                                 edgeNewInCallerTemplate,
@@ -1294,6 +1295,22 @@ public class OwnershipGraph {
   }
 
 
+  private ReachabilitySet toShadowTokens( OwnershipGraph ogCallee,
+                                         ReachabilitySet rsIn ) {
+
+    ReachabilitySet rsOut = new ReachabilitySet( rsIn );
+
+    Iterator<AllocationSite> allocItr = ogCallee.allocationSites.iterator();
+    while( allocItr.hasNext() ) {
+      AllocationSite as = allocItr.next();
+
+      rsOut = rsOut.toShadowTokens( as );
+    }
+
+    return rsOut.makeCanonical();
+  }
+
+
   private void rewriteCallerNodeAlpha( int numParameters, 
                                       Integer paramIndex, 
                                       HeapRegionNode hrn,
@@ -1541,6 +1558,15 @@ public class OwnershipGraph {
   }
   
 
+  protected void majorAgeTokens(AllocationSite as, ReferenceEdge edge) {
+    //edge.setBeta( edge.getBeta().majorAgeTokens( as ) );
+  }
+
+  protected void majorAgeTokens(AllocationSite as, HeapRegionNode hrn) {
+    //hrn.setAlpha( hrn.getAlpha().majorAgeTokens( as ) );
+  }
+
+
 
   ////////////////////////////////////////////////////
   // in merge() and equals() methods the suffix A
index 2f45849ff583a13c3e5989bc6ccd3f91cfc7ef0b..9e4a338e30f01af575bd0df413a1ae2f336dcc59 100644 (file)
@@ -174,7 +174,22 @@ public class ReachabilitySet extends Canonical {
     Iterator itrS = this.iterator();
     while( itrS.hasNext() ) {
       TokenTupleSet tts = (TokenTupleSet) itrS.next();
-      rsOut.possibleReachabilities.add(tts.ageTokens(as) );
+      rsOut.possibleReachabilities.add( tts.ageTokens(as) );
+    }
+
+    return rsOut.makeCanonical();
+  }
+
+
+  public ReachabilitySet toShadowTokens(AllocationSite as) {
+    assert as != null;
+
+    ReachabilitySet rsOut = new ReachabilitySet();
+
+    Iterator itrS = this.iterator();
+    while( itrS.hasNext() ) {
+      TokenTupleSet tts = (TokenTupleSet) itrS.next();
+      rsOut.possibleReachabilities.add( tts.toShadowTokens(as) );
     }
 
     return rsOut.makeCanonical();
index c875bd7d414329384866985a1367be17e4c40e01..b48d5bd80f68051201338699302a5678b1711f1b 100644 (file)
@@ -70,7 +70,6 @@ public class TokenTuple extends Canonical {
 
   public TokenTuple changeTokenTo(Integer tokenToChangeTo) {
     assert tokenToChangeTo != null;
-    assert isNewSummary    == false;
 
     return new TokenTuple(tokenToChangeTo,
                           isNewSummary,
index 8dbe4886b76768f6a64661b248f64e85045f767e..b11d90b3097949a330950d9d7665d3c7f792d011 100644 (file)
@@ -208,6 +208,38 @@ public class TokenTupleSet extends Canonical {
   }
 
 
+  public TokenTupleSet toShadowTokens(AllocationSite as) {
+    assert as != null;
+
+    TokenTupleSet ttsOut = new TokenTupleSet();
+
+    Iterator itrT = this.iterator();
+    while( itrT.hasNext() ) {
+      TokenTuple tt = (TokenTuple) itrT.next();
+
+      Integer token = tt.getToken();
+      int age = as.getAge(token);
+
+      // summary tokens and tokens not associated with
+      // the site should be left alone
+      if( age == AllocationSite.AGE_notInThisSite ) {
+       ttsOut.tokenTuples.add(tt);
+
+      } else if( age == AllocationSite.AGE_summary ) {
+       ttsOut.tokenTuples.add(tt.changeTokenTo( as.getSummaryShadow() ));
+
+      } else if( age == AllocationSite.AGE_oldest ) {
+       ttsOut.tokenTuples.add(tt.changeTokenTo( as.getOldestShadow() ));
+
+      } else {
+       ttsOut.tokenTuples.add(tt.changeTokenTo( as.getIthOldestShadow( age ) ));
+      }
+    }
+
+    return ttsOut.makeCanonical();
+  }
+
+
   public ReachabilitySet rewriteToken( TokenTuple tokenToRewrite,
                                       ReachabilitySet replacements,
                                       boolean makeChangeSet,