From: jjenista Date: Mon, 11 Aug 2008 23:10:45 +0000 (+0000) Subject: equals() and hashCode() methods are bunk X-Git-Tag: preEdgeChange~2 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=7450f183c332823b4bab2a714a3ef3f5f6da10cb;p=IRC.git equals() and hashCode() methods are bunk --- diff --git a/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java b/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java index 4b6464d2..43d808d2 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java +++ b/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java @@ -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() { diff --git a/Robust/src/Analysis/OwnershipAnalysis/LabelNode.java b/Robust/src/Analysis/OwnershipAnalysis/LabelNode.java index 32794060..8802d673 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/LabelNode.java +++ b/Robust/src/Analysis/OwnershipAnalysis/LabelNode.java @@ -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(); diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java index 8e04335b..cb8147d0 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java @@ -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 ); diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java index 96693ecc..2eb6a05d 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java @@ -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 asItr = ogCallee.allocationSites.iterator(); @@ -964,6 +990,7 @@ public class OwnershipGraph { } } } + */ } diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipNode.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipNode.java index 14adde19..f66bf0dc 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipNode.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipNode.java @@ -47,6 +47,8 @@ public abstract class OwnershipNode { } + /* abstract public boolean equals( Object o ); abstract public int hashCode(); + */ } \ No newline at end of file diff --git a/Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java b/Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java index 3adead10..39fe99ba 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java +++ b/Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java @@ -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 ); diff --git a/Robust/src/Analysis/OwnershipAnalysis/ReferenceEdgeProperties.java b/Robust/src/Analysis/OwnershipAnalysis/ReferenceEdgeProperties.java index 4e0b0458..a8bb7714 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/ReferenceEdgeProperties.java +++ b/Robust/src/Analysis/OwnershipAnalysis/ReferenceEdgeProperties.java @@ -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() { diff --git a/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java b/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java index 6cc5b5b6..1becdb6e 100644 --- a/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java +++ b/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java @@ -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 } ) {