Prune change sets during token prop by beta info only, not whether the rule was applied
authorjjenista <jjenista>
Tue, 5 Aug 2008 01:28:15 +0000 (01:28 +0000)
committerjjenista <jjenista>
Tue, 5 Aug 2008 01:28:15 +0000 (01:28 +0000)
Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java
Robust/src/Analysis/OwnershipAnalysis/LabelNode.java
Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java
Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java

index 237f2a51bbd2ee2f847e8eda5f4a372f7b141732..fdbe1fa9b69287b8d4ae7b88b5e0bab9161dc683 100644 (file)
@@ -62,8 +62,13 @@ public class HeapRegionNode extends OwnershipNode {
     }
 
 
-    public boolean equals( HeapRegionNode hrn ) {
-       assert hrn != null;
+    public boolean equals( Object o ) {
+
+       if( !( o instanceof HeapRegionNode) ) {
+           return false;
+       }
+
+       HeapRegionNode hrn = (HeapRegionNode) o;
 
        return id.equals( hrn.getID() )            &&
            isSingleObject == hrn.isSingleObject() &&
@@ -73,6 +78,10 @@ public class HeapRegionNode extends OwnershipNode {
            description.equals( hrn.getDescription() );
     }
 
+    public int hashCode() {
+       return id.intValue();
+    }
+
 
 
     public boolean isSingleObject() {
index c991f1d72687c8157e9feddccdd160c58450178d..8ae1825891917dc18c90b13ba26a667e7b76ddc5 100644 (file)
@@ -5,31 +5,31 @@ import IR.Flat.*;
 import java.util.*;
 
 public class LabelNode extends OwnershipNode {
+    protected TempDescriptor td;
 
     public LabelNode( TempDescriptor td ) {
        this.td = td;
     }
 
-
-    /////////////////
-    // equality  
-    /////////////////
-    protected TempDescriptor td;
-
     public TempDescriptor getTempDescriptor() {
        return td;
     }
 
-    public boolean equals( LabelNode ln ) {
-       assert ln != null;
+    public boolean equals( Object o ) {
+
+       if( !( o instanceof LabelNode) ) {
+           return false;
+       }
+
+       LabelNode ln = (LabelNode) o;
+
        return td == ln.getTempDescriptor();
     }
-    /////////////////
-    // end equality  
-    /////////////////
 
+    public int hashCode() {
+       return td.getNum();
+    }
 
-    // for writing out
     public String getTempDescriptorString() {
        return td.toString();
     }
index fb574f59f24aa1b5c7f4782c7cf729f1d2e80349..ecb65e8eda826b3e027802b0006c3ce99230afe8 100644 (file)
@@ -157,10 +157,11 @@ public class OwnershipGraph {
        }    
     }
     
+
     protected void propagateTokensOverNodes( HeapRegionNode                   nPrime,
                                             ChangeTupleSet                   c0,
                                             HashSet<HeapRegionNode>          nodesWithNewAlpha,
-                                            HashSet<ReferenceEdgeProperties> edgesWithNewBeta ) {
+                                            HashSet<ReferenceEdgeProperties> edgesWithNewBeta ) {      
 
        HashSet<HeapRegionNode> todoNodes
            = new HashSet<HeapRegionNode>();
@@ -176,19 +177,11 @@ public class OwnershipGraph {
        Hashtable<ReferenceEdgeProperties, ChangeTupleSet> edgePlannedChanges 
            = new Hashtable<ReferenceEdgeProperties, ChangeTupleSet>();
        
-       Hashtable<HeapRegionNode, ChangeTupleSet> nodeChangesMade
-           = new Hashtable<HeapRegionNode, ChangeTupleSet>();
 
        while( !todoNodes.isEmpty() ) {
-           HeapRegionNode n = todoNodes.iterator().next();
-           todoNodes.remove( n );
-           
+           HeapRegionNode n = todoNodes.iterator().next();        
            ChangeTupleSet C = nodePlannedChanges.get( n );
 
-           if( !nodeChangesMade.containsKey( n ) ) {
-               nodeChangesMade.put( n, new ChangeTupleSet().makeCanonical() );
-           }
-
            Iterator itrC = C.iterator();
            while( itrC.hasNext() ) {
                ChangeTuple c = (ChangeTuple) itrC.next();
@@ -197,12 +190,9 @@ public class OwnershipGraph {
                    ReachabilitySet withChange = n.getAlpha().union( c.getSetToAdd() );
                    n.setAlphaNew( n.getAlphaNew().union( withChange ) );
                    nodesWithNewAlpha.add( n );
-                   nodeChangesMade.put( n, nodeChangesMade.get( n ).union( c ) );
                }
            }
 
-           ChangeTupleSet Cprime = nodeChangesMade.get( n );
-
            Iterator referItr = n.iteratorToReferencers();
            while( referItr.hasNext() ) {
                OwnershipNode           on  = (OwnershipNode) referItr.next();
@@ -213,7 +203,7 @@ public class OwnershipGraph {
                    edgePlannedChanges.put( rep, new ChangeTupleSet().makeCanonical() );
                }
 
-               edgePlannedChanges.put( rep, edgePlannedChanges.get( rep ).union( Cprime ) );
+               edgePlannedChanges.put( rep, edgePlannedChanges.get( rep ).union( C ) );
            }
 
            HeapRegionNode          m = null;
@@ -226,7 +216,7 @@ public class OwnershipGraph {
 
                ChangeTupleSet changesToPass = new ChangeTupleSet().makeCanonical();
 
-               Iterator itrCprime = Cprime.iterator();
+               Iterator itrCprime = C.iterator();
                while( itrCprime.hasNext() ) {
                    ChangeTuple c = (ChangeTuple) itrCprime.next();
                    if( f.getBeta().contains( c.getSetToMatch() ) ) {
@@ -242,11 +232,14 @@ public class OwnershipGraph {
                    ChangeTupleSet currentChanges = nodePlannedChanges.get( m );
 
                    if( !changesToPass.isSubset( currentChanges ) ) {
-                       todoNodes.add( m );
+
                        nodePlannedChanges.put( m, currentChanges.union( changesToPass ) );
+                       todoNodes.add( m );
                    }
                }
            }
+
+           todoNodes.remove( n );
        }
 
        propagateTokensOverEdges( todoEdges, edgePlannedChanges, nodesWithNewAlpha, edgesWithNewBeta );
index b71138e1b1d1247c1feb4ae1cbe7f7cfb011a795..e72c5f10ec5ca9b3a6c2ca9601d894db34cde229 100644 (file)
@@ -54,6 +54,7 @@ public class Foo {
 // a heap region that is multi-object, flagged, not summary
 task Startup( StartupObject s{ initialstate } ) {
     
+    
     while( false ) {
        Foo a = new Foo();
        a.x   = new Foo();
@@ -63,25 +64,41 @@ task Startup( StartupObject s{ initialstate } ) {
        //z.x = new Foo();
     }
     
+
+
     Foo d = new Foo();
     Foo e = new Foo();
     Foo f = new Foo();
+    Foo g = new Foo();
 
     d.x = e;
-    e.x = f;    
+    e.x = f;
+    f.x = g;
+
+
+    Foo h = new Foo();
+    Foo i = new Foo();
+    Foo j = new Foo();
+    Foo k = new Foo();
+
+    j.x = k;
+    i.x = j;
+    h.x = i;
+
+
+    
 
     // 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 } );
 }