Most up-to-date allocation site algorithm implemented, but some references
[IRC.git] / Robust / src / Analysis / OwnershipAnalysis / AllocationSite.java
1 package Analysis.OwnershipAnalysis;
2
3 import IR.*;
4 import IR.Flat.*;
5 import java.util.*;
6
7 // allocation sites are independent of any particular
8 // ownership graph, unlike most of the other elements
9 // of the ownership analysis.  An allocation site is
10 // simply a collection of heap region identifiers that
11 // are associated with a single allocation site in the
12 // program under analysis.
13
14 // So two different ownership graphs may incorporate
15 // nodes that represent the memory from one allocation
16 // site.  In this case there are two different sets of
17 // HeapRegionNode objects, but they have the same
18 // node identifiers, and there is one AllocationSite
19 // object associated with the FlatNew node that gives
20 // the graphs the identifiers in question.
21
22 public class AllocationSite {
23
24     protected int             allocationDepth;
25     protected Vector<Integer> ithOldest;
26     protected Integer         summary;
27
28     public AllocationSite( int allocationDepth ) {
29         assert allocationDepth >= 3;
30
31         this.allocationDepth = allocationDepth;
32         ithOldest = new Vector<Integer>( allocationDepth );
33     }
34     
35     public void setIthOldest( int i, Integer id ) {
36         assert i  >= 0;
37         assert i  <  allocationDepth;
38         assert id != null;
39
40         ithOldest.add( i, id );
41     }
42
43     public Integer getIthOldest( int i ) {
44         assert i >= 0;
45         assert i <  allocationDepth;
46
47         return ithOldest.get( i );
48     }
49
50     public Integer getOldest() {
51         return ithOldest.get( allocationDepth - 1 );
52     }
53
54     public void setSummary( Integer id ) {
55         assert id != null;
56         summary = id;
57     }
58
59     public Integer getSummary() {
60         return summary;
61     }
62 }