// if we have a new result, schedule forward nodes for
// analysis
-
if(!currentConflictsMap.isAfterChildSESE()){
conflictsResults.put(fn, currentConflictsMap);
for (int i = 0; i < fn.numNext(); i++) {
TempDescriptor dst = ffn.getDst();
TempDescriptor src = ffn.getSrc();
FieldDescriptor field = ffn.getField();
-
+
if (currentConflictsMap.isAfterChildSESE()) {
-
+
HashSet<TempDescriptor> srcTempSet = getTempDescSetReferenceToSameHRN(
og, src);
for (Iterator iterator = srcTempSet.iterator(); iterator
.next();
if (!currentConflictsMap.isAccessible(possibleSrc)) {
HashSet<HeapRegionNode> refHRN=getReferenceHeapIDSet(og, possibleSrc);
- currentConflictsMap.addStallSite(possibleSrc,refHRN);
+ currentConflictsMap.addStallSite(possibleSrc,refHRN,new StallTag(fn));
}
currentConflictsMap.addAccessibleVar(possibleSrc);
// contribute read effect on source's stall site
- currentConflictsMap.contributeEffect(src, field.getType()
+ currentConflictsMap.contributeEffect(possibleSrc, field.getType()
.getSafeSymbol(), field.toString(),
StallSite.READ_EFFECT);
}
- HashSet<TempDescriptor> dstTempSet = getTempDescSetReferenceToSameHRN(
+ HashSet<TempDescriptor> dstTempSet = getTempDescSetReferenceToSameHRN(
og, dst);
for (Iterator iterator = dstTempSet.iterator(); iterator
.hasNext();) {
.next();
if (!currentConflictsMap.isAccessible(possibleSrc)) {
HashSet<HeapRegionNode> refHRN=getReferenceHeapIDSet(og, possibleSrc);
- currentConflictsMap.addStallSite(possibleSrc,refHRN);
+ currentConflictsMap.addStallSite(possibleSrc,refHRN,new StallTag(fn));
}
currentConflictsMap.addAccessibleVar(possibleSrc);
}
if (!currentConflictsMap.isAccessible(possibleDst)) {
HashSet<HeapRegionNode> refHRN=getReferenceHeapIDSet(og, possibleDst);
- currentConflictsMap.addStallSite(possibleDst,refHRN);
+ currentConflictsMap.addStallSite(possibleDst,refHRN,new StallTag(fn));
}
currentConflictsMap.addAccessibleVar(possibleDst);
// contribute write effect on destination's stall site
ReferenceEdge referenceEdge = (ReferenceEdge) iterator
.next();
if(!(referenceEdge.getSrc() instanceof LabelNode)){
- currentConflictsMap.addStallEdge(referenceEdge, ss);
+ currentConflictsMap.addStallEdge(referenceEdge,new StallTag(fn));
}
}
}
case FKind.FlatCall: {
FlatCall fc = (FlatCall) fn;
+
+ int base=0;
+ if(!fc.getMethod().isStatic()){
+ base=1;
+ }
FlatMethod calleeFM = state.getMethodFlat(fc.getMethod());
// If callee has at least one child sese, all parent object
// is going to be inaccessible.
- currentConflictsMap = new ParentChildConflictsMap();
+// currentConflictsMap = new ParentChildConflictsMap();
+ currentConflictsMap.makeAllInaccessible();
+ currentConflictsMap.setAfterChildSESE(true);
TempDescriptor returnTemp = fc.getReturnTemp();
// when return value is accessible, associate with its
// stall site
currentConflictsMap.addAccessibleVar(returnTemp);
+
+ StallSite returnStallSite=calleeMethodSummary.getReturnStallSite().copy();
+ // handling parameter regions
+ HashSet<Integer> stallParamIdx=returnStallSite.getCallerParamIdxSet();
+ for (Iterator iterator = stallParamIdx.iterator(); iterator
+ .hasNext();) {
+ Integer idx = (Integer) iterator.next();
+
+ int paramIdx=idx.intValue()-base;
+ TempDescriptor paramTD=fc.getArg(paramIdx);
+
+ //TODO: resolve callee's parameter heap regions by following call chain
+
+ }
+
currentConflictsMap.addStallSite(returnTemp,
- calleeMethodSummary.getReturnStallSite());
+ returnStallSite);
+
} else if (calleeMethodSummary.getReturnValueAccessibility()
.equals(MethodSummary.INACCESSIBLE)) {
// when return value is inaccessible
currentConflictsMap.addInaccessibleVar(returnTemp);
}
+ // TODO: need to handle edge mappings from callee
+
- // TODO: need to handle edge mappings from callee
- HashSet<Integer> stallParamIdx=calleeMethodSummary.getStallParamIdxSet();
+ Set<Integer> stallParamIdx=calleeMethodSummary.getStallParamIdxSet();
for (Iterator iterator = stallParamIdx.iterator(); iterator
.hasNext();) {
- Integer paramIdx = (Integer) iterator.next();
+ Integer paramIdx = (Integer) iterator.next();
+ HashSet<StallTag> stallTagSet=calleeMethodSummary.getStallTagByParamIdx(paramIdx);
+
+ int argIdx=paramIdx.intValue()-base;
+ TempDescriptor argTD=fc.getArg(argIdx);
+
+ putStallTagOnReferenceEdges(og, argTD,stallTagSet,currentConflictsMap);
+
}
}
// child SESEs.
} else {
if (currentConflictsMap.isAccessible(returnTD)) {
+
currentMethodSummary
.setReturnValueAccessibility(MethodSummary.ACCESSIBLE);
StallSite returnStallSite = currentConflictsMap
.getStallMap().get(returnTD);
+
+ HashSet<HeapRegionNode> stallSiteHRNSet=returnStallSite.getHRNSet();
+ for (Iterator iterator = stallSiteHRNSet.iterator(); iterator
+ .hasNext();) {
+ HeapRegionNode stallSiteHRN = (HeapRegionNode) iterator
+ .next();
+ Set<Integer> paramSet=og.idPrimary2paramIndexSet
+ .get(stallSiteHRN.getID());
+ returnStallSite.addCallerParamIdxSet(paramSet);
+ paramSet=og.idSecondary2paramIndexSet
+ .get(stallSiteHRN.getID());
+ returnStallSite.addCallerParamIdxSet(paramSet);
+ }
+
currentMethodSummary
.setReturnStallSite(returnStallSite);
+
} else {
currentMethodSummary
.setReturnValueAccessibility(MethodSummary.INACCESSIBLE);
for (Iterator iterator = stallTempSet.iterator(); iterator
.hasNext();) {
TempDescriptor stallTD = (TempDescriptor) iterator.next();
- StallSite ss = currentConflictsMap.getStallMap().get(
- stallTD);
+ StallSite stallSite = currentConflictsMap.getStallMap()
+ .get(stallTD);
- HashSet<HeapRegionNode> stallSiteHRNSet = ss.getHRNSet();
+ HashSet<HeapRegionNode> stallSiteHRNSet = stallSite
+ .getHRNSet();
for (Iterator iterator2 = stallSiteHRNSet.iterator(); iterator2
.hasNext();) {
HeapRegionNode stallSiteHRN = (HeapRegionNode) iterator2
.next();
if (stallSiteHRN.isParameter()) {
- currentMethodSummary
- .addStallParamIdxSet(og.idPrimary2paramIndexSet
- .get(stallSiteHRN.getID()));
- currentMethodSummary
- .addStallParamIdxSet(og.idSecondary2paramIndexSet
- .get(stallSiteHRN.getID()));
+
+ Set<Integer> paramSet = og.idPrimary2paramIndexSet
+ .get(stallSiteHRN.getID());
+ currentMethodSummary.addStallParamIdxSet(paramSet,
+ stallSite.getStallTagSet());
+
+ paramSet = og.idSecondary2paramIndexSet
+ .get(stallSiteHRN.getID());
+ currentMethodSummary.addStallParamIdxSet(paramSet,
+ stallSite.getStallTagSet());
}
}
}
+
+ private void putStallTagOnReferenceEdges(OwnershipGraph og,
+ TempDescriptor argTD, HashSet stallTagSet,
+ ParentChildConflictsMap currentConflictsMap) {
+
+ LabelNode ln=og.td2ln.get(argTD);
+ if(ln!=null){
+
+ Iterator<ReferenceEdge> refrenceeIter=ln.iteratorToReferencees();
+ while (refrenceeIter.hasNext()) {
+ ReferenceEdge refEdge = (ReferenceEdge) refrenceeIter.next();
+ HeapRegionNode stallHRN=refEdge.getDst();
+
+ Iterator<ReferenceEdge> referencerIter=stallHRN.iteratorToReferencers();
+ while (referencerIter.hasNext()) {
+ ReferenceEdge referencer = (ReferenceEdge) referencerIter
+ .next();
+ for (Iterator iterator = stallTagSet.iterator(); iterator
+ .hasNext();) {
+ StallTag stallTag = (StallTag) iterator.next();
+ currentConflictsMap.addStallEdge(referencer, stallTag);
+ }
+ }
+ }
+ }
+ }
+
private void preEffectAnalysis(OwnershipGraph og, TempDescriptor td,
FieldDescriptor field, Integer effectType) {
package Analysis.MLP;
import java.util.HashSet;
+import java.util.Hashtable;
import java.util.Iterator;
import java.util.Set;
private HashSet<PreEffectsKey> effectsSet;
private Integer accessibility;
private StallSite returnStallSite;
- private HashSet<Integer> stallParamIdxSet;
-
+
+ private Hashtable<Integer, HashSet<StallTag>> mapParamIndexToRelatedStallTag;
+
public MethodSummary() {
effectsSet = new HashSet<PreEffectsKey>();
accessibility = MethodSummary.VOID;
childSESECount = 0;
returnStallSite=null;
- stallParamIdxSet=new HashSet<Integer>();
+ mapParamIndexToRelatedStallTag=new Hashtable<Integer, HashSet<StallTag>>();
}
- public HashSet<Integer> getStallParamIdxSet(){
- return stallParamIdxSet;
+ public void addStallParamIdxSet(Set<Integer> paramIdxSet, HashSet<StallTag> stallTagSet){
+
+ if(paramIdxSet!=null){
+ for (Iterator iterator = paramIdxSet.iterator(); iterator.hasNext();) {
+ Integer paramIdx = (Integer) iterator.next();
+ mapParamIndexToRelatedStallTag.put(paramIdx, stallTagSet);
+ }
+ }
}
- public void addStallParamIdxSet(Set<Integer> newSet){
- if(newSet!=null){
- stallParamIdxSet.addAll(newSet);
- }
+ public HashSet<StallTag> getStallTagByParamIdx(Integer paramIdx){
+ return mapParamIndexToRelatedStallTag.get(paramIdx);
+ }
+
+
+ public Set<Integer> getStallParamIdxSet(){
+ return mapParamIndexToRelatedStallTag.keySet();
}
public void setReturnStallSite(StallSite ss){
PreEffectsKey in = (PreEffectsKey) o;
- this.paramIndex = paramIndex;
- this.field = field;
- this.type = type;
- this.effectType = effectType;
-
if (paramIndex.equals(in.getParamIndex())
&& field.equals(in.getField()) && type.equals(in.getType())
&& effectType.equals(in.getEffectType())) {
import java.util.Iterator;
import java.util.Set;
+import Analysis.OwnershipAnalysis.AllocationSite;
import Analysis.OwnershipAnalysis.HeapRegionNode;
import Analysis.OwnershipAnalysis.ReachabilitySet;
import Analysis.OwnershipAnalysis.ReferenceEdge;
import Analysis.OwnershipAnalysis.TokenTupleSet;
+import IR.Flat.FlatNode;
import IR.Flat.TempDescriptor;
public class ParentChildConflictsMap {
private Hashtable<TempDescriptor, Integer> accessibleMap;
private Hashtable<TempDescriptor, StallSite> stallMap;
- private Hashtable < ReferenceEdge, StallSite > stallEdgeMap;
+ private Hashtable < ReferenceEdge, HashSet<StallTag> > stallEdgeMap;
private boolean afterChildSESE;
accessibleMap = new Hashtable<TempDescriptor, Integer>();
stallMap = new Hashtable<TempDescriptor, StallSite>();
- stallEdgeMap= new Hashtable < ReferenceEdge, StallSite >();
+ stallEdgeMap= new Hashtable < ReferenceEdge, HashSet<StallTag> >();
afterChildSESE=false;
}
- public Hashtable < ReferenceEdge, StallSite > getStallEdgeMap(){
+ public void makeAllInaccessible(){
+
+ Set<TempDescriptor> keySet=accessibleMap.keySet();
+ for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
+ TempDescriptor key = (TempDescriptor) iterator.next();
+ accessibleMap.put(key, INACCESSIBLE);
+ }
+
+ }
+
+ public Hashtable < ReferenceEdge, HashSet<StallTag> > getStallEdgeMap(){
return stallEdgeMap;
}
- public void addStallEdge(ReferenceEdge edge, StallSite site){
- stallEdgeMap.put(edge, site);
+ public void addStallEdge(ReferenceEdge edge, StallTag sTag){
+
+ HashSet<StallTag> tagSet=stallEdgeMap.get(edge);
+ if(tagSet==null){
+ tagSet=new HashSet<StallTag>();
+ }
+ tagSet.add(sTag);
+ stallEdgeMap.put(edge, tagSet);
}
- public StallSite getStallSiteByEdge(ReferenceEdge edge){
+ public HashSet<StallTag> getStallTagByEdge(ReferenceEdge edge){
return stallEdgeMap.get(edge);
}
accessibleMap.put(td, INACCESSIBLE);
}
- public void addStallSite(TempDescriptor td, HashSet<HeapRegionNode> heapSet) {
- StallSite stallSite=new StallSite(heapSet);
+ public void addStallSite(TempDescriptor td, HashSet<HeapRegionNode> heapSet, StallTag sTag) {
+ StallSite stallSite=new StallSite(heapSet,sTag);
stallMap.put(td, stallSite);
}
if (currentStatus != null && currentStatus == ACCESSIBLE
&& newStatus == INACCESSIBLE) {
getAccessibleMap().put(key, INACCESSIBLE);
- }
+ }else if(currentStatus == null && newStatus == ACCESSIBLE){
+ getAccessibleMap().put(key, ACCESSIBLE);
+ }
}
keySet = newStallMap.keySet();
currentRSet.add(tokenTupleSet);
}
+ //handle allocationsite
+ HashSet<AllocationSite> currentAloc=currentStallSite.getAllocationSiteSet();
+ HashSet<AllocationSite> newAloc=newStallSite.getAllocationSiteSet();
+ currentAloc.addAll(newAloc);
+
+ // handle related stall tags
+ HashSet<StallTag> currentStallTagSet=currentStallSite.getStallTagSet();
+ HashSet<StallTag> newStallTagSet=newStallSite.getStallTagSet();
+ currentStallTagSet.addAll(newStallTagSet);
+
+ // reaching param idxs
+ HashSet<Integer> currentParamIdx=currentStallSite.getCallerParamIdxSet();
+ HashSet<Integer> newParamIdx=newStallSite.getCallerParamIdxSet();
+ currentParamIdx.addAll(newParamIdx);
+
StallSite merged=new StallSite(currentEffectSet, currentHRNSet,
- currentRSet);
+ currentRSet, currentAloc, currentStallTagSet,currentParamIdx);
+
getStallMap()
.put(
// merge edge mapping
- Hashtable<ReferenceEdge, StallSite> newStallEdgeMapping=newConflictsMap.getStallEdgeMap();
+ Hashtable<ReferenceEdge, HashSet<StallTag>> newStallEdgeMapping=newConflictsMap.getStallEdgeMap();
Set<ReferenceEdge> edgeSet=newStallEdgeMapping.keySet();
+
for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) {
ReferenceEdge stallEdge = (ReferenceEdge) iterator.next();
- StallSite newStallSite=newStallEdgeMapping.get(stallEdge);
- getStallEdgeMap().put(stallEdge, newStallSite);
+ HashSet<StallTag> newStallTagSet=newStallEdgeMapping.get(stallEdge);
+ HashSet<StallTag>currentStallTagSet=getStallEdgeMap().get(stallEdge);
+
+ if(currentStallTagSet==null){
+ currentStallTagSet=new HashSet<StallTag>();
+ }
+ currentStallTagSet.addAll(newStallTagSet);
+ getStallEdgeMap().put(stallEdge,currentStallTagSet);
}
}
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 {
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());
}
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);
}
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) {
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;
}
+ @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 {
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() {
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 {
}
+ public String toString() {
+ return "Effect [effect=" + effect + ", field=" + field
+ + ", stallTagSet=" + stallTagSet + ", type=" + type + "]";
+ }
+
}
\ No newline at end of file