rg.merge( rgParent );
}
}
-
+
+ //if(rra.isEndOfRegion(fn)){
+ // rg.clearAccessibleVarSet();
+ // also need to clear stall mapping
+ //}
if( takeDebugSnapshots &&
d.getSymbol().equals( descSymbolDebug )
--- /dev/null
+package Analysis.Disjoint;
+
+import Analysis.OwnershipAnalysis.EffectsKey;
+import IR.FieldDescriptor;
+import IR.Flat.TempDescriptor;
+
+public class Effect {
+
+ // operation type
+ public static final int read = 1;
+ public static final int write = 2;
+ public static final int strongupdate = 3;
+
+ // identify a parameter index
+ protected Integer paramIndex;
+
+ // identify an inset var
+ protected TempDescriptor insetVar;
+
+ // identify an allocation site of inset var
+ protected AllocSite insetAllocSite;
+
+ // identify an allocation site of affected object
+ protected AllocSite affectedAllocSite;
+
+ // identify operation type
+ protected int type;
+
+ // identify a field
+ protected FieldDescriptor field;
+
+ public Effect(Integer pi, AllocSite insetAS, AllocSite affectedAS, int type, FieldDescriptor field) {
+ this.paramIndex = pi;
+ this.insetAllocSite = insetAS;
+ this.affectedAllocSite = affectedAS;
+ this.type = type;
+ this.field = field;
+ }
+
+ public Integer getParamIndex() {
+ return paramIndex;
+ }
+
+ public void setParamIndex(Integer paramIndex) {
+ this.paramIndex = paramIndex;
+ }
+
+ public TempDescriptor getInsetVar() {
+ return insetVar;
+ }
+
+ public void setInsetVar(TempDescriptor insetVar) {
+ this.insetVar = insetVar;
+ }
+
+ public AllocSite getInsetAllocSite() {
+ return insetAllocSite;
+ }
+
+ public void setInsetAllocSite(AllocSite insetAllocSite) {
+ this.insetAllocSite = insetAllocSite;
+ }
+
+ public AllocSite getAffectedAllocSite() {
+ return affectedAllocSite;
+ }
+
+ public void setAffectedAllocSite(AllocSite affectedAllocSite) {
+ this.affectedAllocSite = affectedAllocSite;
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ public void setType(int type) {
+ this.type = type;
+ }
+
+ public FieldDescriptor getField() {
+ return field;
+ }
+
+ public void setField(FieldDescriptor field) {
+ this.field = field;
+ }
+
+ public boolean equals(Object o) {
+
+ if (o == null) {
+ return false;
+ }
+
+ if (!(o instanceof Effect)) {
+ return false;
+ }
+
+ Effect in = (Effect) o;
+
+ if (paramIndex != null) {
+ if (!paramIndex.equals(in.getParamIndex())) {
+ return false;
+ }
+ } else {
+ if (!insetVar.equals(in.getInsetVar())
+ && !insetAllocSite.equals(in.getInsetAllocSite())) {
+ return false;
+ }
+ }
+
+ if (affectedAllocSite.equals(in.getAffectedAllocSite())
+ && type == in.getType()
+ && field.equals(in.getField())) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+
+ int hash = affectedAllocSite.hashCode();
+
+ if (paramIndex != null) {
+ hash = hash ^ paramIndex.hashCode();
+ } else if (insetAllocSite != null) {
+ hash = hash ^ insetAllocSite.hashCode();
+ }
+
+ hash = hash + type;
+
+ if (field != null) {
+ hash = hash ^ field.hashCode();
+ }
+
+ return hash;
+
+ }
+
+ public String toString() {
+ String s = "(";
+
+ if (paramIndex != null) {
+ s += "param" + paramIndex;
+ } else {
+ s += insetVar;
+ s += ", " + insetAllocSite.toStringBrief();
+ }
+
+ s += ", " + affectedAllocSite.toStringBrief();
+ s += ", ";
+ if (type == read) {
+ s += "read";
+ } else if (type == write) {
+ s += "write";
+ } else {
+ s += "SU";
+ }
+
+ s += ", " + field.toStringBrief();
+
+ return s + ")";
+ }
+
+}
// convenient set of alloc sites for all heap regions
// present in the graph without having to search
public HashSet<AllocSite> allocSites;
+
+ // set of accessible variables for current program statement
+ // if not contains, it is an inaccessible variable
+ public HashSet<TempDescriptor> accessibleVars;
public ReachGraph() {
id2hrn = new Hashtable<Integer, HeapRegionNode>();
td2vn = new Hashtable<TempDescriptor, VariableNode >();
allocSites = new HashSet<AllocSite>();
+ accessibleVars = new HashSet<TempDescriptor>();
}
public void assignTempXEqualToTempY( TempDescriptor x,
TempDescriptor y ) {
assignTempXEqualToCastedTempY( x, y, null );
+
+ // x gets status of y
+ // if it is in region,
+ //if(accessibleVars.contains(y)){
+ // accessibleVars.add(x);
+ //}
}
public void assignTempXEqualToCastedTempY( TempDescriptor x,
if( !DISABLE_GLOBAL_SWEEP ) {
globalSweep();
}
- }
+ }
+
+ // accessible status update
+ // if it is in region,
+ //accessibleVars.add(x);
+ //accessibleVars.add(y);
}
globalSweep();
}
}
+
+ // after x.y=f , stall x and y if they are not accessible
+ // also contribute write effects on stall site of x
+ // accessible status update
+ // if it is in region
+ //accessibleVars.add(x);
+ //accessibleVars.add(y);
+
}
);
addRefEdge( lnX, hrnNewest, edgeNew );
+
+ // after x=new , x is accessible
+ // if (isInRegion()) {
+ //accessibleVars.add(x);
}
mergeNodes ( rg );
mergeRefEdges ( rg );
mergeAllocSites( rg );
+ mergeAccessibleSet( rg );
}
protected void mergeNodes( ReachGraph rg ) {
protected void mergeAllocSites( ReachGraph rg ) {
allocSites.addAll( rg.allocSites );
}
+
+ protected void mergeAccessibleSet( ReachGraph rg ){
+ // inaccesible status is prior to accessible status
+
+ Set<TempDescriptor> varsToMerge=rg.getAccessibleVar();
+ Set<TempDescriptor> varsRemoved=new HashSet<TempDescriptor>();
+
+ for (Iterator iterator = accessibleVars.iterator(); iterator.hasNext();) {
+ TempDescriptor accessibleVar = (TempDescriptor) iterator.next();
+ if(!varsToMerge.contains(accessibleVar)){
+ varsRemoved.add(accessibleVar);
+ }
+ }
+
+ accessibleVars.removeAll(varsRemoved);
+
+ }
}
return false;
}
+
+ if( !accessibleVars.equals( rg.accessibleVars) ){
+ return false;
+ }
// if everything is equal up to this point,
// assert that allocSites is also equal--
}
return common;
+ }
+
+ public void addAccessibleVar(TempDescriptor td){
+ accessibleVars.add(td);
+ }
+
+ public Set<TempDescriptor> getAccessibleVar(){
+ return accessibleVars;
+ }
+
+ public void clearAccessibleVarSet(){
+ accessibleVars.clear();
}
+
}
--- /dev/null
+package Analysis.Disjoint;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class StallSite {
+
+ private HashSet<Effect> effectSet;
+ private HashSet<AllocSite> allocSiteSet;
+
+ public StallSite(Set<AllocSite> allocSet) {
+ effectSet = new HashSet<Effect>();
+ allocSiteSet = new HashSet<AllocSite>();
+ allocSiteSet.addAll(allocSet);
+ }
+
+ public void addEffect(Effect e) {
+ effectSet.add(e);
+ }
+
+ public HashSet<Effect> getEffectSet() {
+ return effectSet;
+ }
+
+ public Set<AllocSite> getAllocSiteSet(){
+ return allocSiteSet;
+ }
+
+ public boolean equals(Object o) {
+
+ if (o == null) {
+ return false;
+ }
+
+ if (!(o instanceof StallSite)) {
+ return false;
+ }
+
+ StallSite in = (StallSite) o;
+
+ if (allocSiteSet.equals(in.getAllocSiteSet())
+ && effectSet.equals(in.getEffectSet()) ){
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+
+ @Override
+ public String toString() {
+ return "StallSite [allocationSiteSet=" + allocSiteSet
+ + ", effectSet=" + effectSet + "]";
+ }
+}