strong updates, everything ready to do method calls
authorjjenista <jjenista>
Fri, 15 Aug 2008 22:34:17 +0000 (22:34 +0000)
committerjjenista <jjenista>
Fri, 15 Aug 2008 22:34:17 +0000 (22:34 +0000)
Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java
Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java
Robust/src/Analysis/OwnershipAnalysis/OwnershipNode.java
Robust/src/Tests/OwnershipAnalysisTest/test01/makefile
Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java
Robust/src/Tests/OwnershipAnalysisTest/test02/makefile
Robust/src/Tests/OwnershipAnalysisTest/test02/test02.java
Robust/src/Tests/OwnershipAnalysisTest/test03/makefile

index e9fb24940ec7ed9143d4a2f62bc1a2b0128b5d59..2604b21fd23ac91eb76d062d086367c6bef8b56f 100644 (file)
@@ -114,6 +114,11 @@ public class HeapRegionNode extends OwnershipNode {
        return clone.iterator();
     }
 
+    public int getNumReferencers() {
+       return referencers.size();
+    }
+
+
     public void addReferencer( ReferenceEdge edge ) {
        assert edge != null;
 
index 3c68b4ae42f84f0d9c331867e5f2254e929d9ab0..43e2752881ddacbc9905c7449064925c017aeede 100644 (file)
@@ -449,8 +449,34 @@ public class OwnershipGraph {
                                                           false,
                                                           edgeY.getBetaNew().pruneBy( hrnX.getAlpha() )
                                                         );
+               if( f != null ) {
+                   // we can do a strong update here if one of two cases holds
+                   if( (hrnX.getNumReferencers() == 1)                           ||
+                       ( lnX.getNumReferencees() == 1 && hrnX.isSingleObject() )
+                     ) {
+                       clearReferenceEdgesFrom( hrnX, f, false );
+                   }
+
+                   addReferenceEdge( hrnX, hrnY, edgeNew );
 
-               addReferenceEdge( hrnX, hrnY, edgeNew );
+               } else {
+                   // if the field is null, or "any" field, then
+                   // look to see if an any field already exists
+                   // and merge with it, otherwise just add the edge
+                   ReferenceEdge edgeExisting = hrnX.getReferenceTo( hrnY, f );
+
+                   if( edgeExisting != null ) {
+                       edgeExisting.setBetaNew( 
+                         edgeExisting.getBetaNew().union( edgeNew.getBeta() ) 
+                                              );
+                       // a new edge here cannot be reflexive, so existing will
+                       // always be also not reflexive anymore
+                       edgeExisting.setIsInitialParamReflexive( false );
+                       
+                   } else {
+                       addReferenceEdge( hrnX, hrnY, edgeNew );
+                   }
+               }
            }
        }       
 
@@ -815,22 +841,10 @@ public class OwnershipGraph {
     }
 
     
