Altered ownership graph to dot file by removing label nodes, marking allocation
[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     protected TypeDescriptor  type;
31
32
33     public AllocationSite( int allocationDepth, TypeDescriptor type ) {
34         assert allocationDepth >= 3;
35
36         this.allocationDepth = allocationDepth; 
37         this.type            = type;
38
39         ithOldest = new Vector<Integer>( allocationDepth );
40         id        = generateUniqueAllocationSiteID();
41     }
42
43     static public Integer generateUniqueAllocationSiteID() {
44         ++uniqueIDcount;
45         return new Integer( uniqueIDcount );
46     }    
47
48     
49     public void setIthOldest( int i, Integer id ) {
50         assert i  >= 0;
51         assert i  <  allocationDepth;
52         assert id != null;
53
54         ithOldest.add( i, id );
55     }
56
57     public Integer getIthOldest( int i ) {
58         assert i >= 0;
59         assert i <  allocationDepth;
60
61         return ithOldest.get( i );
62     }
63
64     public Integer getOldest() {
65         return ithOldest.get( allocationDepth - 1 );
66     }
67
68     public void setSummary( Integer id ) {
69         assert id != null;
70         summary = id;
71     }
72
73     public Integer getSummary() {
74         return summary;
75     }
76
77     public TypeDescriptor getType() {
78         return type;
79     }
80
81     public String toString() {
82         return "allocSite" + id + "\\n" + type;
83     }
84 }