.next();
String writeHeapRegionID = seseEffectsKey.getHRNUniqueId();
String writeFieldName = seseEffectsKey.getFieldDescriptor();
+
+ if(writeFieldName.length()>0){
+ HashSet<HeapRegionNode> stallSiteHRNSet = nodeA.getHRNSet();
+ for (Iterator iterator = stallSiteHRNSet.iterator(); iterator
+ .hasNext();) {
+ HeapRegionNode stallHRN = (HeapRegionNode) iterator.next();
+ if (stallHRN.getGloballyUniqueIdentifier().equals(
+ writeHeapRegionID)) {
- HashSet<HeapRegionNode> stallSiteHRNSet = nodeA.getHRNSet();
- for (Iterator iterator = stallSiteHRNSet.iterator(); iterator
- .hasNext();) {
- HeapRegionNode stallHRN = (HeapRegionNode) iterator.next();
- if (stallHRN.getGloballyUniqueIdentifier().equals(
- writeHeapRegionID)) {
-
- // check whether there are read or write effects of
- // stall sites
+ // check whether there are read or write effects of
+ // stall sites
- HashSet<Effect> effectSet = stallSite.getEffectSet();
- for (Iterator iterator2 = effectSet.iterator(); iterator2
- .hasNext();) {
- Effect effect = (Effect) iterator2.next();
- String stallEffectfieldName = effect.getField();
+ HashSet<Effect> effectSet = stallSite.getEffectSet();
+ for (Iterator iterator2 = effectSet.iterator(); iterator2
+ .hasNext();) {
+ Effect effect = (Effect) iterator2.next();
+ String stallEffectfieldName = effect.getField();
- if (stallEffectfieldName.equals(writeFieldName)) {
- result = result | true;
+ if (stallEffectfieldName.equals(writeFieldName)) {
+ result = result | true;
+ }
}
+
}
+ }
+ }else{
+ // no field name
+
+ HashSet<Effect> effectSet = stallSite.getEffectSet();
+ for (Iterator iterator2 = effectSet.iterator(); iterator2
+ .hasNext();) {
+ Effect effect = (Effect) iterator2.next();
+ String stallEffectfieldName = effect.getField();
+ if (stallEffectfieldName.length()==0 && nodeB.getTempDescriptor().equals(nodeA.getStallSite().getTdA())) {
+ result = result | true;
+ }
}
+
}
}
String readHeapRegionID = seseEffectsKey.getHRNUniqueId();
String readFieldName = seseEffectsKey.getFieldDescriptor();
- HashSet<HeapRegionNode> stallSiteHRNSet = nodeA.getHRNSet();
- for (Iterator iterator = stallSiteHRNSet.iterator(); iterator
- .hasNext();) {
- HeapRegionNode stallHRN = (HeapRegionNode) iterator.next();
- if (stallHRN.getGloballyUniqueIdentifier().equals(
- readHeapRegionID)) {
-
- HashSet<Effect> effectSet = stallSite.getEffectSet();
- for (Iterator iterator2 = effectSet.iterator(); iterator2
- .hasNext();) {
- Effect effect = (Effect) iterator2.next();
- String stallEffectfieldName = effect.getField();
-
- if (effect.getEffectType().equals(
- StallSite.WRITE_EFFECT)) {
- if (stallEffectfieldName.equals(readFieldName)) {
- result = result | true;
+ if(readFieldName.length()>0){
+ HashSet<HeapRegionNode> stallSiteHRNSet = nodeA.getHRNSet();
+ for (Iterator iterator = stallSiteHRNSet.iterator(); iterator
+ .hasNext();) {
+ HeapRegionNode stallHRN = (HeapRegionNode) iterator.next();
+ if (stallHRN.getGloballyUniqueIdentifier().equals(
+ readHeapRegionID)) {
+
+ HashSet<Effect> effectSet = stallSite.getEffectSet();
+ for (Iterator iterator2 = effectSet.iterator(); iterator2
+ .hasNext();) {
+ Effect effect = (Effect) iterator2.next();
+ String stallEffectfieldName = effect.getField();
+
+ if (effect.getEffectType().equals(
+ StallSite.WRITE_EFFECT)) {
+ if (stallEffectfieldName.equals(readFieldName)) {
+ result = result | true;
+ }
}
+
}
}
}
+ }else{
+ //no field
+ HashSet<Effect> effectSet = stallSite.getEffectSet();
+ for (Iterator iterator2 = effectSet.iterator(); iterator2
+ .hasNext();) {
+ Effect effect = (Effect) iterator2.next();
+ String stallEffectfieldName = effect.getField();
+ if (effect.getEffectType().equals(
+ StallSite.WRITE_EFFECT)) {
+ if (stallEffectfieldName.length()==0 && nodeB.getTempDescriptor().equals(nodeA.getStallSite().getTdA())) {
+ result = result | true;
+ }
+ }
+
+ }
}
+
}
}
import java.util.Set;
import java.util.Stack;
import java.util.Map.Entry;
-
import Analysis.CallGraph.CallGraph;
import Analysis.CallGraph.JavaCallGraph;
import Analysis.OwnershipAnalysis.AllocationSite;
import IR.Flat.FlatCall;
import IR.Flat.FlatCondBranch;
import IR.Flat.FlatEdge;
+import IR.Flat.FlatElementNode;
import IR.Flat.FlatFieldNode;
import IR.Flat.FlatLiteralNode;
import IR.Flat.FlatMethod;
import IR.Flat.FlatReturnNode;
import IR.Flat.FlatSESEEnterNode;
import IR.Flat.FlatSESEExitNode;
+import IR.Flat.FlatSetElementNode;
import IR.Flat.FlatSetFieldNode;
import IR.Flat.FlatWriteDynamicVarNode;
import IR.Flat.TempDescriptor;
}
}
- /*
- methItr = ownAnalysis.descriptorsToAnalyze.iterator();
- while(methItr.hasNext()){
- Descriptor d = methItr.next();
- FlatMethod fm = state.getMethodFlat(d);
- if (fm.toString().indexOf("SomeWork") > 0) {
- ConflictGraph conflictGraph=conflictGraphResults.get(fm);
- try {
- conflictGraph.writeGraph("ConflictGraphForSomeWork", false);
- } catch (IOException e) {
- System.out.println("Error writing");
- System.exit(0);
- }
- }
- }
- */
- ////////////////
}
Set<FlatNode> flatNodesToVisit = new HashSet<FlatNode>();
flatNodesToVisit.add(fm);
+
+ Hashtable<TempDescriptor, TempDescriptor> invarMap=new Hashtable<TempDescriptor,TempDescriptor>();
while (!flatNodesToVisit.isEmpty()) {
FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next();
assert seseStack != null;
if (!seseStack.empty()) {
- effects_nodeActions(mc, fn, seseStack.peek(), callGraph);
+ effects_nodeActions(mc, fn, seseStack.peek(), callGraph,invarMap);
}
flatNodesToVisit.remove(fn);
}
private void effects_nodeActions(MethodContext mc, FlatNode fn,
- FlatSESEEnterNode currentSESE, CallGraph callGraph) {
+ FlatSESEEnterNode currentSESE, CallGraph callGraph,Hashtable<TempDescriptor, TempDescriptor> invarMap) {
OwnershipGraph og = ownAnalysis.getOwnvershipGraphByMethodContext(mc);
}
break;
+
+ case FKind.FlatOpNode:{
+
+ FlatOpNode fon=(FlatOpNode)fn;
+ TempDescriptor dest=fon.getDest();
+ TempDescriptor src=fon.getLeft();
+
+// if(!currentSESE.getIsCallerSESEplaceholder()){
+ if( fon.getOp().getOp() ==Operation.ASSIGN && currentSESE.getInVarSet().contains(src)){
+ invarMap.put(dest, src);
+ }
+// }
+ }break;
+
+ case FKind.FlatElementNode:{
+
+ FlatElementNode fsen=(FlatElementNode)fn;
+ TempDescriptor src = fsen.getSrc();
+
+ if(invarMap.containsKey(src)){
+ TempDescriptor invarTD=invarMap.get(src);
+ currentSESE.getSeseEffectsSet().addReadingVar(invarTD, new SESEEffectsKey("", src.getType(), new Integer(0), ""));
+ }
+
+ }break;
+
+ case FKind.FlatSetElementNode:{
+
+ FlatSetElementNode fsen=(FlatSetElementNode)fn;
+ TempDescriptor dst = fsen.getDst();
+
+ if(invarMap.containsKey(dst)){
+ TempDescriptor invarTD=invarMap.get(dst);
+ currentSESE.getSeseEffectsSet().addWritingVar(invarTD, new SESEEffectsKey("", dst.getType(), new Integer(0), ""));
+ }
+
+ }break;
+
case FKind.FlatSetFieldNode: {
FlatSetFieldNode fsen = (FlatSetFieldNode) fn;
SESESummary summary = new SESESummary(null, fm);
seseSummaryMap.put(fm, summary);
+
+ Hashtable<TempDescriptor, TempDescriptor> invarMap=new Hashtable<TempDescriptor,TempDescriptor>();
while (!flatNodesToVisit.isEmpty()) {
Iterator<FlatNode> fnItr = flatNodesToVisit.iterator();
conflictGraph);
}
- conflictGraph_nodeAction(mc, fm, fn);
+ conflictGraph_nodeAction(mc, fm, fn,invarMap);
for (int i = 0; i < fn.numNext(); i++) {
FlatNode nn = fn.getNext(i);
}
private void conflictGraph_nodeAction(MethodContext mc, FlatMethod fm,
- FlatNode fn) {
+ FlatNode fn,Hashtable<TempDescriptor, TempDescriptor> invarMap) {
switch (fn.kind()) {
TempDescriptor tempDescriptor = (TempDescriptor) iterator
.next();
- if(tempDescriptor.getType().isImmutable()){
+ if(!tempDescriptor.getType().isArray() && tempDescriptor.getType().isImmutable()){
continue;
}
+// if(tempDescriptor.getType().isArray()){
+//
+// }
+
// effects set
SESEEffectsSet seseEffectsSet = fsen.getSeseEffectsSet();
Set<SESEEffectsKey> readEffectsSet = seseEffectsSet
}
break;
-
+
}
}
SESESummary summary = new SESESummary(null, fm);
seseSummaryMap.put(fm, summary);
+
+ Hashtable<TempDescriptor, TempDescriptor> invarMap=new Hashtable<TempDescriptor,TempDescriptor>();
while (!flatNodesToVisit.isEmpty()) {
FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next();
FlatNode tempS=currentSummary.getCurrentSESE();
conflicts_nodeAction(mc, fn, callGraph, preeffectsSet,
- currentConflictsMap, currentSummary);
+ currentConflictsMap, currentSummary,invarMap);
// if we have a new result, schedule forward nodes for
private void conflicts_nodeAction(MethodContext mc, FlatNode fn,
CallGraph callGraph, HashSet<PreEffectsKey> preeffectsSet,
ParentChildConflictsMap currentConflictsMap,
- SESESummary currentSummary) {
+ SESESummary currentSummary,
+ Hashtable<TempDescriptor, TempDescriptor> invarMap) {
OwnershipGraph og = ownAnalysis.getOwnvershipGraphByMethodContext(mc);
}
break;
+
+ case FKind.FlatElementNode:{
+
+
+ FlatElementNode fen = (FlatElementNode) fn;
+ TempDescriptor src=fen.getSrc();
+
+ boolean isAfterChildSESE = false;
+ FlatNode current = currentSummary.getCurrentSESE();
+ Boolean isAfter = isAfterChildSESEIndicatorMap.get(current);
+ if (isAfter != null && isAfter.booleanValue()) {
+ isAfterChildSESE = true;
+ }
+
+ if(isAfterChildSESE){
+
+ if (!currentConflictsMap.isAccessible(src)) {
+ if(invarMap.containsKey(src)){
+ currentConflictsMap.addStallSite(src, new HashSet<HeapRegionNode>(),
+ new StallTag(fn),invarMap.get(src));
+ }else{
+ currentConflictsMap.addStallSite(src, new HashSet<HeapRegionNode>(),
+ new StallTag(fn),null);
+ }
+ }
+ currentConflictsMap.addAccessibleVar(src);
+
+ // contribute read effect on source's stall site
+ currentConflictsMap.contributeEffect(src, "", "",
+ StallSite.READ_EFFECT);
+
+ }
+
+ if (currentMethodSummary.getChildSESECount() == 0) {
+ // analyze preeffects
+ preEffectAnalysis(og, src, null, PreEffectsKey.READ_EFFECT);
+ }
+
+
+ } break;
case FKind.FlatFieldNode: {
HashSet<HeapRegionNode> refHRN = getReferenceHeapIDSet(
og, src);
currentConflictsMap.addStallSite(src, refHRN,
- new StallTag(fn));
+ new StallTag(fn),null);
// flag stall site for disjoint analysis
for (Iterator iterator2 = refHRN.iterator(); iterator2
}
break;
+ case FKind.FlatSetElementNode:{
+
+ FlatSetElementNode fsen=(FlatSetElementNode)fn;
+ TempDescriptor dst = fsen.getDst();
+ TempDescriptor src = fsen.getSrc();
+
+ boolean isAfterChildSESE = false;
+ FlatNode current = currentSummary.getCurrentSESE();
+ Boolean isAfter = isAfterChildSESEIndicatorMap.get(current);
+ if (isAfter != null && isAfter.booleanValue()) {
+ isAfterChildSESE = true;
+ }
+
+ if (isAfterChildSESE) {
+
+ if (!currentConflictsMap.isAccessible(src)) {
+ HashSet<HeapRegionNode> refHRN = getReferenceHeapIDSet(og,
+ src);
+ currentConflictsMap.addStallSite(src, refHRN , new StallTag(
+ fn),null);
+ }
+ currentConflictsMap.addAccessibleVar(src);
+
+ if (!currentConflictsMap.isAccessible(dst)) {
+
+ if(invarMap.containsKey(dst)){
+ currentConflictsMap.addStallSite(dst, new HashSet<HeapRegionNode>(),
+ new StallTag(fn),invarMap.get(dst));
+ }else{
+ currentConflictsMap.addStallSite(dst, new HashSet<HeapRegionNode>(),
+ new StallTag(fn),null);
+ }
+ }
+ currentConflictsMap.addAccessibleVar(dst);
+ // contribute write effect on destination's stall site
+ currentConflictsMap.contributeEffect(dst, "","",
+ StallSite.WRITE_EFFECT);
+
+ }
+
+ if (currentMethodSummary.getChildSESECount() == 0) {
+ // analyze preeffects
+ preEffectAnalysis(og, dst, null, PreEffectsKey.WRITE_EFFECT);
+ }
+
+
+// if(invarMap.containsKey(dst)){
+// System.out.println("THIS IS FLAT SET FIELD:"+dst+ "with sese="+currentSESE);
+// TempDescriptor invarTD=invarMap.get(dst);
+// currentSESE.getSeseEffectsSet().addWritingVar(invarTD, new SESEEffectsKey("", dst.getType(), new Integer(0), ""));
+// }
+
+
+ } break;
+
case FKind.FlatSetFieldNode: {
FlatSetFieldNode fsen = (FlatSetFieldNode) fn;
HashSet<HeapRegionNode> refHRN = getReferenceHeapIDSet(og,
src);
currentConflictsMap.addStallSite(src, refHRN, new StallTag(
- fn));
+ fn),null);
// flag stall site for disjoint analysis
for (Iterator iterator2 = refHRN.iterator(); iterator2
HashSet<HeapRegionNode> refHRN = getReferenceHeapIDSet(
og, dst);
currentConflictsMap.addStallSite(dst, refHRN,
- new StallTag(fn));
+ new StallTag(fn),null);
// flag stall site for disjoint analysis
for (Iterator iterator2 = refHRN.iterator(); iterator2
break;
case FKind.FlatOpNode: {
+
+ FlatOpNode fon = (FlatOpNode) fn;
boolean isAfterChildSESE = false;
FlatNode current = currentSummary.getCurrentSESE();
Boolean isAfter = isAfterChildSESEIndicatorMap.get(current);
+
+
+ if( fon.getOp().getOp() ==Operation.ASSIGN){
+ invarMap.put(fon.getDest(), fon.getLeft());
+ }
+
if (isAfter != null && isAfter.booleanValue()) {
isAfterChildSESE = true;
}
if (isAfterChildSESE) {
// destination variable gets the status of source.
- FlatOpNode fon = (FlatOpNode) fn;
if (fon.getOp().getOp() == Operation.ASSIGN) {
Iterator<Integer> paramIter = paramSet.iterator();
while (paramIter.hasNext()) {
Integer paramID = paramIter.next();
- PreEffectsKey effectKey = new PreEffectsKey(paramID,
- field.getSymbol(), field.getType()
- .getSafeSymbol(), effectType);
+ PreEffectsKey effectKey=null;
+ if(field!=null){
+ effectKey = new PreEffectsKey(paramID,
+ field.getSymbol(), field.getType()
+ .getSafeSymbol(), effectType);
+ }else{
+ effectKey = new PreEffectsKey(paramID,
+ "", "", effectType);
+ }
preeffectsSet.add(effectKey);
}
}
while (paramIter.hasNext()) {
Integer paramID = paramIter.next();
- PreEffectsKey effectKey = new PreEffectsKey(paramID,
- field.getSymbol(), field.getType()
- .getSafeSymbol(), effectType);
+ PreEffectsKey effectKey=null;
+ if(field!=null){
+ effectKey = new PreEffectsKey(paramID,
+ field.getSymbol(), field.getType()
+ .getSafeSymbol(), effectType);
+ }else{
+ effectKey = new PreEffectsKey(paramID,
+ "", "", effectType);
+ }
preeffectsSet.add(effectKey);
}
}