From a245d30a1f1bf23e91ecf3386b4ed306f98752b6 Mon Sep 17 00:00:00 2001 From: yeom Date: Wed, 23 Jun 2010 02:58:27 +0000 Subject: [PATCH] get set up part of the stall site analysis --- .../Analysis/Disjoint/DisjointAnalysis.java | 6 +- Robust/src/Analysis/Disjoint/Effect.java | 165 ++++++++++++++++++ Robust/src/Analysis/Disjoint/ReachGraph.java | 65 ++++++- Robust/src/Analysis/Disjoint/StallSite.java | 55 ++++++ 4 files changed, 289 insertions(+), 2 deletions(-) create mode 100644 Robust/src/Analysis/Disjoint/Effect.java create mode 100644 Robust/src/Analysis/Disjoint/StallSite.java diff --git a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java index 2e15b921..3649b822 100644 --- a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java +++ b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java @@ -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 index 00000000..f53cff2e --- /dev/null +++ b/Robust/src/Analysis/Disjoint/Effect.java @@ -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 + ")"; + } + +} diff --git a/Robust/src/Analysis/Disjoint/ReachGraph.java b/Robust/src/Analysis/Disjoint/ReachGraph.java index 10568528..ec80db16 100644 --- a/Robust/src/Analysis/Disjoint/ReachGraph.java +++ b/Robust/src/Analysis/Disjoint/ReachGraph.java @@ -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 allocSites; + + // set of accessible variables for current program statement + // if not contains, it is an inaccessible variable + public HashSet accessibleVars; public ReachGraph() { id2hrn = new Hashtable(); td2vn = new Hashtable(); allocSites = new HashSet(); + accessibleVars = new HashSet(); } @@ -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 varsToMerge=rg.getAccessibleVar(); + Set varsRemoved=new HashSet(); + + 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 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 index 00000000..b08cb9d1 --- /dev/null +++ b/Robust/src/Analysis/Disjoint/StallSite.java @@ -0,0 +1,55 @@ +package Analysis.Disjoint; + +import java.util.HashSet; +import java.util.Set; + +public class StallSite { + + private HashSet effectSet; + private HashSet allocSiteSet; + + public StallSite(Set allocSet) { + effectSet = new HashSet(); + allocSiteSet = new HashSet(); + allocSiteSet.addAll(allocSet); + } + + public void addEffect(Effect e) { + effectSet.add(e); + } + + public HashSet getEffectSet() { + return effectSet; + } + + public Set 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 + "]"; + } +} -- 2.34.1