-    // some notes:
-    // the heap regions that are specially allocated as multiple-object
-    // regions for method parameters need to be remembered in order to
-    // resolve a function call.  So actually, we need a mapping from
-    // caller argument descriptors to the callee parameter heap regions
-    // to apply reference edges in the callee to the caller graph.
-    // 
-    // also, Constructors and virtual dispatch methods have a "this"
-    // argument that make the mapping of arguments to parameters a little
-    // tricky.  What happens to that this region?
-
-
-    public void resolveMethodCall( FlatCall                fc,
-                                  boolean                 isStatic,
-                                  FlatMethod              fm,
-                                  OwnershipGraph          ogCallee ) {
+    public void resolveMethodCall( FlatCall       fc,
+                                  boolean        isStatic,
+                                  FlatMethod     fm,
+                                  OwnershipGraph ogCallee ) {
 
        /*
        // verify the existence of allocation sites and their
@@ -975,8 +989,8 @@ public class OwnershipGraph {
                    }
                }
            } 
-       }       
-       */
+       }
+       */      
     }
 
     /*
index f005fff10fca4b9f6701e11909bfcae0c56df2e1..88b786bbc8722626eab42282982cf980b8c31698 100644 (file)
@@ -22,6 +22,9 @@ public abstract class OwnershipNode {
        return clone.iterator();
     }
 
+    public int getNumReferencees() {
+       return referencees.size();
+    }
 
     public void addReferencee( ReferenceEdge edge ) {
        assert edge != null;
index 3d08d27a6ae6ea1306920a7880db2447f63084df..65cc0bbd340734de374148affd8d6c680364b461 100644 (file)
@@ -1,48 +1,17 @@
 PROGRAM=test01
 
-SOURCE_FILES=test01.java
+SOURCE_FILES=$(PROGRAM).java
 
 BUILDSCRIPT=~/research/Robust/src/buildscript
 BSFLAGS= -recover -flatirtasks -ownership -enable-assertions
-#BSFLAGS= -recover -ownership -enable-assertions
 
 all: $(PROGRAM).bin
 
 view: PNGs
-       #eog *flatIRGraph*.png &
-       #eog *FN*.png &
-       #eog *Ownership*.png &
-       eog *COMPLETE*.png &
-       #eog *debug*.png &
-
-printable:
-       rm -f *Startup*.dot
-       rm -f *FlatMethod*.dot
-       rm -f *FlatOpNode*.dot
-       rm -f *FlatFieldNode*.dot
-       rm -f *FlatSetFieldNode*.dot
-       rm -f *FlatCall*.dot
-       rm -f *Parameter*.dot
-       rm -f *Penguin*.dot
-       rm -f *Voo*.dot
-       rm -f *Baw*.dot
-       rm -f *COMPLETE.dot
-       dot2eps *.dot
+       eog *.png
 
 PNGs: DOTs
-       #rm -f *Startup*.dot
-       #rm -f *COMPLETE*.dot
-       rm -f *FlatIR*.dot
-       rm -f *FlatMethod*.dot
-       rm -f *FlatOpNode*.dot
-       rm -f *FlatFieldNode*.dot
-       rm -f *FlatSetFieldNode*.dot
-       rm -f *FlatCall*.dot
-       rm -f *Parameter*.dot
-       rm -f *Penguin*.dot
-       rm -f *Voo*.dot
-       rm -f *Baw*.dot
-       d2p *.dot
+       d2p *COMPLETE*.dot
 
 DOTs: $(PROGRAM).bin
 
index 7cfb7de9c32b81d6f131f3f0a2b81527c2ca92f1..0213b85ae4ba64adabeb49990e9d8c2d502d623b 100644 (file)
@@ -1,4 +1,3 @@
-/*
 public class Parameter {
     flag w;
     int a, b;
@@ -33,7 +32,6 @@ public class Baw {
 
     public void doTheBaw( Voo v ) { v = new Voo(); }
 }
-*/
 
 public class Foo {
     flag f;
@@ -41,14 +39,13 @@ public class Foo {
     public Foo() {}
 
     public Foo x;
+    public Foo y;
 
-    /*
     public void ruinSomeFoos( Foo a, Foo b ) {
        a.x = b.x;
     }
-    */
 
-    static public void test( Foo p0, Foo p1 ) {
+    static public void aStaticMethod( Foo p0, Foo p1 ) {
        Foo f0 = new Foo();
        Foo f1 = new Foo();
        Foo f2 = new Foo();
@@ -66,124 +63,10 @@ public class Foo {
 // look for the parameter s as a label referencing
 // 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();
-               a.x.x = new Foo();
-
-       //Foo z = a.x;
-       //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;
-    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 } );
 }
 
 
-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();
-
-    //p0.x = a;
-    //a.x  = b;
-
-    taskexit( p0{ !f }, p1{ !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();
-       up0.x = a0;     
-       a0.x  = new Foo();
-       //Foo temp = new Foo();
-    }
-
-    if( false ) {
-       a0    = new Foo();
-       a0.x  = new Foo();
-       a1    = a0;
-       up1.x = a0;
-    }
-
-    if( false ) {
-       a1    = new Foo();
-       up2.x = a1;
-    }
-
-    // Foo.test( a0, a1 );
-
-    taskexit( p0{ !f } );
-}
-
-
-
-
-/*
-task NewObject( Foo a{ f }, Foo b{ f } ) {
-
-    Foo c = new Foo();
-
-    a.x = c;
-
-    taskexit( a{ !f }, b{ !f } );
-}
-*/
-
-/*
 task NewObjectA( Foo a{ f }, Foo b{ f } ) {
 
     Foo c = new Foo();
@@ -205,10 +88,8 @@ task NewObjectB( Foo a{ f }, Foo b{ f } ) {
 
     taskexit( a{ !f }, b{ !f } );
 }
-*/
 
-/*
-task NewObject2( Foo a{ f }, Foo b{ f } ) {
+task NewObjectC( Foo a{ f }, Foo b{ f } ) {
 
     Foo c;
 
@@ -219,15 +100,15 @@ task NewObject2( Foo a{ f }, Foo b{ f } ) {
 
     taskexit( a{ !f }, b{ !f } );
 }
-*/
 
 
-/*
+
+
 // this task allocates a new object, so there should
 // be a heap region for the parameter, and several
 // heap regions for the allocation site, but the label
 // merely points to the newest region
-task NewObject( Voo v{ f } ) {
+task NewObjectInMethod( Voo v{ f } ) {
     Voo w = new Voo();
     Baw b = new Baw();
     b.doTheBaw( w );
@@ -236,52 +117,94 @@ task NewObject( Voo v{ f } ) {
 }
 
 
-// this task 
-task Branch( Voo v{ f } ) {
-    Voo w = new Voo();
-    Baw j = new Baw();
-    Baw k = new Baw();
+task ClobberInitParamReflex( Voo v{ f }, Voo w{ f } ) {
+    v.b = v.bb;
+
+    taskexit( v{ !f }, w{ !f } );
+}
+
 
-    if( v.x == 0 ) {
-       w.b = j;
-    } else {
-       w.b = k;
+task SummaryNodeTokens( Foo p0{ f } ) {
+
+    while( false ) {
+       Foo a = new Foo();
+       a.x   = new Foo();
+               a.x.x = new Foo();
+    }
+    
+    Foo b;
+    while( false ) {
+       Foo c = new Foo();
+       c.x = b;
+       b = c;
     }
 
-    taskexit( v{ !f } );
+    taskexit( p0{ !f } );
 }
 
 
-task NoAliasNewInLoop( Voo v{ f } ) {
+task strongUpdates( Foo p0{ f } ) {
 
-    for( int i = 0; i < 10; ++i ) {
-       Voo w = new Voo();
-       w.b   = new Baw();
-       w.b.f = new Foo();
+    Foo b = new Foo();
+
+    Foo a = new Foo();
+    if( false ) {
+       a.x = new Foo();
+       a.y = new Foo();
+    } else if( false ) {
+       a.x = new Foo();
+       a.y = new Foo();
     }
 
-    taskexit( v{ !f } );
+    // this should effect a strong update
+    a.x = b;
+
+
+    if( false ) {
+       p0.x = new Foo();
+       p0.y = new Foo();
+    } else if( false ) {
+       p0.x = new Foo();
+       p0.y = new Foo();
+    }
+
+    // p0 points to a multiple-object heap region
+    // so this should not make a strong update
+    p0.x = b;
+    
+    taskexit( p0{ !f } );
 }
 
 
-task NoAliasNewInLoopAnotherWay( Voo v{ f } ) {
+task methodTest( Foo p0{ f } ) {
+
+    Foo up0 = new Foo();
+    Foo up1 = new Foo();
+    Foo up2 = new Foo();
 
-    for( int i = 0; i < 10; ++i ) {
-       Voo w = new Voo();
-       Baw b = new Baw();
-       Foo f = new Foo();
+    Foo a0;
+    Foo a1;
 
-       w.b = b;
-       b.f = f;
+    if( false ) {
+       a0    = new Foo();
+       up0.x = a0;     
+       a0.x  = new Foo();
+       //Foo temp = new Foo();
     }
 
-    taskexit( v{ !f } );
-}
+    if( false ) {
+       a0    = new Foo();
+       a0.x  = new Foo();
+       a1    = a0;
+       up1.x = a0;
+    }
 
+    if( false ) {
+       a1    = new Foo();
+       up2.x = a1;
+    }
 
-task ClobberInitParamReflex( Voo v{ f }, Voo w{ f } ) {
-    v.b = v.bb;
+    // Foo.test( a0, a1 );
 
-    taskexit( v{ !f }, w{ !f } );
+    taskexit( p0{ !f } );
 }
-*/
\ No newline at end of file
index b93cb876cf5ffd06225ed213189c46060f7eb6b5..65cc0bbd340734de374148affd8d6c680364b461 100644 (file)
@@ -1,29 +1,17 @@
-PROGRAM=test02
+PROGRAM=test01
 
-SOURCE_FILES=test02.java
+SOURCE_FILES=$(PROGRAM).java
 
 BUILDSCRIPT=~/research/Robust/src/buildscript
 BSFLAGS= -recover -flatirtasks -ownership -enable-assertions
-#BSFLAGS= -recover -ownership -enable-assertions
 
 all: $(PROGRAM).bin
 
 view: PNGs
-       #eog *flatIRGraph*.png &
-       #eog *FN*.png &
-       #eog *Ownership*.png &
-       eog *.png &
+       eog *.png
 
 PNGs: DOTs
-       #rm -f *Startup*.dot
-       rm -f *FlatMethod*.dot
-       rm -f *FlatOpNode*.dot
-       rm -f *FlatFieldNode*.dot
-       rm -f *FlatSetFieldNode*.dot
-       rm -f *FlatCall*.dot
-       rm -f *Parameter*.dot
-       rm -f *Penguin*.dot
-       d2p *.dot
+       d2p *COMPLETE*.dot
 
 DOTs: $(PROGRAM).bin
 
@@ -36,3 +24,6 @@ clean:
        rm -f  *~
        rm -f  *.dot
        rm -f  *.png
+       rm -f  *.ps
+       rm -f  *.eps
+       rm -f  identifiedAliases.txt
index 118668d2f35ab5f0307552cbbc8b9753a07c1922..03aedb9b8b7e8536c0f2ddf58b613a95ddbe4054 100644 (file)
@@ -173,3 +173,29 @@ task newPossibleAlias
 
     taskexit( p1{w}, p2{w} );
 }
+
+task NoAliasNewInLoop( Voo v{ f } ) {
+
+    for( int i = 0; i < 10; ++i ) {
+       Voo w = new Voo();
+       w.b   = new Baw();
+       w.b.f = new Foo();
+    }
+
+    taskexit( v{ !f } );
+}
+
+
+task NoAliasNewInLoopAnotherWay( Voo v{ f } ) {
+
+    for( int i = 0; i < 10; ++i ) {
+       Voo w = new Voo();
+       Baw b = new Baw();
+       Foo f = new Foo();
+
+       w.b = b;
+       b.f = f;
+    }
+
+    taskexit( v{ !f } );
+}
index 4944b686ea2d6baa908628a57d32cf664a8615c7..65cc0bbd340734de374148affd8d6c680364b461 100644 (file)
@@ -1,45 +1,17 @@
-PROGRAM=test03
+PROGRAM=test01
 
-SOURCE_FILES=test03.java
+SOURCE_FILES=$(PROGRAM).java
 
 BUILDSCRIPT=~/research/Robust/src/buildscript
-BSFLAGS= -recover -flatirtasks -ownership #-enable-assertions
-#BSFLAGS= -recover -ownership -enable-assertions
+BSFLAGS= -recover -flatirtasks -ownership -enable-assertions
 
 all: $(PROGRAM).bin
 
 view: PNGs
-       eog *flatIRGraph*.png &
-       #eog *FN*.png &
-       #eog *Ownership*.png &
-       eog *.png &
-
-printable:
-       rm -f *Startup*.dot
-       rm -f *FlatMethod*.dot
-       rm -f *FlatOpNode*.dot
-       rm -f *FlatFieldNode*.dot
-       rm -f *FlatSetFieldNode*.dot
-       rm -f *FlatCall*.dot
-       rm -f *Parameter*.dot
-       rm -f *Penguin*.dot
-       rm -f *Voo*.dot
-       rm -f *Baw*.dot
-       rm -f *COMPLETE.dot
-       dot2eps *.dot
+       eog *.png
 
 PNGs: DOTs
-       #rm -f *Startup*.dot
-       rm -f *FlatMethod*.dot
-       rm -f *FlatOpNode*.dot
-       rm -f *FlatFieldNode*.dot
-       rm -f *FlatSetFieldNode*.dot
-       rm -f *FlatCall*.dot
-       rm -f *Parameter*.dot
-       rm -f *Penguin*.dot
-       rm -f *Voo*.dot
-       rm -f *Baw*.dot
-       d2p *.dot
+       d2p *COMPLETE*.dot
 
 DOTs: $(PROGRAM).bin