Fixed a bug where OwnershipGraph.writeGraph() visits heap roots
authorjjenista <jjenista>
Fri, 30 Nov 2007 00:00:25 +0000 (00:00 +0000)
committerjjenista <jjenista>
Fri, 30 Nov 2007 00:00:25 +0000 (00:00 +0000)
that have already been visited by checking if the node is in the
visited set at the top of the traverseHeapNodes() instead of before
visiting children.

Also added more interesting examples in the testing directory.

Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java
Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java
Robust/src/Tests/OwnershipAnalysisTest/test01/makefile
Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java

index 8cfaf95359cdf236801adc07453d7eb3949912e0..e2c2c520fd7926b4deed37f32e4d0479985ac555 100644 (file)
@@ -122,7 +122,7 @@ public class OwnershipAnalysis {
 
            case FKind.FlatOpNode:
                FlatOpNode fon = (FlatOpNode) fn;
-               if(fon.getOp().getOp()==Operation.ASSIGN) {
+               if( fon.getOp().getOp() == Operation.ASSIGN ) {
                    src = fon.getLeft();
                    dst = fon.getDest();
                    og.assignTempToTemp( src, dst );
@@ -136,9 +136,11 @@ public class OwnershipAnalysis {
                src = ffn.getSrc();
                dst = ffn.getDst();
                fld = ffn.getField();
-               og.assignTempToField( src, dst, fld );
-               nodeDescription = "Field";
-               writeGraph = true;
+               if( !fld.getType().isPrimitive() ) {
+                   og.assignTempToField( src, dst, fld );
+                   nodeDescription = "Field";
+                   writeGraph = true;
+               }
                break;
 
            case FKind.FlatSetFieldNode:
index 3109b66f0688918b53a9275fec63c7389d268171..db37c679c793140b21ec1ddb5b80816c40c3c0ea 100644 (file)
@@ -490,6 +490,10 @@ public class OwnershipGraph {
                                      TempDescriptor td,
                                      HashSet<OwnershipHeapRegionNode> visited
                                      ) throws java.io.IOException {
+
+       if( visited.contains( ohrn ) ) {
+           return;
+       }
        visited.add( ohrn );
 
        switch( mode ) {
@@ -534,9 +538,7 @@ public class OwnershipGraph {
                break;
            }
 
-           if( !visited.contains( ohrnChild ) ) {
-               traverseHeapNodes( mode, ohrnChild, bw, td, visited );
-           }
+           traverseHeapNodes( mode, ohrnChild, bw, td, visited );
        }
     }
 }
index 2ff00ccb26ee4c0344948ad4abe9a0105095f32e..b312633c211dab93acfc6fa39f73771e84e4c28c 100644 (file)
@@ -14,6 +14,10 @@ view: PNGs
 
 PNGs: DOTs
        rm -f *Startup*.dot
+       #rm -f *FN*Method*.dot
+       rm -f *FN*Op*.dot
+       rm -f *FN*Field*.dot
+       rm -f *FN*SetField*.dot
        d2p *.dot
 
 DOTs: $(PROGRAM).bin
index 5e3bd7d508cb3d340ad0f1253b4a37431add9d48..dccb32237ea6deb056d2b63bc61b80f9bdd41684 100644 (file)
@@ -1,39 +1,76 @@
-public class Thing { int z; public Thing(){} }
+public class Parameter {
+    flag w;
+    int a, b;
+    Parameter f, g;
+    public Parameter() {
+       a = 0; b = 0; f = null; g = null;
+    }
+}
 
-public class P1 {
-    public P1(){}
-    flag a;
-    int x;
-    Thing m;
+task Startup( StartupObject s{ initialstate } ) {
+    Parameter p1 = new Parameter(){!w};
+    Parameter p2 = new Parameter(){!w};
+    taskexit( s{ !initialstate } );
 }
 
-public class P2 {
-    public P2(){}
-    flag b;
-    int y;
-    Thing n;
+task aliasFromObjectAssignment
+    ( Parameter p1{!w}, Parameter p2{!w} ) {
+    
+    p1.f = p2.g;
+
+    taskexit( p1{w}, p2{w} );
 }
 
-public class P3 {
-    public P2(){}
-    flag b;
-    int y;
-    Thing n;
+task noAliasFromPrimitiveAssignment
+    ( Parameter p1{!w}, Parameter p2{!w} ) {
+    
+    p1.a = p2.b;
+
+    taskexit( p1{w}, p2{w} );
 }
 
-task Startup( StartupObject s{ initialstate } ) {
-    P1 p1f = new P1(){!a};
-    P2 p2f = new P2(){!b};
-    P1 p1t = new P1(){ a};
-    P2 p2t = new P2(){ b};
-    taskexit( s{ !initialstate } );
+task aliasWithTwoLinks
+    ( Parameter p1{!w}, Parameter p2{!w} ) {
+    
+    Parameter j = p1.f;
+    p2.f = j;
+
+    taskexit( p1{w}, p2{w} );
 }
 
-task A( P1 p1f{!a}, 
-       P2 p2f{!b} )
-{
-    p1f.m = p2f.n;
+task aliasWithThreeLinks
+    ( Parameter p1{!w}, Parameter p2{!w} ) {
+    
+    Parameter j = p1.f;
+    Parameter k = j;
+    p2.f = k;
 
-    taskexit( p1f{ a}, 
-             p2f{ b} );
-}
\ No newline at end of file
+    taskexit( p1{w}, p2{w} );
+}
+
+task noAliasBreakLinks
+    ( Parameter p1{!w}, Parameter p2{!w} ) {
+    
+    Parameter j = p1.f;
+    Parameter k = j;
+    k = p2.f;
+    p2.f = k;
+
+    taskexit( p1{w}, p2{w} );
+}
+
+task possibleAliasConditional
+    ( Parameter p1{!w}, Parameter p2{!w} ) {
+    
+    Parameter y;
+
+    if( p1.a == 0 ) {
+       y = p1.f;
+    } else {
+       y = p2.f;
+    }
+
+    p2.g = y;
+
+    taskexit( p1{w}, p2{w} );
+}