Properly use transitive closure of allocation sites when resolving
[IRC.git] / Robust / src / Tests / OwnershipAnalysisTest / test01 / test01.java
1
2 public class Parameter {
3     flag w;
4     int a, b;
5     Parameter f, g;
6     Penguin penguin;
7
8     public Parameter() { a = 0; b = 0; f = null; g = null; }
9
10     public void bar() { foo(); }
11     public void foo() { bar(); }
12 }
13
14 public class Penguin {
15     int x, y;
16
17     public Penguin() { x = 0; y = 0; }
18
19     public void bar() { x = 1; }
20 }
21
22 public class Voo {
23     flag f; int x; Baw b; Baw bb;
24
25     public Voo() {}
26 }
27
28 public class Baw {
29     int y;
30     Foo f;
31
32     public Baw() {}
33
34     public void doTheBaw( Voo v ) { v = new Voo(); }
35 }
36
37
38 public class Foo {
39     public Foo() {}
40
41     public Foo x;
42
43     public void ruinSomeFoos( Foo a, Foo b ) {
44         a.x = b.x;
45     }
46 }
47
48 // this empty task should still create a non-empty
49 // ownership graph showing parameter allocation
50 // look for the parameter s as a label referencing
51 // a heap region that is multi-object, flagged, not summary
52 task Startup( StartupObject s{ initialstate } ) {
53
54     while( false ) {
55         Foo a = new Foo();
56         a.x   = new Foo();
57         a.x.x = new Foo();
58     }
59
60     taskexit( s{ !initialstate } );
61 }
62
63
64
65 // this task allocates a new object, so there should
66 // be a heap region for the parameter, and several
67 // heap regions for the allocation site, but the label
68 // merely points to the newest region
69 task NewObject( Voo v{ f } ) {
70     Voo w = new Voo();
71     Baw b = new Baw();
72     b.doTheBaw( w );
73
74     taskexit( v{ !f } );
75 }
76
77 // this task 
78 task Branch( Voo v{ f } ) {
79     Voo w = new Voo();
80     Baw j = new Baw();
81     Baw k = new Baw();
82
83     if( v.x == 0 ) {
84         w.b = j;
85     } else {
86         w.b = k;
87     }
88
89     taskexit( v{ !f } );
90 }
91
92
93 task NoAliasNewInLoop( Voo v{ f } ) {
94
95     for( int i = 0; i < 10; ++i ) {
96         Voo w = new Voo();
97         w.b   = new Baw();
98         w.b.f = new Foo();
99     }
100
101     taskexit( v{ !f } );
102 }
103
104 task NoAliasNewInLoopAnotherWay( Voo v{ f } ) {
105
106     for( int i = 0; i < 10; ++i ) {
107         Voo w = new Voo();
108         Baw b = new Baw();
109         Foo f = new Foo();
110
111         w.b = b;
112         b.f = f;
113     }
114
115     taskexit( v{ !f } );
116 }
117
118 task ClobberInitParamReflex( Voo v{ f }, Voo w{ f } ) {
119     v.b = v.bb;
120
121     taskexit( v{ !f }, w{ !f } );
122 }
123