From: yeom Date: Tue, 3 Nov 2009 00:28:20 +0000 (+0000) Subject: changes toward keeping globally unique identifier for disjoint analysis result X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2921ea56913d49f87d61877fe81bd740e11a597d;p=IRC.git changes toward keeping globally unique identifier for disjoint analysis result + calculating reachability states for each stall sites and child SESE's live-in variables. --- diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index c031a12a..37fe8dea 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -54,6 +54,7 @@ public class MLPAnalysis { private Hashtable < FlatNode, ParentChildConflictsMap > conflictsResults; private Hashtable< FlatMethod, MethodSummary > methodSummaryResults; + private OwnershipAnalysis ownAnalysisForSESEConflicts; // temporal data structures to track analysis progress. private MethodSummary currentMethodSummary; @@ -192,13 +193,13 @@ public class MLPAnalysis { while( methItr.hasNext() ) { Descriptor d = methItr.next(); FlatMethod fm = state.getMethodFlat( d ); - + // compute what is not available at every program // point, in a forward fixed-point pass notAvailableForward( fm ); } - // new pass + // new pass, sese effects analysis methItr = ownAnalysis.descriptorsToAnalyze.iterator(); JavaCallGraph javaCallGraph = new JavaCallGraph(state,tu); while( methItr.hasNext() ) { @@ -210,8 +211,7 @@ public class MLPAnalysis { // Parent/child memory conflicts analysis seseConflictsForward(javaCallGraph); - - // disjoint analysis with a set of flagged allocation sites of live-in variable + // disjoint analysis with a set of flagged allocation sites of live-in variables & stall sites try { OwnershipAnalysis oa2 = new OwnershipAnalysis(state, tu, @@ -223,18 +223,18 @@ public class MLPAnalysis { state.METHODEFFECTS, mapMethodContextToLiveInAllocationSiteSet); // debug - methItr = oa2.descriptorsToAnalyze.iterator(); + methItr = ownAnalysisForSESEConflicts.descriptorsToAnalyze.iterator(); while (methItr.hasNext()) { Descriptor d = methItr.next(); FlatMethod fm = state.getMethodFlat(d); - debugFunction(oa2, fm); + debugFunction(ownAnalysisForSESEConflicts, fm); } // } catch (IOException e) { System.err.println(e); } - - + + postSESEConflictsForward(javaCallGraph); // 7th pass methItr = ownAnalysis.descriptorsToAnalyze.iterator(); @@ -847,7 +847,7 @@ public class MLPAnalysis { if(fm.toString().indexOf(methodName)>0){ try { - og.writeGraph(fm.toString() + "SECONDGRAPH", + og.writeGraph("SECONDGRAPH"+fm.toString(), true, // write labels (variables) true, // selectively hide intermediate temp vars true, // prune unreachable heap regions @@ -860,9 +860,6 @@ public class MLPAnalysis { System.exit(0); } } - - - } } @@ -1006,7 +1003,7 @@ public class MLPAnalysis { dstHRN, visitedHRN); } } else { - addLiveInAllocationSite(callerMC, dstHRN + flagAllocationSite(callerMC, dstHRN .getAllocationSite()); } } @@ -1077,40 +1074,43 @@ public class MLPAnalysis { FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; assert fsen.equals(currentSESE); + + if (!fsen.getIsCallerSESEplaceholder()) { + // uniquely taint each live-in variable + Set set = fsen.getInVarSet(); + Iterator iter = set.iterator(); + int idx = 0; + while (iter.hasNext()) { + TempDescriptor td = iter.next(); + LabelNode ln = og.td2ln.get(td); + if (ln != null) { + int taint = (int) Math.pow(2, idx); + taintLabelNode(ln, taint); + + // collects related allocation sites + Iterator referenceeIter = ln + .iteratorToReferencees(); + while (referenceeIter.hasNext()) { + ReferenceEdge referenceEdge = (ReferenceEdge) referenceeIter + .next(); + HeapRegionNode dstHRN = referenceEdge.getDst(); + if (dstHRN.isParameter()) { - // uniquely taint each live-in variable - Set set = fsen.getInVarSet(); - Iterator iter = set.iterator(); - int idx = 0; - while (iter.hasNext()) { - TempDescriptor td = iter.next(); - LabelNode ln = og.td2ln.get(td); - if (ln != null) { - int taint = (int) Math.pow(2, idx); - taintLabelNode(ln, taint); - - // collects related allocation sites - Iterator referenceeIter = ln - .iteratorToReferencees(); - while (referenceeIter.hasNext()) { - ReferenceEdge referenceEdge = (ReferenceEdge) referenceeIter - .next(); - HeapRegionNode dstHRN = referenceEdge.getDst(); - if (dstHRN.isParameter()) { - - HashSet visitedHRN=new HashSet(); - visitedHRN.add(dstHRN); - setupRelatedAllocSiteAnalysis(og,mc,dstHRN,visitedHRN); + HashSet visitedHRN = new HashSet(); + visitedHRN.add(dstHRN); + setupRelatedAllocSiteAnalysis(og, mc, dstHRN, + visitedHRN); - } else { - addLiveInAllocationSite(mc, dstHRN - .getAllocationSite()); + } else { + flagAllocationSite(mc, dstHRN + .getAllocationSite()); + } } + } + idx++; } - - idx++; } } @@ -1118,92 +1118,96 @@ public class MLPAnalysis { case FKind.FlatSESEExitNode: { FlatSESEExitNode fsexit = (FlatSESEExitNode) fn; + + if (!fsexit.getFlatEnter().getIsCallerSESEplaceholder()) { + + FlatSESEEnterNode enterNode = fsexit.getFlatEnter(); + FlatSESEEnterNode parent = enterNode.getParent(); + if (parent != null) { + + SESEEffectsSet set = enterNode.getSeseEffectsSet(); + Hashtable> readTable = set + .getReadTable(); + Hashtable> parentReadTable = parent + .getSeseEffectsSet().getReadTable(); + Set keys = readTable.keySet(); + Iterator keyIter = keys.iterator(); + while (keyIter.hasNext()) { + TempDescriptor td = (TempDescriptor) keyIter.next(); + HashSet effectsSet = readTable.get(td); + HashSet parentEffectsSet = parentReadTable + .get(td); + if (parentEffectsSet == null) { + parentEffectsSet = new HashSet(); + } - FlatSESEEnterNode enterNode = fsexit.getFlatEnter(); - FlatSESEEnterNode parent = enterNode.getParent(); - if (parent != null) { - - SESEEffectsSet set = enterNode.getSeseEffectsSet(); - Hashtable> readTable = set - .getReadTable(); - Hashtable> parentReadTable = parent - .getSeseEffectsSet().getReadTable(); - Set keys = readTable.keySet(); - Iterator keyIter = keys.iterator(); - while (keyIter.hasNext()) { - TempDescriptor td = (TempDescriptor) keyIter.next(); - HashSet effectsSet = readTable.get(td); - HashSet parentEffectsSet = parentReadTable - .get(td); - if (parentEffectsSet == null) { - parentEffectsSet = new HashSet(); - } + for (Iterator iterator = effectsSet.iterator(); iterator + .hasNext();) { + SESEEffectsKey seseKey = (SESEEffectsKey) iterator + .next(); + parentEffectsSet.add(new SESEEffectsKey(seseKey + .getFieldDescriptor(), seseKey + .getTypeDescriptor(), seseKey.getHRNId())); + } - for (Iterator iterator = effectsSet.iterator(); iterator - .hasNext();) { - SESEEffectsKey seseKey = (SESEEffectsKey) iterator - .next(); - parentEffectsSet.add(new SESEEffectsKey(seseKey - .getFieldDescriptor(), seseKey - .getTypeDescriptor(), seseKey.getHRNId())); + parentReadTable.put(td, parentEffectsSet); } - parentReadTable.put(td, parentEffectsSet); - } + Hashtable> writeTable = set + .getWriteTable(); + Hashtable> parentWriteTable = parent + .getSeseEffectsSet().getWriteTable(); + keys = writeTable.keySet(); + keyIter = keys.iterator(); + while (keyIter.hasNext()) { + TempDescriptor td = (TempDescriptor) keyIter.next(); + HashSet effectsSet = writeTable.get(td); + HashSet parentEffectsSet = parentWriteTable + .get(td); + if (parentEffectsSet == null) { + parentEffectsSet = new HashSet(); + } - Hashtable> writeTable = set - .getWriteTable(); - Hashtable> parentWriteTable = parent - .getSeseEffectsSet().getWriteTable(); - keys = writeTable.keySet(); - keyIter = keys.iterator(); - while (keyIter.hasNext()) { - TempDescriptor td = (TempDescriptor) keyIter.next(); - HashSet effectsSet = writeTable.get(td); - HashSet parentEffectsSet = parentWriteTable - .get(td); - if (parentEffectsSet == null) { - parentEffectsSet = new HashSet(); - } + for (Iterator iterator = effectsSet.iterator(); iterator + .hasNext();) { + SESEEffectsKey seseKey = (SESEEffectsKey) iterator + .next(); + parentEffectsSet.add(new SESEEffectsKey(seseKey + .getFieldDescriptor(), seseKey + .getTypeDescriptor(), seseKey.getHRNId())); + } - for (Iterator iterator = effectsSet.iterator(); iterator - .hasNext();) { - SESEEffectsKey seseKey = (SESEEffectsKey) iterator - .next(); - parentEffectsSet.add(new SESEEffectsKey(seseKey - .getFieldDescriptor(), seseKey - .getTypeDescriptor(), seseKey.getHRNId())); + parentWriteTable.put(td, parentEffectsSet); } - parentWriteTable.put(td, parentEffectsSet); - } + Hashtable> strongUpdateTable = set + .getStrongUpdateTable(); + Hashtable> parentstrongUpdateTable = parent + .getSeseEffectsSet().getStrongUpdateTable(); + keys = strongUpdateTable.keySet(); + keyIter = keys.iterator(); + while (keyIter.hasNext()) { + TempDescriptor td = (TempDescriptor) keyIter.next(); + HashSet effectsSet = strongUpdateTable + .get(td); + HashSet parentEffectsSet = parentstrongUpdateTable + .get(td); + if (parentEffectsSet == null) { + parentEffectsSet = new HashSet(); + } - Hashtable> strongUpdateTable = set - .getStrongUpdateTable(); - Hashtable> parentstrongUpdateTable = parent - .getSeseEffectsSet().getStrongUpdateTable(); - keys = strongUpdateTable.keySet(); - keyIter = keys.iterator(); - while (keyIter.hasNext()) { - TempDescriptor td = (TempDescriptor) keyIter.next(); - HashSet effectsSet = strongUpdateTable - .get(td); - HashSet parentEffectsSet = parentstrongUpdateTable - .get(td); - if (parentEffectsSet == null) { - parentEffectsSet = new HashSet(); - } + for (Iterator iterator = effectsSet.iterator(); iterator + .hasNext();) { + SESEEffectsKey seseKey = (SESEEffectsKey) iterator + .next(); + parentEffectsSet.add(new SESEEffectsKey(seseKey + .getFieldDescriptor(), seseKey + .getTypeDescriptor(), seseKey.getHRNId())); + } - for (Iterator iterator = effectsSet.iterator(); iterator - .hasNext();) { - SESEEffectsKey seseKey = (SESEEffectsKey) iterator - .next(); - parentEffectsSet.add(new SESEEffectsKey(seseKey - .getFieldDescriptor(), seseKey - .getTypeDescriptor(), seseKey.getHRNId())); + parentstrongUpdateTable.put(td, parentEffectsSet); } - parentstrongUpdateTable.put(td, parentEffectsSet); } } @@ -1566,7 +1570,7 @@ public class MLPAnalysis { } } - private void addLiveInAllocationSite(MethodContext mc, AllocationSite ac){ + private void flagAllocationSite(MethodContext mc, AllocationSite ac){ HashSet set=mapMethodContextToLiveInAllocationSiteSet.get(mc); if(set==null){ set=new HashSet(); @@ -1785,7 +1789,97 @@ public class MLPAnalysis { return sorted; } + private void postSESEConflictsForward(JavaCallGraph javaCallGraph) { + + // store the reachability set in stall site data structure + Set methodCallSet = javaCallGraph.getAllMethods(typeUtil.getMain()); + LinkedList sortedMethodCalls = topologicalSort( + methodCallSet, javaCallGraph); + + for (Iterator iterator = sortedMethodCalls.iterator(); iterator + .hasNext();) { + MethodDescriptor md = (MethodDescriptor) iterator.next(); + FlatMethod fm = state.getMethodFlat(md); + + HashSet mcSet = ownAnalysis + .getAllMethodContextSetByDescriptor(md); + Iterator mcIter = mcSet.iterator(); + + while (mcIter.hasNext()) { + MethodContext mc = mcIter.next(); + + Set visited = new HashSet(); + + Set flatNodesToVisit = new HashSet(); + flatNodesToVisit.add(fm); + + while (!flatNodesToVisit.isEmpty()) { + FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next(); + flatNodesToVisit.remove(fn); + visited.add(fn); + + ParentChildConflictsMap currentConflictsMap = conflictsResults + .get(fn); + + postConflicts_nodeAction(mc, fn, + currentConflictsMap); + + // if we have a new result, schedule forward nodes for + // analysis + conflictsResults.put(fn, currentConflictsMap); + for (int i = 0; i < fn.numNext(); i++) { + FlatNode nn = fn.getNext(i); + if (!visited.contains(nn)) { + flatNodesToVisit.add(nn); + } + } + + } + + } + + } + + } + private void postConflicts_nodeAction(MethodContext mc, FlatNode fn, + ParentChildConflictsMap currentConflictsMap) { + + OwnershipGraph og = ownAnalysisForSESEConflicts.getOwnvershipGraphByMethodContext(mc); + + Hashtable stallMap=currentConflictsMap.getStallMap(); + Set keySet=stallMap.keySet(); + + for (Iterator iterator = keySet.iterator(); iterator.hasNext();) { + TempDescriptor key = (TempDescriptor) iterator.next(); + StallSite stallSite=stallMap.get(key); + + Set hrnSet=stallSite.getHRNSet(); + for (Iterator iterator2 = hrnSet.iterator(); iterator2.hasNext();) { + HeapRegionNode hrn = (HeapRegionNode) iterator2 + .next(); + + HeapRegionNode hrnOG=og.id2hrn.get(hrn.getID()); + if(hrnOG!=null){ + ReachabilitySet rSet=hrnOG.getAlpha(); + Iterator ttIterator=rSet.iterator(); + while (ttIterator.hasNext()) { + TokenTupleSet tts = (TokenTupleSet) ttIterator.next(); + stallSite.addTokenTupleSet(tts); + } + } + + } + } + + //DEBUG + for (Iterator iterator = keySet.iterator(); iterator.hasNext();) { + TempDescriptor key = (TempDescriptor) iterator.next(); + StallSite stallSite=stallMap.get(key); + } + + } + private void seseConflictsForward(JavaCallGraph javaCallGraph) { Set methodCallSet = javaCallGraph.getAllMethods(typeUtil.getMain()); @@ -1812,7 +1906,7 @@ public class MLPAnalysis { MethodContext mc = mcIter.next(); Set visited = new HashSet(); - + Set flatNodesToVisit = new HashSet(); flatNodesToVisit.add(fm); @@ -1840,15 +1934,15 @@ public class MLPAnalysis { // if we have a new result, schedule forward nodes for // analysis - if(!currentConflictsMap.isAfterChildSESE()){ + if (!currentConflictsMap.isAfterChildSESE()) { conflictsResults.put(fn, currentConflictsMap); for (int i = 0; i < fn.numNext(); i++) { FlatNode nn = fn.getNext(i); - if (!visited.contains(nn)) { - flatNodesToVisit.add(nn); + if (!visited.contains(nn)) { + flatNodesToVisit.add(nn); } } - }else{ + } else { if (!currentConflictsMap.equals(prevResult)) { conflictsResults.put(fn, currentConflictsMap); for (int i = 0; i < fn.numNext(); i++) { @@ -1857,12 +1951,52 @@ public class MLPAnalysis { } } } - + } } methodSummaryResults.put(fm, currentMethodSummary); } + // if the method has at least one child SESE, we need to calculate the + // reachability set of its stall sites. + for (Iterator iterator = sortedMethodCalls.iterator(); iterator + .hasNext();) { + MethodDescriptor md = (MethodDescriptor) iterator.next(); + FlatMethod fm = state.getMethodFlat(md); + + + } + + + + + /* + // collects related allocation sites + Iterator referenceeIter = ln + .iteratorToReferencees(); + while (referenceeIter.hasNext()) { + ReferenceEdge referenceEdge = (ReferenceEdge) referenceeIter + .next(); + HeapRegionNode dstHRN = referenceEdge.getDst(); + if (dstHRN.isParameter()) { + + HashSet visitedHRN = new HashSet(); + visitedHRN.add(dstHRN); + setupRelatedAllocSiteAnalysis(og, mc, dstHRN, + visitedHRN); + + } else { + addLiveInAllocationSite(mc, dstHRN + .getAllocationSite()); + } + } + */ + + + // if(currentConflictsMap.isAfterChildSESE()){ + // + // } + } private void conflicts_nodeAction(MethodContext mc, FlatNode fn, @@ -1935,8 +2069,28 @@ public class MLPAnalysis { TempDescriptor possibleSrc = (TempDescriptor) iterator .next(); if (!currentConflictsMap.isAccessible(possibleSrc)) { - HashSet refHRN=getReferenceHeapIDSet(og, possibleSrc); - currentConflictsMap.addStallSite(possibleSrc,refHRN,new StallTag(fn)); + HashSet refHRN = getReferenceHeapIDSet( + og, possibleSrc); + currentConflictsMap.addStallSite(possibleSrc, refHRN, + new StallTag(fn)); + + // flag stall site for disjoint analysis + for (Iterator iterator2 = refHRN.iterator(); iterator2 + .hasNext();) { + HeapRegionNode hrn = (HeapRegionNode) iterator2 + .next(); + if (hrn.isParameter()) { + // if stall site is paramter heap region, need + // to decompose into caller's + HashSet visitedHRN = new HashSet(); + visitedHRN.add(hrn); + setupRelatedAllocSiteAnalysis(og, mc, hrn, + visitedHRN); + } else { + flagAllocationSite(mc, hrn.getAllocationSite()); + } + } + } currentConflictsMap.addAccessibleVar(possibleSrc); @@ -1981,8 +2135,29 @@ public class MLPAnalysis { TempDescriptor possibleSrc = (TempDescriptor) iterator .next(); if (!currentConflictsMap.isAccessible(possibleSrc)) { - HashSet refHRN=getReferenceHeapIDSet(og, possibleSrc); - currentConflictsMap.addStallSite(possibleSrc,refHRN,new StallTag(fn)); + HashSet refHRN = getReferenceHeapIDSet( + og, possibleSrc); + currentConflictsMap.addStallSite(possibleSrc, refHRN, + new StallTag(fn)); + + // flag stall site for disjoint analysis + for (Iterator iterator2 = refHRN.iterator(); iterator2 + .hasNext();) { + HeapRegionNode hrn = (HeapRegionNode) iterator2 + .next(); + + if (hrn.isParameter()) { + // if stall site is paramter heap region, need to decompose into caller's + HashSet visitedHRN = new HashSet(); + visitedHRN.add(hrn); + setupRelatedAllocSiteAnalysis(og, mc, hrn, + visitedHRN); + } else { + flagAllocationSite(mc, hrn.getAllocationSite()); + } + + } + } currentConflictsMap.addAccessibleVar(possibleSrc); } @@ -1995,9 +2170,29 @@ public class MLPAnalysis { .next(); if (!currentConflictsMap.isAccessible(possibleDst)) { - HashSet refHRN=getReferenceHeapIDSet(og, possibleDst); - currentConflictsMap.addStallSite(possibleDst,refHRN,new StallTag(fn)); + HashSet refHRN = getReferenceHeapIDSet( + og, possibleDst); + currentConflictsMap.addStallSite(possibleDst, refHRN, + new StallTag(fn)); + + // flag stall site for disjoint analysis + for (Iterator iterator2 = refHRN.iterator(); iterator2 + .hasNext();) { + HeapRegionNode hrn = (HeapRegionNode) iterator2 + .next(); + if (hrn.isParameter()) { + // if stall site is paramter heap region, need + // to decompose into caller's + HashSet visitedHRN = new HashSet(); + visitedHRN.add(hrn); + setupRelatedAllocSiteAnalysis(og, mc, hrn, + visitedHRN); + } else { + flagAllocationSite(mc, hrn.getAllocationSite()); + } + } } + currentConflictsMap.addAccessibleVar(possibleDst); // contribute write effect on destination's stall site currentConflictsMap.contributeEffect(possibleDst, field @@ -2072,10 +2267,10 @@ public class MLPAnalysis { case FKind.FlatCall: { FlatCall fc = (FlatCall) fn; - - int base=0; - if(!fc.getMethod().isStatic()){ - base=1; + + int base = 0; + if (!fc.getMethod().isStatic()) { + base = 1; } FlatMethod calleeFM = state.getMethodFlat(fc.getMethod()); @@ -2126,7 +2321,7 @@ public class MLPAnalysis { // 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); @@ -2138,43 +2333,63 @@ public class MLPAnalysis { // stall site currentConflictsMap.addAccessibleVar(returnTemp); - StallSite returnStallSite=calleeMethodSummary.getReturnStallSite().copy(); + StallSite returnStallSite = calleeMethodSummary + .getReturnStallSite().copy(); // handling parameter regions - HashSet stallParamIdx=returnStallSite.getCallerParamIdxSet(); + HashSet 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 - + + int paramIdx = idx.intValue() - base; + TempDescriptor paramTD = fc.getArg(paramIdx); + + // TODO: resolve callee's parameter heap regions by + // following call chain + } - + + // flag stall site's allocation sites for disjointness analysis + HashSet hrnSet=returnStallSite.getHRNSet(); + for (Iterator iterator = hrnSet.iterator(); iterator + .hasNext();) { + HeapRegionNode hrn = (HeapRegionNode) iterator + .next(); + if (hrn.isParameter()) { + // if stall site is paramter heap region, need to decompose into caller's + HashSet visitedHRN = new HashSet(); + visitedHRN.add(hrn); + setupRelatedAllocSiteAnalysis(og, mc, hrn, + visitedHRN); + } else { + flagAllocationSite(mc, hrn.getAllocationSite()); + } + } + currentConflictsMap.addStallSite(returnTemp, returnStallSite); - + } else if (calleeMethodSummary.getReturnValueAccessibility() .equals(MethodSummary.INACCESSIBLE)) { // when return value is inaccessible currentConflictsMap.addInaccessibleVar(returnTemp); } - - // TODO: need to handle edge mappings from callee - - - Set stallParamIdx=calleeMethodSummary.getStallParamIdxSet(); + + // TODO: need to handle edge mappings from callee + Set stallParamIdx = calleeMethodSummary + .getStallParamIdxSet(); for (Iterator iterator = stallParamIdx.iterator(); iterator .hasNext();) { - Integer paramIdx = (Integer) iterator.next(); - HashSet stallTagSet=calleeMethodSummary.getStallTagByParamIdx(paramIdx); - - int argIdx=paramIdx.intValue()-base; - TempDescriptor argTD=fc.getArg(argIdx); - - putStallTagOnReferenceEdges(og, argTD,stallTagSet,currentConflictsMap); - + Integer paramIdx = (Integer) iterator.next(); + HashSet stallTagSet = calleeMethodSummary + .getStallTagByParamIdx(paramIdx); + + int argIdx = paramIdx.intValue() - base; + TempDescriptor argTD = fc.getArg(argIdx); + + putStallTagOnReferenceEdges(og, argTD, stallTagSet, + currentConflictsMap); } } @@ -2261,7 +2476,6 @@ public class MLPAnalysis { } methodSummaryResults.put(fm, currentMethodSummary); } - } break; diff --git a/Robust/src/Analysis/MLP/StallSite.java b/Robust/src/Analysis/MLP/StallSite.java index a067a2f1..5058b027 100644 --- a/Robust/src/Analysis/MLP/StallSite.java +++ b/Robust/src/Analysis/MLP/StallSite.java @@ -7,6 +7,7 @@ import java.util.Set; import Analysis.OwnershipAnalysis.AllocationSite; import Analysis.OwnershipAnalysis.HeapRegionNode; import Analysis.OwnershipAnalysis.ReachabilitySet; +import Analysis.OwnershipAnalysis.TokenTupleSet; import IR.Flat.FlatNode; public class StallSite { @@ -17,7 +18,7 @@ public class StallSite { private HashSet effectSet; private HashSet hrnSet; private HashSet allocationSiteSet; - private ReachabilitySet rechabilitySet; + private ReachabilitySet reachabilitySet; private HashSet stallTagSet; // if stall site is caller's parameter heap regtion, store its parameter idx @@ -27,12 +28,12 @@ public class StallSite { public StallSite() { effectSet = new HashSet(); hrnSet = new HashSet(); - rechabilitySet = new ReachabilitySet(); + reachabilitySet = new ReachabilitySet(); allocationSiteSet = new HashSet(); stallTagSet = new HashSet(); callerParamIdxSet = new HashSet(); } - + public StallSite(HashSet hrnSet, StallTag tag) { this(); @@ -45,18 +46,22 @@ public class StallSite { setAllocationSite(heapRegionNode.getAllocationSite()); } } - + public StallSite(HashSet effectSet, HashSet hrnSet, ReachabilitySet rechabilitySet, HashSet alocSet, HashSet tagSet, HashSet paramIdx) { this(); this.effectSet.addAll(effectSet); this.hrnSet.addAll(hrnSet); - this.rechabilitySet = rechabilitySet; + this.reachabilitySet = rechabilitySet; this.allocationSiteSet.addAll(alocSet); this.stallTagSet.addAll(tagSet); this.callerParamIdxSet.addAll(paramIdx); } + + public void addTokenTupleSet(TokenTupleSet newSet){ + reachabilitySet.add(newSet); + } public HashSet getCallerParamIdxSet() { return callerParamIdxSet; @@ -105,7 +110,7 @@ public class StallSite { } public ReachabilitySet getReachabilitySet() { - return rechabilitySet; + return reachabilitySet; } public HashSet getStallTagSet() { @@ -114,7 +119,7 @@ public class StallSite { public StallSite copy() { - StallSite copy = new StallSite(effectSet, hrnSet, rechabilitySet, + StallSite copy = new StallSite(effectSet, hrnSet, reachabilitySet, allocationSiteSet, stallTagSet, callerParamIdxSet); return copy; @@ -136,7 +141,7 @@ public class StallSite { && stallTagSet.equals(in.getStallTagSet()) && effectSet.equals(in.getEffectSet()) && hrnSet.equals(in.getHRNSet()) - && rechabilitySet.equals(in.getReachabilitySet())) { + && reachabilitySet.equals(in.getReachabilitySet())) { return true; } else { return false; @@ -149,7 +154,7 @@ public class StallSite { return "StallSite [allocationSiteSet=" + allocationSiteSet + ", callerParamIdxSet=" + callerParamIdxSet + ", effectSet=" + effectSet + ", hrnSet=" + hrnSet + ", rechabilitySet=" - + rechabilitySet + ", stallTagSet=" + stallTagSet + "]"; + + reachabilitySet + ", stallTagSet=" + stallTagSet + "]"; } } diff --git a/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java b/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java index 71db77b1..36b6c8a5 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java +++ b/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java @@ -23,6 +23,8 @@ public class HeapRegionNode extends OwnershipNode { protected ReachabilitySet alphaNew; protected String description; + + protected String globalIdentifier; @@ -34,7 +36,8 @@ public class HeapRegionNode extends OwnershipNode { TypeDescriptor type, AllocationSite allocSite, ReachabilitySet alpha, - String description) { + String description, + String globalIdentifier) { this.id = id; this.isSingleObject = isSingleObject; this.isFlagged = isFlagged; @@ -44,6 +47,7 @@ public class HeapRegionNode extends OwnershipNode { this.allocSite = allocSite; this.alpha = alpha; this.description = description; + this.globalIdentifier = globalIdentifier; referencers = new HashSet(); alphaNew = new ReachabilitySet().makeCanonical(); @@ -58,7 +62,8 @@ public class HeapRegionNode extends OwnershipNode { type, allocSite, alpha, - description); + description, + globalIdentifier); } @@ -222,4 +227,8 @@ public class HeapRegionNode extends OwnershipNode { return new String(description); //return new String( description+" ID "+getIDString() ); } + + public String getGloballyUniqueIdentifier(){ + return globalIdentifier; + } } diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java index 7c140d05..bc06db3d 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java @@ -837,7 +837,7 @@ public class OwnershipAnalysis { Set aliasedParamIndices = mc.getAliasedParamIndices(); if( !aliasedParamIndices.isEmpty() ) { - og.makeAliasedParamHeapRegionNode(); + og.makeAliasedParamHeapRegionNode(fm); } // set up each parameter @@ -856,13 +856,13 @@ public class OwnershipAnalysis { // use the alias blob but give parameters their // own primary obj region og.assignTempEqualToAliasedParam( tdParam, - paramIndex ); + paramIndex, fm ); } else { // this parameter is not aliased to others, give it // a fresh primary obj and secondary object og.assignTempEqualToParamAlloc( tdParam, mc.getDescriptor() instanceof TaskDescriptor, - paramIndex ); + paramIndex, fm ); } } diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java index 51ec01be..cf29903d 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java @@ -157,7 +157,8 @@ public class OwnershipGraph { TypeDescriptor type, AllocationSite allocSite, ReachabilitySet alpha, - String description) { + String description, + String globalIdentifier) { boolean markForAnalysis = isFlagged || isParameter; @@ -190,7 +191,7 @@ public class OwnershipGraph { ).makeCanonical(); } } - + HeapRegionNode hrn = new HeapRegionNode(id, isSingleObject, markForAnalysis, @@ -199,7 +200,8 @@ public class OwnershipGraph { typeToUse, allocSite, alpha, - description); + description, + globalIdentifier); id2hrn.put(id, hrn); return hrn; } @@ -578,9 +580,9 @@ public class OwnershipGraph { // primary object, if necessary public void assignTempEqualToParamAlloc( TempDescriptor td, boolean isTask, - Integer paramIndex ) { + Integer paramIndex, FlatMethod fm ) { assert td != null; - + TypeDescriptor typeParam = td.getType(); assert typeParam != null; @@ -641,7 +643,7 @@ public class OwnershipGraph { cd = cd.getSuperDesc(); } } - + // now build everything we need LabelNode lnParam = getLabelNodeFromTemp( td ); @@ -653,7 +655,8 @@ public class OwnershipGraph { typeParam, // type null, // allocation site null, // reachability set - "param"+paramIndex+" obj" ); + "param"+paramIndex+" obj", + generateUniqueIdentifier(fm,paramIndex,"P")); parameterTemps.add( td ); parameterLabels.add( lnParam ); @@ -705,7 +708,8 @@ public class OwnershipGraph { null, // type null, // allocation site null, // reachability set - "param"+paramIndex+" reachable" ); + "param"+paramIndex+" reachable", + generateUniqueIdentifier(fm,paramIndex,"S")); newSecondaryID = hrnSecondary.getID(); assert !idSecondary2paramIndexSet.containsKey( newSecondaryID ); @@ -814,13 +818,13 @@ public class OwnershipGraph { } - public void makeAliasedParamHeapRegionNode() { + public void makeAliasedParamHeapRegionNode(FlatMethod fm) { LabelNode lnBlob = getLabelNodeFromTemp( tdAliasBlob ); outOfScopeTemps.add( tdAliasBlob ); outOfScopeLabels.add( lnBlob ); - + HeapRegionNode hrn = createNewHeapRegionNode( null, // id or null to generate a new one false, // single object? false, // summary? @@ -829,7 +833,8 @@ public class OwnershipGraph { null, // type null, // allocation site null, // reachability set - "aliasedParams" ); + "aliasedParams", + generateUniqueIdentifier(fm,0,"A")); ReachabilitySet beta = new ReachabilitySet( new TokenTuple( hrn.getID(), @@ -849,7 +854,7 @@ public class OwnershipGraph { public void assignTempEqualToAliasedParam( TempDescriptor tdParam, - Integer paramIndex ) { + Integer paramIndex, FlatMethod fm ) { assert tdParam != null; TypeDescriptor typeParam = tdParam.getType(); @@ -897,7 +902,8 @@ public class OwnershipGraph { typeParam, // type null, // allocation site null, // reachability set - "param"+paramIndex+" obj" ); + "param"+paramIndex+" obj", + generateUniqueIdentifier(fm, paramIndex.intValue(), "P")); Integer newPrimaryID = hrnPrimary.getID(); assert !idPrimary2paramIndexSet.containsKey( newPrimaryID ); @@ -1415,7 +1421,8 @@ public class OwnershipGraph { as.getType(), // type as, // allocation site null, // reachability set - as.toStringForDOT() + "\\nsummary"); + as.toStringForDOT() + "\\nsummary", + generateUniqueIdentifier(as,0,true)); for( int i = 0; i < as.getAllocationDepth(); ++i ) { Integer idIth = as.getIthOldest(i); @@ -1428,7 +1435,8 @@ public class OwnershipGraph { as.getType(), // type as, // allocation site null, // reachability set - as.toStringForDOT() + "\\n" + i + " oldest"); + as.toStringForDOT() + "\\n" + i + " oldest", + generateUniqueIdentifier(as,i,false)); } } @@ -1456,7 +1464,8 @@ public class OwnershipGraph { as.getType(), // type as, // allocation site null, // reachability set - as + "\\n" + as.getType() + "\\nshadowSum"); + as + "\\n" + as.getType() + "\\nshadowSum", + ""); for( int i = 0; i < as.getAllocationDepth(); ++i ) { Integer idShadowIth = as.getIthOldestShadow(i); @@ -1469,7 +1478,8 @@ public class OwnershipGraph { as.getType(), // type as, // allocation site null, // reachability set - as + "\\n" + as.getType() + "\\n" + i + " shadow"); + as + "\\n" + as.getType() + "\\n" + i + " shadow", + ""); } } @@ -4855,4 +4865,38 @@ public class OwnershipGraph { } + public String generateUniqueIdentifier(FlatMethod fm, int paramIdx, String type){ + + //type: A->aliapsed parameter heap region + // P -> primary paramter heap region + // S -> secondary paramter heap region + + String identifier; + if(type.equals("A")){ + //aliased param + identifier="FM"+fm.hashCode()+".A"; + }else{ + identifier="FM"+fm.hashCode()+"."+paramIdx+"."+type; + } + return identifier; + + } + + public String generateUniqueIdentifier(AllocationSite as, int age, boolean isSummary){ + + String identifier; + + FlatNew fn=as.getFlatNew(); + + if(isSummary){ + identifier="FN"+fn.hashCode()+".S"; + }else{ + identifier="FN"+fn.hashCode()+"."+age; + } + + return identifier; + + } + + }