get set up part of the stall site analysis
authoryeom <yeom>
Wed, 23 Jun 2010 02:58:27 +0000 (02:58 +0000)
committeryeom <yeom>
Wed, 23 Jun 2010 02:58:27 +0000 (02:58 +0000)
Robust/src/Analysis/Disjoint/DisjointAnalysis.java
Robust/src/Analysis/Disjoint/Effect.java [new file with mode: 0644]
Robust/src/Analysis/Disjoint/ReachGraph.java
Robust/src/Analysis/Disjoint/StallSite.java [new file with mode: 0644]

index 2e15b921981a16a9fdf7adad97221b21765297fb..3649b822c3db5269f402ed6b7a6c51352a4d95de 100644 (file)
@@ -897,7 +897,11 @@ public class DisjointAnalysis {
          rg.merge( rgParent );
        }
       }
-
+      
+      //if(rra.isEndOfRegion(fn)){
+      //  rg.clearAccessibleVarSet();
+      //  also need to clear stall mapping
+      //}
 
       if( takeDebugSnapshots && 
          d.getSymbol().equals( descSymbolDebug ) 
diff --git a/Robust/src/Analysis/Disjoint/Effect.java b/Robust/src/Analysis/Disjoint/Effect.java
new file mode 100644 (file)
index 0000000..f53cff2
--- /dev/null
@@ -0,0 +1,165 @@
+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 + ")";
+  }
+
+}
index 105685289d98fcfe308a6360c06ef8434ec7959d..ec80db16781fb8e1d5688c724c4f6434feee476f 100644 (file)
@@ -38,11 +38,16 @@ public class ReachGraph {
   // 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>();
   }
 
   
@@ -365,6 +370,12 @@ public class ReachGraph {
   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,
@@ -490,7 +501,12 @@ public class ReachGraph {
       if( !DISABLE_GLOBAL_SWEEP ) {
        globalSweep();
       }
-    }    
+    }
+    
+    // accessible status update
+    // if it is in region,
+    //accessibleVars.add(x);
+    //accessibleVars.add(y);
   }
 
 
@@ -646,6 +662,14 @@ public class ReachGraph {
         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);
+    
   }
 
 
@@ -700,6 +724,10 @@ public class ReachGraph {
                    );
 
     addRefEdge( lnX, hrnNewest, edgeNew );
+    
+    // after x=new , x is accessible
+    // if (isInRegion()) {
+    //accessibleVars.add(x);
   }
 
 
@@ -3483,6 +3511,7 @@ public class ReachGraph {
     mergeNodes     ( rg );
     mergeRefEdges  ( rg );
     mergeAllocSites( rg );
+    mergeAccessibleSet( rg );
   }
   
   protected void mergeNodes( ReachGraph rg ) {
@@ -3689,6 +3718,23 @@ public class ReachGraph {
   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);
+        
+  }
 
 
 
@@ -3734,6 +3780,10 @@ public class ReachGraph {
       }
       return false;
     }
+    
+    if( !accessibleVars.equals( rg.accessibleVars) ){
+      return false;
+    }
 
     // if everything is equal up to this point,
     // assert that allocSites is also equal--
@@ -4744,5 +4794,18 @@ public class ReachGraph {
     }
 
     return common;
+  }
+  
+  public void addAccessibleVar(TempDescriptor td){
+    accessibleVars.add(td);
+  }
+  
+  public Set<TempDescriptor> getAccessibleVar(){
+    return accessibleVars;
+  }
+  
+  public void clearAccessibleVarSet(){
+    accessibleVars.clear();
   }  
+  
 }
diff --git a/Robust/src/Analysis/Disjoint/StallSite.java b/Robust/src/Analysis/Disjoint/StallSite.java
new file mode 100644 (file)
index 0000000..b08cb9d
--- /dev/null
@@ -0,0 +1,55 @@
+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 + "]";
+       }
+}