Retooled edges and basic stuff is working again (finally) but reachability needs...
authorjjenista <jjenista>
Fri, 15 Aug 2008 00:26:02 +0000 (00:26 +0000)
committerjjenista <jjenista>
Fri, 15 Aug 2008 00:26:02 +0000 (00:26 +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/Tests/OwnershipAnalysisTest/test01/test01.java
Robust/src/Tests/OwnershipAnalysisTest/testGraphs/Main.java

index 0263143e26850de7f9ff128d33328666811b3498..3c14a6cc9bc2a9925dc4e753907825b0391d5b04 100644 (file)
@@ -12,7 +12,7 @@ public class HeapRegionNode extends OwnershipNode {
     protected boolean isFlagged;
     protected boolean isNewSummary;
 
-    protected HashSet<ReferenceEdge>  referencers;
+    protected HashSet<ReferenceEdge> referencers;
 
     protected AllocationSite allocSite;
 
index 5be55331e67fa0893b8f7f448c493fd64f3b7553..5633ee2d09ec822c16f949312b08050d49808012 100644 (file)
@@ -15,7 +15,6 @@ public class LabelNode extends OwnershipNode {
        return td;
     }
 
-
     public boolean equals( Object o ) {
        if( o == null ) {
            return false;
@@ -34,7 +33,6 @@ public class LabelNode extends OwnershipNode {
        return td.getNum();
     }
 
-
     public String getTempDescriptorString() {
        return td.toString();
     }
index 864c60a6afb4e8540560d4695d9dcf1ab4a0c66d..b9ca6096199d40434b4f19cdb5657772c3fd9644 100644 (file)
@@ -303,7 +303,13 @@ public class OwnershipAnalysis {
            OwnershipGraph ogPrev = mapDescriptorToCompleteOwnershipGraph.get( d );
            if( !og.equals( ogPrev ) ) {
                mapDescriptorToCompleteOwnershipGraph.put( d, og );
-
+               
+               /*
+               boolean writeLabels,
+               boolean labelSelect,
+               boolean pruneGarbage,
+               boolean writeReferencers 
+               */
                og.writeGraph( d, true, true, true, false );
 
                // only methods have dependents, tasks cannot
@@ -431,7 +437,7 @@ public class OwnershipAnalysis {
            // adding parameters labels to new heap regions
            for( int i = 0; i < fm.numParameters(); ++i ) {
                TempDescriptor tdParam = fm.getParameter( i );
-               og.assignTempToParameterAllocation( methodDesc instanceof TaskDescriptor,
+               og.assignParameterAllocationToTemp( methodDesc instanceof TaskDescriptor,
                                                    tdParam,
                                                    new Integer( i ) );
            }
@@ -443,7 +449,7 @@ public class OwnershipAnalysis {
            if( fon.getOp().getOp() == Operation.ASSIGN ) {
                src = fon.getLeft();
                dst = fon.getDest();
-               og.assignTempXToTempY( src, dst );
+               og.assignTempYToTempX( src, dst );
            }
            break;
            
@@ -453,7 +459,7 @@ public class OwnershipAnalysis {
            dst = ffn.getDst();
            fld = ffn.getField();
            if( !fld.getType().isPrimitive() ) {
-               og.assignTempXToTempYFieldF( src, dst, fld );
+               og.assignTempYFieldFToTempX( src, fld, dst );
            }
            break;
            
@@ -462,7 +468,7 @@ public class OwnershipAnalysis {
            src = fsfn.getSrc();
            dst = fsfn.getDst();
            fld = fsfn.getField();
-           og.assignTempXFieldFToTempY( src, fld, dst );
+           og.assignTempYToTempXFieldF( src, dst, fld );
            break;
            
        case FKind.FlatNew:
@@ -470,7 +476,7 @@ public class OwnershipAnalysis {
             dst = fnn.getDst();
            AllocationSite as = getAllocationSiteFromFlatNewPRIVATE( fnn );
 
-           og.assignTempXToNewAllocation( dst, as );
+           og.assignNewAllocationToTempX( dst, as );
            break;
 
        case FKind.FlatCall:
index 34437c350b5c257681afeeb9829b77a515d1145b..d4eb8fe20a2bdd3610bd5a8a98fe20a4604ea0a5 100644 (file)
@@ -341,8 +341,8 @@ public class OwnershipGraph {
     //  of the nodes and edges involved.
     //
     ////////////////////////////////////////////////////
-    public void assignTempXToTempY( TempDescriptor x
-                                   TempDescriptor y ) {
+    public void assignTempYToTempX( TempDescriptor y
+                                   TempDescriptor x ) {
 
        LabelNode lnX = getLabelNodeFromTemp( x );
        LabelNode lnY = getLabelNodeFromTemp( y );
@@ -361,9 +361,9 @@ public class OwnershipGraph {
     }
 
 
-    public void assignTempXToTempYFieldF( TempDescriptor  x,
-                                         TempDescriptor  y,
-                                         FieldDescriptor f ) {
+    public void assignTempYFieldFToTempX( TempDescriptor  y,
+                                         FieldDescriptor f,
+                                         TempDescriptor  x ) {
 
        LabelNode lnX = getLabelNodeFromTemp( x );
        LabelNode lnY = getLabelNodeFromTemp( y );
@@ -398,9 +398,9 @@ public class OwnershipGraph {
     }
 
 
-    public void assignTempXFieldFToTempY( TempDescriptor  x,
-                                         FieldDescriptor f, 
-                                         TempDescriptor  y ) {
+    public void assignTempYToTempXFieldF( TempDescriptor  y,
+                                         TempDescriptor  x,
+                                         FieldDescriptor f ) {
 
        LabelNode lnX = getLabelNodeFromTemp( x );
        LabelNode lnY = getLabelNodeFromTemp( y );
@@ -493,7 +493,7 @@ public class OwnershipGraph {
     }
 
 
-    public void assignTempToParameterAllocation( boolean        isTask,
+    public void assignParameterAllocationToTemp( boolean        isTask,
                                                 TempDescriptor td,
                                                 Integer        paramIndex ) {
        assert td != null;
@@ -537,12 +537,12 @@ public class OwnershipGraph {
     }
 
     
-    public void assignTempXToNewAllocation( TempDescriptor x,
+    public void assignNewAllocationToTempX( TempDescriptor x,
                                            AllocationSite as ) {
        assert x  != null;
        assert as != null;
 
-       //age( as );
+       age( as );
 
        // after the age operation the newest (or zero-ith oldest)
        // node associated with the allocation site should have
@@ -550,7 +550,6 @@ public class OwnershipGraph {
        // heap region, so make a reference to it to complete
        // this operation
 
-       /*
        Integer        idNewest  = as.getIthOldest( 0 );
        HeapRegionNode hrnNewest = id2hrn.get( idNewest );
        assert hrnNewest != null;
@@ -562,13 +561,9 @@ public class OwnershipGraph {
            new ReferenceEdge( lnX, hrnNewest, null, false, hrnNewest.getAlpha() );     
        
        addReferenceEdge( lnX, hrnNewest, edgeNew );
-       */
     }
 
 
-    /*
-
-
     // use the allocation site (unique to entire analysis) to
     // locate the heap region nodes in this ownership graph
     // that should be aged.  The process models the allocation
@@ -626,7 +621,7 @@ public class OwnershipGraph {
        clearReferenceEdgesFrom( hrn0, null, true );
        clearReferenceEdgesTo  ( hrn0, null, true );
        
-
+       /*
        // now tokens in reachability sets need to "age" also
        ReferenceEdgeProperties repToAge = null;
        Iterator itrAllLabelNodes = td2ln.entrySet().iterator();
@@ -658,7 +653,7 @@ public class OwnershipGraph {
                ageTokens( as, repToAge );
            }
        }
-
+       */
 
        // after tokens have been aged, reset newest node's reachability
        hrn0.setAlpha( new ReachabilitySet( 
@@ -759,48 +754,46 @@ public class OwnershipGraph {
        assert hrnSummary.isNewSummary();
 
        // transfer references _from_ hrn over to hrnSummary
-       HeapRegionNode hrnReferencee = null;
-       Iterator       itrReferencee = hrn.setIteratorToReferencedRegions();
+       Iterator<ReferenceEdge> itrReferencee = hrn.iteratorToReferencees();
        while( itrReferencee.hasNext() ) {
-           Map.Entry               me  = (Map.Entry)               itrReferencee.next();
-           hrnReferencee               = (HeapRegionNode)          me.getKey();
-           ReferenceEdgeProperties rep = (ReferenceEdgeProperties) me.getValue();
+           ReferenceEdge edge       = itrReferencee.next();
+           ReferenceEdge edgeMerged = edge.copy();
+           edgeMerged.setSrc( hrnSummary );
 
-           ReferenceEdgeProperties repSummary = hrnSummary.getReferenceTo( hrnReferencee );
-           ReferenceEdgeProperties repMerged = rep.copy();
+           HeapRegionNode hrnReferencee = edge.getDst();
+           ReferenceEdge  edgeSummary   = hrnSummary.getReferenceTo( hrnReferencee, edge.getFieldDesc() );
 
-           if( repSummary == null ) {      
+           if( edgeSummary == null ) {     
                // the merge is trivial, nothing to be done
            } else {
                // otherwise an edge from the referencer to hrnSummary exists already
                // and the edge referencer->hrn should be merged with it
-               repMerged.setBeta( repMerged.getBeta().union( repSummary.getBeta() ) );
+               edgeMerged.setBeta( edgeMerged.getBeta().union( edgeSummary.getBeta() ) );
            }
 
-           addReferenceEdge( hrnSummary, hrnReferencee, repMerged );
+           addReferenceEdge( hrnSummary, hrnReferencee, edgeMerged );
        }
-
+       
        // next transfer references _to_ hrn over to hrnSummary
-       OwnershipNode onReferencer  = null;
-       Iterator      itrReferencer = hrn.iteratorToReferencers();
+       Iterator<ReferenceEdge> itrReferencer = hrn.iteratorToReferencers();
        while( itrReferencer.hasNext() ) {
-           onReferencer = (OwnershipNode) itrReferencer.next();
-           
-           ReferenceEdgeProperties rep = onReferencer.getReferenceTo( hrn );
-           assert rep != null;     
-           ReferenceEdgeProperties repSummary = onReferencer.getReferenceTo( hrnSummary );
-           ReferenceEdgeProperties repMerged = rep.copy();
+           ReferenceEdge edge         = itrReferencer.next();
+           ReferenceEdge edgeMerged   = edge.copy();
+           edgeMerged.setDst( hrnSummary );
 
-           if( repSummary == null ) {      
+           OwnershipNode onReferencer = edge.getSrc();
+           ReferenceEdge edgeSummary  = onReferencer.getReferenceTo( hrnSummary, edge.getFieldDesc() );
+               
+           if( edgeSummary == null ) {     
                // the merge is trivial, nothing to be done
            } else {
                // otherwise an edge from the referencer to alpha_S exists already
                // and the edge referencer->alpha_K should be merged with it
-               repMerged.setBeta( repMerged.getBeta().union( repSummary.getBeta() ) );
+               edgeMerged.setBeta( edgeMerged.getBeta().union( edgeSummary.getBeta() ) );
            }
-
-           addReferenceEdge( onReferencer, hrnSummary, repMerged );
-       }
+           
+           addReferenceEdge( onReferencer, hrnSummary, edgeMerged );
+       }       
 
        // then merge hrn reachability into hrnSummary
        hrnSummary.setAlpha( hrnSummary.getAlpha().union( hrn.getAlpha() ) );
@@ -810,35 +803,34 @@ public class OwnershipGraph {
     protected void transferOnto( HeapRegionNode hrnA, HeapRegionNode hrnB ) {
 
        // clear references in and out of node i
-       clearReferenceEdgesFrom( hrnB );
-       clearReferenceEdgesTo  ( hrnB );
+       clearReferenceEdgesFrom( hrnB, null, true );
+       clearReferenceEdgesTo  ( hrnB, null, true );
        
        // copy each edge in and out of A to B
-       HeapRegionNode hrnReferencee = null;
-       Iterator       itrReferencee = hrnA.setIteratorToReferencedRegions();
+       Iterator<ReferenceEdge> itrReferencee = hrnA.iteratorToReferencees();
        while( itrReferencee.hasNext() ) {
-           Map.Entry               me  = (Map.Entry)               itrReferencee.next();
-           hrnReferencee               = (HeapRegionNode)          me.getKey();
-           ReferenceEdgeProperties rep = (ReferenceEdgeProperties) me.getValue();
-           
-           addReferenceEdge( hrnB, hrnReferencee, rep.copy() );
+           ReferenceEdge  edge          = itrReferencee.next();
+           HeapRegionNode hrnReferencee = edge.getDst();
+           ReferenceEdge  edgeNew       = edge.copy();
+           edgeNew.setSrc( hrnB );
+
+           addReferenceEdge( hrnB, hrnReferencee, edgeNew );
        }
        
-       OwnershipNode onReferencer  = null;
-       Iterator      itrReferencer = hrnA.iteratorToReferencers();
+       Iterator<ReferenceEdge> itrReferencer = hrnA.iteratorToReferencers();
        while( itrReferencer.hasNext() ) {
-           onReferencer = (OwnershipNode) itrReferencer.next();
-           
-           ReferenceEdgeProperties rep = onReferencer.getReferenceTo( hrnA );
-           assert rep != null;
-           
-           addReferenceEdge( onReferencer, hrnB, rep.copy() );
+           ReferenceEdge edge         = itrReferencer.next();
+           OwnershipNode onReferencer = edge.getSrc();
+           ReferenceEdge edgeNew      = edge.copy();
+           edgeNew.setDst( hrnB );
+                   
+           addReferenceEdge( onReferencer, hrnB, edgeNew );
        }           
        
        // replace hrnB reachability with hrnA's
        hrnB.setAlpha( hrnA.getAlpha() );
     }
-    */
+
 
     /*
     protected void ageTokens( AllocationSite as, ReferenceEdgeProperties rep ) {
@@ -1210,7 +1202,7 @@ public class OwnershipGraph {
            while( heapRegionsItrA.hasNext() ) {
                ReferenceEdge  edgeA     = heapRegionsItrA.next();
                HeapRegionNode hrnChildA = edgeA.getDst();
-               Integer        idChildA  = hrnChildA.getID();
+               Integer        idChildA  = hrnChildA.getID();           
 
                // at this point we know an edge in graph A exists
                // tdA -> idChildA, does this exist in B?
@@ -1218,16 +1210,23 @@ public class OwnershipGraph {
                LabelNode     lnB         = td2ln.get( tdA );
                ReferenceEdge edgeToMerge = null;
 
+               // labels never have edges with a field
+               //assert edgeA.getFieldDesc() == null;
+
                Iterator<ReferenceEdge> heapRegionsItrB = lnB.iteratorToReferencees();
                while( heapRegionsItrB.hasNext() &&
                       edgeToMerge == null          ) {
 
                    ReferenceEdge  edgeB     = heapRegionsItrB.next();
                    HeapRegionNode hrnChildB = edgeB.getDst();
+                   Integer        idChildB  = hrnChildB.getID();
+
+                   // labels never have edges with a field
+                   //assert edgeB.getFieldDesc() == null;
 
                    // don't use the ReferenceEdge.equals() here because
                    // we're talking about existence between graphs
-                   if( hrnChildB.equals( idChildA ) &&
+                   if( idChildB.equals( idChildA ) &&
                        edgeB.getFieldDesc() == edgeA.getFieldDesc() ) {
                        edgeToMerge = edgeB;
                    }
@@ -1247,7 +1246,6 @@ public class OwnershipGraph {
                // so merge their reachability sets
                else {
                    // just replace this beta set with the union
-                   assert edgeToMerge != null;
                    edgeToMerge.setBeta( 
                      edgeToMerge.getBeta().union( edgeA.getBeta() ) 
                                       );
@@ -1736,6 +1734,8 @@ public class OwnershipGraph {
                    }
                }
 
+               bw.write( ln.toString() + ";\n" );
+
                Iterator<ReferenceEdge> heapRegionsItr = ln.iteratorToReferencees();
                while( heapRegionsItr.hasNext() ) {
                    ReferenceEdge  edge = heapRegionsItr.next();
index b7063c37a50df8e4035ee54fc37a95b9f98d66b8..aebfcdfa6f65c66666b746c0374a532f791dd909 100644 (file)
@@ -52,6 +52,24 @@ public abstract class OwnershipNode {
        return null;
     }
 
+    /*
+    public HashSet<ReferenceEdge> getAllReferencesTo( HeapRegionNode  hrn ) {
+       assert hrn != null;
+
+       HashSet<ReferenceEdge> s = new HashSet<ReferenceEdge>();
+
+       Iterator<ReferenceEdge> itrEdge = referencees.iterator();
+       while( itrEdge.hasNext() ) {
+           ReferenceEdge edge = itrEdge.next();
+           if( edge.getDst().equals( hrn ) ) {
+               s.add( edge );
+           }
+       }
+
+       return s;
+    }
+    */
+
     /*
     abstract public boolean equals( Object o );
     abstract public int hashCode();
index 9d4281758d3c62e6756e09fd8e7764c7ae7b8614..151cef1776f6e7736c657fc0cfadb428caaca666 100644 (file)
@@ -1,4 +1,4 @@
-
+/*
 public class Parameter {
     flag w;
     int a, b;
@@ -33,7 +33,7 @@ public class Baw {
 
     public void doTheBaw( Voo v ) { v = new Voo(); }
 }
-
+*/
 
 public class Foo {
     flag f;
@@ -42,6 +42,7 @@ public class Foo {
 
     public Foo x;
 
+    /*
     public void ruinSomeFoos( Foo a, Foo b ) {
        a.x = b.x;
     }
@@ -57,6 +58,7 @@ public class Foo {
        p1.x = f1;
        p1.x = f2;
     }
+    */
 }
 
 
@@ -66,7 +68,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();
@@ -110,17 +112,20 @@ task Startup( StartupObject s{ initialstate } ) {
        c.x = b;
        b = c;
     }
-
+    */
 
     taskexit( s{ !initialstate } );
 }
 
 
-task basics( Foo p0{ f } ) {
+task basics( Foo p0{ f }, Foo p1{ f } ) {
 
     //Foo a = new Foo();
     //Foo b = new Foo();
 
+    Foo q = p0;
+    p0.x = p1;
+
     Foo a = new Foo();
     a.x   = new Foo();
     a.x.x = new Foo();
@@ -128,10 +133,10 @@ task basics( Foo p0{ f } ) {
     //p0.x = a;
     //a.x  = b;
 
-    taskexit( p0{ !f } );
+    taskexit( p0{ !f }, p1{ !f } );
 }
 
-
+/*
 task methodTest( Foo p0{ f } ) {
 
     Foo up0 = new Foo();
@@ -164,7 +169,7 @@ task methodTest( Foo p0{ f } ) {
 
     taskexit( p0{ !f } );
 }
-
+*/
 
 
 
index c6581ef0ab652c5cbb4f9700800c69c05dd0e85c..d64e43aa1439999b107d3dc7d42437112e7385a2 100644 (file)
@@ -40,6 +40,8 @@ public class Main {
        System.out.println( "---------------------------------------" );
        testNodesAndEdges();
        System.out.println( "---------------------------------------" );
+       testGraphs();
+       System.out.println( "---------------------------------------" );
 
        if( aTestFailed ) {
            System.out.println( "<><><><><><><><><><><><><><><><><><><><><><><><>" );
@@ -155,7 +157,7 @@ public class Main {
     }
 
 
-    public static void garbage() {
+    public static void testGraphs() {
        // test equality of label objects that are logically
        // same/different but all separate objects
        // these tests show how a label node object or other
@@ -214,6 +216,17 @@ public class Main {
        g4.merge( g2 );
        g4.merge( g0 );
 
+       OwnershipGraph g5     = new OwnershipGraph( allocationDepth );
+       TempDescriptor g5tdp1 = new TempDescriptor( "p1" );
+       TempDescriptor g5tdy  = new TempDescriptor( "y" );
+       g5.assignTempToParameterAllocation( true, g5tdp1, new Integer( 0 ) );
+       g5.assignTempXToTempY             ( g5tdy, g5tdp1 );
+
+       try {
+           g3.writeGraph( "g3", true, false, false, false );
+           g4.writeGraph( "g4", true, false, false, false );
+       } catch( IOException e ) {}
+
        test( "g0 equals to g1?", false, g0.equals( g1 ) );
        test( "g1 equals to g0?", false, g1.equals( g0 ) );
 
@@ -233,5 +246,8 @@ public class Main {
        
        test( "g3 equals to g4?", true,  g3.equals( g4 ) );
        test( "g4 equals to g3?", true,  g4.equals( g3 ) );
+
+       test( "g0 equals to g5?", false, g0.equals( g5 ) );
+       test( "g5 equals to g0?", false, g5.equals( g0 ) );
     }
 }
\ No newline at end of file