From: jjenista Date: Tue, 5 Aug 2008 01:28:15 +0000 (+0000) Subject: Prune change sets during token prop by beta info only, not whether the rule was applied X-Git-Tag: preEdgeChange~30 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=9e396f069061b9c3a65f25b3d534d4cf1a071e6c;p=IRC.git Prune change sets during token prop by beta info only, not whether the rule was applied --- diff --git a/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java b/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java index 237f2a51..fdbe1fa9 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java +++ b/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java @@ -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() { diff --git a/Robust/src/Analysis/OwnershipAnalysis/LabelNode.java b/Robust/src/Analysis/OwnershipAnalysis/LabelNode.java index c991f1d7..8ae18258 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/LabelNode.java +++ b/Robust/src/Analysis/OwnershipAnalysis/LabelNode.java @@ -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(); } diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java index fb574f59..ecb65e8e 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java @@ -157,10 +157,11 @@ public class OwnershipGraph { } } + protected void propagateTokensOverNodes( HeapRegionNode nPrime, ChangeTupleSet c0, HashSet nodesWithNewAlpha, - HashSet edgesWithNewBeta ) { + HashSet edgesWithNewBeta ) { HashSet todoNodes = new HashSet(); @@ -176,19 +177,11 @@ public class OwnershipGraph { Hashtable edgePlannedChanges = new Hashtable(); - Hashtable nodeChangesMade - = new Hashtable(); 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 ); diff --git a/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java b/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java index b71138e1..e72c5f10 100644 --- a/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java +++ b/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java @@ -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 } ); }