Added fields to ReferenceEdgeProperties and combed over all classes that need proper...
authorjjenista <jjenista>
Wed, 6 Aug 2008 19:33:14 +0000 (19:33 +0000)
committerjjenista <jjenista>
Wed, 6 Aug 2008 19:33:14 +0000 (19:33 +0000)
Robust/src/Analysis/OwnershipAnalysis/ChangeTuple.java
Robust/src/Analysis/OwnershipAnalysis/ChangeTupleSet.java
Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java
Robust/src/Analysis/OwnershipAnalysis/LabelNode.java
Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java
Robust/src/Analysis/OwnershipAnalysis/OwnershipNode.java
Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java
Robust/src/Analysis/OwnershipAnalysis/ReferenceEdgeProperties.java
Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java
Robust/src/Analysis/OwnershipAnalysis/TokenTupleSet.java
Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java

index 296e578d353900ec1f8af3d9e0fb3dc352a2f9f6..ce36f67190d4064a24101f5d764e2d89b8a5149d 100644 (file)
@@ -31,6 +31,10 @@ public class ChangeTuple extends Canonical
     public TokenTupleSet getSetToAdd()   { return toAdd;   }
 
     public boolean equals( Object o ) {
+       if( o == null ) {
+           return false;
+       }
+
        if( !(o instanceof ChangeTuple) ) {
            return false;
        }
index 498cda9bec2a4c6863303c6031f1c0edb31bd349..1a91061aac0241f289eb79390bd669f6fa39ba3a 100644 (file)
@@ -57,6 +57,10 @@ public class ChangeTupleSet extends Canonical {
     }
 
     public boolean equals( Object o ) {
+       if( o == null ) {
+           return false;
+       }
+
        if( !(o instanceof ChangeTupleSet) ) {
            return false;
        }
index fdbe1fa9b69287b8d4ae7b88b5e0bab9161dc683..4b6464d29191eac78588d5be95d4405d5c040544 100644 (file)
@@ -63,6 +63,9 @@ public class HeapRegionNode extends OwnershipNode {
 
 
     public boolean equals( Object o ) {
+       if( o == null ) {
+           return false;
+       }
 
        if( !( o instanceof HeapRegionNode) ) {
            return false;
index 8ae1825891917dc18c90b13ba26a667e7b76ddc5..327940606947fe2be078f4251c339c03ad3c00b2 100644 (file)
@@ -16,6 +16,9 @@ public class LabelNode extends OwnershipNode {
     }
 
     public boolean equals( Object o ) {
+       if( o == null ) {
+           return false;
+       }
 
        if( !( o instanceof LabelNode) ) {
            return false;
@@ -30,6 +33,7 @@ public class LabelNode extends OwnershipNode {
        return td.getNum();
     }
 
+
     public String getTempDescriptorString() {
        return td.toString();
     }
index 65b39c9345c91df262cb3cbca310d8b2de4d7030..bd5d6ef9c74663dd71e092bb0695e37638945e49 100644 (file)
@@ -361,7 +361,7 @@ public class OwnershipGraph {
                ReachabilitySet beta2        = rep2.getBeta();
 
                ReferenceEdgeProperties rep = 
-                   new ReferenceEdgeProperties( false,
+                   new ReferenceEdgeProperties( null,
                                                 false,
                                                 beta1.intersection( beta2 ) );
 
@@ -435,7 +435,7 @@ public class OwnershipGraph {
 
                // finally, create the actual reference edge hrn->hrnSrc
                ReferenceEdgeProperties repNew 
-                   = new ReferenceEdgeProperties( false
+                   = new ReferenceEdgeProperties( fd
                                                   false, 
                                                   repSrc.getBetaNew().pruneBy( hrn.getAlpha() )
                                                 );
@@ -487,8 +487,8 @@ public class OwnershipGraph {
        // and have a reference to themselves, because we can't know the
        // structure of memory that is passed into the method.  We're assuming
        // the worst here.
-       addReferenceEdge( lnParam, hrn, new ReferenceEdgeProperties( false, false, beta ) );
-       addReferenceEdge( hrn,     hrn, new ReferenceEdgeProperties( false, true,  beta ) );
+       addReferenceEdge( lnParam, hrn, new ReferenceEdgeProperties( null, false, beta ) );
+       addReferenceEdge( hrn,     hrn, new ReferenceEdgeProperties( null, true,  beta ) );
     }
     
     public void assignTempToNewAllocation( TempDescriptor td,
@@ -512,7 +512,7 @@ public class OwnershipGraph {
        
        clearReferenceEdgesFrom( dst );
        
-       addReferenceEdge( dst, hrnNewest, new ReferenceEdgeProperties( false, false, hrnNewest.getAlpha() ) );
+       addReferenceEdge( dst, hrnNewest, new ReferenceEdgeProperties( null, false, hrnNewest.getAlpha() ) );
     }
 
 
@@ -828,11 +828,7 @@ public class OwnershipGraph {
            AllocationSite allocSite = i.next();    
            HeapRegionNode hrnSummary       = getSummaryNode      ( allocSite );
            HeapRegionNode hrnShadowSummary = getShadowSummaryNode( allocSite );
-       }
-
-
-       
-       /*
+       }      
 
        // in non-static methods there is a "this" pointer
        // that should be taken into account
@@ -885,13 +881,13 @@ public class OwnershipGraph {
                    // and a set of destination heaps in the caller graph, and make
                    // a reference edge in the caller for every possible (src,dst) pair 
                    if( !ogCallee.id2hrn.contains( idChildCallee ) ) {
-                       //System.out.println( "Houston, we got a problem." );
-                       //System.out.println( "idCallee is "+idCallee );
-                       //System.out.println( "idChildCallee is "+idChildCallee );
+                       System.out.println( "Houston, we got a problem." );
+                       System.out.println( "idCallee is "+idCallee );
+                       System.out.println( "idChildCallee is "+idChildCallee );
                        
                        try {                       
-                           writeGraph( "caller", false, false, false );
-                           ogCallee.writeGraph( "callee", false, false, false );                           
+                           writeGraph         ( "caller", false, false, false, false );
+                           ogCallee.writeGraph( "callee", false, false, false, false );                            
                        } catch( IOException e ) {}
                    }
 
@@ -922,9 +918,9 @@ public class OwnershipGraph {
                }
            } 
        }       
-       */
     }
 
+
     private HashSet<HeapRegionNode> getHRNSetThatPossiblyMapToCalleeHRN( OwnershipGraph ogCallee,
                                                                         Integer        idCallee,
                                                                         FlatCall       fc,
index a216ca7a0655f627ca3eb85c77729fcdd46c2691..14adde19c74e8498acc5143fbddfd8b3e5a709b1 100644 (file)
@@ -4,7 +4,9 @@ import IR.*;
 import IR.Flat.*;
 import java.util.*;
 
-public class OwnershipNode {   
+public abstract class OwnershipNode {   
+
+    protected Hashtable <HeapRegionNode, ReferenceEdgeProperties> referencedRegions;
 
     public OwnershipNode() {
        referencedRegions = 
@@ -12,13 +14,6 @@ public class OwnershipNode {
     }
 
 
-    ///////////////////////////////////////////
-    // interface with larger graph
-    ///////////////////////////////////////////
-    protected Hashtable
-       <HeapRegionNode, ReferenceEdgeProperties>
-       referencedRegions;
-
     public Iterator setIteratorToReferencedRegions() {
        Set s = referencedRegions.entrySet();
        return s.iterator();
@@ -50,7 +45,8 @@ public class OwnershipNode {
 
        return referencedRegions.get( hrn );
     }
-    ///////////////////////////////////////////////
-    // end interface with larger graph
-    ///////////////////////////////////////////////
+
+
+    abstract public boolean equals( Object o );
+    abstract public int hashCode();
 }
\ No newline at end of file
index f7a5721ac255b1b980618a8a273ee16641b9c4ff..08b2b7a81db5d54ca334d6ccb9187c02aa3dd26e 100644 (file)
@@ -243,6 +243,10 @@ public class ReachabilitySet extends Canonical {
 
 
     public boolean equals( Object o ) {
+       if( o == null ) {
+           return false;
+       }
+
        if( !(o instanceof ReachabilitySet) ) {
            return false;
        }
index 4b85b2afa1c4c42cfceb8c679a1f2441aecf5ad5..4e0b0458a8483e2331ca3733de47250df15f91f4 100644 (file)
@@ -1,8 +1,14 @@
 package Analysis.OwnershipAnalysis;
 
+import IR.*;
+import IR.Flat.*;
+
+
 public class ReferenceEdgeProperties {
 
-    protected boolean isUnique;
+    // a null field descriptor means "any field"
+    protected FieldDescriptor fieldDesc;
+
     protected boolean isInitialParamReflexive;
 
     protected ReachabilitySet beta;
@@ -12,29 +18,15 @@ public class ReferenceEdgeProperties {
     protected HeapRegionNode dst;
 
     public ReferenceEdgeProperties() {
-       this( false, false, null );
+       this( null, false, null );
     }    
 
-    public ReferenceEdgeProperties( boolean isUnique ) {
-       this( isUnique, false, null );
-    }
-
-    public ReferenceEdgeProperties( boolean isUnique,
-                                   boolean isInitialParamReflexive ) {
-       this( isUnique, isInitialParamReflexive, null );
-    }
-
-    public ReferenceEdgeProperties( boolean         isUnique,
+    public ReferenceEdgeProperties( FieldDescriptor fieldDesc, 
                                    boolean         isInitialParamReflexive,
-                                   ReachabilitySet beta) {
-       this.isUnique                = isUnique;
-       this.isInitialParamReflexive = isInitialParamReflexive;
+                                   ReachabilitySet beta ) {
 
-       // these members are set by higher-level code
-       // when this ReferenceEdgeProperties object is
-       // applied to an edge
-       this.src = null;
-       this.dst = null;
+       this.fieldDesc               = fieldDesc;
+       this.isInitialParamReflexive = isInitialParamReflexive; 
 
        if( beta != null ) {
            this.beta = beta;
@@ -43,6 +35,14 @@ public class ReferenceEdgeProperties {
            this.beta = this.beta.makeCanonical();
        }
 
+       // these members are set by higher-level code
+       // when this ReferenceEdgeProperties object is
+       // applied to an edge
+       this.src = null;
+       this.dst = null;
+
+       // when edges are not undergoing a transitional operation
+       // that is changing beta info, betaNew is always empty
        betaNew = new ReachabilitySet();
        betaNew = betaNew.makeCanonical();
     }
@@ -67,20 +67,20 @@ public class ReferenceEdgeProperties {
     }
 
 
-    // copying does not copy source and destination members!
+    // copying does not copy source and destination members! or betaNew
     public ReferenceEdgeProperties copy() {
-       return new ReferenceEdgeProperties( isUnique,
+       return new ReferenceEdgeProperties( fieldDesc,
                                            isInitialParamReflexive,
                                            beta );
     }
 
 
-
-    public boolean isUnique() {
-       return isUnique;
+    public FieldDescriptor getFieldDesc() {
+       return fieldDesc;
     }
-    public void setIsUnique( boolean isUnique ) {
-       this.isUnique = isUnique;
+
+    public void setFieldDesc( FieldDescriptor fieldDesc ) {
+       this.fieldDesc = fieldDesc;
     }
 
 
@@ -93,7 +93,6 @@ public class ReferenceEdgeProperties {
     }
 
 
-
     public ReachabilitySet getBeta() {
        return beta;
     }
@@ -122,24 +121,42 @@ public class ReferenceEdgeProperties {
     }
 
 
-    public boolean equals( ReferenceEdgeProperties rep ) {
-       assert rep != null;
+    public boolean equals( Object o ) {
+       if( o == null ) {
+           return false;
+       }
+
+       if( !(o instanceof ReferenceEdgeProperties) ) {
+           return false;
+       }
        
-       return isUnique                == rep.isUnique()                &&
-              isInitialParamReflexive == rep.isInitialParamReflexive();
+       ReferenceEdgeProperties rep = (ReferenceEdgeProperties) o;
+
+       // field descriptors maintain the invariant that they are reference comparable
+       return fieldDesc               == rep.fieldDesc               &&
+              isInitialParamReflexive == rep.isInitialParamReflexive &&
+              beta.equals( rep.beta );
     }
 
+    public int hashCode() {
+       int hash = 0;
+       if( fieldDesc != null ) {
+           hash += fieldDesc.getType().hashCode();
+       }
+       hash += beta.hashCode();
+       return hash;
+    }
+
+
     public String getBetaString() {
        return beta.toStringEscapeNewline();
     }
     
     public String toEdgeLabelString() {
        String edgeLabel = "";
-       /*
-       if( rep.isUnique() ) {
-         edgeLabel += "Unq";
+       if( fieldDesc != null ) {
+           edgeLabel += fieldDesc.toStringBrief() + "\\n";
        }
-       */
        if( isInitialParamReflexive ) {
            edgeLabel += "Rflx\\n";
        }
index acaf257dc7e674811ed2eb86c3e6c56e505170c5..e8fd95a97e39de72058aac9f40ad3801815b3e11 100644 (file)
@@ -60,6 +60,10 @@ public class TokenTuple extends Canonical
     }
 
     public boolean equals( Object o ) {
+       if( o == null ) {
+           return false;
+       }
+
        if( !(o instanceof TokenTuple) ) {
            return false;
        }
index 4bd1a7186e66062f29aa05d29a6aa07f35cdffc5..fb6ee256a434c20a94ea7d690684288f2611ff07 100644 (file)
@@ -100,6 +100,10 @@ public class TokenTupleSet extends Canonical {
     }
 
     public boolean equals( Object o ) {
+       if( o == null ) {
+           return false;
+       }
+
        if( !(o instanceof TokenTupleSet) ) {
            return false;
        }
index a203ca46590f50aef60dac881c6944954fa32fe9..6cc5b5b691885115e26e2bf202f841746a276a23 100644 (file)
@@ -46,7 +46,7 @@ public class Foo {
        a.x = b.x;
     }
 
-    public void test( Foo p0, Foo p1 ) {
+    static public void test( Foo p0, Foo p1 ) {
        Foo f0 = new Foo();
        Foo f1 = new Foo();
        Foo f2 = new Foo();
@@ -110,15 +110,8 @@ task Startup( StartupObject s{ initialstate } ) {
        b = c;
     }
     */
-
-    Foo aa = new Foo();
-    aa.test( aa, aa );
-
-    /*
-    Foo ab = new Foo();
-    Foo ac = new Foo();
-    Foo ad = new Foo();
     
+    /*
     aa.x = ab;
     ab.x = ac;
     ab.x = aa;
@@ -128,6 +121,29 @@ task Startup( StartupObject s{ initialstate } ) {
     taskexit( s{ !initialstate } );
 }
 
+
+task methodTest( Foo p0{ f } ) {
+
+    Foo a0;
+    if( false ) {
+       a0 = new Foo();
+    } else {
+       a0   = new Foo();
+       a0.x = new Foo();
+       p0.x = a0;
+    }
+
+    Foo a1 = new Foo();
+
+    if( false ) {      
+       p0.x = a1;
+    }
+
+    Foo.test( a0, a1 );
+
+    taskexit( p0{ !f } );
+}
+
 /*
 task NewObject( Foo a{ f }, Foo b{ f } ) {