Starting implementation for definite reachability analysis
[IRC.git] / Robust / src / Analysis / Disjoint / DefiniteReachAnalysis.java
1 package Analysis.Disjoint;
2
3 import java.util.*;
4
5 import IR.*;
6 import IR.Flat.*;
7 import Util.*;
8
9
10 public class DefiniteReachAnalysis {
11
12   // R
13   //
14   // Maps variables and an edge (x, y, e) to an unused value when the
15   // object of x is already reachable from the object of y, and the
16   // set of edges conservatively gives the path.
17   // NOTE: Use EdgeKey instead of edges because this analysis's
18   // scope is beyond the scope of a single reach graph.
19
20   // Fs
21   // Just a hashmap of variable to enum (unknown, new).
22
23   // Fu
24
25   // Fd
26
27   public DefiniteReachAnalysis() {
28   }
29
30   // what are the transfer functions that are relevant for this analyis?
31
32   public void methodEntry(Set<TempDescriptor> parameters) {
33     // R' := {}
34     // R.clear();
35
36     // Rs' := P x {unknown}
37   }
38
39   public void copy(TempDescriptor x,
40                    TempDescriptor y) {
41     // R' := (R - <x,*> - <*,x>)        U
42     //       {<x,z>->e | <y,z>->e in R} U
43     //       {<z,x>->e | <z,y>->e in R}
44     // R' = new Map(R)
45     // R'.remove(view0, x);
46     // R'.remove(view1, x);
47     // setYs = R.get(view0, y);
48     // for each <y,z>->e: R'.put(<x,z>, e);
49     // setYs = R.get(view1, y);
50     // for each <z,y>->e: R'.put(<z,x>, e);
51
52     // Rs' := (Rs - <x,*>) U {<x,v> | <y,v> in Rs}
53   }
54
55   public void load(TempDescriptor x,
56                    TempDescriptor y,
57                    FieldDescriptor f) {
58     // R' := (R - <x,*> - <*,x>) U
59     //       ({<x,y>} x Eo(y,f)) U
60     //       U        {<x,z>} x (Eo(y,f)U{e})
61     //   <y,z>->e in R
62     // R' = new Map(R)
63     // R'.remove(view0, x);
64     // R'.remove(view1, x);
65     // R'.put(<x,y>, eee!);
66     // setYs = R.get(view0, y);
67     // for each <y,z>->e: R'.put(<x,z>, eee!Ue);
68
69     // Rs' := (Rs - <x,*>) U {<x, unknown>}
70   }
71
72   public void store(TempDescriptor x,
73                    FieldDescriptor f,
74                    TempDescriptor y) {
75     // I think this should be if there is ANY <w,z>->e' IN Eremove, then kill all <w,z>
76     // R' := (R - {<w,z>->e | <w,z>->e in R, A<w,z>->e' in R, e' notin Eremove}) U
77     //       {<y,x>->e | e in E(x) x {f} x E(y)}
78     // R' = new Map(R)
79     // R'.remove(?); some e's...
80     // R'.put(<y,x>, E(x) x {f} x E(y));
81
82     // Rs' := Rs
83   }
84
85   public void newObject(TempDescriptor x) {
86     // R' := (R - <x,*> - <*,x>)
87     // R' = new Map(R)
88     // R'.remove(view0, x);
89     // R'.remove(view1, x);
90
91     // Rs' := (Rs - <x,*>) U {<x, new>}
92   }
93
94   public void methodCall(TempDescriptor x) {
95     // R' := (R - <x,*> - <*,x>)
96     // R' = new Map(R)
97     // R'.remove(view0, x);
98     // R'.remove(view1, x);
99
100     // Rs' := (Rs - <x,*>) U {<x, unknown>}
101   }
102
103   public void merge() {
104     // R' := <x,y>->e iff its in all incoming edges
105
106     // Rs' := <x, new> iff in all incoming edges, otherwie <x, unknown>
107   }
108 }