3 import java.util.HashSet;
4 import java.util.Iterator;
7 import Analysis.OwnershipAnalysis.AllocationSite;
8 import Analysis.OwnershipAnalysis.HeapRegionNode;
9 import Analysis.OwnershipAnalysis.TokenTupleSet;
10 import IR.Flat.FlatNode;
11 import IR.Flat.TempDescriptor;
13 public class StallSite {
15 public static final Integer READ_EFFECT = new Integer(1);
16 public static final Integer WRITE_EFFECT = new Integer(2);
18 private HashSet<Effect> effectSet;
19 private HashSet<HeapRegionNode> hrnSet;
20 private HashSet<AllocationSite> allocationSiteSet;
21 // private ReachabilitySet reachabilitySet;
22 HashSet<TokenTupleSet> reachabilitySet;
23 private HashSet<StallTag> stallTagSet;
24 private TempDescriptor tdA;
26 // if stall site is caller's parameter heap regtion, store its parameter idx
27 // for further analysis
28 private HashSet<Integer> callerParamIdxSet;
31 effectSet = new HashSet<Effect>();
32 hrnSet = new HashSet<HeapRegionNode>();
33 reachabilitySet = new HashSet<TokenTupleSet>();
34 allocationSiteSet = new HashSet<AllocationSite>();
35 stallTagSet = new HashSet<StallTag>();
36 callerParamIdxSet = new HashSet<Integer>();
39 public StallSite(HashSet<HeapRegionNode> hrnSet, StallTag tag) {
43 setHeapRegionNodeSet(hrnSet);
46 for (Iterator iterator = hrnSet.iterator(); iterator.hasNext();) {
47 HeapRegionNode heapRegionNode = (HeapRegionNode) iterator.next();
48 setAllocationSite(heapRegionNode.getAllocationSite());
52 public StallSite(HashSet<Effect> effectSet, HashSet<HeapRegionNode> hrnSet,
53 HashSet<TokenTupleSet> rechabilitySet, HashSet<AllocationSite> alocSet,
54 HashSet<StallTag> tagSet, HashSet<Integer> paramIdx) {
56 this.effectSet.addAll(effectSet);
57 this.hrnSet.addAll(hrnSet);
58 this.reachabilitySet = rechabilitySet;
59 this.allocationSiteSet.addAll(alocSet);
60 this.stallTagSet.addAll(tagSet);
61 this.callerParamIdxSet.addAll(paramIdx);
64 public void addTokenTupleSet(TokenTupleSet newSet){
65 reachabilitySet.add(newSet);
68 public HashSet<Integer> getCallerParamIdxSet() {
69 return callerParamIdxSet;
72 public void addCallerParamIdxSet(Set<Integer> newParamSet) {
73 if (newParamSet != null) {
74 callerParamIdxSet.addAll(newParamSet);
78 public void setStallTagSet(HashSet<StallTag> tags) {
82 public void addRelatedStallTag(StallTag stallTag) {
83 stallTagSet.add(stallTag);
86 public void setAllocationSite(AllocationSite allocationSite) {
87 if (allocationSite != null) {
88 allocationSiteSet.add(allocationSite);
92 public void setHeapRegionNodeSet(HashSet<HeapRegionNode> newSet) {
93 hrnSet.addAll(newSet);
96 public HashSet<AllocationSite> getAllocationSiteSet() {
97 return allocationSiteSet;
100 public void addEffect(String type, String field, Integer effect) {
102 Effect e = new Effect(type, field, effect, stallTagSet);
106 public HashSet<Effect> getEffectSet() {
110 public HashSet<HeapRegionNode> getHRNSet() {
114 public HashSet<TokenTupleSet> getReachabilitySet() {
115 return reachabilitySet;
118 public HashSet<StallTag> getStallTagSet() {
122 public StallSite copy() {
124 StallSite copy = new StallSite(effectSet, hrnSet, reachabilitySet,
125 allocationSiteSet, stallTagSet, callerParamIdxSet);
130 public void setTdA(TempDescriptor tdA){
134 public TempDescriptor getTdA(){
138 public boolean equals(Object o) {
144 if (!(o instanceof StallSite)) {
148 StallSite in = (StallSite) o;
150 if (allocationSiteSet.equals(in.getAllocationSiteSet())
151 && stallTagSet.equals(in.getStallTagSet())
152 && effectSet.equals(in.getEffectSet())
153 && hrnSet.equals(in.getHRNSet())
154 && reachabilitySet.equals(in.getReachabilitySet())) {
163 public String toString() {
164 return "StallSite [allocationSiteSet=" + allocationSiteSet
165 + ", callerParamIdxSet=" + callerParamIdxSet + ", effectSet="
166 + effectSet + ", hrnSet=" + hrnSet + ", rechabilitySet="
167 + reachabilitySet + ", stallTagSet=" + stallTagSet + "]";
176 public StallTag(FlatNode fn) {
180 public FlatNode getKey() {
184 public boolean equals(Object o) {
190 if (!(o instanceof StallTag)) {
194 StallTag in = (StallTag) o;
196 if (getKey().equals(in.getKey())) {
208 private String field;
210 private Integer effect;
211 private HashSet<StallTag> stallTagSet;
214 stallTagSet = new HashSet<StallTag>();
217 public Effect(String type, String field, Integer effect,
218 HashSet<StallTag> tagSet) {
222 this.effect = effect;
223 stallTagSet.addAll(tagSet);
226 public String getField() {
230 public String getType() {
234 public Integer getEffectType() {
238 public HashSet<StallTag> getStallTagSet() {
242 public boolean equals(Object o) {
248 if (!(o instanceof Effect)) {
252 Effect in = (Effect) o;
254 if (stallTagSet.equals(in.getStallTagSet())
255 && type.equals(in.getType()) && field.equals(in.getField())
256 && effect.equals(in.getEffectType())) {
264 public String toString() {
265 return "Effect [effect=" + effect + ", field=" + field
266 + ", stallTagSet=" + stallTagSet + ", type=" + type + "]";