equals() and hashCode() methods are bunk
authorjjenista <jjenista>
Mon, 11 Aug 2008 23:10:45 +0000 (23:10 +0000)
committerjjenista <jjenista>
Mon, 11 Aug 2008 23:10:45 +0000 (23:10 +0000)
Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java
Robust/src/Analysis/OwnershipAnalysis/LabelNode.java
Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.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/Tests/OwnershipAnalysisTest/test01/test01.java

index 4b6464d29191eac78588d5be95d4405d5c040544..43d808d2c6d3b8fc749188075d4dd3e318019bfd 100644 (file)
@@ -62,6 +62,7 @@ public class HeapRegionNode extends OwnershipNode {
     }
 
 
+    /*
     public boolean equals( Object o ) {
        if( o == null ) {
            return false;
@@ -84,7 +85,7 @@ public class HeapRegionNode extends OwnershipNode {
     public int hashCode() {
        return id.intValue();
     }
-
+    */
 
 
     public boolean isSingleObject() {
index 327940606947fe2be078f4251c339c03ad3c00b2..8802d673e77a15de1632dcf9adcccc0b26945b6b 100644 (file)
@@ -15,6 +15,7 @@ public class LabelNode extends OwnershipNode {
        return td;
     }
 
+    /*
     public boolean equals( Object o ) {
        if( o == null ) {
            return false;
@@ -32,7 +33,7 @@ public class LabelNode extends OwnershipNode {
     public int hashCode() {
        return td.getNum();
     }
-
+    */
 
     public String getTempDescriptorString() {
        return td.toString();
index 8e04335ba1a8cc7ae8e9d4173f67be57a0a6fabe..cb8147d0d8294a44b6e5b7ce61359909495d11e2 100644 (file)
@@ -318,6 +318,9 @@ public class OwnershipAnalysis {
     }
 
 
+    int x = 0;
+
+
     // keep passing the Descriptor of the method along for debugging
     // and dot file writing
     private OwnershipGraph
@@ -371,6 +374,16 @@ public class OwnershipAnalysis {
            if( !og.equals( ogPrev ) ) {
                setGraphForFlatNode( fn, og );
 
+
+
+               x++;
+               if( x > 0 ) {
+                   String s = String.format( "debug%04d", x );
+                   //og.writeGraph( s, true, true, true, false );
+               }
+
+
+
                for( int i = 0; i < fn.numNext(); i++ ) {
                    FlatNode nn = fn.getNext( i );                
                    flatNodesToVisit.add( nn );
index 96693ecc013cc3bd4bb74ef35791fb337ffbbce2..2eb6a05d734932fd8063212c922f940d21724a17 100644 (file)
@@ -370,6 +370,12 @@ public class OwnershipGraph {
        }
     }
 
+
+
+
+
+    static int x = 0;
+
     public void assignFieldToTemp( TempDescriptor  src, 
                                   TempDescriptor  dst,
                                   FieldDescriptor fd ) {
@@ -401,8 +407,20 @@ public class OwnershipGraph {
                hrnSrc        = (HeapRegionNode)          meS.getKey();
                repSrc        = (ReferenceEdgeProperties) meS.getValue();
                
-               ReachabilitySet O = srcln.getReferenceTo( hrnSrc ).getBeta();
+               ReachabilitySet O = repSrc.getBeta();
+
+
+               x++;
+               System.out.println( "x is "+x );
+               if( x > 0 ) {
+                   String s = String.format( "debug%04d", x );
+                   try {
+                   writeGraph( s, true, true, true, false );
+                   } catch( Exception e ) {}
+               }
+
 
+               System.out.println( "  O is "+O );
 
                // propagate tokens over nodes starting from hrnSrc, and it will
                // take care of propagating back up edges from any touched nodes
@@ -422,17 +440,24 @@ public class OwnershipGraph {
                Iterator referItr = hrn.iteratorToReferencers();
                while( referItr.hasNext() ) {
                    OwnershipNode onRef = (OwnershipNode) referItr.next();
+
+                   System.out.println( "    "+onRef+" is upstream" );
+
                    ReferenceEdgeProperties repUpstream = onRef.getReferenceTo( hrn );
 
                    todoEdges.add( repUpstream );
                    edgePlannedChanges.put( repUpstream, Cx );
                }
 
+               System.out.println( "plans "+edgePlannedChanges );
+
                propagateTokensOverEdges( todoEdges, 
                                          edgePlannedChanges,
                                          nodesWithNewAlpha,
                                          edgesWithNewBeta );
 
+               System.out.println( "  Onew = "+repSrc.getBetaNew() );
+
                // finally, create the actual reference edge hrn->hrnSrc
                ReferenceEdgeProperties repNew 
                    = new ReferenceEdgeProperties( fd, 
@@ -452,7 +477,7 @@ public class OwnershipGraph {
        Iterator edgeItr = edgesWithNewBeta.iterator();
        while( edgeItr.hasNext() ) {
            ((ReferenceEdgeProperties) edgeItr.next()).applyBetaNew();
-       }
+       }       
     }
 
     public void assignTempToParameterAllocation( boolean        isTask,
@@ -821,6 +846,7 @@ public class OwnershipGraph {
                                   FlatMethod              fm,
                                   OwnershipGraph          ogCallee ) {
 
+       /*
        // verify the existence of allocation sites and their
        // shadows from the callee in the context of this caller graph
        Iterator<AllocationSite> asItr = ogCallee.allocationSites.iterator();
@@ -964,6 +990,7 @@ public class OwnershipGraph {
                }
            } 
        }       
+       */
     }
 
 
index 14adde19c74e8498acc5143fbddfd8b3e5a709b1..f66bf0dc7f437927e08990ade81619fb25117209 100644 (file)
@@ -47,6 +47,8 @@ public abstract class OwnershipNode {
     }
 
 
+    /*
     abstract public boolean equals( Object o );
     abstract public int hashCode();
+    */
 }
\ No newline at end of file
index 3adead1006dd00b35700c65b80879acea84c2348..39fe99bae1241df8b32c99943ff3708c64aec3d8 100644 (file)
@@ -42,6 +42,17 @@ public class ReachabilitySet extends Canonical {
        return possibleReachabilities.contains( tts );
     }
 
+    public boolean containsTuple( TokenTuple tt ) {
+       Iterator itr = iterator();
+       while( itr.hasNext() ) {
+           TokenTupleSet tts = (TokenTupleSet) itr.next();
+           if( tts.containsTuple( tt ) ) {
+               return true;
+           }
+       }
+       return false;
+    }
+
     public ReachabilitySet add( TokenTupleSet tts ) {
        ReachabilitySet rsOut = new ReachabilitySet( tts );
        return this.union( rsOut );
index 4e0b0458a8483e2331ca3733de47250df15f91f4..a8bb771444273170b2e0fe6a7beda48536317639 100644 (file)
@@ -6,6 +6,7 @@ import IR.Flat.*;
 
 public class ReferenceEdgeProperties {
 
+
     // a null field descriptor means "any field"
     protected FieldDescriptor fieldDesc;
 
@@ -17,6 +18,7 @@ public class ReferenceEdgeProperties {
     protected OwnershipNode  src;
     protected HeapRegionNode dst;
 
+
     public ReferenceEdgeProperties() {
        this( null, false, null );
     }    
@@ -31,8 +33,7 @@ public class ReferenceEdgeProperties {
        if( beta != null ) {
            this.beta = beta;
        } else {
-           this.beta = new ReachabilitySet();
-           this.beta = this.beta.makeCanonical();
+           this.beta = new ReachabilitySet().makeCanonical();
        }
 
        // these members are set by higher-level code
@@ -43,8 +44,7 @@ public class ReferenceEdgeProperties {
 
        // when edges are not undergoing a transitional operation
        // that is changing beta info, betaNew is always empty
-       betaNew = new ReachabilitySet();
-       betaNew = betaNew.makeCanonical();
+       betaNew = new ReachabilitySet().makeCanonical();
     }
 
 
@@ -84,7 +84,6 @@ public class ReferenceEdgeProperties {
     }
 
 
-
     public boolean isInitialParamReflexive() {
        return isInitialParamReflexive;
     }
@@ -114,13 +113,16 @@ public class ReferenceEdgeProperties {
     public void applyBetaNew() {
        assert betaNew != null;
 
-       beta = betaNew;
-
-       betaNew = new ReachabilitySet();
-       betaNew = betaNew.makeCanonical();
+       beta    = betaNew;
+       betaNew = new ReachabilitySet().makeCanonical();
     }
 
 
+    /*
+
+      WHY ARE THESE METHODS INCORRECT?  WHEN INCLUDED, THE ANALYSIS GOES
+      HAYWIRE WITH REGARD TO REFERENCE EDGES
+
     public boolean equals( Object o ) {
        if( o == null ) {
            return false;
@@ -140,12 +142,20 @@ public class ReferenceEdgeProperties {
 
     public int hashCode() {
        int hash = 0;
+
        if( fieldDesc != null ) {
            hash += fieldDesc.getType().hashCode();
        }
+
+       if( isInitialParamReflexive ) {
+           hash += 1;
+       }
+
        hash += beta.hashCode();
+
        return hash;
     }
+    */
 
 
     public String getBetaString() {
index 6cc5b5b691885115e26e2bf202f841746a276a23..1becdb6ee06d27032575a6d351209acaf88bc367 100644 (file)
@@ -46,6 +46,7 @@ public class Foo {
        a.x = b.x;
     }
 
+    /*
     static public void test( Foo p0, Foo p1 ) {
        Foo f0 = new Foo();
        Foo f1 = new Foo();
@@ -56,6 +57,7 @@ public class Foo {
        p1.x = f1;
        p1.x = f2;
     }
+    */
 }
 
 
@@ -110,40 +112,63 @@ task Startup( StartupObject s{ initialstate } ) {
        b = c;
     }
     */
-    
-    /*
-    aa.x = ab;
-    ab.x = ac;
-    ab.x = aa;
-    ad.x = aa;
-    */
 
     taskexit( s{ !initialstate } );
 }
 
 
+task basics( Foo p0{ f } ) {
+
+    //Foo a = new Foo();
+    //Foo b = new Foo();
+
+    Foo a = new Foo();
+    a.x   = new Foo();
+    a.x.x = new Foo();
+
+    //p0.x = a;
+    //a.x  = b;
+
+    taskexit( p0{ !f } );
+}
+
+
 task methodTest( Foo p0{ f } ) {
 
+    Foo up0 = new Foo();
+    Foo up1 = new Foo();
+    Foo up2 = new Foo();
+
     Foo a0;
+    Foo a1;
+
     if( false ) {
-       a0 = new Foo();
-    } else {
-       a0   = new Foo();
-       a0.x = new Foo();
-       p0.x = a0;
+       a0    = new Foo();
+       up0.x = a0;     
+       a0.x  = new Foo();
+       //Foo temp = new Foo();
     }
 
-    Foo a1 = new Foo();
+    if( false ) {
+       a0    = new Foo();
+       a0.x  = new Foo();
+       a1    = a0;
+       up1.x = a0;
+    }
 
-    if( false ) {      
-       p0.x = a1;
+    if( false ) {
+       a1    = new Foo();
+       up2.x = a1;
     }
 
-    Foo.test( a0, a1 );
+    // Foo.test( a0, a1 );
 
     taskexit( p0{ !f } );
 }
 
+
+
+
 /*
 task NewObject( Foo a{ f }, Foo b{ f } ) {