model the allocation of string literals in heap analysis
[IRC.git] / Robust / src / Analysis / Disjoint / HeapAnalysis.java
1 package Analysis.Disjoint;
2
3 import java.util.*;
4
5 import IR.*;
6 import IR.Flat.TempDescriptor;
7 import IR.Flat.FlatNode;
8 import IR.Flat.FlatNew;
9
10
11 public interface HeapAnalysis {
12   public EffectsAnalysis getEffectsAnalysis();
13   public Alloc getAllocationSiteFromFlatNew(FlatNew node);
14
15   // what are these for?  Well, if your heap analysis wants to model
16   // the command line argument heap as the initial context, AND you are
17   // assigning IDs to allocation sites, the problem is there is no explicit
18   // allocation site for the command line arguments in the source code.  So
19   // what you do is build your model and when these methods are invoked, return
20   // the alloc ID from your model.  So the structure is an array of Strings has
21   // elements that reference a single String, and that String has a field that
22   // references an array of char primitives.
23   public Alloc getCmdLineArgsAlloc();    // an array of String
24   public Alloc getCmdLineArgAlloc();     // a String
25   public Alloc getCmdLineArgBytesAlloc();// an array of char
26
27
28   // similar to above, new string literals have a runtime alloc site (not in
29   // code explicitly) so make one in your model and return it here
30   public Alloc getNewStringLiteralAlloc(); // a String
31
32
33   // Use these methods to find out what allocation sites
34   // the given pointer might point to at or after the 
35   // given program point.  In the case of a variable and
36   // a field or element dereference you get a hashtable
37   // where the keys are allocs for the variables and the
38   // values are from following the second hop
39   // NOTE: if the set of Alloc's that something can point
40   // to is DONTCARE, this will mean "the analysis doesn't care
41   // what it points to" so the client shouldn't either, NOT
42   // interpreting it as "it can't point to anything."  The
43   // meaning "it can't point to anything" will be represented
44   // by an empty set of Alloc.
45   static public final Set<Alloc>                     DONTCARE_PTR  = new HashSet<Alloc>();
46   static public final Hashtable< Alloc, Set<Alloc> > DONTCARE_DREF = new Hashtable< Alloc, Set<Alloc> >();
47
48   public Set<Alloc> canPointToAt( TempDescriptor x,
49                                   FlatNode programPoint );
50
51   public Set<Alloc> canPointToAfter( TempDescriptor x,
52                                      FlatNode programPoint );
53   
54   public Hashtable< Alloc, Set<Alloc> > canPointToAt( TempDescriptor x,
55                                                       FieldDescriptor f,
56                                                       FlatNode programPoint );
57
58   public Hashtable< Alloc, Set<Alloc> > canPointToAtElement( TempDescriptor x, // x[i]
59                                                              FlatNode programPoint );
60 }
61