1 package Analysis.OwnershipAnalysis;
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.
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.
22 public class AllocationSite {
24 static private int uniqueIDcount = 0;
27 protected int allocationDepth;
28 protected Vector<Integer> ithOldest;
29 protected Integer summary;
30 protected TypeDescriptor type;
32 public static final int AGE_notInThisSite = -1;
33 public static final int AGE_oldest = -2;
34 public static final int AGE_summary = -3;
37 public AllocationSite(int allocationDepth, TypeDescriptor type) {
38 assert allocationDepth >= 1;
40 this.allocationDepth = allocationDepth;
43 ithOldest = new Vector<Integer>(allocationDepth);
44 id = generateUniqueAllocationSiteID();
47 static public Integer generateUniqueAllocationSiteID() {
49 return new Integer(uniqueIDcount);
53 public int getAllocationDepth() {
54 return allocationDepth;
57 public void setIthOldest(int i, Integer id) {
59 assert i < allocationDepth;
65 public Integer getIthOldest(int i) {
67 assert i < allocationDepth;
69 return ithOldest.get(i);
72 public Integer getOldest() {
73 return ithOldest.get(allocationDepth - 1);
76 public void setSummary(Integer id) {
81 public Integer getSummary() {
85 public TypeDescriptor getType() {
89 public int getAge(Integer id) {
90 if( id.equals(summary) ) {
94 if( id.equals(getOldest() ) ) {
98 for( int i = 0; i < allocationDepth - 1; ++i ) {
99 if( id.equals(ithOldest.get(i) ) ) {
104 return AGE_notInThisSite;
107 public String toString() {
108 return "allocSite" + id;