fixes and associate each effect with unique stall tag identifier.
[IRC.git] / Robust / src / Analysis / MLP / StallSite.java
index beb1b65e8098819c62c85accc1d2ede166d12a09..a067a2f1224da291ca831aee41b34b688230bb9e 100644 (file)
@@ -2,10 +2,12 @@ package Analysis.MLP;
 
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.Set;
 
 import Analysis.OwnershipAnalysis.AllocationSite;
 import Analysis.OwnershipAnalysis.HeapRegionNode;
 import Analysis.OwnershipAnalysis.ReachabilitySet;
+import IR.Flat.FlatNode;
 
 public class StallSite {
 
@@ -16,17 +18,28 @@ public class StallSite {
        private HashSet<HeapRegionNode> hrnSet;
        private HashSet<AllocationSite> allocationSiteSet;
        private ReachabilitySet rechabilitySet;
+       private HashSet<StallTag> stallTagSet;
+
+       // if stall site is caller's parameter heap regtion, store its parameter idx
+       // for further analysis
+       private HashSet<Integer> callerParamIdxSet;
 
        public StallSite() {
                effectSet = new HashSet<Effect>();
                hrnSet = new HashSet<HeapRegionNode>();
                rechabilitySet = new ReachabilitySet();
-               allocationSiteSet=new HashSet<AllocationSite>();
+               allocationSiteSet = new HashSet<AllocationSite>();
+               stallTagSet = new HashSet<StallTag>();
+               callerParamIdxSet = new HashSet<Integer>();
        }
-       
-       public StallSite(HashSet<HeapRegionNode> hrnSet){
+
+       public StallSite(HashSet<HeapRegionNode> hrnSet, StallTag tag) {
+
                this();
+
                setHeapRegionNodeSet(hrnSet);
+               stallTagSet.add(tag);
+
                for (Iterator iterator = hrnSet.iterator(); iterator.hasNext();) {
                        HeapRegionNode heapRegionNode = (HeapRegionNode) iterator.next();
                        setAllocationSite(heapRegionNode.getAllocationSite());
@@ -34,28 +47,52 @@ public class StallSite {
        }
 
        public StallSite(HashSet<Effect> effectSet, HashSet<HeapRegionNode> hrnSet,
-                       ReachabilitySet rechabilitySet) {
-               this.effectSet = effectSet;
-               this.hrnSet = hrnSet;
+                       ReachabilitySet rechabilitySet, HashSet<AllocationSite> alocSet,
+                       HashSet<StallTag> tagSet, HashSet<Integer> paramIdx) {
+               this();
+               this.effectSet.addAll(effectSet);
+               this.hrnSet.addAll(hrnSet);
                this.rechabilitySet = rechabilitySet;
+               this.allocationSiteSet.addAll(alocSet);
+               this.stallTagSet.addAll(tagSet);
+               this.callerParamIdxSet.addAll(paramIdx);
+       }
+
+       public HashSet<Integer> getCallerParamIdxSet() {
+               return callerParamIdxSet;
+       }
+
+       public void addCallerParamIdxSet(Set<Integer> newParamSet) {
+               if (newParamSet != null) {
+                       callerParamIdxSet.addAll(newParamSet);
+               }
+       }
+
+       public void setStallTagSet(HashSet<StallTag> tags) {
+               stallTagSet = tags;
+       }
+
+       public void addRelatedStallTag(StallTag stallTag) {
+               stallTagSet.add(stallTag);
        }
-       
-       public void setAllocationSite(AllocationSite allocationSite){
-               if(allocationSite!=null){
+
+       public void setAllocationSite(AllocationSite allocationSite) {
+               if (allocationSite != null) {
                        allocationSiteSet.add(allocationSite);
                }
        }
-       
-       public void setHeapRegionNodeSet(HashSet<HeapRegionNode> newSet){
+
+       public void setHeapRegionNodeSet(HashSet<HeapRegionNode> newSet) {
                hrnSet.addAll(newSet);
        }
-       
-       public HashSet<AllocationSite> getAllocationSiteSet(){
+
+       public HashSet<AllocationSite> getAllocationSiteSet() {
                return allocationSiteSet;
        }
 
        public void addEffect(String type, String field, Integer effect) {
-               Effect e = new Effect(type, field, effect);
+
+               Effect e = new Effect(type, field, effect, stallTagSet);
                effectSet.add(e);
        }
 
@@ -71,6 +108,18 @@ public class StallSite {
                return rechabilitySet;
        }
 
+       public HashSet<StallTag> getStallTagSet() {
+               return stallTagSet;
+       }
+
+       public StallSite copy() {
+
+               StallSite copy = new StallSite(effectSet, hrnSet, rechabilitySet,
+                               allocationSiteSet, stallTagSet, callerParamIdxSet);
+               return copy;
+               
+       }
+
        public boolean equals(Object o) {
 
                if (o == null) {
@@ -83,7 +132,9 @@ public class StallSite {
 
                StallSite in = (StallSite) o;
 
-               if (effectSet.equals(in.getEffectSet())
+               if (allocationSiteSet.equals(in.getAllocationSiteSet())
+                               && stallTagSet.equals(in.getStallTagSet())
+                               && effectSet.equals(in.getEffectSet())
                                && hrnSet.equals(in.getHRNSet())
                                && rechabilitySet.equals(in.getReachabilitySet())) {
                        return true;
@@ -93,11 +144,48 @@ public class StallSite {
 
        }
 
+       @Override
        public String toString() {
-               return "StallSite [effectSet=" + effectSet + ", hrnIDSet=" + hrnSet
-                               + ", rechabilitySet=" + rechabilitySet + "]";
+               return "StallSite [allocationSiteSet=" + allocationSiteSet
+                               + ", callerParamIdxSet=" + callerParamIdxSet + ", effectSet="
+                               + effectSet + ", hrnSet=" + hrnSet + ", rechabilitySet="
+                               + rechabilitySet + ", stallTagSet=" + stallTagSet + "]";
        }
-       
+
+}
+
+class StallTag {
+
+       private FlatNode fn;
+
+       public StallTag(FlatNode fn) {
+               this.fn = fn;
+       }
+
+       public FlatNode getKey() {
+               return fn;
+       }
+
+       public boolean equals(Object o) {
+
+               if (o == null) {
+                       return false;
+               }
+
+               if (!(o instanceof StallTag)) {
+                       return false;
+               }
+
+               StallTag in = (StallTag) o;
+
+               if (getKey().equals(in.getKey())) {
+                       return true;
+               } else {
+                       return false;
+               }
+
+       }
+
 }
 
 class Effect {
@@ -105,11 +193,19 @@ class Effect {
        private String field;
        private String type;
        private Integer effect;
+       private HashSet<StallTag> stallTagSet;
+
+       public Effect() {
+               stallTagSet = new HashSet<StallTag>();
+       }
 
-       public Effect(String type, String field, Integer effect) {
+       public Effect(String type, String field, Integer effect,
+                       HashSet<StallTag> tagSet) {
+               this();
                this.type = type;
                this.field = field;
                this.effect = effect;
+               stallTagSet.addAll(tagSet);
        }
 
        public String getField() {
@@ -124,19 +220,24 @@ class Effect {
                return effect;
        }
 
+       public HashSet<StallTag> getStallTagSet() {
+               return stallTagSet;
+       }
+
        public boolean equals(Object o) {
 
                if (o == null) {
                        return false;
                }
 
-               if (!(o instanceof StallSite)) {
+               if (!(o instanceof Effect)) {
                        return false;
                }
 
                Effect in = (Effect) o;
 
-               if (type.equals(in.getType()) && field.equals(in.getField())
+               if (stallTagSet.equals(in.getStallTagSet())
+                               && type.equals(in.getType()) && field.equals(in.getField())
                                && effect.equals(in.getEffect())) {
                        return true;
                } else {
@@ -145,4 +246,9 @@ class Effect {
 
        }
 
+       public String toString() {
+               return "Effect [effect=" + effect + ", field=" + field
+                               + ", stallTagSet=" + stallTagSet + ", type=" + type + "]";
+       }
+
 }
\ No newline at end of file