changes toward keeping globally unique identifier for disjoint analysis result
authoryeom <yeom>
Tue, 3 Nov 2009 00:28:20 +0000 (00:28 +0000)
committeryeom <yeom>
Tue, 3 Nov 2009 00:28:20 +0000 (00:28 +0000)
+ calculating reachability states for each stall sites and child SESE's live-in variables.

Robust/src/Analysis/MLP/MLPAnalysis.java
Robust/src/Analysis/MLP/StallSite.java
Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java
Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java
Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java

index c031a12a221b1a250771380a9f881cce6dc53f54..37fe8dea4bbd6e0f4413dbd72d2031cb0cbbdc98 100644 (file)
@@ -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<TempDescriptor> set = fsen.getInVarSet();
+                               Iterator<TempDescriptor> 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<ReferenceEdge> 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<TempDescriptor> set = fsen.getInVarSet();
-                       Iterator<TempDescriptor> 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<ReferenceEdge> referenceeIter = ln
-                                                       .iteratorToReferencees();
-                                       while (referenceeIter.hasNext()) {
-                                               ReferenceEdge referenceEdge = (ReferenceEdge) referenceeIter
-                                                               .next();
-                                               HeapRegionNode dstHRN = referenceEdge.getDst();
-                                               if (dstHRN.isParameter()) {
-                                                       
-                                                       HashSet<HeapRegionNode> visitedHRN=new HashSet<HeapRegionNode>();
-                                                       visitedHRN.add(dstHRN);
-                                                       setupRelatedAllocSiteAnalysis(og,mc,dstHRN,visitedHRN);
+                                                               HashSet<HeapRegionNode> visitedHRN = new HashSet<HeapRegionNode>();
+                                                               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<TempDescriptor, HashSet<SESEEffectsKey>> readTable = set
+                                                       .getReadTable();
+                                       Hashtable<TempDescriptor, HashSet<SESEEffectsKey>> parentReadTable = parent
+                                                       .getSeseEffectsSet().getReadTable();
+                                       Set<TempDescriptor> keys = readTable.keySet();
+                                       Iterator<TempDescriptor> keyIter = keys.iterator();
+                                       while (keyIter.hasNext()) {
+                                               TempDescriptor td = (TempDescriptor) keyIter.next();
+                                               HashSet<SESEEffectsKey> effectsSet = readTable.get(td);
+                                               HashSet<SESEEffectsKey> parentEffectsSet = parentReadTable
+                                                               .get(td);
+                                               if (parentEffectsSet == null) {
+                                                       parentEffectsSet = new HashSet<SESEEffectsKey>();
+                                               }
 
-                       FlatSESEEnterNode enterNode = fsexit.getFlatEnter();
-                       FlatSESEEnterNode parent = enterNode.getParent();
-                       if (parent != null) {
-
-                               SESEEffectsSet set = enterNode.getSeseEffectsSet();
-                               Hashtable<TempDescriptor, HashSet<SESEEffectsKey>> readTable = set
-                                               .getReadTable();
-                               Hashtable<TempDescriptor, HashSet<SESEEffectsKey>> parentReadTable = parent
-                                               .getSeseEffectsSet().getReadTable();
-                               Set<TempDescriptor> keys = readTable.keySet();
-                               Iterator<TempDescriptor> keyIter = keys.iterator();
-                               while (keyIter.hasNext()) {
-                                       TempDescriptor td = (TempDescriptor) keyIter.next();
-                                       HashSet<SESEEffectsKey> effectsSet = readTable.get(td);
-                                       HashSet<SESEEffectsKey> parentEffectsSet = parentReadTable
-                                                       .get(td);
-                                       if (parentEffectsSet == null) {
-                                               parentEffectsSet = new HashSet<SESEEffectsKey>();
-                                       }
+                                               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<TempDescriptor, HashSet<SESEEffectsKey>> writeTable = set
+                                                       .getWriteTable();
+                                       Hashtable<TempDescriptor, HashSet<SESEEffectsKey>> parentWriteTable = parent
+                                                       .getSeseEffectsSet().getWriteTable();
+                                       keys = writeTable.keySet();
+                                       keyIter = keys.iterator();
+                                       while (keyIter.hasNext()) {
+                                               TempDescriptor td = (TempDescriptor) keyIter.next();
+                                               HashSet<SESEEffectsKey> effectsSet = writeTable.get(td);
+                                               HashSet<SESEEffectsKey> parentEffectsSet = parentWriteTable
+                                                               .get(td);
+                                               if (parentEffectsSet == null) {
+                                                       parentEffectsSet = new HashSet<SESEEffectsKey>();
+                                               }
 
-                               Hashtable<TempDescriptor, HashSet<SESEEffectsKey>> writeTable = set
-                                               .getWriteTable();
-                               Hashtable<TempDescriptor, HashSet<SESEEffectsKey>> parentWriteTable = parent
-                                               .getSeseEffectsSet().getWriteTable();
-                               keys = writeTable.keySet();
-                               keyIter = keys.iterator();
-                               while (keyIter.hasNext()) {
-                                       TempDescriptor td = (TempDescriptor) keyIter.next();
-                                       HashSet<SESEEffectsKey> effectsSet = writeTable.get(td);
-                                       HashSet<SESEEffectsKey> parentEffectsSet = parentWriteTable
-                                                       .get(td);
-                                       if (parentEffectsSet == null) {
-                                               parentEffectsSet = new HashSet<SESEEffectsKey>();
-                                       }
+                                               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<TempDescriptor, HashSet<SESEEffectsKey>> strongUpdateTable = set
+                                                       .getStrongUpdateTable();
+                                       Hashtable<TempDescriptor, HashSet<SESEEffectsKey>> parentstrongUpdateTable = parent
+                                                       .getSeseEffectsSet().getStrongUpdateTable();
+                                       keys = strongUpdateTable.keySet();
+                                       keyIter = keys.iterator();
+                                       while (keyIter.hasNext()) {
+                                               TempDescriptor td = (TempDescriptor) keyIter.next();
+                                               HashSet<SESEEffectsKey> effectsSet = strongUpdateTable
+                                                               .get(td);
+                                               HashSet<SESEEffectsKey> parentEffectsSet = parentstrongUpdateTable
+                                                               .get(td);
+                                               if (parentEffectsSet == null) {
+                                                       parentEffectsSet = new HashSet<SESEEffectsKey>();
+                                               }
 
-                               Hashtable<TempDescriptor, HashSet<SESEEffectsKey>> strongUpdateTable = set
-                                               .getStrongUpdateTable();
-                               Hashtable<TempDescriptor, HashSet<SESEEffectsKey>> parentstrongUpdateTable = parent
-                                               .getSeseEffectsSet().getStrongUpdateTable();
-                               keys = strongUpdateTable.keySet();
-                               keyIter = keys.iterator();
-                               while (keyIter.hasNext()) {
-                                       TempDescriptor td = (TempDescriptor) keyIter.next();
-                                       HashSet<SESEEffectsKey> effectsSet = strongUpdateTable
-                                                       .get(td);
-                                       HashSet<SESEEffectsKey> parentEffectsSet = parentstrongUpdateTable
-                                                       .get(td);
-                                       if (parentEffectsSet == null) {
-                                               parentEffectsSet = new HashSet<SESEEffectsKey>();
-                                       }
+                                               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<AllocationSite> set=mapMethodContextToLiveInAllocationSiteSet.get(mc);
                if(set==null){
                        set=new HashSet<AllocationSite>();                      
@@ -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<MethodDescriptor> sortedMethodCalls = topologicalSort(
+                               methodCallSet, javaCallGraph);
+
+               for (Iterator iterator = sortedMethodCalls.iterator(); iterator
+                               .hasNext();) {
+                       MethodDescriptor md = (MethodDescriptor) iterator.next();
+                       FlatMethod fm = state.getMethodFlat(md);
+
+                       HashSet<MethodContext> mcSet = ownAnalysis
+                                       .getAllMethodContextSetByDescriptor(md);
+                       Iterator<MethodContext> mcIter = mcSet.iterator();
+
+                       while (mcIter.hasNext()) {
+                               MethodContext mc = mcIter.next();
+
+                               Set<FlatNode> visited = new HashSet<FlatNode>();
+
+                               Set<FlatNode> flatNodesToVisit = new HashSet<FlatNode>();
+                               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<TempDescriptor,StallSite> stallMap=currentConflictsMap.getStallMap();
+               Set<TempDescriptor> keySet=stallMap.keySet();
+               
+               for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
+                       TempDescriptor key = (TempDescriptor) iterator.next();
+                       StallSite stallSite=stallMap.get(key);
+                       
+                       Set<HeapRegionNode> 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<TokenTupleSet> 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<FlatNode> visited = new HashSet<FlatNode>();
-
+                                              
                                Set<FlatNode> flatNodesToVisit = new HashSet<FlatNode>();
                                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<ReferenceEdge> referenceeIter = ln
+                               .iteratorToReferencees();
+               while (referenceeIter.hasNext()) {
+                       ReferenceEdge referenceEdge = (ReferenceEdge) referenceeIter
+                                       .next();
+                       HeapRegionNode dstHRN = referenceEdge.getDst();
+                       if (dstHRN.isParameter()) {
+
+                               HashSet<HeapRegionNode> visitedHRN = new HashSet<HeapRegionNode>();
+                               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<HeapRegionNode> refHRN=getReferenceHeapIDSet(og, possibleSrc);
-                                               currentConflictsMap.addStallSite(possibleSrc,refHRN,new StallTag(fn));
+                                               HashSet<HeapRegionNode> 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<HeapRegionNode> visitedHRN = new HashSet<HeapRegionNode>();
+                                                               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<HeapRegionNode> refHRN=getReferenceHeapIDSet(og, possibleSrc);
-                                               currentConflictsMap.addStallSite(possibleSrc,refHRN,new StallTag(fn));
+                                               HashSet<HeapRegionNode> 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<HeapRegionNode> visitedHRN = new HashSet<HeapRegionNode>();
+                                                               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<HeapRegionNode> refHRN=getReferenceHeapIDSet(og, possibleDst);
-                                               currentConflictsMap.addStallSite(possibleDst,refHRN,new StallTag(fn));
+                                               HashSet<HeapRegionNode> 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<HeapRegionNode> visitedHRN = new HashSet<HeapRegionNode>();
+                                                               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<Integer> stallParamIdx=returnStallSite.getCallerParamIdxSet();
+                                       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
-                                               
+
+                                               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<HeapRegionNode> 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<HeapRegionNode> visitedHRN = new HashSet<HeapRegionNode>();
+                                                       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<Integer> stallParamIdx=calleeMethodSummary.getStallParamIdxSet();
+
+                               // TODO: need to handle edge mappings from callee
+                               Set<Integer> stallParamIdx = calleeMethodSummary
+                                               .getStallParamIdxSet();
                                for (Iterator iterator = stallParamIdx.iterator(); iterator
                                                .hasNext();) {
-                                       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);
-                                       
+                                       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);
                                }
                        }
 
@@ -2261,7 +2476,6 @@ public class MLPAnalysis {
                                }
                                methodSummaryResults.put(fm, currentMethodSummary);
                        }
-
                }
                        break;
 
index a067a2f1224da291ca831aee41b34b688230bb9e..5058b0276508feddbe7c0a2c1c8b8f2749f6446f 100644 (file)
@@ -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<Effect> effectSet;
        private HashSet<HeapRegionNode> hrnSet;
        private HashSet<AllocationSite> allocationSiteSet;
-       private ReachabilitySet rechabilitySet;
+       private ReachabilitySet reachabilitySet;
        private HashSet<StallTag> 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<Effect>();
                hrnSet = new HashSet<HeapRegionNode>();
-               rechabilitySet = new ReachabilitySet();
+               reachabilitySet = new ReachabilitySet();
                allocationSiteSet = new HashSet<AllocationSite>();
                stallTagSet = new HashSet<StallTag>();
                callerParamIdxSet = new HashSet<Integer>();
        }
-
+       
        public StallSite(HashSet<HeapRegionNode> hrnSet, StallTag tag) {
 
                this();
@@ -45,18 +46,22 @@ public class StallSite {
                        setAllocationSite(heapRegionNode.getAllocationSite());
                }
        }
-
+       
        public StallSite(HashSet<Effect> effectSet, HashSet<HeapRegionNode> 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.reachabilitySet = rechabilitySet;
                this.allocationSiteSet.addAll(alocSet);
                this.stallTagSet.addAll(tagSet);
                this.callerParamIdxSet.addAll(paramIdx);
        }
+       
+       public void addTokenTupleSet(TokenTupleSet newSet){
+               reachabilitySet.add(newSet);
+       }
 
        public HashSet<Integer> getCallerParamIdxSet() {
                return callerParamIdxSet;
@@ -105,7 +110,7 @@ public class StallSite {
        }
 
        public ReachabilitySet getReachabilitySet() {
-               return rechabilitySet;
+               return reachabilitySet;
        }
 
        public HashSet<StallTag> 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 + "]";
        }
 
 }
index 71db77b17c8892d6726f33fcfa9a54d7dae66072..36b6c8a58729b04c54ad4ef1e51eb639bacce9dc 100644 (file)
@@ -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<ReferenceEdge>();
     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;
+  }
 }
index 7c140d0504925fd64517ca86abaa36cb5808cc71..bc06db3d4d565d04be374b064fcb12f0f3ef27ed 100644 (file)
@@ -837,7 +837,7 @@ public class OwnershipAnalysis {
        Set<Integer> 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 );
          }
        }
        
index 51ec01be25a9ad11f4658427fa9f9805471ff3de..cf29903d7072ecc6e48ff879540dc324d1135a3a 100644 (file)
@@ -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;
+         
+  }
+
+  
 }