Token propagation implemented, stable but incorrect. This is just a capture.
authorjjenista <jjenista>
Tue, 15 Jul 2008 23:24:06 +0000 (23:24 +0000)
committerjjenista <jjenista>
Tue, 15 Jul 2008 23:24:06 +0000 (23:24 +0000)
Robust/src/Analysis/OwnershipAnalysis/ChangeTupleSet.java
Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java
Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java
Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java
Robust/src/Analysis/OwnershipAnalysis/ReferenceEdgeProperties.java

index afbd04052c87aa67229867b29e4ddc1c93bdf26a..498cda9bec2a4c6863303c6031f1c0edb31bd349 100644 (file)
@@ -32,12 +32,27 @@ public class ChangeTupleSet extends Canonical {
     }
 
     public ChangeTupleSet union( ChangeTupleSet ctsIn ) {
+       assert ctsIn != null;
+
        ChangeTupleSet ctsOut = new ChangeTupleSet( this );
        ctsOut.changeTuples.addAll( ctsIn.changeTuples );
        return ctsOut.makeCanonical();
     }
 
+    public ChangeTupleSet union( ChangeTuple ctIn ) {
+       assert ctIn != null;
+
+       ChangeTupleSet ctsOut = new ChangeTupleSet( this );
+       ctsOut.changeTuples.add( ctIn );
+       return ctsOut.makeCanonical();
+    }
+
+    public boolean isEmpty() {
+       return changeTuples.isEmpty();
+    }
+
     public boolean isSubset( ChangeTupleSet ctsIn ) {
+       assert ctsIn != null;
        return ctsIn.changeTuples.containsAll( this.changeTuples );
     }
 
index 6650e669c343b4c0a0c2206dedc10d45484008a3..237f2a51bbd2ee2f847e8eda5f4a372f7b141732 100644 (file)
@@ -37,9 +37,11 @@ public class HeapRegionNode extends OwnershipNode {
        this.isNewSummary   = isNewSummary;
        this.allocSite      = allocSite;
        this.alpha          = alpha;
-       this.alphaNew       = null;
        this.description    = description;
 
+       alphaNew = new ReachabilitySet();
+       alphaNew = alphaNew.makeCanonical();
+
        referencers  = new HashSet<OwnershipNode>();
        memberFields = new HashSet<TempDescriptor>();
     }
