Reachability bug fixes. Tokens propagate and age in allocation sites,
[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     flag f;
40
41     public Foo() {}
42
43     public Foo x;
44
45     public void ruinSomeFoos( Foo a, Foo b ) {
46         a.x = b.x;
47     }
48 }
49
50
51 // this empty task should still create a non-empty
52 // ownership graph showing parameter allocation
53 // look for the parameter s as a label referencing
54 // a heap region that is multi-object, flagged, not summary
55 task Startup( StartupObject s{ initialstate } ) {
56     
57     while( false ) {
58         Foo a = new Foo();
59         a.x   = new Foo();
60         a.x.x = new Foo();
61     }
62     
63     
64     Foo b;
65     while( false ) {
66         Foo c = new Foo();
67         c.x = b;
68         b = c;
69     }
70     
71     
72     Foo d = new Foo();
73     Foo e = new Foo();
74     Foo f = new Foo();
75
76     d.x = e;
77     e.x = f;    
78
79     taskexit( s{ !initialstate } );
80 }
81
82 /*
83 task NewObject( Foo a{ f }, Foo b{ f } ) {
84
85     Foo c = new Foo();
86
87     a.x = c;
88
89     taskexit( a{ !f }, b{ !f } );
90 }
91 */
92
93 /*
94 task NewObjectA( Foo a{ f }, Foo b{ f } ) {
95
96     Foo c = new Foo();
97     Foo d = new Foo();
98
99     c.x = d;
100     a.x = c;
101
102     taskexit( a{ !f }, b{ !f } );
103 }
104
105 task NewObjectB( Foo a{ f }, Foo b{ f } ) {
106
107     Foo c = new Foo();
108     Foo d = new Foo();
109
110     a.x = c;
111     c.x = d;
112
113     taskexit( a{ !f }, b{ !f } );
114 }
115 */
116
117 /*
118 task NewObject2( Foo a{ f }, Foo b{ f } ) {
119
120     Foo c;
121
122     while( false ) {
123         c   = new Foo();
124         c.x = new Foo();
125     }
126
127     taskexit( a{ !f }, b{ !f } );
128 }
129 */
130
131
132 /*
133 // this task allocates a new object, so there should
134 // be a heap region for the parameter, and several
135 // heap regions for the allocation site, but the label
136 // merely points to the newest region
137 task NewObject( Voo v{ f } ) {
138     Voo w = new Voo();
139     Baw b = new Baw();
140     b.doTheBaw( w );
141
142     taskexit( v{ !f } );
143 }
144
145
146 // this task 
147 task Branch( Voo v{ f } ) {
148     Voo w = new Voo();
149     Baw j = new Baw();
150     Baw k = new Baw();
151
152     if( v.x == 0 ) {
153         w.b = j;
154     } else {
155         w.b = k;
156     }
157
158     taskexit( v{ !f } );
159 }
160
161
162 task NoAliasNewInLoop( Voo v{ f } ) {
163
164     for( int i = 0; i < 10; ++i ) {
165         Voo w = new Voo();
166         w.b   = new Baw();
167         w.b.f = new Foo();
168     }
169
170     taskexit( v{ !f } );
171 }
172
173
174 task NoAliasNewInLoopAnotherWay( Voo v{ f } ) {
175
176     for( int i = 0; i < 10; ++i ) {
177         Voo w = new Voo();
178         Baw b = new Baw();
179         Foo f = new Foo();
180
181         w.b = b;
182         b.f = f;
183     }
184
185     taskexit( v{ !f } );
186 }
187
188
189 task ClobberInitParamReflex( Voo v{ f }, Voo w{ f } ) {
190     v.b = v.bb;
191
192     taskexit( v{ !f }, w{ !f } );
193 }
194 */