1 package Analysis.Disjoint;
7 // allocation sites are independent of any particular
8 // reachability graph, unlike most of the other elements
9 // of the reachability 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 reachability 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 AllocSite
19 // object associated with the FlatNew node that gives
20 // the graphs the identifiers in question.
22 // note that an allocsite extends Canonical because they
23 // are Canonical, but specifically so an AllocSite can
24 // be an operand to a CanonicalOp
26 public class AllocSite extends Canonical {
28 static protected int uniqueIDcount = 0;
30 public static final int AGE_notInThisSite = 100;
31 public static final int AGE_in_I = 101;
32 public static final int AGE_oldest = 102;
33 public static final int AGE_summary = 103;
34 public static final int AGE_siteSummary = 200;
36 public static final int SHADOWAGE_notInThisSite = -100;
37 public static final int SHADOWAGE_in_I = -101;
38 public static final int SHADOWAGE_oldest = -102;
39 public static final int SHADOWAGE_summary = -103;
40 public static final int SHADOWAGE_siteSummary = -200;
43 protected int allocationDepth;
44 protected Vector<Integer> ithOldest;
45 protected Integer summary;
46 protected Integer siteSummary;
47 protected FlatNew flatNew;
48 protected String disjointId;
49 protected boolean flag;
52 public AllocSite( int allocationDepth,
57 assert allocationDepth >= 1;
59 this.allocationDepth = allocationDepth;
60 this.flatNew = flatNew;
61 this.disjointId = disjointId;
64 ithOldest = new Vector<Integer>( allocationDepth );
65 id = generateUniqueAllocSiteID();
68 static public Integer generateUniqueAllocSiteID() {
70 return new Integer( uniqueIDcount );
73 public String getDisjointAnalysisId() {
78 public int getAllocationDepth() {
79 return allocationDepth;
82 public void setIthOldest( int i, Integer id ) {
84 assert i < allocationDepth;
87 ithOldest.add( i, id );
90 public Integer getIthOldest( int i ) {
92 assert i < allocationDepth;
94 return ithOldest.get( i );
97 public Integer getIthOldestShadow( int i ) {
99 assert i < allocationDepth;
101 return -ithOldest.get( i );
104 public Integer getOldest() {
105 return ithOldest.get( allocationDepth - 1 );
108 public Integer getOldestShadow() {
109 return -ithOldest.get( allocationDepth - 1 );
112 public void setSummary( Integer id ) {
117 public Integer getSummary() {
121 public Integer getSummaryShadow() {
125 public void setSiteSummary( Integer id ) {
130 public FlatNew getFlatNew() {
134 public TypeDescriptor getType() {
135 return flatNew.getType();
138 public int getAgeCategory( Integer id ) {
140 if( id.equals( summary ) ) {
144 if( id.equals( getOldest() ) ) {
148 for( int i = 0; i < allocationDepth - 1; ++i ) {
149 if( id.equals( ithOldest.get( i ) ) ) {
154 return AGE_notInThisSite;
157 public Integer getAge( Integer id ) {
158 for( int i = 0; i < allocationDepth - 1; ++i ) {
159 if( id.equals( ithOldest.get( i ) ) ) {
160 return new Integer( i );
167 public int getShadowAgeCategory( Integer id ) {
168 if( id.equals( -summary ) ) {
169 return SHADOWAGE_summary;
172 if( id.equals( getOldestShadow() ) ) {
173 return SHADOWAGE_oldest;
176 for( int i = 0; i < allocationDepth - 1; ++i ) {
177 if( id.equals( getIthOldestShadow( i ) ) ) {
178 return SHADOWAGE_in_I;
182 return SHADOWAGE_notInThisSite;
185 public Integer getShadowAge( Integer id ) {
186 for( int i = 0; i < allocationDepth - 1; ++i ) {
187 if( id.equals( getIthOldestShadow( i ) ) ) {
188 return new Integer( -i );
196 public String toString() {
197 if( disjointId == null ) {
198 return "allocSite"+id;
200 return "allocSite "+disjointId+" ("+id+")";
203 public String toStringVerbose() {
204 if( disjointId == null ) {
205 return "allocSite"+id+" "+
206 flatNew.getType().toPrettyString();
208 return "allocSite "+disjointId+" ("+id+") "+
209 flatNew.getType().toPrettyString();
212 public String toStringForDOT() {
213 if( disjointId != null ) {
214 return "disjoint "+disjointId+"\\n"+toString()+
215 "\\n"+getType().toPrettyString();
218 "\\n"+getType().toPrettyString();
222 public String toStringWithIDs() {
223 String s = "allocSite ";
224 for( int i = 0; i < ithOldest.size(); ++i ) {
225 s += i+"("+ithOldest.get( i )+") ";
227 s += "summary("+summary+")";
232 public int hashCodeSpecific() {
236 public void setFlag( boolean flag ) {
240 public boolean getFlag() {