Fixed x.f = y operation
authorjjenista <jjenista>
Mon, 4 Aug 2008 23:09:09 +0000 (23:09 +0000)
committerjjenista <jjenista>
Mon, 4 Aug 2008 23:09:09 +0000 (23:09 +0000)
Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java
Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java

index 7010de5bbdb71d575c7d8aee8d04434e5b41d813..69db25c20faf9782f14dbc906be99fd666133365 100644 (file)
@@ -157,10 +157,10 @@ public class OwnershipGraph {
        }    
     }
     
-    protected void propagateTokens( HeapRegionNode                   nPrime,
-                                   ChangeTupleSet                   c0,
-                                   HashSet<HeapRegionNode>          nodesWithNewAlpha,
-                                   HashSet<ReferenceEdgeProperties> edgesWithNewBeta ) {
+    protected void propagateTokensOverNodes( HeapRegionNode                   nPrime,
+                                            ChangeTupleSet                   c0,
+                                            HashSet<HeapRegionNode>          nodesWithNewAlpha,
+                                            HashSet<ReferenceEdgeProperties> edgesWithNewBeta ) {
 
        HashSet<HeapRegionNode> todoNodes
            = new HashSet<HeapRegionNode>();
@@ -249,7 +249,17 @@ public class OwnershipGraph {
            }
        }
 
+       propagateTokensOverEdges( todoEdges, edgePlannedChanges, nodesWithNewAlpha, edgesWithNewBeta );
+    }
+
+
+    protected void propagateTokensOverEdges( 
+        HashSet<ReferenceEdgeProperties>                   todoEdges,
+        Hashtable<ReferenceEdgeProperties, ChangeTupleSet> edgePlannedChanges,
+        HashSet<HeapRegionNode>                            nodesWithNewAlpha,
+        HashSet<ReferenceEdgeProperties>                   edgesWithNewBeta ) {
        
+
        while( !todoEdges.isEmpty() ) {
            ReferenceEdgeProperties e = todoEdges.iterator().next();
            todoEdges.remove( e );
@@ -400,14 +410,41 @@ public class OwnershipGraph {
                
                ReachabilitySet O = srcln.getReferenceTo( hrnSrc ).getBeta();
 
-               ReferenceEdgeProperties repNew 
-                   = new ReferenceEdgeProperties( false, false, repSrc.getBeta() );
-
-               addReferenceEdge( hrn, hrnSrc, repNew );
 
+               // propagate tokens over nodes starting from hrnSrc, and it will
+               // take care of propagating back up edges from any touched nodes
                ChangeTupleSet Cy = O.unionUpArityToChangeSet( R );
+               propagateTokensOverNodes( hrnSrc, Cy, nodesWithNewAlpha, edgesWithNewBeta );
+
+
+               // then propagate back just up the edges from hrn
+               ChangeTupleSet Cx = R.unionUpArityToChangeSet( O );
+
+               HashSet<ReferenceEdgeProperties> todoEdges = 
+                   new HashSet<ReferenceEdgeProperties>();
 
-               propagateTokens( hrnSrc, Cy, nodesWithNewAlpha, edgesWithNewBeta );
+               Hashtable<ReferenceEdgeProperties, ChangeTupleSet> edgePlannedChanges =
+                   new Hashtable<ReferenceEdgeProperties, ChangeTupleSet>();
+
+               Iterator referItr = hrn.iteratorToReferencers();
+               while( referItr.hasNext() ) {
+                   OwnershipNode onRef = (OwnershipNode) referItr.next();
+                   ReferenceEdgeProperties repUpstream = onRef.getReferenceTo( hrn );
+
+                   todoEdges.add( repUpstream );
+                   edgePlannedChanges.put( repUpstream, Cx );
+               }
+
+               propagateTokensOverEdges( todoEdges, 
+                                         edgePlannedChanges,
+                                         nodesWithNewAlpha,
+                                         edgesWithNewBeta );
+
+               // finally, create the actual reference edge hrn->hrnSrc
+               ReferenceEdgeProperties repNew 
+                   = new ReferenceEdgeProperties( false, false, repSrc.getBetaNew() );
+
+               addReferenceEdge( hrn, hrnSrc, repNew );
            }
        }       
 
index c616953a207ea306d115f900cd28bb620bf97d9c..b71138e1b1d1247c1feb4ae1cbe7f7cfb011a795 100644 (file)
@@ -57,18 +57,12 @@ task Startup( StartupObject s{ initialstate } ) {
     while( false ) {
        Foo a = new Foo();
        a.x   = new Foo();
-       a.x.x = new Foo();
-    }
-    
-    
-    Foo b;
-    while( false ) {
-       Foo c = new Foo();
-       c.x = b;
-       b = c;
+               a.x.x = new Foo();
+
+       //Foo z = a.x;
+       //z.x = new Foo();
     }
     
-    
     Foo d = new Foo();
     Foo e = new Foo();
     Foo f = new Foo();
@@ -76,6 +70,19 @@ task Startup( StartupObject s{ initialstate } ) {
     d.x = e;
     e.x = f;    
 
+    // to look like Foo a above
+    //d.x.x = f;
+
+
+    /*
+    Foo b;
+    while( false ) {
+       Foo c = new Foo();
+       c.x = b;
+       b = c;
+    }
+    */
+
     taskexit( s{ !initialstate } );
 }