@@ -138,8 +140,11 @@ public class HeapRegionNode extends OwnershipNode {
 
     public void applyAlphaNew() {
        assert alphaNew != null;
-       alpha    = alphaNew;
-       alphaNew = null;
+
+       alpha = alphaNew;
+
+       alphaNew = new ReachabilitySet();
+       alphaNew = alphaNew.makeCanonical();
     }
 
 
index cee91235777ddb6224dfbd490e1242106db11529..6fb336a04c50c2d1f1f7e65405b353ede9ca3208 100644 (file)
@@ -115,6 +115,8 @@ public class OwnershipGraph {
        assert rep        != null;
        referencer.addReferencedRegion( referencee, rep );
        referencee.addReferencer( referencer );
+       rep.setSrc( referencer );
+       rep.setDst( referencee );
     }
 
     protected void removeReferenceEdge( OwnershipNode  referencer,
@@ -158,7 +160,94 @@ public class OwnershipGraph {
 
 
     protected void propagateTokens( HeapRegionNode nPrime, ChangeTupleSet c0 ) {
+       HashSet<HeapRegionNode> todoNodes
+           = new HashSet<HeapRegionNode>();
+       todoNodes.add( nPrime );
 
+       HashSet<ReferenceEdgeProperties> todoEdges 
+           = new HashSet<ReferenceEdgeProperties>();
+       
+       Hashtable<HeapRegionNode, ChangeTupleSet> nodePlannedChanges 
+           = new Hashtable<HeapRegionNode, ChangeTupleSet>();
+       nodePlannedChanges.put( nPrime, c0 );
+
+       Hashtable<ReferenceEdgeProperties, ChangeTupleSet> edgePlannedChanges 
+           = new Hashtable<ReferenceEdgeProperties, ChangeTupleSet>();
+       
+       Hashtable<HeapRegionNode, ChangeTupleSet> nodeChangesMade
+           = new Hashtable<HeapRegionNode, ChangeTupleSet>();
+
+       Hashtable<ReferenceEdgeProperties, ChangeTupleSet> edgeChangesMade
+           = new Hashtable<ReferenceEdgeProperties, ChangeTupleSet>();
+
+       while( !todoNodes.isEmpty() ) {
+           HeapRegionNode n = todoNodes.iterator().next();
+           todoNodes.remove( n );
+
+           if( !nodeChangesMade.containsKey( n ) ) {
+               nodeChangesMade.put( n, new ChangeTupleSet().makeCanonical() );
+           }
+           
+           ChangeTupleSet C = nodePlannedChanges.get( n );
+
+           Iterator itrC = C.iterator();
+           while( itrC.hasNext() ) {
+               ChangeTuple c = (ChangeTuple) itrC.next();
+
+               if( n.getAlpha().contains( c.getSetToMatch() ) ) {
+                   n.setAlphaNew( n.getAlphaNew().union( c.getSetToAdd() ) );              
+                   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();
+               ReferenceEdgeProperties rep = on.getReferenceTo( n );
+               todoEdges.add( rep );
+
+               if( !edgePlannedChanges.containsKey( rep ) ) {
+                   edgePlannedChanges.put( rep, new ChangeTupleSet().makeCanonical() );
+               }
+
+               edgePlannedChanges.put( rep, edgePlannedChanges.get( rep ).union( Cprime ) );
+           }
+
+           HeapRegionNode          m = null;
+           ReferenceEdgeProperties f = null;
+           Iterator refeeItr = n.setIteratorToReferencedRegions();
+           while( refeeItr.hasNext() ) {
+               Map.Entry me = (Map.Entry)               refeeItr.next();
+               m            = (HeapRegionNode)          me.getKey();
+               f            = (ReferenceEdgeProperties) me.getValue();
+
+               ChangeTupleSet changesToPass = new ChangeTupleSet();
+
+               Iterator itrCprime = Cprime.iterator();
+               while( itrCprime.hasNext() ) {
+                   ChangeTuple c = (ChangeTuple) itrCprime.next();
+                   if( f.getBeta().contains( c.getSetToMatch() ) ) {
+                       changesToPass = changesToPass.union( c );
+                   }
+               }
+
+               if( !changesToPass.isEmpty() ) {
+                   if( !nodePlannedChanges.containsKey( m ) ) {
+                       nodePlannedChanges.put( m, new ChangeTupleSet().makeCanonical() );
+                   }
+
+                   ChangeTupleSet currentChanges = nodePlannedChanges.get( m );
+
+                   if( !changesToPass.isSubset( currentChanges ) ) {
+                       todoNodes.add( m );
+                       nodePlannedChanges.put( m, currentChanges.union( changesToPass ) );
+                   }
+               }
+           }
+       }
+       
     }
 
 
index d333f2c8b6c3f38edeac6e79c5bf5eb83d0cc701..842098d10d09d1fdd401090a3a0c8c731c4e8ea1 100644 (file)
@@ -15,6 +15,7 @@ public class ReachabilitySet extends Canonical {
     }
 
     public ReachabilitySet( TokenTupleSet tts ) {
+       assert tts != null;
        possibleReachabilities = new HashSet<TokenTupleSet>();
        possibleReachabilities.add( tts );
     }
@@ -24,6 +25,7 @@ public class ReachabilitySet extends Canonical {
     }
 
     public ReachabilitySet( ReachabilitySet rs ) {
+       assert rs != null;
        possibleReachabilities = (HashSet<TokenTupleSet>) rs.possibleReachabilities.clone(); // again, DEEP COPY?!
     }
 
@@ -31,17 +33,34 @@ public class ReachabilitySet extends Canonical {
        return (ReachabilitySet) Canonical.makeCanonical( this );
     }
 
+    public boolean contains( TokenTupleSet tts ) {
+       assert tts != null;
+       return possibleReachabilities.contains( tts );
+    }
+
     public Iterator iterator() {
        return possibleReachabilities.iterator();
     }
 
     public ReachabilitySet union( ReachabilitySet rsIn ) {
+       assert rsIn != null;
+
        ReachabilitySet rsOut = new ReachabilitySet( this );
        rsOut.possibleReachabilities.addAll( rsIn.possibleReachabilities );
        return rsOut.makeCanonical();
     }
 
+    public ReachabilitySet union( TokenTupleSet ttsIn ) {
+       assert ttsIn != null;
+
+       ReachabilitySet rsOut = new ReachabilitySet( this );
+       rsOut.possibleReachabilities.add( ttsIn );
+       return rsOut.makeCanonical();
+    }
+
     public ReachabilitySet intersection( ReachabilitySet rsIn ) {
+       assert rsIn != null;
+
        ReachabilitySet rsOut = new ReachabilitySet();
 
        Iterator i = this.iterator();
@@ -56,6 +75,8 @@ public class ReachabilitySet extends Canonical {
     }
 
     public ChangeTupleSet unionUpArity( ReachabilitySet rsIn ) {
+       assert rsIn != null;
+
        ChangeTupleSet ctsOut = new ChangeTupleSet();
 
        Iterator itrO = this.iterator();
index 3226d681a0ff5b28b4e5b11ed2fc5b4c38bab22f..4b85b2afa1c4c42cfceb8c679a1f2441aecf5ad5 100644 (file)
@@ -8,27 +8,20 @@ public class ReferenceEdgeProperties {
     protected ReachabilitySet beta;
     protected ReachabilitySet betaNew;
 
+    protected OwnershipNode  src;
+    protected HeapRegionNode dst;
 
     public ReferenceEdgeProperties() {
-       this.isUnique                = false;
-       this.isInitialParamReflexive = false;
-       this.beta                    = new ReachabilitySet();
-       this.betaNew                 = null;
+       this( false, false, null );
     }    
 
     public ReferenceEdgeProperties( boolean isUnique ) {
-       this.isUnique                = isUnique;
-       this.isInitialParamReflexive = false;
-       this.beta                    = new ReachabilitySet();
-       this.betaNew                 = null;
+       this( isUnique, false, null );
     }
 
     public ReferenceEdgeProperties( boolean isUnique,
                                    boolean isInitialParamReflexive ) {
-       this.isUnique                = isUnique;
-       this.isInitialParamReflexive = isInitialParamReflexive;
-       this.beta                    = new ReachabilitySet();
-       this.betaNew                 = null;
+       this( isUnique, isInitialParamReflexive, null );
     }
 
     public ReferenceEdgeProperties( boolean         isUnique,
@@ -36,11 +29,45 @@ public class ReferenceEdgeProperties {
                                    ReachabilitySet beta) {
        this.isUnique                = isUnique;
        this.isInitialParamReflexive = isInitialParamReflexive;
-       this.beta                    = beta;
-       this.betaNew                 = null;
+
+       // these members are set by higher-level code
+       // when this ReferenceEdgeProperties object is
+       // applied to an edge
+       this.src = null;
+       this.dst = null;
+
+       if( beta != null ) {
+           this.beta = beta;
+       } else {
+           this.beta = new ReachabilitySet();
+           this.beta = this.beta.makeCanonical();
+       }
+
+       betaNew = new ReachabilitySet();
+       betaNew = betaNew.makeCanonical();
+    }
+
+
+    public OwnershipNode getSrc() {
+       return src;
+    }
+
+    public void setSrc( OwnershipNode on ) {
+       assert on != null;
+       src = on;
+    }
+
+    public HeapRegionNode getDst() {
+       return dst;
+    }
+
+    public void setDst( HeapRegionNode hrn ) {
+       assert hrn != null;
+       dst = hrn;
     }
 
 
+    // copying does not copy source and destination members!
     public ReferenceEdgeProperties copy() {
        return new ReferenceEdgeProperties( isUnique,
                                            isInitialParamReflexive,
@@ -70,24 +97,34 @@ public class ReferenceEdgeProperties {
     public ReachabilitySet getBeta() {
        return beta;
     }
+
     public void setBeta( ReachabilitySet beta ) {
+       assert beta != null;
        this.beta = beta;
     }
 
     public ReachabilitySet getBetaNew() {
        return betaNew;
     }
+
     public void setBetaNew( ReachabilitySet beta ) {
+       assert beta != null;
        this.betaNew = beta;
     }
+
     public void applyBetaNew() {
        assert betaNew != null;
-       beta    = betaNew;
-       betaNew = null;
+
+       beta = betaNew;
+
+       betaNew = new ReachabilitySet();
+       betaNew = betaNew.makeCanonical();
     }
 
 
     public boolean equals( ReferenceEdgeProperties rep ) {
+       assert rep != null;
+       
        return isUnique                == rep.isUnique()                &&
               isInitialParamReflexive == rep.isInitialParamReflexive();
     }