changes.
authoryeom <yeom>
Mon, 30 Nov 2009 20:36:28 +0000 (20:36 +0000)
committeryeom <yeom>
Mon, 30 Nov 2009 20:36:28 +0000 (20:36 +0000)
Robust/src/Analysis/MLP/ConflictGraph.java
Robust/src/Analysis/MLP/ConflictNode.java
Robust/src/Analysis/MLP/GloballyUniqueTokenTuple.java [new file with mode: 0644]
Robust/src/Analysis/MLP/LiveInNode.java
Robust/src/Analysis/MLP/MLPAnalysis.java
Robust/src/Analysis/MLP/StallSiteNode.java

index 63fb010b4b0ef19737edce51a8f03c168dc8d7e7..79a2c383531abbdb66ce85d915d56e32007cad02 100644 (file)
@@ -9,27 +9,190 @@ import java.util.Set;
 import java.util.Map.Entry;
 
 import Analysis.OwnershipAnalysis.HeapRegionNode;
+import Analysis.OwnershipAnalysis.TokenTuple;
 import IR.Flat.FlatMethod;
 import IR.Flat.FlatSESEEnterNode;
 import IR.Flat.TempDescriptor;
 
 public class ConflictGraph {
 
-       public Hashtable<String, ConflictNode> td2cn;
+       public Hashtable<String, ConflictNode> id2cn;
 
        public ConflictGraph() {
-               td2cn = new Hashtable<String, ConflictNode>();
+               id2cn = new Hashtable<String, ConflictNode>();
+       }
+
+       public void analyzeConflicts() {
+               Set<String> keySet = id2cn.keySet();
+               for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
+                       String nodeID = (String) iterator.next();
+                       ConflictNode node = id2cn.get(nodeID);
+                       analyzePossibleConflicts(node);
+               }
+       }
+
+       public void analyzePossibleConflicts(ConflictNode node) {
+
+               // compare with all nodes
+
+               Set<Set> nodeReachabilitySet = node.getReachabilitySet();
+
+               Set<Entry<String, ConflictNode>> set = id2cn.entrySet();
+               for (Iterator iterator = set.iterator(); iterator.hasNext();) {
+                       Entry<String, ConflictNode> entry = (Entry<String, ConflictNode>) iterator
+                                       .next();
+
+                       String currentNodeID = entry.getKey();
+                       ConflictNode currentNode = entry.getValue();
+
+                       if ((node instanceof StallSiteNode)
+                                       && (currentNode instanceof StallSiteNode)) {
+                               continue;
+                       }
+
+                       if (currentNodeID.equals(node.getID())) {
+                               continue;
+                       }
+
+                       Set<Set> currentNodeReachabilitySet = currentNode
+                                       .getReachabilitySet();
+
+                       Set<GloballyUniqueTokenTuple> overlapSet = calculateOverlappedReachableRegion(
+                                       nodeReachabilitySet, currentNodeReachabilitySet);
+                       if (overlapSet.size() > 0) {
+
+                               // System.out.println("OVERLAPPED=" + overlapSet);
+
+                               if (node instanceof StallSiteNode
+                                               && currentNode instanceof LiveInNode) {
+                                       int edgeType = decideConflictEdgeType(overlapSet,
+                                                       (StallSiteNode) node, (LiveInNode) currentNode);
+                                       addConflictEdge(edgeType, node, currentNode);
+                               } else if (node instanceof LiveInNode
+                                               && currentNode instanceof LiveInNode) {
+                                       int edgeType = decideConflictEdgeType(overlapSet,
+                                                       (LiveInNode) node, (LiveInNode) currentNode);
+                                       addConflictEdge(edgeType, node, currentNode);
+                               }
+
+                       } else {
+                               // System.out.println("DOSE NOT OVERLAPPED " + node + " <-> "
+                               // + currentNode);
+                       }
+               }
+       }
+
+       public boolean containsTokenTuple(Set<GloballyUniqueTokenTuple> overlapSet,
+                       String uniqueID) {
+
+               for (Iterator iterator = overlapSet.iterator(); iterator.hasNext();) {
+                       GloballyUniqueTokenTuple globallyUniqueTokenTuple = (GloballyUniqueTokenTuple) iterator
+                                       .next();
+                       if (globallyUniqueTokenTuple.getID().equals(uniqueID)) {
+                               return true;
+                       }
+               }
+
+               return false;
+
+       }
+
+       private int decideConflictEdgeType(
+                       Set<GloballyUniqueTokenTuple> overlapSet,
+                       StallSiteNode stallSiteNode, LiveInNode liveInNode) {
+
+               Set<SESEEffectsKey> liveInWriteEffectSet = liveInNode
+                               .getWriteEffectsSet();
+
+               if (liveInWriteEffectSet != null) {
+                       for (Iterator iterator = liveInWriteEffectSet.iterator(); iterator
+                                       .hasNext();) {
+                               SESEEffectsKey seseEffectsKey = (SESEEffectsKey) iterator
+                                               .next();
+                               String hrnUniqueID = seseEffectsKey.getHRNUniqueId();
+
+                               if (containsTokenTuple(overlapSet, hrnUniqueID)) {
+                                       return ConflictEdge.COARSE_GRAIN_EDGE;
+                               }
+                       }
+               }
+
+               return ConflictEdge.FINE_GRAIN_EDGE;
+       }
+
+       private int decideConflictEdgeType(
+                       Set<GloballyUniqueTokenTuple> overlapSet, LiveInNode liveInNodeA,
+                       LiveInNode liveInNodeB) {
+
+               Set<SESEEffectsKey> liveInWriteEffectSetA = liveInNodeA
+                               .getWriteEffectsSet();
+
+               if (liveInWriteEffectSetA != null) {
+                       for (Iterator iterator = liveInWriteEffectSetA.iterator(); iterator
+                                       .hasNext();) {
+                               SESEEffectsKey seseEffectsKey = (SESEEffectsKey) iterator
+                                               .next();
+                               String hrnUniqueID = seseEffectsKey.getHRNUniqueId();
+
+                               if (containsTokenTuple(overlapSet, hrnUniqueID)) {
+                                       return ConflictEdge.COARSE_GRAIN_EDGE;
+                               }
+                       }
+               }
+
+               Set<SESEEffectsKey> liveInWriteEffectSetB = liveInNodeB
+                               .getWriteEffectsSet();
+
+               if (liveInWriteEffectSetB != null) {
+                       for (Iterator iterator = liveInWriteEffectSetB.iterator(); iterator
+                                       .hasNext();) {
+                               SESEEffectsKey seseEffectsKey = (SESEEffectsKey) iterator
+                                               .next();
+                               String hrnUniqueID = seseEffectsKey.getHRNUniqueId();
+
+                               if (containsTokenTuple(overlapSet, hrnUniqueID)) {
+                                       return ConflictEdge.COARSE_GRAIN_EDGE;
+                               }
+                       }
+               }
+
+               return 0;
+       }
+
+       private Set<GloballyUniqueTokenTuple> calculateOverlappedReachableRegion(
+                       Set<Set> setA, Set<Set> setB) {
+
+               Set<GloballyUniqueTokenTuple> returnSet = new HashSet<GloballyUniqueTokenTuple>();
+
+               for (Iterator iterator2 = setA.iterator(); iterator2.hasNext();) {
+                       Set tokenTupleSetA = (Set) iterator2.next();
+
+                       for (Iterator iterator3 = setB.iterator(); iterator3.hasNext();) {
+                               Set tokenTupleSetB = (Set) iterator3.next();
+
+                               if (tokenTupleSetA.equals(tokenTupleSetB)) {
+                                       // reachability states are overlapped
+                                       Iterator ttsIter = tokenTupleSetA.iterator();
+                                       while (ttsIter.hasNext()) {
+                                               GloballyUniqueTokenTuple tt = (GloballyUniqueTokenTuple) ttsIter
+                                                               .next();
+                                               returnSet.add(tt);
+                                       }
+                               }
+                       }
+               }
+               return returnSet;
        }
 
        public String addStallNode(TempDescriptor td, FlatMethod fm,
-                       StallSite stallSite) {
+                       StallSite stallSite, Set<Set> reachabilitySet) {
 
                String stallNodeID = td + "_" + fm.getMethod().getSymbol();
 
-               if (!td2cn.containsKey(stallNodeID)) {
+               if (!id2cn.containsKey(stallNodeID)) {
                        StallSiteNode newNode = new StallSiteNode(stallNodeID, td,
-                                       stallSite);
-                       td2cn.put(stallNodeID, newNode);
+                                       stallSite, reachabilitySet);
+                       id2cn.put(stallNodeID, newNode);
                        // it add new new stall node to conflict graph
                        return stallNodeID;
                }
@@ -39,7 +202,7 @@ public class ConflictGraph {
        }
 
        public StallSiteNode getStallNode(String stallNodeID) {
-               ConflictNode node = td2cn.get(stallNodeID);
+               ConflictNode node = id2cn.get(stallNodeID);
                if (node instanceof StallSiteNode) {
                        return (StallSiteNode) node;
                } else {
@@ -49,13 +212,31 @@ public class ConflictGraph {
 
        public void addLiveInNode(TempDescriptor td, FlatSESEEnterNode fsen,
                        Set<SESEEffectsKey> readEffectsSet,
-                       Set<SESEEffectsKey> writeEffectsSet) {
+                       Set<SESEEffectsKey> writeEffectsSet, Set<Set> reachabilitySet) {
 
                String liveinNodeID = td + "_" + fsen.getIdentifier();
 
-               LiveInNode newNode = new LiveInNode(liveinNodeID, td, readEffectsSet,
-                               writeEffectsSet);
-               td2cn.put(liveinNodeID, newNode);
+               LiveInNode liveInNode = (LiveInNode) id2cn.get(liveinNodeID);
+               if (liveInNode != null) {
+                       liveInNode.addReadEffectsSet(readEffectsSet);
+                       liveInNode.addWriteEffectsSet(writeEffectsSet);
+                       liveInNode.addReachabilitySet(reachabilitySet);
+                       id2cn.put(liveinNodeID, liveInNode);
+               } else {
+                       LiveInNode newNode = new LiveInNode(liveinNodeID, td,
+                                       readEffectsSet, writeEffectsSet, reachabilitySet);
+                       id2cn.put(liveinNodeID, newNode);
+               }
+
+       }
+
+       public void addConflictEdge(int type, ConflictNode nodeU, ConflictNode nodeV) {
+
+               if (!nodeU.isConflictConnectedTo(nodeV)) {
+                       ConflictEdge newEdge = new ConflictEdge(nodeU, nodeV, type);
+                       nodeU.addEdge(newEdge);
+                       nodeV.addEdge(newEdge);
+               }
 
        }
 
@@ -70,10 +251,10 @@ public class ConflictGraph {
        public HashSet<LiveInNode> getLiveInNodeSet() {
                HashSet<LiveInNode> resultSet = new HashSet<LiveInNode>();
 
-               Set<String> keySet = td2cn.keySet();
+               Set<String> keySet = id2cn.keySet();
                for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
                        String key = (String) iterator.next();
-                       ConflictNode node = td2cn.get(key);
+                       ConflictNode node = id2cn.get(key);
 
                        if (node instanceof LiveInNode) {
                                resultSet.add((LiveInNode) node);
@@ -93,14 +274,23 @@ public class ConflictGraph {
 
                HashSet<HeapRegionNode> visited = new HashSet<HeapRegionNode>();
                // then visit every heap region node
-               Set<Entry<String, ConflictNode>> s = td2cn.entrySet();
+               Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
                Iterator<Entry<String, ConflictNode>> i = s.iterator();
-               
-               HashSet<ConflictEdge> addedSet=new HashSet<ConflictEdge>();
-               
+
+               HashSet<ConflictEdge> addedSet = new HashSet<ConflictEdge>();
+
                while (i.hasNext()) {
                        Entry<String, ConflictNode> entry = i.next();
                        ConflictNode node = entry.getValue();
+
+                       // if (node.getID().startsWith("___dst")
+                       // || node.getID().startsWith("___srctmp")
+                       // || node.getID().startsWith("___neverused")
+                       // || node.getID().startsWith("___temp")) {
+                       //                              
+                       // continue;
+                       // }
+
                        String attributes = "[";
 
                        attributes += "label=\"ID" + node.getID() + "\\n";
@@ -118,9 +308,22 @@ public class ConflictGraph {
 
                                ConflictNode u = conflictEdge.getVertexU();
                                ConflictNode v = conflictEdge.getVertexV();
-                               
+
+                               // String uID=u.getID();
+                               // String vID=v.getID();
+                               // if (uID.startsWith("___dst")
+                               // || uID.startsWith("___srctmp")
+                               // || uID.startsWith("___neverused")
+                               // || uID.startsWith("___temp")
+                               // || vID.startsWith("___dst")
+                               // || vID.startsWith("___srctmp")
+                               // || vID.startsWith("___neverused")
+                               // || vID.startsWith("___temp")) {
+                               // continue;
+                               // }
+
                                if (conflictEdge.getType() == ConflictEdge.WRITE_CONFLICT) {
-                                       if(!addedSet.contains(conflictEdge)){
+                                       if (!addedSet.contains(conflictEdge)) {
                                                bw.write(" " + u.getID() + "--" + v.getID()
                                                                + "[label=\""
                                                                + conflictEdge.toGraphEdgeString()
@@ -147,7 +350,8 @@ class ConflictEdge {
        private int type;
 
        public static final int WRITE_CONFLICT = 0;
-       public static final int REACH_CONFLICT = 1;
+       public static final int FINE_GRAIN_EDGE = 1;
+       public static final int COARSE_GRAIN_EDGE = 2;
 
        public ConflictEdge(ConflictNode u, ConflictNode v, int type) {
                this.u = u;
@@ -158,8 +362,10 @@ class ConflictEdge {
        public String toGraphEdgeString() {
                if (type == WRITE_CONFLICT) {
                        return "W_CONFLICT";
+               } else if (type == FINE_GRAIN_EDGE) {
+                       return "F_CONFLICT";
                } else {
-                       return "R_CONFLICT";
+                       return "C_CONFLICT";
                }
        }
 
@@ -170,8 +376,8 @@ class ConflictEdge {
        public ConflictNode getVertexV() {
                return v;
        }
-       
-       public int getType(){
+
+       public int getType() {
                return type;
        }
 
index 623def2f54aa0ccf0b558e324c57d375ee1c0939..d2ba07f0143f360cd77e098b4fb9adfc877acd21 100644 (file)
@@ -1,7 +1,10 @@
 package Analysis.MLP;
 
 import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
 
+import Analysis.OwnershipAnalysis.TokenTupleSet;
 import IR.Flat.TempDescriptor;
 
 public abstract class ConflictNode {
@@ -9,6 +12,7 @@ public abstract class ConflictNode {
        protected TempDescriptor td;
        protected String id;
        protected HashSet<ConflictEdge> edgeSet;
+       protected Set<Set> reachabilitySet;
 
        public ConflictNode() {
                edgeSet = new HashSet<ConflictEdge>();
@@ -22,6 +26,20 @@ public abstract class ConflictNode {
                return id;
        }
 
+       public boolean isConflictConnectedTo(ConflictNode node) {
+
+               for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) {
+                       ConflictEdge edge = (ConflictEdge) iterator.next();
+                       if (edge.getType() != ConflictEdge.WRITE_CONFLICT) {
+                               if (edge.getVertexU().equals(node)
+                                               || edge.getVertexV().equals(node)) {
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+
        public void addEdge(ConflictEdge edge) {
                edgeSet.add(edge);
        }
@@ -30,4 +48,8 @@ public abstract class ConflictNode {
                return edgeSet;
        }
 
+       public Set<Set> getReachabilitySet() {
+               return reachabilitySet;
+       }
+
 }
diff --git a/Robust/src/Analysis/MLP/GloballyUniqueTokenTuple.java b/Robust/src/Analysis/MLP/GloballyUniqueTokenTuple.java
new file mode 100644 (file)
index 0000000..adb270a
--- /dev/null
@@ -0,0 +1,65 @@
+package Analysis.MLP;
+
+import Analysis.OwnershipAnalysis.TokenTuple;
+
+public class GloballyUniqueTokenTuple {
+
+       private Integer token;
+       private boolean isMultiObject;
+       private int arity;
+       private String id;
+
+       public GloballyUniqueTokenTuple(String uniqueID, TokenTuple tt) {
+               this.id = uniqueID;
+               this.arity = tt.getArity();
+               this.token = tt.getToken();
+               this.isMultiObject = tt.isMultiObject();
+       }
+
+       public boolean isMultiObject() {
+               return isMultiObject;
+       }
+
+       public int getArity() {
+               return arity;
+       }
+
+       public int hashCode() {
+               return id.hashCode() + arity;
+       }
+
+       public String getID() {
+               return id;
+       }
+
+       public boolean equals(Object o) {
+               if (o == null) {
+                       return false;
+               }
+
+               if (!(o instanceof GloballyUniqueTokenTuple)) {
+                       return false;
+               }
+
+               GloballyUniqueTokenTuple tt = (GloballyUniqueTokenTuple) o;
+
+               return id.equals(tt.getID()) && arity == tt.getArity();
+       }
+
+       public String toString() {
+               String s = id;
+
+               if (isMultiObject) {
+                       s += "M";
+               }
+
+               if (arity == TokenTuple.ARITY_ZEROORMORE) {
+                       s += "*";
+               } else if (arity == TokenTuple.ARITY_ONEORMORE) {
+                       s += "+";
+               }
+
+               return s;
+       }
+
+}
index f2898219ea1d64d31cb6bb3c9f8274ac5edbb4c1..9d2b7abc3bec033933d51538dd57aab49ea8a79e 100644 (file)
@@ -14,11 +14,38 @@ public class LiveInNode extends ConflictNode {
 
        public LiveInNode(String id, TempDescriptor td,
                        Set<SESEEffectsKey> readEffectsSet,
-                       Set<SESEEffectsKey> writeEffectsSet) {
+                       Set<SESEEffectsKey> writeEffectsSet, Set<Set> reachabilitySet) {
                this.id = id;
                this.td = td;
                this.readEffectsSet = readEffectsSet;
                this.writeEffectsSet = writeEffectsSet;
+               this.reachabilitySet = reachabilitySet;
+       }
+
+       public Set<SESEEffectsKey> getReadEffectsSet() {
+               return readEffectsSet;
+       }
+
+       public Set<SESEEffectsKey> getWriteEffectsSet() {
+               return writeEffectsSet;
+       }
+
+       public void addReadEffectsSet(Set<SESEEffectsKey> newReadEffectsSet) {
+               if (newReadEffectsSet != null) {
+                       readEffectsSet.addAll(newReadEffectsSet);
+               }
+       }
+
+       public void addWriteEffectsSet(Set<SESEEffectsKey> newWriteEffectsSet) {
+               if (newWriteEffectsSet != null) {
+                       writeEffectsSet.addAll(newWriteEffectsSet);
+               }
+       }
+
+       public void addReachabilitySet(Set<Set> newReachabilitySet) {
+               if (newReachabilitySet != null) {
+                       reachabilitySet.addAll(newReachabilitySet);
+               }
        }
 
        public boolean isWriteConflictWith(StallSiteNode stallNode) {
@@ -105,4 +132,24 @@ public class LiveInNode extends ConflictNode {
                return result;
        }
 
+       public boolean equals(Object o) {
+
+               if (o == null) {
+                       return false;
+               }
+
+               if (!(o instanceof LiveInNode)) {
+                       return false;
+               }
+
+               LiveInNode in = (LiveInNode) o;
+
+               if (id.equals(in.id)) {
+                       return true;
+               } else {
+                       return false;
+               }
+
+       }
+
 }
index 437603ccb005f14b46b014aca1b1a0e2190cc23b..ed1d7aec87a028e6cac33f291595af95459c5dec 100644 (file)
@@ -27,6 +27,7 @@ import Analysis.OwnershipAnalysis.OwnershipNode;
 import Analysis.OwnershipAnalysis.ParameterDecomposition;
 import Analysis.OwnershipAnalysis.ReachabilitySet;
 import Analysis.OwnershipAnalysis.ReferenceEdge;
+import Analysis.OwnershipAnalysis.TokenTuple;
 import Analysis.OwnershipAnalysis.TokenTupleSet;
 import IR.Descriptor;
 import IR.FieldDescriptor;
@@ -38,6 +39,7 @@ import IR.Flat.FKind;
 import IR.Flat.FlatCall;
 import IR.Flat.FlatEdge;
 import IR.Flat.FlatFieldNode;
+import IR.Flat.FlatLiteralNode;
 import IR.Flat.FlatMethod;
 import IR.Flat.FlatNew;
 import IR.Flat.FlatNode;
@@ -1884,7 +1886,7 @@ public class MLPAnalysis {
 
                return sorted;
        }
-        
+        /*
        private void postSESEConflictsForward(JavaCallGraph javaCallGraph) {
 
                // store the reachability set in stall site data structure
@@ -1978,7 +1980,7 @@ public class MLPAnalysis {
                }
 
        }
-       
+       */
        private void postConflicts_nodeAction(MethodContext mc, FlatNode fn,
                        ParentChildConflictsMap currentConflictsMap) {
                
@@ -2033,112 +2035,179 @@ public class MLPAnalysis {
                // create conflict graph for each flat method
                ConflictGraph conflictGraph = new ConflictGraph();
 
-               Set<FlatNode> flatNodesToVisit = new HashSet<FlatNode>();
-               flatNodesToVisit.add(fm);
-
-               Set<FlatNode> visited = new HashSet<FlatNode>();
+               HashSet<MethodContext> mcSet = ownAnalysisForSESEConflicts
+                               .getAllMethodContextSetByDescriptor(fm.getMethod());
+               Iterator<MethodContext> mcIter = mcSet.iterator();
 
-               while (!flatNodesToVisit.isEmpty()) {
-                       Iterator<FlatNode> fnItr = flatNodesToVisit.iterator();
-                       FlatNode fn = fnItr.next();
+               while (mcIter.hasNext()) {
+                       MethodContext mc = mcIter.next();
 
-                       flatNodesToVisit.remove(fn);
-                       visited.add(fn);
+                       Set<FlatNode> flatNodesToVisit = new HashSet<FlatNode>();
+                       flatNodesToVisit.add(fm);
 
-                       // ///////////////////////////////////////////////////////////////////////
-                       // Adding Stall Node of current program statement
-                       ParentChildConflictsMap currentConflictsMap = conflictsResults
-                                       .get(fn);
+                       Set<FlatNode> visited = new HashSet<FlatNode>();
 
-                       Hashtable<TempDescriptor, StallSite> stallMap = currentConflictsMap
-                                       .getStallMap();
-                       Set<Entry<TempDescriptor, StallSite>> entrySet = stallMap
-                                       .entrySet();
+                       while (!flatNodesToVisit.isEmpty()) {
+                               Iterator<FlatNode> fnItr = flatNodesToVisit.iterator();
+                               FlatNode fn = fnItr.next();
 
-                       HashSet<String> newStallNodeSet = new HashSet<String>();
+                               flatNodesToVisit.remove(fn);
+                               visited.add(fn);
 
-                       for (Iterator<Entry<TempDescriptor, StallSite>> iterator2 = entrySet
-                                       .iterator(); iterator2.hasNext();) {
-                               Entry<TempDescriptor, StallSite> entry = iterator2.next();
-                               TempDescriptor td = entry.getKey();
-                               StallSite stallSite = entry.getValue();
-                               String stallNodeID;
-                               if ((stallNodeID = conflictGraph
-                                               .addStallNode(td, fm, stallSite)) != null) {
-                                       // it added new stall node
-                                       newStallNodeSet.add(stallNodeID);
+                               // ///////////////////////////////////////////////////////////////////////
+                               // Adding Stall Node of current program statement
+                               ParentChildConflictsMap currentConflictsMap = conflictsResults
+                                               .get(fn);
+
+                               Hashtable<TempDescriptor, StallSite> stallMap = currentConflictsMap
+                                               .getStallMap();
+                               Set<Entry<TempDescriptor, StallSite>> entrySet = stallMap
+                                               .entrySet();
+
+                               HashSet<String> newStallNodeSet = new HashSet<String>();
+
+                               for (Iterator<Entry<TempDescriptor, StallSite>> iterator2 = entrySet
+                                               .iterator(); iterator2.hasNext();) {
+                                       Entry<TempDescriptor, StallSite> entry = iterator2.next();
+                                       TempDescriptor td = entry.getKey();
+                                       StallSite stallSite = entry.getValue();
+                                       String stallNodeID;
+
+                                       // reachability set
+                                       OwnershipGraph og = ownAnalysisForSESEConflicts
+                                                       .getOwnvershipGraphByMethodContext(mc);
+                                       Set<Set> reachabilitySet = calculateReachabilitySet(og, td);
+
+                                       if ((stallNodeID = conflictGraph.addStallNode(td, fm,
+                                                       stallSite, reachabilitySet)) != null) {
+                                               // it added new stall node
+                                               newStallNodeSet.add(stallNodeID);
+                                       }
                                }
-                       }
 
-                       // Analyzing write conflicts between stall site and live-in
-                       // variables
-                       for (Iterator iterator = newStallNodeSet.iterator(); iterator
-                                       .hasNext();) {
-                               String stallNodeID = (String) iterator.next();
-
-                               StallSiteNode stallNode = conflictGraph
-                                               .getStallNode(stallNodeID);
-
-                               if (stallNode != null) {
-                                       // if prior sese blocks have write effects on this stall
-                                       // node, it should be connected between them.
-                                       HashSet<LiveInNode> liveInNodeSet = conflictGraph
-                                                       .getLiveInNodeSet();
-                                       for (Iterator iterator2 = liveInNodeSet.iterator(); iterator2
-                                                       .hasNext();) {
-                                               LiveInNode liveInNode = (LiveInNode) iterator2.next();
-                                               if (liveInNode.isWriteConflictWith(stallNode)) {
-                                                       // create conflict edge
-                                                       conflictGraph.addWriteConflictEdge(stallNode, liveInNode);
+                               // Analyzing write conflicts between stall site and live-in
+                               // variables
+                               for (Iterator iterator = newStallNodeSet.iterator(); iterator
+                                               .hasNext();) {
+                                       String stallNodeID = (String) iterator.next();
+
+                                       StallSiteNode stallNode = conflictGraph
+                                                       .getStallNode(stallNodeID);
+
+                                       if (stallNode != null) {
+                                               // if prior sese blocks have write effects on this stall
+                                               // node, it should be connected between them.
+                                               HashSet<LiveInNode> liveInNodeSet = conflictGraph
+                                                               .getLiveInNodeSet();
+                                               for (Iterator iterator2 = liveInNodeSet.iterator(); iterator2
+                                                               .hasNext();) {
+                                                       LiveInNode liveInNode = (LiveInNode) iterator2
+                                                                       .next();
+                                                       if (liveInNode.isWriteConflictWith(stallNode)) {
+                                                               // create conflict edge
+                                                               conflictGraph.addWriteConflictEdge(stallNode,
+                                                                               liveInNode);
+                                                       }
                                                }
                                        }
                                }
-                       }
 
-                       // ///////////////////////////////////////////////////////////////////////
+                               // ///////////////////////////////////////////////////////////////////////
 
-                       conflictGraph_nodeAction(fm, fn, conflictGraph, currentConflictsMap);
+                               conflictGraph_nodeAction(mc, fm, fn, conflictGraph,
+                                               currentConflictsMap);
 
-                       for (int i = 0; i < fn.numNext(); i++) {
-                               FlatNode nn = fn.getNext(i);
-                               if (!visited.contains(nn)) {
-                                       flatNodesToVisit.add(nn);
+                               for (int i = 0; i < fn.numNext(); i++) {
+                                       FlatNode nn = fn.getNext(i);
+                                       if (!visited.contains(nn)) {
+                                               flatNodesToVisit.add(nn);
+                                       }
                                }
-                       }
-               }
+
+                       } // end of while(flatNodesToVisit)
+
+               } // end of while(mcIter)
+
+               // decide fine-grain edge or coarse-grain edge among all vertexes
+               conflictGraph.analyzeConflicts();
 
                conflictGraphResults.put(fm, conflictGraph);
 
        }
        
-       private void conflictGraph_nodeAction(FlatMethod fm, FlatNode fn,
-                       ConflictGraph graph, ParentChildConflictsMap currentConflictsMap) {
+       private Set<Set> calculateReachabilitySet(OwnershipGraph og, TempDescriptor tempDescriptor){
+               // reachability set
+               Set<Set> reachabilitySet = new HashSet();
+               LabelNode ln = og.td2ln.get(tempDescriptor);
+               Iterator<ReferenceEdge> refEdgeIter = ln
+                               .iteratorToReferencees();
+               while (refEdgeIter.hasNext()) {
+                       ReferenceEdge referenceEdge = (ReferenceEdge) refEdgeIter
+                                       .next();
+                       ReachabilitySet set = referenceEdge.getBeta();
+                       Iterator<TokenTupleSet> ttsIter = set.iterator();
+                       while (ttsIter.hasNext()) {
+                               TokenTupleSet tokenTupleSet = (TokenTupleSet) ttsIter
+                                               .next();
+
+                               HashSet<GloballyUniqueTokenTuple> newTokenTupleSet = new HashSet<GloballyUniqueTokenTuple>();
+                               // reachabilitySet.add(tokenTupleSet);
+
+                               Iterator iter = tokenTupleSet.iterator();
+                               while (iter.hasNext()) {
+                                       TokenTuple tt = (TokenTuple) iter.next();
+                                       int token = tt.getToken();
+                                       String uniqueID = og.id2hrn.get(
+                                                       new Integer(token))
+                                                       .getGloballyUniqueIdentifier();
+                                       GloballyUniqueTokenTuple gtt = new GloballyUniqueTokenTuple(
+                                                       uniqueID, tt);
+                                       newTokenTupleSet.add(gtt);
+                               }
+
+                               reachabilitySet.add(newTokenTupleSet);
+                       }
+               }
+               return reachabilitySet;
+       }
+       
+       private void conflictGraph_nodeAction(MethodContext mc, FlatMethod fm, FlatNode fn,
+ ConflictGraph graph,
+                       ParentChildConflictsMap currentConflictsMap) {
 
                switch (fn.kind()) {
 
                case FKind.FlatSESEEnterNode: {
 
                        FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn;
+                       OwnershipGraph og = ownAnalysisForSESEConflicts
+                                       .getOwnvershipGraphByMethodContext(mc);
 
                        if (!fsen.getIsCallerSESEplaceholder()) {
                                Set<TempDescriptor> invar_set = fsen.getInVarSet();
 
-                               String liveinStr = "";
-
                                for (Iterator iterator = invar_set.iterator(); iterator
                                                .hasNext();) {
                                        TempDescriptor tempDescriptor = (TempDescriptor) iterator
                                                        .next();
-                                       
+
+                                       // effects set
                                        SESEEffectsSet seseEffectsSet = fsen.getSeseEffectsSet();
-                                       Set<SESEEffectsKey> readEffectsSet=seseEffectsSet.getReadingSet(tempDescriptor);
-                                       Set<SESEEffectsKey> writeEffectsSet=seseEffectsSet.getWritingSet(tempDescriptor);
-                                       
-                                       graph.addLiveInNode(tempDescriptor,fsen,readEffectsSet,writeEffectsSet);
+                                       Set<SESEEffectsKey> readEffectsSet = seseEffectsSet
+                                                       .getReadingSet(tempDescriptor);
+                                       Set<SESEEffectsKey> writeEffectsSet = seseEffectsSet
+                                                       .getWritingSet(tempDescriptor);
+
+                                       Set<Set> reachabilitySet=calculateReachabilitySet(og,tempDescriptor);
+
+                                       // add new live-in node
+                                       graph.addLiveInNode(tempDescriptor, fsen, readEffectsSet,
+                                                       writeEffectsSet, reachabilitySet);
+
                                }
 
                        }
-                       
+
                }
 
                        break;
@@ -2358,9 +2427,10 @@ public class MLPAnalysis {
                                                        }
                                                }
 
-                                       }else{
-                                               System.out.println("src is accessible="+possibleSrc);
                                        }
+//                                     else{
+//                                             System.out.println("src is accessible="+possibleSrc);
+//                                     }
 
                                        currentConflictsMap.addAccessibleVar(possibleSrc);
 
@@ -2665,6 +2735,18 @@ public class MLPAnalysis {
                }
                        break;
 
+               /* do we need this case? 
+               case FKind.FlatLiteralNode: {
+
+                       if (currentConflictsMap.isAfterChildSESE()) {
+                               FlatLiteralNode fln = (FlatLiteralNode) fn;
+                               TempDescriptor dst = fln.getDst();
+                               currentConflictsMap.addAccessibleVar(dst);
+                       }
+
+               } break;
+               */
+
                case FKind.FlatReturnNode: {
 
                        FlatReturnNode frn = (FlatReturnNode) fn;
index e5d5742168ed3521610f66e6b592ea5d775a03e3..5797028a1e74d23b538f43e244f151e1d82be0d0 100644 (file)
@@ -1,25 +1,29 @@
 package Analysis.MLP;
 
 import java.util.HashSet;
+import java.util.Set;
 
 import Analysis.OwnershipAnalysis.HeapRegionNode;
+import Analysis.OwnershipAnalysis.TokenTupleSet;
 import IR.Flat.TempDescriptor;
 
 public class StallSiteNode extends ConflictNode {
 
        protected StallSite stallSite;
 
-       public StallSiteNode(String id, TempDescriptor td, StallSite stallSite) {
+       public StallSiteNode(String id, TempDescriptor td, StallSite stallSite,
+                       Set<Set> reachabilitySet) {
                this.id = id;
                this.td = td;
                this.stallSite = stallSite;
+               this.reachabilitySet = reachabilitySet;
        }
-       
-       public HashSet<HeapRegionNode> getHRNSet(){
+
+       public HashSet<HeapRegionNode> getHRNSet() {
                return stallSite.getHRNSet();
        }
-       
-       public StallSite getStallSite(){
+
+       public StallSite getStallSite() {
                return stallSite;
        }