Stable state capture.
[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     static private int uniqueIDcount = 0;
25
26     protected Integer         id;
27     protected int             allocationDepth;
28     protected Vector<Integer> ithOldest;
29     protected Integer         summary;
30
31
32     public AllocationSite( int allocationDepth ) {
33         assert allocationDepth >= 3;
34
35         this.allocationDepth = allocationDepth; 
36
37         ithOldest = new Vector<Integer>( allocationDepth );
38         id        = generateUniqueAllocationSiteID();
39     }
40
41     static public Integer generateUniqueAllocationSiteID() {
42         ++uniqueIDcount;
43         return new Integer( uniqueIDcount );
44     }    
45
46     
47     public void setIthOldest( int i, Integer id ) {
48         assert i  >= 0;
49         assert i  <  allocationDepth;
50         assert id != null;
51
52         ithOldest.add( i, id );
53     }
54
55     public Integer getIthOldest( int i ) {
56         assert i >= 0;
57         assert i <  allocationDepth;
58
59         return ithOldest.get( i );
60     }
61
62     public Integer getOldest() {
63         return ithOldest.get( allocationDepth - 1 );
64     }
65
66     public void setSummary( Integer id ) {
67         assert id != null;
68         summary = id;
69     }
70
71     public Integer getSummary() {
72         return summary;
73     }
74
75     public String toString() {
76         return "allocSite" + id;
77     }
78 }