bring a snapshot before further changes of memory queue(OID and multiple enqueue...
authoryeom <yeom>
Mon, 3 May 2010 18:52:49 +0000 (18:52 +0000)
committeryeom <yeom>
Mon, 3 May 2010 18:52:49 +0000 (18:52 +0000)
13 files changed:
Robust/src/Analysis/MLP/ConflictGraph.java
Robust/src/Analysis/MLP/GloballyUniqueTokenTuple.java
Robust/src/Analysis/MLP/MLPAnalysis.java
Robust/src/Analysis/MLP/SESEEffectsKey.java
Robust/src/Analysis/MLP/SESEEffectsSet.java
Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/Runtime/garbage.c
Robust/src/Runtime/garbage.h
Robust/src/Runtime/mlp_runtime.c
Robust/src/Runtime/mlp_runtime.h
Robust/src/Runtime/workschedule.c
Robust/src/Runtime/workschedule.h

index bb67390d4ad6885a4145fee2e82658d4de27ef4c..3903a2cf66fa485a3b046401a692bd00dae8be60 100644 (file)
@@ -10,30 +10,35 @@ import java.util.Set;
 import java.util.Map.Entry;
 
 import Analysis.OwnershipAnalysis.HeapRegionNode;
+import Analysis.OwnershipAnalysis.OwnershipGraph;
+import Analysis.OwnershipAnalysis.ReachabilitySet;
+import Analysis.OwnershipAnalysis.TokenTuple;
 import IR.Flat.FlatMethod;
 import IR.Flat.FlatSESEEnterNode;
 import IR.Flat.TempDescriptor;
 
 public class ConflictGraph {
-       
+
        static private int uniqueCliqueIDcount = 100;
 
        public Hashtable<String, ConflictNode> id2cn;
+       private OwnershipGraph og;
 
-       public ConflictGraph() {
+       public ConflictGraph(OwnershipGraph og) {
                id2cn = new Hashtable<String, ConflictNode>();
+               this.og = og;
        }
-       
-       public boolean hasConflictEdge(){
-               
-               Set<String> keySet=id2cn.keySet();
+
+       public boolean hasConflictEdge() {
+
+               Set<String> keySet = id2cn.keySet();
                for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
                        String key = (String) iterator.next();
-                       ConflictNode node=id2cn.get(key);
-                       if(node.getEdgeSet().size()>0){
+                       ConflictNode node = id2cn.get(key);
+                       if (node.getEdgeSet().size() > 0) {
                                return true;
                        }
-               }               
+               }
                return false;
        }
 
@@ -49,574 +54,25 @@ public class ConflictGraph {
                }
        }
 
-       private boolean isWriteConflicts(StallSiteNode nodeA, LiveInNode nodeB) {
-
-               boolean result = false;
-               StallSite stallSite = nodeA.getStallSite();
-
-               Set<SESEEffectsKey> writeEffectsSet = nodeB.getWriteEffectsSet();
-               Set<SESEEffectsKey> readEffectsSet = nodeB.getReadEffectsSet();
-
-               if (writeEffectsSet != null) {
-                       Iterator<SESEEffectsKey> writeIter = writeEffectsSet.iterator();
-                       while (writeIter.hasNext()) {
-                               SESEEffectsKey seseEffectsKey = (SESEEffectsKey) writeIter
-                                               .next();
-                               String writeHeapRegionID = seseEffectsKey.getHRNUniqueId();
-                               String writeFieldName = seseEffectsKey.getFieldDescriptor();
-                               
-                               if(writeFieldName.length()>0){
-                                       HashSet<HeapRegionNode> stallSiteHRNSet = nodeA.getHRNSet();
-                                       for (Iterator iterator = stallSiteHRNSet.iterator(); iterator
-                                                       .hasNext();) {
-                                               HeapRegionNode stallHRN = (HeapRegionNode) iterator.next();
-                                               if (stallHRN.getGloballyUniqueIdentifier().equals(
-                                                               writeHeapRegionID)) {
-
-                                                       // check whether there are read or write effects of
-                                                       // stall sites
-
-                                                       HashSet<Effect> effectSet = stallSite.getEffectSet();
-                                                       for (Iterator iterator2 = effectSet.iterator(); iterator2
-                                                                       .hasNext();) {
-                                                               Effect effect = (Effect) iterator2.next();
-                                                               String stallEffectfieldName = effect.getField();
-
-                                                               if (stallEffectfieldName.equals(writeFieldName)) {
-                                                                       result = result | true;
-                                                               }
-                                                       }
-
-                                               }
-                                       }
-                               }else{
-                                       // no field name
-                                       
-                                       HashSet<Effect> effectSet = stallSite.getEffectSet();
-                                       for (Iterator iterator2 = effectSet.iterator(); iterator2
-                                                       .hasNext();) {
-                                               Effect effect = (Effect) iterator2.next();
-                                               String stallEffectfieldName = effect.getField();
-
-                                               if (stallEffectfieldName.length()==0 && nodeB.getTempDescriptor().equals(nodeA.getStallSite().getTdA())) {
-                                                       result = result | true;
-                                               }
-                                       }
-                                       
-                               }
-
-                       }
-
-               }
-
-               if (readEffectsSet != null) {
-                       Iterator<SESEEffectsKey> readIter = readEffectsSet.iterator();
-                       while (readIter.hasNext()) {
-
-                               SESEEffectsKey seseEffectsKey = (SESEEffectsKey) readIter
-                                               .next();
-                               String readHeapRegionID = seseEffectsKey.getHRNUniqueId();
-                               String readFieldName = seseEffectsKey.getFieldDescriptor();
-
-                               if(readFieldName.length()>0){
-                                       HashSet<HeapRegionNode> stallSiteHRNSet = nodeA.getHRNSet();
-                                       for (Iterator iterator = stallSiteHRNSet.iterator(); iterator
-                                                       .hasNext();) {
-                                               HeapRegionNode stallHRN = (HeapRegionNode) iterator.next();
-                                               if (stallHRN.getGloballyUniqueIdentifier().equals(
-                                                               readHeapRegionID)) {
-
-                                                       HashSet<Effect> effectSet = stallSite.getEffectSet();
-                                                       for (Iterator iterator2 = effectSet.iterator(); iterator2
-                                                                       .hasNext();) {
-                                                               Effect effect = (Effect) iterator2.next();
-                                                               String stallEffectfieldName = effect.getField();
-
-                                                               if (effect.getEffectType().equals(
-                                                                               StallSite.WRITE_EFFECT)) {
-                                                                       if (stallEffectfieldName.equals(readFieldName)) {
-                                                                               result = result | true;
-                                                                       }
-                                                               }
-
-                                                       }
-
-                                               }
-
-                                       }
-                               }else{
-                                       //no field
-                                       HashSet<Effect> effectSet = stallSite.getEffectSet();
-                                       for (Iterator iterator2 = effectSet.iterator(); iterator2
-                                                       .hasNext();) {
-                                               Effect effect = (Effect) iterator2.next();
-                                               String stallEffectfieldName = effect.getField();
-
-                                               if (effect.getEffectType().equals(
-                                                               StallSite.WRITE_EFFECT)) {
-                                                       if (stallEffectfieldName.length()==0 && nodeB.getTempDescriptor().equals(nodeA.getStallSite().getTdA())) {
-                                                               result = result | true;
-                                                       }
-                                               }
-
-                                       }
-                               }
-
-
-                       }
-
-               }
-
-               return result;
-       }
-
-       private int determineWriteConflictsType(LiveInNode liveInNodeA,
-                       LiveInNode liveInNodeB) {
-               
-               if(liveInNodeA.getSESEIdentifier()==liveInNodeB.getSESEIdentifier()){
-                       return ConflictEdge.NON_WRITE_CONFLICT;
-               }
-
-               Set<HeapRegionNode> liveInHrnSetA = liveInNodeA.getHRNSet();
-               Set<HeapRegionNode> liveInHrnSetB = liveInNodeB.getHRNSet();
-
-               boolean isPointingToSameRegion = compareHRNSet(liveInHrnSetA,
-                               liveInHrnSetB);
-
-               boolean isSharingReachability = false;
-
-               Set<Set> liveInNodeReachabilitySetA = liveInNodeA.getReachabilitySet();
-               Set<Set> liveInNodeReachabilitySetB = liveInNodeB.getReachabilitySet();
-
-               Set<GloballyUniqueTokenTuple> overlappedReachableRegionSet = calculateOverlappedReachableRegion(
-                               liveInNodeReachabilitySetA, liveInNodeReachabilitySetB);
-               if (overlappedReachableRegionSet.size() > 0) {
-                       isSharingReachability = true;
-               }
-
-               if (isPointingToSameRegion && isSharingReachability) {
-                       // two node share same reachability and points to same region, then
-                       // it is fine grain conflicts
-                       return ConflictEdge.FINE_GRAIN_EDGE;
-               } else if (isSharingReachability) {
-                       // two node share same reachability but points to different region,
-                       // then it is coarse grain conflicts
-//                     System.out.println("##coarse:");
-//                     System.out.println(liveInNodeA.getSESEIdentifier()+" <-> "+liveInNodeB.getSESEIdentifier());
-//                     System.out.println(liveInNodeA.getID()+" <-> "+liveInNodeB.getID());
-//                     System.out.println("--");
-                       return ConflictEdge.COARSE_GRAIN_EDGE;
-               } else {
-                       // otherwise, it is not write conflicts
-                       return ConflictEdge.NON_WRITE_CONFLICT;
-               }
-
-       }
-
        private boolean compareHRNSet(Set<HeapRegionNode> setA,
                        Set<HeapRegionNode> setB) {
-
-               for (Iterator iterator = setA.iterator(); iterator.hasNext();) {
-                       HeapRegionNode heapRegionNode = (HeapRegionNode) iterator.next();
-                       String gID = heapRegionNode.getGloballyUniqueIdentifier();
-                       boolean found = false;
-                       for (Iterator iterator2 = setB.iterator(); iterator2.hasNext();) {
-                               HeapRegionNode heapRegionNode2 = (HeapRegionNode) iterator2
-                                               .next();
-                               if (heapRegionNode2.getGloballyUniqueIdentifier().equals(gID)) {
-                                       found = true;
-                               }
-                       }
-                       if (!found) {
-                               return false;
-                       }
-               }
-               return true;
-       }
-
-       private int determineWriteConflictsType(StallSiteNode stallNode,
-                       LiveInNode liveInNode) {
-
-               Set<HeapRegionNode> stallHrnSet = stallNode.getHRNSet();
-               Set<HeapRegionNode> liveInHrnSet = liveInNode.getHRNSet();
-
-               boolean isPointingToSameRegion = compareHRNSet(stallHrnSet,
-                               liveInHrnSet);
-
-               boolean isSharingReachability = false;
-
-               Set<Set> stallNodeReachabilitySet = stallNode.getReachabilitySet();
-               Set<Set> liveInNodeReachabilitySet = liveInNode.getReachabilitySet();
-
-               Set<GloballyUniqueTokenTuple> overlappedReachableRegionSet = calculateOverlappedReachableRegion(
-                               stallNodeReachabilitySet, liveInNodeReachabilitySet);
-               if (overlappedReachableRegionSet.size() > 0) {
-                       isSharingReachability = true;
-               }
-
-               if (isPointingToSameRegion && isSharingReachability) {
-                       // two node share same reachability and points to same region, then
-                       // it is fine grain conflicts
-                       return ConflictEdge.FINE_GRAIN_EDGE;
-               } else if (isSharingReachability) {
-                       // two node share same reachability but points to different region,
-                       // then it is coarse grain conflicts
-                       return ConflictEdge.COARSE_GRAIN_EDGE;
-               } else {
-                       // otherwise, it is not write conflicts
-                       return ConflictEdge.NON_WRITE_CONFLICT;
-               }
-
-       }
-
-       private boolean hasStrongUpdate(SESEEffectsKey writeEffect,
-                       Set<SESEEffectsKey> strongUpdateSet) {
-               
-               if(strongUpdateSet!=null){
-                       Iterator<SESEEffectsKey> strongUpdateIter = strongUpdateSet.iterator();
-                       while (strongUpdateIter.hasNext()) {
-                               SESEEffectsKey strongEffect = (SESEEffectsKey) strongUpdateIter
-                                               .next();
-
-                               if (strongEffect.getHRNUniqueId().equals(
-                                               writeEffect.getHRNUniqueId())
-                                               && strongEffect.getFieldDescriptor().equals(
-                                                               writeEffect.getFieldDescriptor())) {
-                                       return true;
-                               }
-                       }
-               }
-
-               return false;
-       }
-
-       private boolean isWriteConflicts(LiveInNode nodeA, LiveInNode nodeB) {
-
-               Set<SESEEffectsKey> readEffectsSetA = nodeA.getReadEffectsSet();
-               Set<SESEEffectsKey> writeEffectsSetA = nodeA.getWriteEffectsSet();
-               Set<SESEEffectsKey> strongUpdateSetA = nodeA.getStrongUpdateSet();
-
-               Set<SESEEffectsKey> readEffectsSetB = nodeB.getReadEffectsSet();
-               Set<SESEEffectsKey> writeEffectsSetB = nodeB.getWriteEffectsSet();
-               Set<SESEEffectsKey> strongUpdateSetB = nodeB.getStrongUpdateSet();
-               
-               boolean result=false;
-               /*
-               System.out.println("nodeA="+nodeA);
-               System.out.println("readEffectsSetA="+readEffectsSetA);
-               System.out.println("writeEffectsSetA="+writeEffectsSetA);
-               System.out.println("strongUpdateSetA="+strongUpdateSetA);
-               System.out.println("nodeB="+nodeB);
-               System.out.println("readEffectsSetB="+readEffectsSetB);
-               System.out.println("writeEffectsSetB="+writeEffectsSetB);
-               System.out.println("strongUpdateSetB="+strongUpdateSetB);
-               System.out.println("--");
-               */
-               
-               // if node A has write effects on reading/writing regions of node B
-               if (writeEffectsSetA != null) {
-                       Iterator<SESEEffectsKey> writeIterA = writeEffectsSetA.iterator();
-                       while (writeIterA.hasNext()) {
-                               SESEEffectsKey seseEffectsKey = (SESEEffectsKey) writeIterA
-                                               .next();
-
-//                             if (!hasStrongUpdate(seseEffectsKey, strongUpdateSetA)) {
-
-                                       String writeHeapRegionID = seseEffectsKey.getHRNUniqueId();
-                                       String writeFieldName = seseEffectsKey.getFieldDescriptor();
-
-                                       if (readEffectsSetB != null) {
-                                               
-                                               if(writeFieldName.length()>0){
-                                                       Iterator<SESEEffectsKey> readIterB = readEffectsSetB
-                                                                       .iterator();
-                                                       while (readIterB.hasNext()) {
-                                                               SESEEffectsKey readingEffect = (SESEEffectsKey) readIterB
-                                                                               .next();
-
-                                                               if (readingEffect.getHRNUniqueId().equals(
-                                                                               writeHeapRegionID)
-                                                                               && readingEffect.getFieldDescriptor()
-                                                                                               .equals(writeFieldName)) {
-                                                                       result = result | true;
-                                                               }
-                                                       }
-                                               }else{
-                                                       //no field name
-                                                       Iterator<SESEEffectsKey> readIterB = readEffectsSetB
-                                                       .iterator();
-                                                       while (readIterB.hasNext()) {
-                                                               SESEEffectsKey readingEffect = (SESEEffectsKey) readIterB
-                                                               .next();
-
-                                                               if (readingEffect.getFieldDescriptor().length()==0 && nodeA.getTempDescriptor().equals(nodeB.getTempDescriptor())) {
-                                                                       result = result | true;
-                                                               }
-                                                       }
-                                                       
-                                               }
-       
-                                       }
-
-                                       if (writeEffectsSetB != null) {
-                                               Iterator<SESEEffectsKey> writeIterB = writeEffectsSetB
-                                                               .iterator();
-                                               while (writeIterB.hasNext()) {
-                                                       SESEEffectsKey writingEffect = (SESEEffectsKey) writeIterB
-                                                                       .next();
-                                                       
-                                                       if(writeFieldName.length()>0){
-                                                               if (writingEffect.getHRNUniqueId().equals(
-                                                                               writeHeapRegionID)
-                                                                               && writingEffect.getFieldDescriptor()
-                                                                                               .equals(writeFieldName)) {
-                                                                       result = result | true;
-                                                               }
-                                                       }else{
-                                                               //no field
-                                                               if (writingEffect.getFieldDescriptor().length()==0 && nodeA.getTempDescriptor().equals(nodeB.getTempDescriptor())) {
-                                                                       result = result | true;
-                                                               }
-                                                       }
-
-
-                                               }
-                                       }
-
-//                             } // end of if(hasStrong)
-
-                       }
-               }
-
-               // if node B has write effects on reading regions of node A
-               if (writeEffectsSetB != null) {
-                       Iterator<SESEEffectsKey> writeIterB = writeEffectsSetB.iterator();
-                       while (writeIterB.hasNext()) {
-                               SESEEffectsKey seseEffectsKey = (SESEEffectsKey) writeIterB
-                                               .next();
-
-                               //if (!hasStrongUpdate(seseEffectsKey, strongUpdateSetB)) {
-
-                                       String writeHeapRegionID = seseEffectsKey.getHRNUniqueId();
-                                       String writeFieldName = seseEffectsKey.getFieldDescriptor();
-
-                                       if (readEffectsSetA != null) {
-                                               Iterator<SESEEffectsKey> readIterA = readEffectsSetA
-                                                               .iterator();
-                                               while (readIterA.hasNext()) {
-                                                       SESEEffectsKey readingEffect = (SESEEffectsKey) readIterA
-                                                                       .next();
-                                                       
-                                                       if(writeFieldName.length()>0){
-                                                               if (readingEffect.getHRNUniqueId().equals(
-                                                                               writeHeapRegionID)
-                                                                               && readingEffect.getFieldDescriptor()
-                                                                                               .equals(writeFieldName)) {
-                                                                       result = result | true;
-                                                               }
-                                                       }else{
-                                                               if (readingEffect.getFieldDescriptor().length()==0 && nodeA.getTempDescriptor().equals(nodeB.getTempDescriptor())) {
-                                                                       result = result | true;
-                                                               }
-                                                       }
-
-                                               }
-                                       }
-
-                                       if (writeEffectsSetA != null) {
-                                               Iterator<SESEEffectsKey> writeIterA = writeEffectsSetA
-                                                               .iterator();
-                                               while (writeIterA.hasNext()) {
-                                                       SESEEffectsKey writingEffect = (SESEEffectsKey) writeIterA
-                                                                       .next();
-                                                       
-                                                       if(writeFieldName.length()>0){
-                                                               if (writingEffect.getHRNUniqueId().equals(
-                                                                               writeHeapRegionID)
-                                                                               && writingEffect.getFieldDescriptor()
-                                                                                               .equals(writeFieldName)) {
-                                                                       result = result | true;
-                                                               }
-                                                       }else{
-                                                               if (writingEffect.getFieldDescriptor().length()==0 && nodeA.getTempDescriptor().equals(nodeB.getTempDescriptor())) {
-                                                                       result = result | true;
-                                                               }
-                                                       }
-
-                                               }
-                                       }
-                               //} // if(hasStrong)
-
-                       }
-               }
-               return result;
-       }
-
-       private boolean isSelfConflicted(LiveInNode liveInNode) {
-
-               int strongUpdateCount = 0;
-
-               if (liveInNode.getWriteEffectsSet() != null
-                               && liveInNode.getWriteEffectsSet().size() > 0) {
-
-                       Set<SESEEffectsKey> strongUpdateSet = liveInNode
-                                       .getStrongUpdateSet();
-
-                       Iterator<SESEEffectsKey> writeIter = liveInNode
-                                       .getWriteEffectsSet().iterator();
-                       while (writeIter.hasNext()) {
-                               SESEEffectsKey writeEffect = (SESEEffectsKey) writeIter.next();
-                               if (hasStrongUpdate(writeEffect, strongUpdateSet)) {
-                                       strongUpdateCount++;
-                               }
-                               
-                               if(writeEffect.isStrong()){
-                                       return false;
-                               }
-                       }
-
-
-                       if (liveInNode.getWriteEffectsSet().size() == strongUpdateCount) {
-                               return false;
-                       }else{
-                               return true;
-                       }
-
-               }
-
-               return false;
-       }
-       
-       private boolean isSCC(LiveInNode liveInNode){
-               
-               Set<HeapRegionNode> liveInHrnSet = liveInNode.getHRNSet();
-//             for (Iterator iterator = liveInHrnSet.iterator(); iterator.hasNext();) {
-//                     HeapRegionNode heapRegionNode = (HeapRegionNode) iterator.next();
-//                     System.out.println("hrn="+heapRegionNode.getGloballyUniqueIdentifier());
-//             }               
-               
-               Set<Set> liveInNodeReachabilitySet = liveInNode.getReachabilitySet();
-               Set<GloballyUniqueTokenTuple> overlappedReachableRegionSet = calculateOverlappedReachableRegion(liveInNodeReachabilitySet,liveInNodeReachabilitySet);
-               
-               if(liveInHrnSet.size()>1){
-                       if(overlappedReachableRegionSet.size()>0){
-                               return true;
-                       }
-               }
-               
-               return false;
-       }
-
-       public void analyzePossibleConflicts(Set<String> analyzedIDSet,
-                       ConflictNode currentNode) {
-
-               // compare with all nodes
-
-               // examine the case where self-edge exists
-               if (currentNode instanceof LiveInNode) {
-                       LiveInNode liveInNode = (LiveInNode) currentNode;
-//                     if (liveInNode.getWriteEffectsSet() != null
-//                                     && liveInNode.getWriteEffectsSet().size() > 0) {
-//                             addConflictEdge(ConflictEdge.FINE_GRAIN_EDGE, currentNode,
-//                                             currentNode);
-//                     }
-                       if(isSCC(liveInNode)){
-                               addConflictEdge(ConflictEdge.COARSE_GRAIN_EDGE, currentNode,
-                                               currentNode);
-                       }else if(isSelfConflicted(liveInNode)){                         
-                               addConflictEdge(ConflictEdge.FINE_GRAIN_EDGE, currentNode,
-                                               currentNode);
-                       }
-                       
-               }
-
-               Set<Entry<String, ConflictNode>> set = id2cn.entrySet();
-               for (Iterator iterator = set.iterator(); iterator.hasNext();) {
-                       Entry<String, ConflictNode> entry = (Entry<String, ConflictNode>) iterator
-                                       .next();
-
-                       String entryNodeID = entry.getKey();
-                       ConflictNode entryNode = entry.getValue();
-
-                       if ((!currentNode.getID().equals(entryNodeID))
-                                       && !(analyzedIDSet.contains(currentNode.getID()
-                                                       + entryNodeID) || analyzedIDSet
-                                                       .contains(entryNodeID + currentNode.getID()))) {
-
-                               if (currentNode instanceof StallSiteNode
-                                               && entryNode instanceof LiveInNode) {
-                                       if (isWriteConflicts((StallSiteNode) currentNode,
-                                                       (LiveInNode) entryNode)) {
-                                               int conflictType = determineWriteConflictsType(
-                                                               (StallSiteNode) currentNode,
-                                                               (LiveInNode) entryNode);
-                                               if (conflictType > 0) {
-                                                       addConflictEdge(conflictType, currentNode,
-                                                                       entryNode);
-                                               }
-                                       }
-                                       analyzedIDSet.add(currentNode.getID() + entryNodeID);
-
-                               } else if (currentNode instanceof LiveInNode
-                                               && entryNode instanceof LiveInNode) {
-                                       if (isWriteConflicts((LiveInNode) currentNode,
-                                                       (LiveInNode) entryNode)) {
-
-                                               int conflictType = determineWriteConflictsType(
-                                                               (LiveInNode) currentNode,
-                                                               (LiveInNode) entryNode);
-                                               if (conflictType > 0) {
-                                                       addConflictEdge(conflictType, currentNode,
-                                                                       entryNode);
-                                               }
-                                       }
-                                       analyzedIDSet.add(currentNode.getID() + entryNodeID);
-                               }
-
-                       }
-
-               }
-
-       }
-
-       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 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);
-                                       }
+
+               for (Iterator iterator = setA.iterator(); iterator.hasNext();) {
+                       HeapRegionNode heapRegionNode = (HeapRegionNode) iterator.next();
+                       String gID = heapRegionNode.getGloballyUniqueIdentifier();
+                       boolean found = false;
+                       for (Iterator iterator2 = setB.iterator(); iterator2.hasNext();) {
+                               HeapRegionNode heapRegionNode2 = (HeapRegionNode) iterator2
+                                               .next();
+                               if (heapRegionNode2.getGloballyUniqueIdentifier().equals(gID)) {
+                                       found = true;
                                }
                        }
+                       if (!found) {
+                               return false;
+                       }
                }
-               return returnSet;
+               return true;
        }
 
        public String addStallNode(TempDescriptor td, FlatMethod fm,
@@ -661,60 +117,47 @@ public class ConflictGraph {
 
        public void addConflictEdge(int type, ConflictNode nodeU, ConflictNode nodeV) {
 
-               // if there are two edges between the same node pair, coarse has a priority
-               HashSet<ConflictEdge> set=nodeU.getEdgeSet();
-               ConflictEdge toBeRemoved=null;
+               // if there are two edges between the same node pair, coarse has a
+               // priority
+               HashSet<ConflictEdge> set = nodeU.getEdgeSet();
+               ConflictEdge toBeRemoved = null;
                for (Iterator iterator = set.iterator(); iterator.hasNext();) {
                        ConflictEdge conflictEdge = (ConflictEdge) iterator.next();
-                       
-                       if((conflictEdge.getVertexU().equals(nodeU) && conflictEdge.getVertexV().equals(nodeV)) ||
-                                       (conflictEdge.getVertexU().equals(nodeV) && conflictEdge.getVertexV().equals(nodeU))            
-                       ){
-                               if(conflictEdge.getType()==ConflictEdge.FINE_GRAIN_EDGE && type==ConflictEdge.COARSE_GRAIN_EDGE){
-                                       toBeRemoved=conflictEdge;
+
+                       if ((conflictEdge.getVertexU().equals(nodeU) && conflictEdge
+                                       .getVertexV().equals(nodeV))
+                                       || (conflictEdge.getVertexU().equals(nodeV) && conflictEdge
+                                                       .getVertexV().equals(nodeU))) {
+                               if (conflictEdge.getType() == ConflictEdge.FINE_GRAIN_EDGE
+                                               && type == ConflictEdge.COARSE_GRAIN_EDGE) {
+                                       toBeRemoved = conflictEdge;
                                        break;
-                               }else if(conflictEdge.getType()==ConflictEdge.COARSE_GRAIN_EDGE && type==ConflictEdge.FINE_GRAIN_EDGE){
-                                       //ignore
+                               } else if (conflictEdge.getType() == ConflictEdge.COARSE_GRAIN_EDGE
+                                               && type == ConflictEdge.FINE_GRAIN_EDGE) {
+                                       // ignore
                                        return;
                                }
                        }
                }
-               
-               if(toBeRemoved!=null){
+
+               if (toBeRemoved != null) {
                        nodeU.getEdgeSet().remove(toBeRemoved);
                        nodeV.getEdgeSet().remove(toBeRemoved);
                }
-               
-               
+
                ConflictEdge newEdge = new ConflictEdge(nodeU, nodeV, type);
                nodeU.addEdge(newEdge);
                nodeV.addEdge(newEdge);
 
        }
 
-       public HashSet<LiveInNode> getLiveInNodeSet() {
-               HashSet<LiveInNode> resultSet = new HashSet<LiveInNode>();
-
-               Set<String> keySet = id2cn.keySet();
-               for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
-                       String key = (String) iterator.next();
-                       ConflictNode node = id2cn.get(key);
-
-                       if (node instanceof LiveInNode) {
-                               resultSet.add((LiveInNode) node);
-                       }
-               }
-
-               return resultSet;
-       }
-
        public Set<WaitingElement> getStallSiteWaitingElementSet(
                        ParentChildConflictsMap conflictsMap, HashSet<SESELock> seseLockSet) {
 
                HashSet<WaitingElement> waitingElementSet = new HashSet<WaitingElement>();
                Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
                Collection<StallSite> stallSites = conflictsMap.getStallMap().values();
-               
+
                for (Iterator iterator = stallSites.iterator(); iterator.hasNext();) {
 
                        StallSite stallSite = (StallSite) iterator.next();
@@ -733,20 +176,26 @@ public class ConflictGraph {
                                                        ConflictEdge conflictEdge = (ConflictEdge) iter2
                                                                        .next();
 
-                                                               for (Iterator<SESELock> seseLockIter = seseLockSet
-                                                                               .iterator(); seseLockIter.hasNext();) {
-                                                                       SESELock seseLock = seseLockIter.next();
-                                                                       if (seseLock.containsConflictNode(stallSiteNode) && seseLock.containsConflictEdge(conflictEdge)) {
-                                                                               WaitingElement newElement = new WaitingElement();
-                                                                               newElement.setWaitingID(seseLock
-                                                                                               .getID());
-                                                                               if(isFineElement(newElement.getStatus())){
-                                                                                       newElement.setDynID(node.getTempDescriptor().toString());
-                                                                               }                                                                               
-                                                                               newElement.setStatus(seseLock.getNodeType(stallSiteNode));
-                                                                               waitingElementSet.add(newElement);
+                                                       for (Iterator<SESELock> seseLockIter = seseLockSet
+                                                                       .iterator(); seseLockIter.hasNext();) {
+                                                               SESELock seseLock = seseLockIter.next();
+                                                               if (seseLock
+                                                                               .containsConflictNode(stallSiteNode)
+                                                                               && seseLock
+                                                                                               .containsConflictEdge(conflictEdge)) {
+                                                                       WaitingElement newElement = new WaitingElement();
+                                                                       newElement.setWaitingID(seseLock.getID());
+                                                                       if (isFineElement(newElement.getStatus())) {
+                                                                               newElement
+                                                                                               .setDynID(node
+                                                                                                               .getTempDescriptor()
+                                                                                                               .toString());
                                                                        }
+                                                                       newElement.setStatus(seseLock
+                                                                                       .getNodeType(stallSiteNode));
+                                                                       waitingElementSet.add(newElement);
                                                                }
+                                                       }
                                                }
                                        }
                                }
@@ -757,58 +206,6 @@ public class ConflictGraph {
                return waitingElementSet;
        }
 
-       public Set<Integer> getConnectedConflictNodeSet(
-                       ParentChildConflictsMap conflictsMap) {
-
-               HashSet<Integer> nodeIDSet = new HashSet<Integer>();
-
-               Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
-
-               Collection<StallSite> stallSites = conflictsMap.getStallMap().values();
-               for (Iterator iterator = stallSites.iterator(); iterator.hasNext();) {
-                       StallSite stallSite = (StallSite) iterator.next();
-                       Iterator<Entry<String, ConflictNode>> i = s.iterator();
-                       while (i.hasNext()) {
-                               Entry<String, ConflictNode> entry = i.next();
-                               ConflictNode node = entry.getValue();
-
-                               if (node instanceof StallSiteNode) {
-                                       StallSiteNode stallSiteNode = (StallSiteNode) node;
-                                       if (stallSiteNode.getStallSite().equals(stallSite)) {
-                                               HashSet<ConflictEdge> edgeSet = stallSiteNode
-                                                               .getEdgeSet();
-                                               for (Iterator iter2 = edgeSet.iterator(); iter2
-                                                               .hasNext();) {
-                                                       ConflictEdge conflictEdge = (ConflictEdge) iter2
-                                                                       .next();
-                                                       nodeIDSet
-                                                                       .addAll(getConnectedConflictNode(conflictEdge));
-                                               }
-                                       }
-                               }
-                       }
-               }
-
-               return nodeIDSet;
-
-       }
-
-       private Set<Integer> getConnectedConflictNode(ConflictEdge conflictEdge) {
-
-               HashSet<Integer> nodeIDSet = new HashSet<Integer>();
-
-               if (conflictEdge.getVertexU() instanceof LiveInNode) {
-                       LiveInNode lin = (LiveInNode) conflictEdge.getVertexU();
-                       nodeIDSet.add(new Integer(lin.getSESEIdentifier()));
-               }
-               if (conflictEdge.getVertexV() instanceof LiveInNode) {
-                       LiveInNode lin = (LiveInNode) conflictEdge.getVertexV();
-                       nodeIDSet.add(new Integer(lin.getSESEIdentifier()));
-               }
-
-               return nodeIDSet;
-       }
-
        private Set<Integer> getConnectedConflictNode(ConflictEdge conflictEdge,
                        int seseID) {
 
@@ -901,21 +298,24 @@ public class ConflictGraph {
                                                                .next();
 
                                                for (Iterator<SESELock> seseLockIter = seseLockSet
-                                                                       .iterator(); seseLockIter.hasNext();) {
-                                                               SESELock seseLock = seseLockIter.next();
-                                                               if (seseLock.containsConflictNode(liveInNode) && seseLock.containsConflictEdge(conflictEdge)) {
-                                                                       WaitingElement newElement = new WaitingElement();
-                                                                       newElement.setWaitingID(seseLock.getID());
-                                                                       newElement.setStatus(seseLock.getNodeType(liveInNode));
-                                                                       if(isFineElement(newElement.getStatus())){
-                                                                           // for fine waiting element, set temp descriptor to handle unresolved pointer case.
-                                                                               newElement.setDynID(node.getTempDescriptor().toString());
-                                                                               newElement.setTempDesc(node.getTempDescriptor());
-                                                                       }
-                                                                       if(!waitingElementSet.contains(newElement)){
-                                                                               waitingElementSet.add(newElement);
-                                                                       }
-                                                                       
+                                                               .iterator(); seseLockIter.hasNext();) {
+                                                       SESELock seseLock = seseLockIter.next();
+                                                       if (seseLock.containsConflictNode(liveInNode)
+                                                                       && seseLock
+                                                                                       .containsConflictEdge(conflictEdge)) {
+                                                               WaitingElement newElement = new WaitingElement();
+                                                               newElement.setWaitingID(seseLock.getID());
+                                                               newElement.setStatus(seseLock
+                                                                               .getNodeType(liveInNode));
+                                                               if (isFineElement(newElement.getStatus())) {
+                                                                       newElement.setDynID(node
+                                                                                       .getTempDescriptor().toString());
+                                                                       newElement.setTempDesc(node.getTempDescriptor());
+                                                               }
+                                                               if (!waitingElementSet.contains(newElement)) {
+                                                                       waitingElementSet.add(newElement);
+                                                               }
+
                                                        }
                                                }
                                        }
@@ -927,7 +327,7 @@ public class ConflictGraph {
 
                return waitingElementSet;
        }
-       
+
        public boolean isFineElement(int type) {
                if (type == ConflictNode.FINE_READ || type == ConflictNode.FINE_WRITE
                                || type == ConflictNode.PARENT_READ
@@ -938,253 +338,728 @@ public class ConflictGraph {
                }
        }
 
-       public Set<Long> getAllocationSiteIDSetBySESEID(int seseID) {
-               // deprecated
-               HashSet<Long> allocSiteIDSet = new HashSet<Long>();
+       public HashSet<ConflictEdge> getEdgeSet() {
+
+               HashSet<ConflictEdge> returnSet = new HashSet<ConflictEdge>();
+
+               Collection<ConflictNode> nodes = id2cn.values();
+               for (Iterator iterator = nodes.iterator(); iterator.hasNext();) {
+                       ConflictNode conflictNode = (ConflictNode) iterator.next();
+                       returnSet.addAll(conflictNode.getEdgeSet());
+               }
+
+               return returnSet;
+       }
+
+       public void writeGraph(String graphName, boolean filter)
+                       throws java.io.IOException {
+
+               graphName = graphName.replaceAll("[\\W]", "");
+
+               BufferedWriter bw = new BufferedWriter(new FileWriter(graphName
+                               + ".dot"));
+               bw.write("graph " + graphName + " {\n");
 
+               HashSet<HeapRegionNode> visited = new HashSet<HeapRegionNode>();
+               // then visit every heap region node
                Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
                Iterator<Entry<String, ConflictNode>> i = s.iterator();
 
+               HashSet<ConflictEdge> addedSet = new HashSet<ConflictEdge>();
+
                while (i.hasNext()) {
                        Entry<String, ConflictNode> entry = i.next();
                        ConflictNode node = entry.getValue();
 
-                       if (node instanceof LiveInNode) {
-                               LiveInNode liveInNode = (LiveInNode) node;
-                               if (liveInNode.getSESEIdentifier() == seseID) {
-                                       HashSet<ConflictEdge> edgeSet = liveInNode.getEdgeSet();
-                                       for (Iterator iterator = edgeSet.iterator(); iterator
-                                                       .hasNext();) {
-                                               ConflictEdge conflictEdge = (ConflictEdge) iterator
+                       if (filter) {
+                               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";
+
+                       if (node instanceof StallSiteNode) {
+                               attributes += "STALL SITE" + "\\n" + "\"]";
+                       } else {
+                               attributes += "LIVE-IN" + "\\n" + "\"]";
+                       }
+                       bw.write(entry.getKey() + attributes + ";\n");
+
+                       HashSet<ConflictEdge> edgeSet = node.getEdgeSet();
+                       for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) {
+                               ConflictEdge conflictEdge = (ConflictEdge) iterator.next();
+
+                               ConflictNode u = conflictEdge.getVertexU();
+                               ConflictNode v = conflictEdge.getVertexV();
+
+                               if (filter) {
+                                       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 (!addedSet.contains(conflictEdge)) {
+                                       bw.write(" " + u.getID() + "--" + v.getID() + "[label="
+                                                       + conflictEdge.toGraphEdgeString()
+                                                       + ",decorate];\n");
+                                       addedSet.add(conflictEdge);
+                               }
+
+                       }
+               }
+
+               bw.write("  graphTitle[label=\"" + graphName + "\",shape=box];\n");
+
+               bw.write("}\n");
+               bw.close();
+
+       }
+       
+       private int calculateConflictType(StallSiteNode nodeA, LiveInNode nodeB) {
+
+               StallSite stallSite = nodeA.getStallSite();
+               Set<SESEEffectsKey> writeEffectsSet = nodeB.getWriteEffectsSet();
+               Set<SESEEffectsKey> readEffectsSet = nodeB.getReadEffectsSet();
+
+               int conflictType = 0;
+
+               if (writeEffectsSet != null) {
+                       Iterator<SESEEffectsKey> writeIter = writeEffectsSet.iterator();
+                       while (writeIter.hasNext()) {
+                               SESEEffectsKey seseEffectsKey = (SESEEffectsKey) writeIter
+                                               .next();
+                               String writeHeapRegionID = seseEffectsKey.getHRNUniqueId();
+                               String writeFieldName = seseEffectsKey.getFieldDescriptor();
+
+                               HashSet<HeapRegionNode> stallSiteHRNSet = nodeA.getHRNSet();
+                               for (Iterator iterator = stallSiteHRNSet.iterator(); iterator
+                                               .hasNext();) {
+                                       HeapRegionNode stallHRN = (HeapRegionNode) iterator.next();
+                                       if (stallHRN.getGloballyUniqueIdentifier().equals(
+                                                       writeHeapRegionID)) {
+                                               // check whether there are read or write effects of
+                                               // stall sites
+                                               HashSet<Effect> effectSet = stallSite.getEffectSet();
+                                               for (Iterator iterator2 = effectSet.iterator(); iterator2
+                                                               .hasNext();) {
+                                                       Effect effect = (Effect) iterator2.next();
+                                                       String stallEffectfieldName = effect.getField();
+
+                                                       if (stallEffectfieldName.equals(writeFieldName)) {
+                                                               int newType = determineConflictType(nodeA,
+                                                                               effect, nodeB, seseEffectsKey);
+                                                               if (newType > conflictType) {
+                                                                       // coarse-grain conflict overrides
+                                                                       // fine-grain conflict
+                                                                       conflictType = newType;
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+
+                       }
+               }
+
+               if (readEffectsSet != null) {
+                       Iterator<SESEEffectsKey> readIter = readEffectsSet.iterator();
+                       while (readIter.hasNext()) {
+                               SESEEffectsKey seseEffectsKey = (SESEEffectsKey) readIter
+                                               .next();
+                               String readHeapRegionID = seseEffectsKey.getHRNUniqueId();
+                               String readFieldName = seseEffectsKey.getFieldDescriptor();
+
+                               HashSet<HeapRegionNode> stallSiteHRNSet = nodeA.getHRNSet();
+                               for (Iterator iterator = stallSiteHRNSet.iterator(); iterator
+                                               .hasNext();) {
+                                       HeapRegionNode stallHRN = (HeapRegionNode) iterator.next();
+                                       if (stallHRN.getGloballyUniqueIdentifier().equals(
+                                                       readHeapRegionID)) {
+
+                                               HashSet<Effect> effectSet = stallSite.getEffectSet();
+                                               for (Iterator iterator2 = effectSet.iterator(); iterator2
+                                                               .hasNext();) {
+                                                       Effect effect = (Effect) iterator2.next();
+                                                       String stallEffectfieldName = effect.getField();
+
+                                                       if (effect.getEffectType().equals(
+                                                                       StallSite.WRITE_EFFECT)) {
+                                                               if (stallEffectfieldName.equals(readFieldName)) {
+                                                                       int newType = determineConflictType(nodeA,
+                                                                                       effect, nodeB, seseEffectsKey);
+                                                                       if (newType > conflictType) {
+                                                                               // coarse-grain conflict overrides
+                                                                               // fine-grain conflict
+                                                                               conflictType = newType;
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+//System.out.println("%%%%%%%%%%%%%% RETURN conflictType="+conflictType);
+               return conflictType;
+       }
+       
+       private int calculateConflictType(LiveInNode nodeA, LiveInNode nodeB) {
+
+               Set<SESEEffectsKey> readEffectsSetA = nodeA.getReadEffectsSet();
+               Set<SESEEffectsKey> writeEffectsSetA = nodeA.getWriteEffectsSet();
+               Set<SESEEffectsKey> strongUpdateSetA = nodeA.getStrongUpdateSet();
+
+               Set<SESEEffectsKey> readEffectsSetB = nodeB.getReadEffectsSet();
+               Set<SESEEffectsKey> writeEffectsSetB = nodeB.getWriteEffectsSet();
+               Set<SESEEffectsKey> strongUpdateSetB = nodeB.getStrongUpdateSet();
+
+               int conflictType = 0;
+               
+               // if node A has write effects on reading/writing regions of node B
+               if (writeEffectsSetA != null) {
+                       Iterator<SESEEffectsKey> writeIterA = writeEffectsSetA.iterator();
+                       while (writeIterA.hasNext()) {
+                               SESEEffectsKey seseEffectsKey = (SESEEffectsKey) writeIterA
+                                               .next();
+                               String writeHeapRegionID = seseEffectsKey.getHRNUniqueId();
+                               String writeFieldName = seseEffectsKey.getFieldDescriptor();
+
+                               if (readEffectsSetB != null) {
+
+                                       Iterator<SESEEffectsKey> readIterB = readEffectsSetB
+                                                       .iterator();
+                                       while (readIterB.hasNext()) {
+                                               SESEEffectsKey readingEffect = (SESEEffectsKey) readIterB
                                                                .next();
-                                               //
-                                               getConnectedConflictNode(conflictEdge, seseID);
-                                               //
-                                               if (conflictEdge.getType() == ConflictEdge.COARSE_GRAIN_EDGE) {
-                                                       allocSiteIDSet
-                                                                       .addAll(getHRNIdentifierSet(conflictEdge
-                                                                                       .getVertexU()));
-                                                       allocSiteIDSet
-                                                                       .addAll(getHRNIdentifierSet(conflictEdge
-                                                                                       .getVertexV()));
-                                               } else {// it is fine-grain edge
-                                                       allocSiteIDSet.addAll(getHRNIdentifierSet(node));
+
+                                               if (readingEffect.getHRNUniqueId().equals(
+                                                               writeHeapRegionID)
+                                                               && readingEffect.getFieldDescriptor().equals(
+                                                                               writeFieldName)) {
+                                                       int newType = determineConflictType(nodeA,
+                                                                       seseEffectsKey, nodeB, readingEffect);
+                                                       if (newType > conflictType) {
+                                                               // coarse-grain conflict overrides fine-grain
+                                                               // conflict
+                                                               conflictType = newType;
+                                                       }
                                                }
                                        }
 
                                }
-                       }
-               }
 
-               return allocSiteIDSet;
+                               if (writeEffectsSetB != null) {
+                                       Iterator<SESEEffectsKey> writeIterB = writeEffectsSetB
+                                                       .iterator();
+                                       while (writeIterB.hasNext()) {
+                                               SESEEffectsKey writingEffect = (SESEEffectsKey) writeIterB
+                                                               .next();
 
-       }
+                                               if (writingEffect.getHRNUniqueId().equals(
+                                                               writeHeapRegionID)
+                                                               && writingEffect.getFieldDescriptor().equals(
+                                                                               writeFieldName)) {
+                                                       int newType = determineConflictType(nodeA,
+                                                                       seseEffectsKey, nodeB, writingEffect);
+                                                       if (newType > conflictType) {
+                                                               // coarse-grain conflict overrides fine-grain
+                                                               // conflict
+                                                               conflictType = newType;
+                                                       }
+                                               }
 
-       public Set<Long> getAllocationSiteIDSetofStallSite() {
+                                       }
+                               }
 
-               HashSet<Long> allocSiteIDSet = new HashSet<Long>();
+                       }
+               }
 
-               Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
-               Iterator<Entry<String, ConflictNode>> i = s.iterator();
+               // if node B has write effects on reading regions of node A
+               if (writeEffectsSetB != null) {
+                       Iterator<SESEEffectsKey> writeIterB = writeEffectsSetB.iterator();
+                       while (writeIterB.hasNext()) {
+                               SESEEffectsKey seseEffectsKey = (SESEEffectsKey) writeIterB
+                                               .next();
 
-               while (i.hasNext()) {
+                               // if (!hasStrongUpdate(seseEffectsKey, strongUpdateSetB)) {
 
-                       Entry<String, ConflictNode> entry = i.next();
-                       ConflictNode node = entry.getValue();
+                               String writeHeapRegionID = seseEffectsKey.getHRNUniqueId();
+                               String writeFieldName = seseEffectsKey.getFieldDescriptor();
 
-                       if (node instanceof StallSiteNode) {
-                               allocSiteIDSet.addAll(getHRNIdentifierSet(node));
-                       }
+                               if (readEffectsSetA != null) {
+                                       Iterator<SESEEffectsKey> readIterA = readEffectsSetA
+                                                       .iterator();
+                                       while (readIterA.hasNext()) {
+                                               SESEEffectsKey readingEffect = (SESEEffectsKey) readIterA
+                                                               .next();
 
-               }
+                                               if (readingEffect.getHRNUniqueId().equals(
+                                                               writeHeapRegionID)
+                                                               && readingEffect.getFieldDescriptor().equals(
+                                                                               writeFieldName)) {
+                                                       int newType = determineConflictType(nodeA,
+                                                                       readingEffect, nodeB, seseEffectsKey);
+                                                       if (newType > conflictType) {
+                                                               // coarse-grain conflict overrides fine-grain
+                                                               // conflict
+                                                               conflictType = newType;
+                                                       }
+                                               }
 
-               return allocSiteIDSet;
+                                       }
+                               }
 
-       }
+                               if (writeEffectsSetA != null) {
+                                       Iterator<SESEEffectsKey> writeIterA = writeEffectsSetA
+                                                       .iterator();
+                                       while (writeIterA.hasNext()) {
+                                               SESEEffectsKey writingEffect = (SESEEffectsKey) writeIterA
+                                                               .next();
 
-       public Set<Long> getAllocationSiteIDSet() {
+                                               if (writingEffect.getHRNUniqueId().equals(
+                                                               writeHeapRegionID)
+                                                               && writingEffect.getFieldDescriptor().equals(
+                                                                               writeFieldName)) {
+                                                       int newType = determineConflictType(nodeA,
+                                                                       writingEffect, nodeB, seseEffectsKey);
+                                                       if (newType > conflictType) {
+                                                               // coarse-grain conflict overrides fine-grain
+                                                               // conflict
+                                                               conflictType = newType;
+                                                       }
+                                               }
 
-               HashSet<Long> allocSiteIDSet = new HashSet<Long>();
+                                       }
+                               }
 
-               Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
-               Iterator<Entry<String, ConflictNode>> i = s.iterator();
+                       }
+               }
+               return conflictType;
+       }
 
-               while (i.hasNext()) {
-                       Entry<String, ConflictNode> entry = i.next();
-                       ConflictNode node = entry.getValue();
+       private Set<HeapRegionNode> getSameHeapRoot(Set<HeapRegionNode> setA,
+                       Set<HeapRegionNode> setB) {
 
-                       HashSet<ConflictEdge> edgeSet = node.getEdgeSet();
-                       for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) {
-                               ConflictEdge conflictEdge = (ConflictEdge) iterator.next();
-                               if (conflictEdge.getType() == ConflictEdge.COARSE_GRAIN_EDGE) {
-                                       allocSiteIDSet.addAll(getHRNIdentifierSet(conflictEdge
-                                                       .getVertexU()));
-                                       allocSiteIDSet.addAll(getHRNIdentifierSet(conflictEdge
-                                                       .getVertexV()));
-                               } else {// it is fine-grain edge
-                                       allocSiteIDSet.addAll(getHRNIdentifierSet(node));
+               Set<HeapRegionNode> retSet = new HashSet<HeapRegionNode>();
+
+               if (compareHRNSet(setA, setB)) {
+                       for (Iterator iterator = setA.iterator(); iterator.hasNext();) {
+                               HeapRegionNode heapRegionNode = (HeapRegionNode) iterator
+                                               .next();
+                               String gID = heapRegionNode.getGloballyUniqueIdentifier();
+                               boolean found = false;
+                               for (Iterator iterator2 = setB.iterator(); iterator2.hasNext();) {
+                                       HeapRegionNode heapRegionNode2 = (HeapRegionNode) iterator2
+                                                       .next();
+                                       if (heapRegionNode2.getGloballyUniqueIdentifier().equals(
+                                                       gID)) {
+                                               retSet.add(heapRegionNode2);
+                                       }
                                }
                        }
-
                }
 
-               return allocSiteIDSet;
+               return retSet;
 
        }
+       
+       private boolean isReachableFrom(HeapRegionNode root1, HeapRegionNode root2,
+                       ReachabilitySet rset) {
+               
+               boolean reachable=false;
+
+               TokenTuple h1 = new TokenTuple(root1.getID(), !root1.isSingleObject(),
+                               TokenTuple.ARITY_ONE).makeCanonical();
+
+               TokenTuple h1plus = new TokenTuple(root1.getID(), !root1
+                               .isSingleObject(), TokenTuple.ARITY_ONEORMORE).makeCanonical();
+
+               TokenTuple h1star = new TokenTuple(root1.getID(), !root1
+                               .isSingleObject(), TokenTuple.ARITY_ZEROORMORE).makeCanonical();
+
+               TokenTuple h2 = new TokenTuple(root2.getID(), !root2.isSingleObject(),
+                               TokenTuple.ARITY_ONE).makeCanonical();
+
+               TokenTuple h2plus = new TokenTuple(root2.getID(), !root2
+                               .isSingleObject(), TokenTuple.ARITY_ONEORMORE).makeCanonical();
+
+               TokenTuple h2star = new TokenTuple(root2.getID(), !root2
+                               .isSingleObject(), TokenTuple.ARITY_ZEROORMORE).makeCanonical();
+
+                // only do this one if they are different tokens
+           if( h1 != h2 &&
+                       rset.containsTupleSetWithBoth(h1,     h2) ) {
+               reachable = true;
+           }
+           if( rset.containsTupleSetWithBoth(h1plus, h2) ) {
+               reachable = true;
+           }
+           if( rset.containsTupleSetWithBoth(h1star, h2) ) {
+               reachable = true;
+           }
+           if( rset.containsTupleSetWithBoth(h1,     h2plus) ) {
+               reachable = true;
+           }
+           if( rset.containsTupleSetWithBoth(h1plus, h2plus) ) {
+               reachable = true;
+           }
+           if( rset.containsTupleSetWithBoth(h1star, h2plus) ) {
+               reachable = true;
+           }
+           if( rset.containsTupleSetWithBoth(h1,     h2star) ) {
+               reachable = true;
+           }
+           if( rset.containsTupleSetWithBoth(h1plus, h2star) ) {
+               reachable = true;
+           }
+           if( rset.containsTupleSetWithBoth(h1star, h2star) ) {
+               reachable = true;
+           }
+               
+               return reachable;
 
-       private HashSet<Integer> getAllocSet(ConflictNode node) {
-
-               HashSet<Integer> returnSet = new HashSet<Integer>();
-
-               if (node instanceof StallSiteNode) {
-                       StallSiteNode stallSiteNode = (StallSiteNode) node;
-                       Set<HeapRegionNode> hrnSet = stallSiteNode.getHRNSet();
-                       for (Iterator iterator = hrnSet.iterator(); iterator.hasNext();) {
-                               HeapRegionNode hrn = (HeapRegionNode) iterator.next();
-                               // allocSiteIDSet.add(hrn.getGloballyUniqueIdentifier());
-                               if (hrn.getAllocationSite() != null) {
-                                       returnSet.add(new Integer(hrn.getAllocationSite().getID()));
+       }
+       
+       private int determineConflictType(StallSiteNode stallSiteNodeA,
+                       Effect effect, LiveInNode liveInNodeB,
+                       SESEEffectsKey effectB) {
+               
+               Set<HeapRegionNode> liveInHrnSetA = stallSiteNodeA.getStallSite().getHRNSet();
+               Set<HeapRegionNode> liveInHrnSetB = liveInNodeB.getHRNSet();
+               
+               // check whether alloc site is reached from both  heap roots 
+               boolean isDisjoint=true;
+               HeapRegionNode effectHrn=og.gid2hrn.get(effectB.getHRNUniqueId());
+               if(effectHrn.isSingleObject()){
+                       for (Iterator iterator = liveInHrnSetA.iterator(); iterator.hasNext();) {
+                               HeapRegionNode r1 = (HeapRegionNode) iterator.next();
+                               for (Iterator iterator2 = liveInHrnSetB.iterator(); iterator2.hasNext();) {
+                                       HeapRegionNode r2 = (HeapRegionNode) iterator2.next();
+                                       r1=og.gid2hrn.get(r1.getGloballyUniqueIdentifier());
+                                       r2=og.gid2hrn.get(r2.getGloballyUniqueIdentifier());
+                                       if(isReachableFrom(r1,r2,effectB.getRSet())){
+                                               isDisjoint=false;
+                                       }
                                }
                        }
-               } else {
-                       LiveInNode liveInNode = (LiveInNode) node;
-                       Set<HeapRegionNode> hrnSet = liveInNode.getHRNSet();
-                       for (Iterator iterator = hrnSet.iterator(); iterator.hasNext();) {
-                               HeapRegionNode hrn = (HeapRegionNode) iterator.next();
-                               // allocSiteIDSet.add(hrn.getGloballyUniqueIdentifier());
-                               if (hrn.getAllocationSite() != null) {
-                                       returnSet.add(new Integer(hrn.getAllocationSite().getID()));
-                               }else{
-                                       returnSet.add(new Integer(hrn.getID()));
-                               }
+                       if(isDisjoint){
+                               return ConflictEdge.NON_WRITE_CONFLICT;
                        }
                }
+               
+               /*
+               HeapRegionNode r1=liveInHrnSetA.iterator().next();
+               HeapRegionNode r2=liveInHrnSetB.iterator().next();
+               
+               r1=og.gid2hrn.get(r1.getGloballyUniqueIdentifier());
+               r2=og.gid2hrn.get(r2.getGloballyUniqueIdentifier());
+               
+               System.out.println("r1="+r1);
+               System.out.println("r2="+r2);
+               System.out.println("effectB="+effectB.getRSet());
+               System.out.println("###STALL calculateConflictType2");
+               if(!isReachableFrom(r1,r2,effectB.getRSet())){
+                       System.out.println("###STALL calculateConflictType3");
+                       return ConflictEdge.NON_WRITE_CONFLICT;
+               }
+               */
+               Set<HeapRegionNode> entryHRNSet = getSameHeapRoot(liveInHrnSetA,
+                               liveInHrnSetB);
+               if (entryHRNSet.size() == 0) {
+                       return ConflictEdge.COARSE_GRAIN_EDGE;
+               }
 
-               return returnSet;
-       }
-
-       private HashSet<Long> getHRNIdentifierSet(ConflictNode node) {
+               for (Iterator iterator = entryHRNSet.iterator(); iterator.hasNext();) {
+                       HeapRegionNode hrn = (HeapRegionNode) iterator.next();
 
-               HashSet<Long> returnSet = new HashSet<Long>();
+                       String entryIdentifier = hrn.getGloballyUniqueIdentifier();
+                       HeapRegionNode entryHRN = og.gid2hrn.get(entryIdentifier);
 
-               if (node instanceof StallSiteNode) {
-                       StallSiteNode stallSiteNode = (StallSiteNode) node;
-                       Set<HeapRegionNode> hrnSet = stallSiteNode.getHRNSet();
-                       for (Iterator iterator = hrnSet.iterator(); iterator.hasNext();) {
-                               HeapRegionNode hrn = (HeapRegionNode) iterator.next();
-                               // allocSiteIDSet.add(hrn.getGloballyUniqueIdentifier());
-                               returnSet
-                                               .add(new Long(hrn.getGloballyUniqueIntegerIdentifier()));
-                       }
-               } else {
-                       LiveInNode liveInNode = (LiveInNode) node;
-                       Set<HeapRegionNode> hrnSet = liveInNode.getHRNSet();
-                       for (Iterator iterator = hrnSet.iterator(); iterator.hasNext();) {
-                               HeapRegionNode hrn = (HeapRegionNode) iterator.next();
-                               // allocSiteIDSet.add(hrn.getGloballyUniqueIdentifier());
-                               returnSet
-                                               .add(new Long(hrn.getGloballyUniqueIntegerIdentifier()));
+                       TokenTuple h1 = new TokenTuple(entryHRN.getID(), !entryHRN
+                                       .isSingleObject(), TokenTuple.ARITY_ONE).makeCanonical();
+                       
+                       TokenTuple h1star = new TokenTuple(entryHRN.getID(), true,
+                                       TokenTuple.ARITY_ONEORMORE).makeCanonical();
+                       
+                       if (effectB.getRSet().containsTuple(h1star)) {
+                               return ConflictEdge.COARSE_GRAIN_EDGE;
+                       }else if (effectB.getRSet().containsTuple(h1)) {
+                               // rechability states contain heap root with arity 1
+                               return ConflictEdge.FINE_GRAIN_EDGE;
                        }
                }
-
-               return returnSet;
-
+               return ConflictEdge.NON_WRITE_CONFLICT;
        }
 
-       public HashSet<ConflictEdge> getEdgeSet() {
+       private int determineConflictType(LiveInNode liveInNodeA,
+                       SESEEffectsKey effectA, LiveInNode liveInNodeB,
+                       SESEEffectsKey effectB) {
 
-               HashSet<ConflictEdge> returnSet = new HashSet<ConflictEdge>();
+               if (liveInNodeA.getSESEIdentifier() == liveInNodeB.getSESEIdentifier()) {
+                       return ConflictEdge.NON_WRITE_CONFLICT;
+               }
 
-               Collection<ConflictNode> nodes = id2cn.values();
-               for (Iterator iterator = nodes.iterator(); iterator.hasNext();) {
-                       ConflictNode conflictNode = (ConflictNode) iterator.next();
-                       returnSet.addAll(conflictNode.getEdgeSet());
+               Set<HeapRegionNode> liveInHrnSetA = liveInNodeA.getHRNSet();
+               Set<HeapRegionNode> liveInHrnSetB = liveInNodeB.getHRNSet();
+               
+               // check whether alloc site is reached from both  heap roots
+               boolean isDisjoint=true;
+               HeapRegionNode effectHrn=og.gid2hrn.get(effectB.getHRNUniqueId());
+               if(effectHrn.isSingleObject()){
+                       for (Iterator iterator = liveInHrnSetA.iterator(); iterator.hasNext();) {
+                               HeapRegionNode r1 = (HeapRegionNode) iterator.next();
+                               for (Iterator iterator2 = liveInHrnSetB.iterator(); iterator2.hasNext();) {
+                                       HeapRegionNode r2 = (HeapRegionNode) iterator2.next();
+                                       r1=og.gid2hrn.get(r1.getGloballyUniqueIdentifier());
+                                       r2=og.gid2hrn.get(r2.getGloballyUniqueIdentifier());
+                                       
+                                       if(isReachableFrom(r1,r2,effectB.getRSet())){
+                                               isDisjoint=false;
+                                       }else{
+                                       }
+                               }
+                       }
+                       if(isDisjoint){
+                               return ConflictEdge.NON_WRITE_CONFLICT;
+                       }
+               }
+               
+               /*
+               HeapRegionNode r1=liveInHrnSetA.iterator().next();
+               HeapRegionNode r2=liveInHrnSetB.iterator().next();
+               
+//             r1=og.gid2hrn.get(r1.getGloballyUniqueIdentifier());
+//             r2=og.gid2hrn.get(r2.getGloballyUniqueIdentifier());
+               System.out.println("@@r1="+r1);
+               System.out.println("@@r2="+r2);
+               System.out.println("@@effectB="+effectA.getRSet());
+               
+               if(!isReachableFrom(r1,r2,effectA.getRSet())){
+                       // two heap root are disjoint
+                       return ConflictEdge.NON_WRITE_CONFLICT;
+               }
+               */
+               
+               Set<HeapRegionNode> entryHRNSet = getSameHeapRoot(liveInHrnSetA,
+                               liveInHrnSetB);
+               if (entryHRNSet.size() == 0) {
+                       return ConflictEdge.COARSE_GRAIN_EDGE;
                }
 
-               return returnSet;
-       }
+               int count=0;
+               for (Iterator iterator = entryHRNSet.iterator(); iterator.hasNext();) {
+                       HeapRegionNode hrn = (HeapRegionNode) iterator.next();
+                       if(hrn.getType()!=null && hrn.getType().isImmutable()){
+                               count++;
+                       }
+               }
+               if(count==entryHRNSet.size()){
+                       return ConflictEdge.FINE_GRAIN_EDGE;
+               }
+               
+               for (Iterator iterator = entryHRNSet.iterator(); iterator.hasNext();) {
+                       HeapRegionNode hrn = (HeapRegionNode) iterator.next();
 
-       static public int generateUniqueCliqueID() {
-               ++uniqueCliqueIDcount;
-               return uniqueCliqueIDcount;
-       }
+                       String entryIdentifier = hrn.getGloballyUniqueIdentifier();
+                       HeapRegionNode entryHRN = og.gid2hrn.get(entryIdentifier);
 
-       public void writeGraph(String graphName, boolean filter)
-                       throws java.io.IOException {
+                       TokenTuple h1 = new TokenTuple(entryHRN.getID(), !entryHRN
+                                       .isSingleObject(), TokenTuple.ARITY_ONE).makeCanonical();
 
-               graphName = graphName.replaceAll("[\\W]", "");
+                       TokenTuple h1star = new TokenTuple(entryHRN.getID(), true,
+                                       TokenTuple.ARITY_ONEORMORE).makeCanonical();
 
-               BufferedWriter bw = new BufferedWriter(new FileWriter(graphName
-                               + ".dot"));
-               bw.write("graph " + graphName + " {\n");
+                       if (effectA.getRSet().containsTuple(h1star)) {
+                               return ConflictEdge.COARSE_GRAIN_EDGE;
+                       } else if (effectA.getRSet().containsTuple(h1)) {
+                               // rechability states contain heap root with arity 1
+                               return ConflictEdge.FINE_GRAIN_EDGE;
+                       }
 
-               HashSet<HeapRegionNode> visited = new HashSet<HeapRegionNode>();
-               // then visit every heap region node
-               Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
-               Iterator<Entry<String, ConflictNode>> i = s.iterator();
+               }
 
-               HashSet<ConflictEdge> addedSet = new HashSet<ConflictEdge>();
+               return ConflictEdge.NON_WRITE_CONFLICT;
 
-               while (i.hasNext()) {
-                       Entry<String, ConflictNode> entry = i.next();
-                       ConflictNode node = entry.getValue();
+       }
+       
+       private int calculateSelfConflictType(LiveInNode liveInNode) {
+               
+               // if strong update effect exists, it conflicts every effects of objects that are reachable from same heap root
+               Set<SESEEffectsKey> strongUpdateSet = liveInNode.getStrongUpdateSet();
+               if(strongUpdateSet!=null && strongUpdateSet.size()>0){
+                       return ConflictEdge.FINE_GRAIN_EDGE;
+               }               
+               
+               if (liveInNode.getWriteEffectsSet() != null
+                               && liveInNode.getWriteEffectsSet().size() > 0) {
+                       
+                       Set<SESEEffectsKey> writeEffectsSet=liveInNode.getWriteEffectsSet();
+                       
+                       int immuntableCount = 0;
+                       for (Iterator<HeapRegionNode> iterator = liveInNode.getHRNSet()
+                                       .iterator(); iterator.hasNext();) {
+                               HeapRegionNode root = iterator.next();
+                               if(root.getType()!=null && root.getType().isImmutable()){
+                                       immuntableCount++;
+                               }
+                       }
+                       if (immuntableCount == liveInNode.getHRNSet().size()) {
+                               // in this case, heap root is a parameter heap region
+                               return ConflictEdge.FINE_GRAIN_EDGE;
+                       }
+                       
+                       
+                       int paramCount = 0;
+                       for (Iterator<HeapRegionNode> iterator = liveInNode.getHRNSet()
+                                       .iterator(); iterator.hasNext();) {
+                               HeapRegionNode root = iterator.next();
+                               if (root.isParameter()) {
+                                       paramCount++;
+                               }
+                       }
 
-                       if (filter) {
-                               if (node.getID().startsWith("___dst")
-                                               || node.getID().startsWith("___srctmp")
-                                               || node.getID().startsWith("___neverused")
-                                               || node.getID().startsWith("___temp")) {
+                       if (paramCount == liveInNode.getHRNSet().size()) {
+                               // in this case, heap root is a parameter heap region
+                               return ConflictEdge.FINE_GRAIN_EDGE;
+                       }
 
-                                       continue;
+                       if (liveInNode.getHRNSet().size()==1) {
+                               HeapRegionNode hrn = liveInNode.getHRNSet().iterator().next();
+                                       String entryIdentifier = hrn.getGloballyUniqueIdentifier();
+                                       HeapRegionNode entryHRN = og.gid2hrn.get(entryIdentifier);
+                                       
+                                       boolean containsStar=false;
+                                       for (Iterator iterator = writeEffectsSet.iterator(); iterator
+                                                       .hasNext();) {
+                                               SESEEffectsKey effect = (SESEEffectsKey) iterator.next();
+                                               TokenTuple h1 = new TokenTuple(entryHRN.getID(), !entryHRN
+                                                               .isSingleObject(), TokenTuple.ARITY_ONE).makeCanonical();
+                                               TokenTuple h1star = new TokenTuple(entryHRN.getID(), true, TokenTuple.ARITY_ZEROORMORE).makeCanonical();
+                                               if (effect.getRSet().containsTuple(h1star)) {
+                                                       // rechability states contain heap root with arity star
+                                                       containsStar=true;
+                                               }                                               
+                                       }
+                                       if(containsStar){
+                                               return ConflictEdge.COARSE_GRAIN_EDGE;
+                                       }else{
+                                               return ConflictEdge.FINE_GRAIN_EDGE;
+                                       }
+                       }else{
+                               return ConflictEdge.COARSE_GRAIN_EDGE;
+                       }
+                                       
+                       
+                       /*
+                       boolean containsAllTuple=true;
+                       for (Iterator iterator2 = writeEffectsSet.iterator(); iterator2
+                                       .hasNext();) {
+                               SESEEffectsKey seseEffectsKey = (SESEEffectsKey) iterator2
+                                               .next();
+                               ReachabilitySet rset = seseEffectsKey.getRSet();
+                               Iterator<TokenTupleSet> tsetIter=rset.iterator();
+                               int countNotContained=0;
+                               while (tsetIter.hasNext()) {
+                                       TokenTupleSet tokenTupleSet = (TokenTupleSet) tsetIter
+                                                       .next();
+                                       boolean found=true;
+                                       for (Iterator iterator = rootIDSet.iterator(); iterator
+                                                       .hasNext();) {
+                                               Integer rootID = (Integer) iterator.next();
+                                               if(tokenTupleSet.containsToken(rootID)==null){
+                                                       found=false;
+                                               }
+                                       }
+                                       if(!found){
+                                               countNotContained++;
+                                       }
                                }
+                               if(countNotContained==rset.size()){
+                                       containsAllTuple=false;
+                               }
+                       }
+                       
+                       if (containsAllTuple && liveInNode.getHRNSet().size() > 1) {
+                               return ConflictEdge.COARSE_GRAIN_EDGE;
+                       } else {
+                               return ConflictEdge.FINE_GRAIN_EDGE;
                        }
+                       */
+                       
+                       
+                       
+               }
+               
+               return ConflictEdge.NON_WRITE_CONFLICT;
 
-                       String attributes = "[";
+       }
 
-                       attributes += "label=\"ID" + node.getID() + "\\n";
+       public void analyzePossibleConflicts(Set<String> analyzedIDSet,
+                       ConflictNode currentNode) {
 
-                       if (node instanceof StallSiteNode) {
-                               attributes += "STALL SITE" + "\\n" + "\"]";
-                       } else {
-                               attributes += "LIVE-IN" + "\\n" + "\"]";
+               // compare with all nodes
+               // examine the case where self-edge exists
+               if (currentNode instanceof LiveInNode) {
+                       LiveInNode liveInNode = (LiveInNode) currentNode;
+                       int conflictType=calculateSelfConflictType(liveInNode);
+                       if(conflictType>0){
+                               addConflictEdge(conflictType, currentNode,
+                                               currentNode);
                        }
-                       bw.write(entry.getKey() + attributes + ";\n");
+               }
 
-                       HashSet<ConflictEdge> edgeSet = node.getEdgeSet();
-                       for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) {
-                               ConflictEdge conflictEdge = (ConflictEdge) iterator.next();
+               Set<Entry<String, ConflictNode>> set = id2cn.entrySet();
+               for (Iterator iterator = set.iterator(); iterator.hasNext();) {
+                       Entry<String, ConflictNode> entry = (Entry<String, ConflictNode>) iterator
+                                       .next();
 
-                               ConflictNode u = conflictEdge.getVertexU();
-                               ConflictNode v = conflictEdge.getVertexV();
+                       String entryNodeID = entry.getKey();
+                       ConflictNode entryNode = entry.getValue();
 
-                               if (filter) {
-                                       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 ((!currentNode.getID().equals(entryNodeID))
+                                       && !(analyzedIDSet.contains(currentNode.getID()
+                                                       + entryNodeID) || analyzedIDSet
+                                                       .contains(entryNodeID + currentNode.getID()))) {
+
+                               if (currentNode instanceof StallSiteNode
+                                               && entryNode instanceof LiveInNode) {
+                                       
+                                       int conflictType = calculateConflictType((StallSiteNode) currentNode,   (LiveInNode) entryNode);
+                                       if (conflictType > 0) {
+                                               addConflictEdge(conflictType, currentNode, entryNode);
                                        }
-                               }
+                                       
+                                       analyzedIDSet.add(currentNode.getID() + entryNodeID);
 
-                               if (!addedSet.contains(conflictEdge)) {
-                                       bw.write(" " + u.getID() + "--" + v.getID() + "[label="
-                                                       + conflictEdge.toGraphEdgeString()
-                                                       + ",decorate];\n");
-                                       addedSet.add(conflictEdge);
+                               } else if (currentNode instanceof LiveInNode
+                                               && entryNode instanceof LiveInNode) {
+
+                                       int conflictType = calculateConflictType(
+                                                       (LiveInNode) currentNode, (LiveInNode) entryNode);
+                                       if (conflictType > 0) {
+                                               addConflictEdge(conflictType, currentNode, entryNode);
+                                       }
+                                       analyzedIDSet.add(currentNode.getID() + entryNodeID);
                                }
 
                        }
-               }
-
-               bw.write("  graphTitle[label=\"" + graphName + "\",shape=box];\n");
 
-               bw.write("}\n");
-               bw.close();
+               }
 
        }
 
@@ -1227,9 +1102,9 @@ class ConflictEdge {
        public int getType() {
                return type;
        }
-       
-       public String toString(){
-               return getVertexU()+"-"+getVertexV();
+
+       public String toString() {
+               return getVertexU() + "-" + getVertexV();
        }
 
 }
\ No newline at end of file
index adb270a7b9253cf2336de84bbb8297fc0f765dbf..a461c484db46caa240a3ab6b0092931c5f4b521a 100644 (file)
@@ -1,8 +1,9 @@
 package Analysis.MLP;
 
+import Analysis.OwnershipAnalysis.Canonical;
 import Analysis.OwnershipAnalysis.TokenTuple;
 
-public class GloballyUniqueTokenTuple {
+public class GloballyUniqueTokenTuple extends Canonical{
 
        private Integer token;
        private boolean isMultiObject;
index 0f805a46e3af4b3133cde5f753059cdea0ca432c..95744071d11dc8421b1aa02d783cf971fee145dd 100644 (file)
@@ -331,7 +331,9 @@ public class MLPAnalysis {
                        FlatNode key = (FlatNode) keyEnum.nextElement();
                        ConflictGraph cg=conflictGraphResults.get(key);
                        try {
-                               cg.writeGraph("ConflictGraphFor"+key, false);
+                               if(cg.hasConflictEdge()){
+                                       cg.writeGraph("ConflictGraphFor"+key, false);
+                               }
                        } catch (IOException e) {
                                System.out.println("Error writing");
                                System.exit(0);
@@ -1212,9 +1214,14 @@ public class MLPAnalysis {
                                while (iter.hasNext()) {
                                        TempDescriptor td = iter.next();
                                        LabelNode ln = og.td2ln.get(td);
+                                       
+                                       if(currentSESE.getSeseEffectsSet().getMapTempDescToInVarIdx().containsKey(td)){
+                                               idx=currentSESE.getSeseEffectsSet().getInVarIdx(td);
+                                       }
+                                       
                                        if (ln != null) {
                                                int taint = (int) Math.pow(2, idx);
-                                               taintLabelNode(ln, taint);
+                                               taintLabelNode(ln, taint,currentSESE.getSeseEffectsSet());
                                                currentSESE.getSeseEffectsSet().setInVarIdx(idx, td);
 
                                                // collects related allocation sites
@@ -1365,20 +1372,22 @@ public class MLPAnalysis {
                case FKind.FlatFieldNode: {
 
                        FlatFieldNode ffn = (FlatFieldNode) fn;
+                       TempDescriptor dst = ffn.getDst();
                        TempDescriptor src = ffn.getSrc();
                        FieldDescriptor field = ffn.getField();
                        
                        LabelNode srcLN = og.td2ln.get(src);
                        if(srcLN!=null){
                                Iterator<ReferenceEdge> edgeIter=srcLN.iteratorToReferencees();
+                               int taintIdentifier=0;
                                while (edgeIter.hasNext()) {
                                        ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter
                                                        .next();
                                        HeapRegionNode refHRN=referenceEdge.getDst();
-                                       int edgeTaint=referenceEdge.getSESETaintIdentifier();
+                                       taintIdentifier=currentSESE.getSeseEffectsSet().getTaint(referenceEdge);
+//                                     taintIdentifier=referenceEdge.getSESETaintIdentifier();
                                        
                                        // figure out which invar has related effects
-                                       int taint=referenceEdge.getSESETaintIdentifier();
                                        Hashtable<TempDescriptor, Integer> map=currentSESE.getSeseEffectsSet().getMapTempDescToInVarIdx();
                                        Set<TempDescriptor> keySet=map.keySet();
                                        for (Iterator iterator = keySet.iterator(); iterator
@@ -1386,13 +1395,26 @@ public class MLPAnalysis {
                                                TempDescriptor inVarTD = (TempDescriptor) iterator
                                                                .next();
                                                int inVarMask=(int) Math.pow(2, map.get(inVarTD).intValue());
-                                               if((inVarMask&edgeTaint)>0){
+                                               if((inVarMask&taintIdentifier)>0){
                                                        // found related invar, contribute effects
                                                        currentSESE.readEffects(inVarTD, field.getSymbol(),src.getType(), refHRN);
                                                }
                                        }
                                }
+                               
+                               // taint
+                               if(!field.getType().isImmutable()){
+                                               LabelNode dstLN = og.td2ln.get(dst);
+                                               edgeIter=dstLN.iteratorToReferencees();
+                                               while (edgeIter.hasNext()) {
+                                                       ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter
+                                                                       .next();
+                                                       currentSESE.getSeseEffectsSet().mapEdgeToTaint(referenceEdge, taintIdentifier);
+//                                                     referenceEdge.unionSESETaintIdentifier(taintIdentifier);
+                                               }
+                               }
                        }
+                       
 
                }
                        break;
@@ -1416,7 +1438,11 @@ public class MLPAnalysis {
                                        while (refEdgeIter.hasNext()) {
                                                ReferenceEdge edge = refEdgeIter.next();
                                                int newTaint = (int) Math.pow(2, idx);
-                                               edge.unionSESETaintIdentifier(newTaint);
+//                                             System.out.println("fon="+fon);
+//                                             System.out.println(currentSESE+" src:"+src+"->"+"dest:"+dest+" with taint="+newTaint);
+//                                             System.out.println("referenceEdge="+edge);
+                                               currentSESE.getSeseEffectsSet().mapEdgeToTaint(edge, newTaint);
+//                                             System.out.println("after tainting="+edge.getSESETaintIdentifier());
                                        }
                                }
                        }
@@ -1437,10 +1463,10 @@ public class MLPAnalysis {
                                        ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter
                                                        .next();
                                        HeapRegionNode dstHRN=referenceEdge.getDst();
-                                       taintIdentifier=referenceEdge.getSESETaintIdentifier();                                 
+                                       taintIdentifier=currentSESE.getSeseEffectsSet().getTaint(referenceEdge);
+//                                     taintIdentifier=referenceEdge.getSESETaintIdentifier();                                 
                                        
                                        // figure out which invar has related effects
-                                       int taint=referenceEdge.getSESETaintIdentifier();
                                        Hashtable<TempDescriptor, Integer> map=currentSESE.getSeseEffectsSet().getMapTempDescToInVarIdx();
                                        Set<TempDescriptor> keySet=map.keySet();
                                        for (Iterator iterator = keySet.iterator(); iterator
@@ -1464,7 +1490,8 @@ public class MLPAnalysis {
                                while (edgeIter.hasNext()) {
                                        ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter
                                                        .next();
-                                       referenceEdge.unionSESETaintIdentifier(taintIdentifier);
+                                       currentSESE.getSeseEffectsSet().mapEdgeToTaint(referenceEdge, taintIdentifier);
+//                                     referenceEdge.unionSESETaintIdentifier(taintIdentifier);
                                }
                        }
                        
@@ -1486,7 +1513,8 @@ public class MLPAnalysis {
                                        ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter
                                                        .next();
                                        HeapRegionNode dstHRN=referenceEdge.getDst();
-                                       int edgeTaint=referenceEdge.getSESETaintIdentifier();
+                                       int edgeTaint=currentSESE.getSeseEffectsSet().getTaint(referenceEdge);
+//                                     int edgeTaint=referenceEdge.getSESETaintIdentifier();
                                        
                                        // we can do a strong update here if one of two cases
                                        // holds
@@ -1535,7 +1563,8 @@ public class MLPAnalysis {
                                        ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter
                                                        .next();
                                        HeapRegionNode dstHRN=referenceEdge.getDst();
-                                       int edgeTaint=referenceEdge.getSESETaintIdentifier();
+                                       int edgeTaint=currentSESE.getSeseEffectsSet().getTaint(referenceEdge);
+//                                     int edgeTaint=referenceEdge.getSESETaintIdentifier();
                                        
                                        // we can do a strong update here if one of two cases
                                        // holds
@@ -1638,7 +1667,8 @@ public class MLPAnalysis {
                                                ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter
                                                                .next();
                                                HeapRegionNode dstHRN=referenceEdge.getDst();
-                                               int edgeTaint=referenceEdge.getSESETaintIdentifier();
+                                               int edgeTaint=currentSESE.getSeseEffectsSet().getTaint(referenceEdge);
+//                                             int edgeTaint=referenceEdge.getSESETaintIdentifier();
                                                
                                                // figure out which invar has related effects
                                                Hashtable<TempDescriptor, Integer> map = currentSESE
@@ -1798,12 +1828,12 @@ public class MLPAnalysis {
                return new HashSet<Integer>();
        }
        
-       private void taintLabelNode(LabelNode ln, int identifier) {
+       private void taintLabelNode(LabelNode ln, int identifier, SESEEffectsSet effectSet) {
 
                Iterator<ReferenceEdge> edgeIter = ln.iteratorToReferencees();
                while (edgeIter.hasNext()) {
                        ReferenceEdge edge = edgeIter.next();
-                       edge.setSESETaintIdentifier(identifier);
+                       effectSet.mapEdgeToTaint(edge, identifier);
                }
 
        }
@@ -2174,6 +2204,7 @@ public class MLPAnalysis {
 
                        while (mcIter.hasNext()) {
                                MethodContext mc = mcIter.next();
+                               OwnershipGraph og=ownAnalysisForSESEConflicts.getOwnvershipGraphByMethodContext(mc);
 
                                Set<FlatNode> flatNodesToVisit = new HashSet<FlatNode>();
                                flatNodesToVisit.add(fm);
@@ -2209,7 +2240,7 @@ public class MLPAnalysis {
                                                        .getCurrentSESE());
 
                                        if (conflictGraph == null) {
-                                               conflictGraph = new ConflictGraph();
+                                               conflictGraph = new ConflictGraph(og);
                                        }
                                        for (Iterator<Entry<TempDescriptor, StallSite>> iterator2 = entrySet
                                                        .iterator(); iterator2.hasNext();) {
@@ -2219,7 +2250,7 @@ public class MLPAnalysis {
                                                StallSite stallSite = entry.getValue();
 
                                                // reachability set
-                                               OwnershipGraph og = ownAnalysisForSESEConflicts
+                                               og = ownAnalysisForSESEConflicts
                                                                .getOwnvershipGraphByMethodContext(mc);
                                                Set<Set> reachabilitySet = calculateReachabilitySet(og,
                                                                td);
@@ -2295,6 +2326,62 @@ public class MLPAnalysis {
                return reachabilitySet;
        }
        
+       private ReachabilitySet packupStates(OwnershipGraph og, HeapRegionNode hrn) {
+               
+               ReachabilitySet betaSet = new ReachabilitySet().makeCanonical();
+               
+               Iterator<ReferenceEdge> itrEdge = hrn.iteratorToReferencers();
+               while (itrEdge.hasNext()) {
+                       ReferenceEdge edge = itrEdge.next();
+                       betaSet = betaSet.union(edge.getBeta());
+               }
+               
+               return betaSet;
+               
+       }
+       
+       private ReachabilitySet packupStates(OwnershipGraph og, AllocationSite as) {
+
+               ReachabilitySet betaSet = new ReachabilitySet().makeCanonical();
+               assert as!=null;
+               HeapRegionNode hrnSummary = og.id2hrn.get(as.getSummary());
+               if(hrnSummary!=null){
+                       Iterator<ReferenceEdge> itrEdge = hrnSummary.iteratorToReferencers();
+                       while (itrEdge.hasNext()) {
+                               ReferenceEdge edge = itrEdge.next();
+                               betaSet = betaSet.union(edge.getBeta());
+                       }
+               }
+
+               // check for other nodes
+               for (int i = 0; i < as.getAllocationDepth(); ++i) {
+
+                       HeapRegionNode hrnIthOldest = og.id2hrn.get(as.getIthOldest(i));
+//                     betaSet = new ReachabilitySet().makeCanonical();
+//                     itrEdge = hrnIthOldest.iteratorToReferencees();
+                       Iterator<ReferenceEdge> itrEdge = hrnIthOldest.iteratorToReferencers();
+                       while (itrEdge.hasNext()) {
+                               ReferenceEdge edge = itrEdge.next();
+                               betaSet = betaSet.union(edge.getBeta());
+                       }
+               }
+
+               Iterator<TokenTupleSet> ttSetIter = betaSet.iterator();
+               while (ttSetIter.hasNext()) {
+                       TokenTupleSet tokenTupleSet = (TokenTupleSet) ttSetIter.next();
+                       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);
+                       }
+               }
+               return betaSet;
+       }
+       
        private void conflictGraph_nodeAction(MethodContext mc, FlatMethod fm,
                        FlatNode fn,Hashtable<TempDescriptor, TempDescriptor> invarMap) {
 
@@ -2314,7 +2401,7 @@ public class MLPAnalysis {
                                conflictGraph=conflictGraphResults.get(seseSummary.getCurrentParent());
                                
                                if(conflictGraph==null){
-                                       conflictGraph = new ConflictGraph();
+                                       conflictGraph = new ConflictGraph(og);
                                }
                                
 
@@ -2327,23 +2414,60 @@ public class MLPAnalysis {
                                                continue;
                                        }
                                        
-//                                     if(tempDescriptor.getType().isArray()){
-//                                             
-//                                     }
-                                       
                                        // effects set
                                        SESEEffectsSet seseEffectsSet = fsen.getSeseEffectsSet();
                                        Set<SESEEffectsKey> readEffectsSet = seseEffectsSet
                                                        .getReadingSet(tempDescriptor);
+                                       
+                                       if (readEffectsSet != null) {
+                                               for (Iterator iterator2 = readEffectsSet.iterator(); iterator2
+                                                               .hasNext();) {
+                                                       SESEEffectsKey seseEffectsKey = (SESEEffectsKey) iterator2
+                                                                       .next();
+                                                       String uniqueID = seseEffectsKey.getHRNUniqueId();
+                                                       HeapRegionNode node = og.gid2hrn.get(uniqueID);
+                                                       if(node.isParameter()){
+                                                               seseEffectsKey.setRSet(packupStates(og,node));
+                                                       }else{
+                                                               AllocationSite as = node.getAllocationSite();
+                                                               seseEffectsKey.setRSet(packupStates(og,as));
+                                                       }
+                                               }
+                                       }
+                                       
+                                       if (readEffectsSet != null) {
+                                               for (Iterator iterator2 = readEffectsSet.iterator(); iterator2
+                                                               .hasNext();) {
+                                                       SESEEffectsKey seseEffectsKey = (SESEEffectsKey) iterator2
+                                                       .next();
+                                               }
+                                       }
                                        Set<SESEEffectsKey> writeEffectsSet = seseEffectsSet
                                                        .getWritingSet(tempDescriptor);
+                                                                               
+                                       if (writeEffectsSet != null) {
+                                               for (Iterator iterator2 = writeEffectsSet.iterator(); iterator2
+                                                               .hasNext();) {
+                                                       SESEEffectsKey seseEffectsKey = (SESEEffectsKey) iterator2
+                                                                       .next();
+                                                       String uniqueID = seseEffectsKey.getHRNUniqueId();
+                                                       HeapRegionNode node = og.gid2hrn.get(uniqueID);
+                                                       
+                                                       if(node.isParameter()){
+                                                               seseEffectsKey.setRSet(packupStates(og,node));
+                                                       }else{
+                                                               AllocationSite as = node.getAllocationSite();
+                                                               seseEffectsKey.setRSet(packupStates(og,as));
+                                                       }
+                                               }
+                                       }
+                                       
                                        Set<SESEEffectsKey> strongUpdateSet = seseEffectsSet.getStrongUpdateSet(tempDescriptor);                
                                        
                                        Set<Set> reachabilitySet = calculateReachabilitySet(og,
                                                        tempDescriptor);
 
                                        // add new live-in node
-//                                     LabelNode ln = og.td2ln.get(tempDescriptor);
                                        
                                        OwnershipGraph lastOG = ownAnalysis
                                        .getOwnvershipGraphByMethodContext(mc);
@@ -2356,7 +2480,16 @@ public class MLPAnalysis {
                                        while (refIter.hasNext()) {
                                                ReferenceEdge referenceEdge = (ReferenceEdge) refIter
                                                                .next();
-                                               hrnSet.add(referenceEdge.getDst());
+                                               //
+                                               SESEEffectsSet seseEffects=fsen.getSeseEffectsSet();
+                                               int taintIdentifier=fsen.getSeseEffectsSet().getTaint(referenceEdge);
+                                               int invarIdx=fsen.getSeseEffectsSet().getInVarIdx(tempDescriptor);
+                                               int inVarMask=(int) Math.pow(2,invarIdx);
+                                               if((inVarMask&taintIdentifier)>0){
+                                                       // find tainted edge, add heap root to live-in node
+                                                       hrnSet.add(referenceEdge.getDst());
+                                               }
+                                               //
                                        }
                                        
                                        conflictGraph.addLiveInNode(tempDescriptor, hrnSet, fsen,
index dc824900841ffe822eb7ca556eb7cb78832dae05..d26e5ebd25ab34dd9c139a63c87600bd3ee90b93 100644 (file)
@@ -1,5 +1,6 @@
 package Analysis.MLP;
 
+import Analysis.OwnershipAnalysis.ReachabilitySet;
 import IR.TypeDescriptor;
 
 public class SESEEffectsKey {
@@ -8,6 +9,7 @@ public class SESEEffectsKey {
        private TypeDescriptor td;
        private Integer hrnId;
        private String hrnUniqueId;
+       private ReachabilitySet rset;
        private boolean wStrong=false;
 
        public SESEEffectsKey(String fd, TypeDescriptor td, Integer hrnId, String hrnUniqueId) {
@@ -17,6 +19,14 @@ public class SESEEffectsKey {
                this.hrnUniqueId=hrnUniqueId;
        }
        
+       public void setRSet(ReachabilitySet rset){
+               this.rset=rset;
+       }
+       
+       public ReachabilitySet getRSet(){
+               return rset;
+       }
+       
        public void setStrong(boolean wStrong){
                this.wStrong=wStrong;
        }
index e8f0da960f9ecdaca470a539c75393eecde96758..91a0cfa843cf69bcc70516f282f7afb28e033aa0 100644 (file)
@@ -6,6 +6,7 @@ import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Set;
 
+import Analysis.OwnershipAnalysis.ReferenceEdge;
 import IR.Flat.TempDescriptor;
 
 public class SESEEffectsSet {
@@ -13,12 +14,31 @@ public class SESEEffectsSet {
        private Hashtable<TempDescriptor, HashSet<SESEEffectsKey>> writeTable;
        private Hashtable<TempDescriptor, HashSet<SESEEffectsKey>> strongUpdateTable;
        private Hashtable<TempDescriptor, Integer> mapTempDescToInVarIdx;
+       private Hashtable<ReferenceEdge, Integer> mapEdgeToTaint;
 
        public SESEEffectsSet() {
                readTable = new Hashtable<TempDescriptor, HashSet<SESEEffectsKey>>();
                writeTable = new Hashtable<TempDescriptor, HashSet<SESEEffectsKey>>();
                strongUpdateTable =  new Hashtable<TempDescriptor, HashSet<SESEEffectsKey>>();
                mapTempDescToInVarIdx = new Hashtable<TempDescriptor, Integer>();
+               mapEdgeToTaint = new  Hashtable<ReferenceEdge, Integer>();
+       }
+       
+       public int getTaint(ReferenceEdge edge){
+               int taint=0;
+               if(mapEdgeToTaint.containsKey(edge)){
+                       taint=mapEdgeToTaint.get(edge).intValue();
+               }
+               return taint;
+       }
+       
+       public void mapEdgeToTaint(ReferenceEdge edge, int newTaint){
+               int taint=0;
+               if(mapEdgeToTaint.containsKey(edge)){
+                       taint=mapEdgeToTaint.get(edge).intValue();
+               }
+               taint=taint | newTaint;
+               mapEdgeToTaint.put(edge, new Integer(taint));
        }
 
        public void setInVarIdx(int idx, TempDescriptor td){
index 5429938fe38788290c855f74bdf2a8323066ad96..3c37e4a124e20eb19ec50c9885a129038868e0c4 100644 (file)
@@ -87,6 +87,8 @@ public class OwnershipGraph {
   // to know the access paths that allowed it, to prune edges when
   // mapping them back into the caller--an access path must appear
   public Hashtable< TempDescriptor, Set<AccessPath> > temp2accessPaths;
+  
+  public Hashtable< String, HeapRegionNode > gid2hrn;
 
 
   public OwnershipGraph() {
@@ -121,6 +123,8 @@ public class OwnershipGraph {
     outOfScopeLabels.add( getLabelNodeFromTemp( tdReturn ) );
 
     temp2accessPaths = new Hashtable< TempDescriptor, Set<AccessPath> >();
+    
+    gid2hrn =new  Hashtable< String, HeapRegionNode >(); 
   }
 
 
@@ -202,6 +206,7 @@ public class OwnershipGraph {
                                             description,
                                             globalIdentifier);
     id2hrn.put(id, hrn);
+    gid2hrn.put(globalIdentifier, hrn);
     return hrn;
   }
 
@@ -3938,6 +3943,7 @@ public class OwnershipGraph {
       if( !id2hrn.containsKey(idA) ) {
        HeapRegionNode hrnB = hrnA.copy();
        id2hrn.put(idA, hrnB);
+       gid2hrn.put(hrnA.getGloballyUniqueIdentifier(), hrnB);
 
       } else {
        // otherwise this is a node present in both graphs
index 0f8df47448798559c0b14c8cb3c711b2c5994888..85b4c1e3621342021235b1bd3e4286f18dd0e2d2 100644 (file)
@@ -367,7 +367,7 @@ public class BuildCode {
        outmethod.print("       struct "+cd.getSafeSymbol()+locality.getMain().getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={");
       } else
        outmethod.print("       struct "+cd.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={");
-      outmethod.println("1, NULL,"+"stringarray};");
+    outmethod.println("1, NULL,"+"stringarray};");
       if (state.DSM||state.SINGLETM)
        outmethod.println("     "+cd.getSafeSymbol()+locality.getMain().getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"(& __parameterlist__);");
       else
@@ -1450,8 +1450,8 @@ public class BuildCode {
        output.println("struct "+cn.getSafeSymbol()+lb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params {");
       else
        output.println("struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params {");
-      output.println("  INTPTR size;");
-      output.println("  void * next;");
+      output.println("  int size;");
+      output.println("  void * next;");      
       for(int i=0; i<objectparams.numPointers(); i++) {
        TempDescriptor temp=objectparams.getPointer(i);
        output.println("  struct "+temp.getType().getSafeSymbol()+" * "+temp.getSafeSymbol()+";");
@@ -1475,7 +1475,7 @@ public class BuildCode {
        output.println("struct "+cn.getSafeSymbol()+lb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals {");
       else
        output.println("struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals {");
-      output.println("  INTPTR size;");
+      output.println("  int size;");
       output.println("  void * next;");
       for(int i=0; i<objecttemps.numPointers(); i++) {
        TempDescriptor temp=objecttemps.getPointer(i);
@@ -1553,8 +1553,7 @@ public class BuildCode {
       /* Output parameter structure */
       if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
        output.println("struct "+task.getSafeSymbol()+"_params {");
-
-       output.println("  INTPTR size;");
+       output.println("  int size;");
        output.println("  void * next;");
        for(int i=0; i<objectparams.numPointers(); i++) {
          TempDescriptor temp=objectparams.getPointer(i);
@@ -1570,7 +1569,7 @@ public class BuildCode {
       /* Output temp structure */
       if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
        output.println("struct "+task.getSafeSymbol()+"_locals {");
-       output.println("  INTPTR size;");
+       output.println("  int size;");
        output.println("  void * next;");
        for(int i=0; i<objecttemps.numPointers(); i++) {
          TempDescriptor temp=objecttemps.getPointer(i);
@@ -1731,7 +1730,6 @@ public class BuildCode {
        output.print("   struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals "+localsprefix+"={");
       else
        output.print("   struct "+task.getSafeSymbol()+"_locals "+localsprefix+"={");
-
       output.print(objecttemp.numPointers()+",");
       output.print(paramsprefix);
       for(int j=0; j<objecttemp.numPointers(); j++)
@@ -1807,7 +1805,7 @@ public class BuildCode {
     /* Check to see if we need to do a GC if this is a
      * multi-threaded program...*/
 
-    if (((state.THREAD||state.DSM||state.SINGLETM)&&GENERATEPRECISEGC) 
+    if (((state.MLP||state.THREAD||state.DSM||state.SINGLETM)&&GENERATEPRECISEGC) 
         || this.state.MULTICOREGC) {
       //Don't bother if we aren't in recursive methods...The loops case will catch it
       if (callgraph.getAllMethods(md).contains(md)) {
@@ -1903,7 +1901,7 @@ public class BuildCode {
                          fsen.getmdBogus().getSafeSymbol()+"_"+
                          fsen.getmdBogus().getSafeMethodDescriptor()+
                          "_locals {");
-    outputStructs.println("  INTPTR size;");
+    outputStructs.println("  int size;");
     outputStructs.println("  void * next;");
     for(int i=0; i<objecttemps.numPointers(); i++) {
       TempDescriptor temp=objecttemps.getPointer(i);
@@ -1927,25 +1925,12 @@ public class BuildCode {
     outputStructs.println("  SESEcommon common;");
 
     // then garbage list stuff
-    outputStructs.println("  INTPTR size;");
+    outputStructs.println("  int size;");
     outputStructs.println("  void * next;");
 
-    // in-set source tracking
-    // in-vars that are READY come from parent, don't need anything
-    // stuff STATIC needs a custom SESE pointer for each age pair
-    Iterator<SESEandAgePair> itrStaticInVarSrcs = fsen.getStaticInVarSrcs().iterator();
-    while( itrStaticInVarSrcs.hasNext() ) {
-      SESEandAgePair srcPair = itrStaticInVarSrcs.next();
-      outputStructs.println("  "+srcPair.getSESE().getSESErecordName()+"* "+srcPair+";");
-    }    
-
-    // DYNAMIC stuff needs a source SESE ptr and offset
-    Iterator<TempDescriptor> itrDynInVars = fsen.getDynamicInVarSet().iterator();
-    while( itrDynInVars.hasNext() ) {
-      TempDescriptor dynInVar = itrDynInVars.next();
-      outputStructs.println("  void* "+dynInVar+"_srcSESE;");
-      outputStructs.println("  int   "+dynInVar+"_srcOffset;");
-    }    
+    // DYNAMIC stuff was here
+    
+    // invar source taking was here
 
     // space for all in and out set primitives
     Set<TempDescriptor> inSetAndOutSet = new HashSet<TempDescriptor>();
@@ -1967,7 +1952,9 @@ public class BuildCode {
     while( itrPrims.hasNext() ) {
       TempDescriptor temp = itrPrims.next();
       TypeDescriptor type = temp.getType();
-      outputStructs.println("  "+temp.getType().getSafeSymbol()+" "+temp.getSafeSymbol()+";");
+      if(!type.isPrimitive()){
+         outputStructs.println("  "+temp.getType().getSafeSymbol()+" "+temp.getSafeSymbol()+";");
+      }      
     }
 
     for(int i=0; i<objectparams.numPointers(); i++) {
@@ -1978,6 +1965,42 @@ public class BuildCode {
         outputStructs.println("  struct "+temp.getType().getSafeSymbol()+" * "+temp.getSafeSymbol()+";");
     }
     
+    // DYNAMIC stuff needs a source SESE ptr and offset
+    Iterator<TempDescriptor> itrDynInVars = fsen.getDynamicInVarSet().iterator();
+    while( itrDynInVars.hasNext() ) {
+      TempDescriptor dynInVar = itrDynInVars.next();
+//      outputStructs.println("  void* "+dynInVar+"_srcSESE;");
+      outputStructs.println("  int   "+dynInVar+"_srcOffset;");
+    }  
+    
+    itrPrims = inSetAndOutSetPrims.iterator();
+    while( itrPrims.hasNext() ) {
+      TempDescriptor temp = itrPrims.next();
+      TypeDescriptor type = temp.getType();
+      if(type.isPrimitive()){
+         outputStructs.println("  "+temp.getType().getSafeSymbol()+" "+temp.getSafeSymbol()+";");
+      }      
+    }
+    
+    outputStructs.println("  int prevSESECount;");
+    
+    // DYNAMIC stuff needs a source SESE ptr and offset
+    itrDynInVars = fsen.getDynamicInVarSet().iterator();
+    while( itrDynInVars.hasNext() ) {
+      TempDescriptor dynInVar = itrDynInVars.next();
+      outputStructs.println("  void* "+dynInVar+"_srcSESE;");
+//      outputStructs.println("  int   "+dynInVar+"_srcOffset;");
+    }  
+    
+    // in-set source tracking
+    // in-vars that are READY come from parent, don't need anything
+    // stuff STATIC needs a custom SESE pointer for each age pair
+    Iterator<SESEandAgePair> itrStaticInVarSrcs = fsen.getStaticInVarSrcs().iterator();
+    while( itrStaticInVarSrcs.hasNext() ) {
+      SESEandAgePair srcPair = itrStaticInVarSrcs.next();
+      outputStructs.println("  "+srcPair.getSESE().getSESErecordName()+"* "+srcPair+";");
+    }    
+    
     outputStructs.println("};\n");
 
     
@@ -2014,7 +2037,7 @@ public class BuildCode {
     if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
       output.print("   struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals "+localsprefix+"={");
       output.print(objecttemp.numPointers()+",");
-      output.print("(void*) &("+paramsprefix+"->size)");
+      output.print("&(((SESEcommon*)(___params___))[1])");
       for(int j=0; j<objecttemp.numPointers(); j++)
        output.print(", NULL");
       output.println("};");
@@ -2178,14 +2201,15 @@ public class BuildCode {
     // Check to see if we need to do a GC if this is a
     // multi-threaded program...    
     if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
+       output.println("if (unlikely(needtocollect)) checkcollect("+localsprefixaddr+");");
       //Don't bother if we aren't in recursive methods...The loops case will catch it
-      if (callgraph.getAllMethods(md).contains(md)) {
-        if(this.state.MULTICOREGC) {
-          output.println("if(gcflag) gc("+localsprefixaddr+");");
-        } else {
-         output.println("if (unlikely(needtocollect)) checkcollect("+localsprefixaddr+");");
-       }
-      }
+//      if (callgraph.getAllMethods(md).contains(md)) {
+//        if(this.state.MULTICOREGC) {
+//          output.println("if(gcflag) gc("+localsprefixaddr+");");
+//        } else {
+//       output.println("if (unlikely(needtocollect)) checkcollect("+localsprefixaddr+");");
+//     }
+//      }
     }    
 
     // initialize thread-local var to a non-zero, invalid address
@@ -2860,7 +2884,7 @@ public class BuildCode {
       if(state.DSM&&state.SANDBOX&&(locality.getAtomic(lb).get(fn).intValue()>0)) {
         output.println("if (unlikely((--transaction_check_counter)<=0)) checkObjects();");
       }
-      if (((state.THREAD||state.DSM||state.SINGLETM)&&GENERATEPRECISEGC)
+      if (((state.MLP||state.THREAD||state.DSM||state.SINGLETM)&&GENERATEPRECISEGC)
           || (this.state.MULTICOREGC)) {
        if(state.DSM&&locality.getAtomic(lb).get(fn).intValue()>0) {
          output.println("if (needtocollect) checkcollect2("+localsprefixaddr+");");
@@ -3323,6 +3347,21 @@ public class BuildCode {
     output.println("     "+fsen.getSESErecordName()+"* seseToIssue = ("+
                           fsen.getSESErecordName()+"*) mlpAllocSESErecord( sizeof( "+
                           fsen.getSESErecordName()+" ) );");
+    //eomgc need to set next, size
+//    output.println("       struct garbagelist * gl= (struct garbagelist *)&(((SESEcommon*)(seseToIssue))[1]);");
+    output.println("     struct garbagelist * gl= (struct garbagelist *)&(((SESEcommon*)(seseToIssue))[1]);");
+    // sizeof(int)*2 + sizeof(void*)*calculateSizeOfSESEParamList(fsen)
+    //output.println("       // sizeof(int)*2+sizeof(void*)*"+calculateSizeOfSESEParamList(fsen));
+    //output.println("       // blah="+calculateSizeOfSESEParamSize(fsen));
+    output.println("     (seseToIssue->common).offsetsize=sizeof(int)+sizeof(void*)+sizeof(void*)*"+calculateSizeOfSESEParamList(fsen)+calculateSizeOfSESEParamSize(fsen)+";");
+    output.println("     gl->size="+calculateSizeOfSESEParamList(fsen)+";");
+//    output.println("       gl->next = (struct garbagelist *)&___locals___;");
+    output.println("     seseToIssue->prevSESECount="+calculatePrevSESECount(fsen)+";");
+//    output.println("     seseToIssue->prevSESECount=50;");
+    output.println("     gl->next = NULL;");
+//    output.println("     seseToIssue->size = "+calculateSizeOfSESEParamList(fsen)+";");
+//    output.println("     seseToIssue->next = &___locals___;");
+    
 
     // and keep the thread-local sese stack up to date
     //output.println("     addNewItem( seseCallStack, (void*) seseToIssue);");
@@ -3378,7 +3417,14 @@ public class BuildCode {
        SESEandAgePair srcPair = staticSrcsItr.next();
        output.println("     {");
        output.println("       SESEcommon* src = (SESEcommon*)"+srcPair+";");
+       //eomgc
+       if(GENERATEPRECISEGC){
+               output.println("       stopforgc((struct garbagelist *)&___locals___);");
+       }
        output.println("       pthread_mutex_lock( &(src->lock) );");
+       if(GENERATEPRECISEGC){
+               output.println("       restartaftergc();");
+       }
        output.println("       if( !isEmpty( src->forwardList ) &&");
        output.println("           seseToIssue == peekItem( src->forwardList ) ) {");
        output.println("         printf( \"This shouldnt already be here\\n\");");
@@ -3409,7 +3455,14 @@ public class BuildCode {
        // the address off to the new child, because you're not done executing and
        // might change the variable, so copy it right now
        output.println("       if( src != NULL ) {");
+       //eomgc
+       if(GENERATEPRECISEGC){
+               output.println("         stopforgc((struct garbagelist *)&___locals___);");
+       }
        output.println("         pthread_mutex_lock( &(src->lock) );");
+       if(GENERATEPRECISEGC){
+               output.println("         restartaftergc();");
+       }
        output.println("         if( isEmpty( src->forwardList ) ||");
        output.println("             seseToIssue != peekItem( src->forwardList ) ) {");
        output.println("           if( !src->doneExecuting ) {");
@@ -3606,11 +3659,25 @@ public class BuildCode {
     // this SESE cannot be done until all of its children are done
     // so grab your own lock with the condition variable for watching
     // that the number of your running children is greater than zero    
+    if (GENERATEPRECISEGC){
+       output.println("   stopforgc((struct garbagelist *)&___locals___);");
+    }
     output.println("   pthread_mutex_lock( &("+com+".lock) );");
+    if (GENERATEPRECISEGC){
+       output.println("   restartaftergc();");
+    }
     output.println("   while( "+com+".numRunningChildren > 0 ) {");
+    if (GENERATEPRECISEGC){
+//     output.println("   stopforgc((struct garbagelist *)&(((SESEcommon*)(___params___))[1]));");
+       output.println("   stopforgc((struct garbagelist *)&___locals___);");
+    }
     output.println("     pthread_cond_wait( &("+com+".runningChildrenCond), &("+com+".lock) );");
+    if (GENERATEPRECISEGC){
+       output.println("   restartaftergc();");
+    }
     output.println("   }");
 
+
     // copy out-set from local temps into the sese record
     Iterator<TempDescriptor> itr = fsen.getOutVarSet().iterator();
     while( itr.hasNext() ) {
@@ -3699,7 +3766,13 @@ public class BuildCode {
     // last of all, decrement your parent's number of running children    
     output.println("   if( "+paramsprefix+"->common.parent != NULL ) {");
     output.println("     if (atomic_sub_and_test(1, &"+paramsprefix+"->common.parent->numRunningChildren)) {");
+    if (GENERATEPRECISEGC){
+       output.println("   stopforgc((struct garbagelist *)&___locals___);");
+    }
     output.println("       pthread_mutex_lock( &("+paramsprefix+"->common.parent->lock) );");
+    if (GENERATEPRECISEGC){
+       output.println("   restartaftergc();");
+    }
     output.println("       pthread_cond_signal( &("+paramsprefix+"->common.parent->runningChildrenCond) );");
     output.println("       pthread_mutex_unlock( &("+paramsprefix+"->common.parent->lock) );");
     output.println("     }");
@@ -3798,7 +3871,6 @@ public class BuildCode {
        output.print("       struct "+cn.getSafeSymbol()+fclb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={");
       } else
        output.print("       struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={");
-
       output.print(objectparams.numPointers());
       output.print(", "+localsprefixaddr);
       if (md.getThis()!=null) {
@@ -4005,8 +4077,12 @@ public class BuildCode {
        output.println(generateTemp(fm, ffn.getDst(),lb)+"="+ generateTemp(fm,ffn.getSrc(),lb)+"->"+ ffn.getField().getSafeSymbol()+";");
       } else
        throw new Error("Read from non-global/non-local in:"+lb.getExplanation());
-    } else
+    } else{
+// DEBUG       if(!ffn.getDst().getType().isPrimitive()){
+// DEBUG               output.println("within((void*)"+generateTemp(fm,ffn.getSrc(),lb)+"->"+ ffn.getField().getSafeSymbol()+");");
+// DEBUG       }      
       output.println(generateTemp(fm, ffn.getDst(),lb)+"="+ generateTemp(fm,ffn.getSrc(),lb)+"->"+ ffn.getField().getSafeSymbol()+";");
+    }
   }
 
 
@@ -4103,6 +4179,10 @@ public class BuildCode {
        output.println(fcrevert+"=(struct ___Object___ *)"+dst+";");
        output.println("}");
       }
+      
+// DEBUG       if(!fsfn.getField().getType().isPrimitive()){
+// DEBUG               output.println("within((void*)"+generateTemp(fm,fsfn.getSrc(),lb)+");");
+// DEBUG   }   
       output.println(generateTemp(fm, fsfn.getDst(),lb)+"->"+ fsfn.getField().getSafeSymbol()+"="+ generateTemp(fm,fsfn.getSrc(),lb)+";");
     }
   }
@@ -4164,7 +4244,8 @@ public class BuildCode {
       } else
        throw new Error("Read from non-global/non-local in:"+lb.getExplanation());
     } else {
-      output.println(generateTemp(fm, fen.getDst(),lb)+"=(("+ type+"*)(((char *) &("+ generateTemp(fm,fen.getSrc(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fen.getIndex(),lb)+"];");
+// DEBUG output.println("within((void*)"+generateTemp(fm,fen.getSrc(),lb)+");");
+        output.println(generateTemp(fm, fen.getDst(),lb)+"=(("+ type+"*)(((char *) &("+ generateTemp(fm,fen.getSrc(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fen.getIndex(),lb)+"];");
     }
   }
 
@@ -4266,6 +4347,7 @@ public class BuildCode {
        output.println(fcrevert+"=(struct ___Object___ *)"+dst+";");
        output.println("}");
       }
+// DEBUG      output.println("within((void*)"+generateTemp(fm,fsen.getDst(),lb)+");");
       output.println("(("+type +"*)(((char *) &("+ generateTemp(fm,fsen.getDst(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fsen.getIndex(),lb)+"]="+generateTemp(fm,fsen.getSrc(),lb)+";");
     }
   }
@@ -5055,6 +5137,93 @@ public class BuildCode {
 
   protected void outputTransCode(PrintWriter output) {
   }
+  
+  private int calculateSizeOfSESEParamList(FlatSESEEnterNode fsen){
+         
+         Set<TempDescriptor> tdSet=new HashSet<TempDescriptor>();
+         
+         for (Iterator iterator = fsen.getInVarSet().iterator(); iterator.hasNext();) {
+               TempDescriptor tempDescriptor = (TempDescriptor) iterator.next();
+               if(!tempDescriptor.getType().isPrimitive() || tempDescriptor.getType().isArray()){
+                       tdSet.add(tempDescriptor);
+               }       
+         }
+         
+         for (Iterator iterator = fsen.getOutVarSet().iterator(); iterator.hasNext();) {
+                       TempDescriptor tempDescriptor = (TempDescriptor) iterator.next();
+                       if(!tempDescriptor.getType().isPrimitive() || tempDescriptor.getType().isArray()){
+                               tdSet.add(tempDescriptor);
+                       }       
+         }       
+                 
+         return tdSet.size();
+  }
+  
+private String calculateSizeOfSESEParamSize(FlatSESEEnterNode fsen){
+         HashMap <String,Integer> map=new HashMap();
+         HashSet <TempDescriptor> processed=new HashSet<TempDescriptor>();
+         String rtr="";
+         
+         // space for all in and out set primitives
+           Set<TempDescriptor> inSetAndOutSet = new HashSet<TempDescriptor>();
+           inSetAndOutSet.addAll( fsen.getInVarSet() );
+           inSetAndOutSet.addAll( fsen.getOutVarSet() );
+           
+           Set<TempDescriptor> inSetAndOutSetPrims = new HashSet<TempDescriptor>();
+
+           Iterator<TempDescriptor> itr = inSetAndOutSet.iterator();
+           while( itr.hasNext() ) {
+             TempDescriptor temp = itr.next();
+             TypeDescriptor type = temp.getType();
+             if( !type.isPtr() ) {
+               inSetAndOutSetPrims.add( temp );
+             }
+           }
+           
+           Iterator<TempDescriptor> itrPrims = inSetAndOutSetPrims.iterator();
+           while( itrPrims.hasNext() ) {
+             TempDescriptor temp = itrPrims.next();
+             TypeDescriptor type = temp.getType();
+             if(type.isPrimitive()){
+                               Integer count=map.get(type.getSymbol());
+                               if(count==null){
+                                       count=new Integer(1);
+                                       map.put(type.getSymbol(), count);
+                               }else{
+                                       map.put(type.getSymbol(), new Integer(count.intValue()+1));
+                               }
+             }      
+           }
+         
+         Set<String> keySet=map.keySet();
+         for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
+               String key = (String) iterator.next();
+               rtr+="+sizeof("+key+")*"+map.get(key);
+         }
+         return  rtr;
+}
+
+private int calculatePrevSESECount(FlatSESEEnterNode fsen){
+       int count=0;
+       
+    // dynamic stuff
+    Iterator<TempDescriptor>itrDynInVars = fsen.getDynamicInVarSet().iterator();
+    while( itrDynInVars.hasNext() ) {
+      TempDescriptor dynInVar = itrDynInVars.next();
+      count++;
+    }  
+    
+    // in-set source tracking
+    Iterator<SESEandAgePair> itrStaticInVarSrcs = fsen.getStaticInVarSrcs().iterator();
+    while( itrStaticInVarSrcs.hasNext() ) {
+      SESEandAgePair srcPair = itrStaticInVarSrcs.next();
+      count++;
+    }   
+    
+       return count;
+}
+
+
 }
 
 
index 8ca3a616c947cc170ce4283f9f406d208f149767..bc12ef06a5043d2bcc02698dedc95b7033e89ccc 100644 (file)
@@ -11,6 +11,8 @@
 #endif
 #ifdef MLP
 #include "workschedule.h"
+extern struct QI * headqi;
+extern struct QI * tailqi;
 #endif
 
 #ifdef DMALLOC
@@ -64,6 +66,10 @@ __thread struct listitem litem;
 #endif
 #endif
 
+#ifdef MLP
+__thread SESEcommon* seseCommon;
+#endif
+
 //Need to check if pointers are transaction pointers
 //this also catches the special flag value of 1 for local copies
 #ifdef DSTM
@@ -100,12 +106,15 @@ __thread struct listitem litem;
     dst=copy; }
 #else
 #define ENQUEUE(orig, dst) \
-  void *copy; \
-  if (gc_createcopy(orig,&copy)) \
-    enqueue(copy);\
-  dst=copy
+  if (orig>=curr_heapbase&&orig<curr_heaptop) {        \
+     void *copy; \
+     if (gc_createcopy(orig,&copy)) \
+         enqueue(copy); \
+     dst=copy; \
+  }
 #endif
 
+
 struct pointerblock {
   void * ptrs[NUMPTRS];
   struct pointerblock *next;
@@ -121,6 +130,7 @@ void * to_heapptr=0;
 void * to_heaptop=0;
 long lastgcsize=0;
 
+
 struct pointerblock *head=NULL;
 int headindex=0;
 struct pointerblock *tail=NULL;
@@ -133,8 +143,7 @@ void enqueue(void *ptr) {
     if (spare!=NULL) {
       tmp=spare;
       spare=NULL;
-    } else
-      tmp=malloc(sizeof(struct pointerblock));
+    } else      tmp=malloc(sizeof(struct pointerblock));
     head->next=tmp;
     head=tmp;
     headindex=0;
@@ -362,14 +371,14 @@ void collect(struct garbagelist * stackptr) {
 #if defined(STM)||defined(THREADS)||defined(MLP)
   memorybase=NULL;
 #endif
-
   /* Check current stack */
 #if defined(THREADS)||defined(DSTM)||defined(STM)||defined(MLP)
   {
     struct listitem *listptr=list;
     while(1) {
 #endif
-
+      
   while(stackptr!=NULL) {
     int i;
     for(i=0; i<stackptr->size; i++) {
@@ -383,6 +392,11 @@ void collect(struct garbagelist * stackptr) {
 #ifndef MAC
   //skip over us
   if (listptr==&litem) {
+#ifdef MLP
+    // update forward list & memory queue for the current SESE
+    updateForwardList(((SESEcommon*)listptr->seseCommon)->forwardList,FALSE);
+    updateMemoryQueue((SESEcommon*)(listptr->seseCommon));
+#endif
     listptr=listptr->next;
   }
 #else
@@ -393,7 +407,7 @@ void collect(struct garbagelist * stackptr) {
   }
  }
 #endif
-
   if (listptr!=NULL) {
 #ifdef THREADS
     void * orig=listptr->locklist;
@@ -410,6 +424,11 @@ void collect(struct garbagelist * stackptr) {
 #endif
 #if defined(STM)||defined(THREADS)||defined(MLP)
     *(listptr->base)=NULL;
+#endif
+#ifdef MLP
+    // update forward list & memory queue for all running SESEs.
+    updateForwardList(((SESEcommon*)listptr->seseCommon)->forwardList,FALSE);
+    updateMemoryQueue((SESEcommon*)(listptr->seseCommon));
 #endif
     stackptr=listptr->stackptr;
     listptr=listptr->next;
@@ -516,6 +535,36 @@ void collect(struct garbagelist * stackptr) {
   }
 #endif
 
+#ifdef MLP
+  {
+    // goes over ready-to-run SESEs
+    struct QI * qitem = headqi;
+    while(qitem!=NULL){
+      SESEcommon* common=(SESEcommon*)qitem->value;
+      if(common==seseCommon){
+       // skip the current running SESE
+       qitem=qitem->next;
+       continue;
+      }
+      struct garbagelist * gl=(struct garbagelist *)&(((SESEcommon*)(qitem->value))[1]);
+      struct garbagelist * glroot=gl;
+      // update its ascendant SESEs 
+      updateAscendantSESE(gl); 
+  
+      while(gl!=NULL) {
+       int i;
+       for(i=0; i<gl->size; i++) {
+         void * orig=gl->array[i];
+         ENQUEUE(orig, gl->array[i]);
+       }
+       gl=gl->next;
+      } 
+      qitem=qitem->next;
+    }
+  }    
+#endif
+
+
   while(moreItems()) {
     void * ptr=dequeue();
     void *cpy=ptr;
@@ -575,6 +624,17 @@ void collect(struct garbagelist * stackptr) {
   fixtags();
 #endif
 
+#ifdef MLP
+  {
+    //rehash memory queues of current running SESEs
+    struct listitem *listptr=list;
+    while(listptr!=NULL){
+      rehashMemoryQueue((SESEcommon*)(listptr->seseCommon));
+      listptr=listptr->next;
+    }
+  }
+#endif
+
 #if defined(THREADS)||defined(DSTM)||defined(STM)||defined(MLP)
   needtocollect=0;
   pthread_mutex_unlock(&gclistlock);
@@ -757,7 +817,7 @@ void * mygcmalloc(struct garbagelist * stackptr, int size) {
       /* Need to allocate base heap */
       curr_heapbase=malloc(INITIALHEAPSIZE);
       if (curr_heapbase==NULL) {
-       printf("malloc failed.  Garbage collector couldn't get enough memory.  Try changing heap size.\n");
+       printf("malloc failed.  Garbage colletcor couldn't get enough memory.  Try changing heap size.\n");
        exit(-1);
       }
 #if defined(STM)||defined(THREADS)||defined(MLP)
@@ -767,7 +827,7 @@ void * mygcmalloc(struct garbagelist * stackptr, int size) {
       curr_heaptop=curr_heapbase+INITIALHEAPSIZE;
       curr_heapgcpoint=((char *) curr_heapbase)+GCPOINT(INITIALHEAPSIZE);
       curr_heapptr=curr_heapbase+size;
-    
+          
       to_heapbase=malloc(INITIALHEAPSIZE);
       if (to_heapbase==NULL) {
        printf("malloc failed.  Garbage collector couldn't get enough memory.  Try changing heap size.\n");
@@ -926,3 +986,138 @@ int gc_createcopy(void * orig, void ** copy_ptr) {
     }
   }
 }
+
+#ifdef MLP
+updateForwardList(struct Queue *forwardList, int prevUpdate){
+
+  struct QueueItem * fqItem=getHead(forwardList);
+  while(fqItem!=NULL){
+    struct garbagelist * gl=(struct garbagelist *)&(((SESEcommon*)(fqItem->objectptr))[1]);
+    if(prevUpdate==TRUE){
+      updateAscendantSESE(gl); 
+    }
+    // do something here
+    while(gl!=NULL) {
+      int i;
+        for(i=0; i<gl->size; i++) {
+          void * orig=gl->array[i];
+          ENQUEUE(orig, gl->array[i]);
+        }
+        gl=gl->next;
+    }    
+    // iterate forwarding list of seseRec      
+    SESEcommon *common=(SESEcommon*)fqItem->objectptr;
+    struct Queue* fList=common->forwardList;
+    updateForwardList(fList,prevUpdate);   
+    fqItem=getNextQueueItem(fqItem);
+  }   
+
+}
+
+updateMemoryQueue(SESEcommon_p seseParent){
+  // update memory queue
+  int i,binidx;
+  for(i=0; i<seseParent->numMemoryQueue; i++){
+    MemoryQueue *memoryQueue=seseParent->memoryQueueArray[i];
+    MemoryQueueItem *memoryItem=memoryQueue->head;
+    while(memoryItem!=NULL){
+      if(memoryItem->type==HASHTABLE){
+       Hashtable *ht=(Hashtable*)memoryItem;
+       for(binidx=0; binidx<NUMBINS; binidx++){
+         BinElement *bin=ht->array[binidx];
+         BinItem *binItem=bin->head;
+         while(binItem!=NULL){
+           if(binItem->type==READBIN){
+             ReadBinItem* readBinItem=(ReadBinItem*)binItem;
+             int ridx;
+             for(ridx=0; ridx<readBinItem->index; ridx++){
+               REntry *rentry=readBinItem->array[ridx];                  
+               struct garbagelist * gl= (struct garbagelist *)&(((SESEcommon*)(rentry->seseRec))[1]);
+               updateAscendantSESE(gl);
+               while(gl!=NULL) {
+                 int i;
+                 for(i=0; i<gl->size; i++) {
+                   void * orig=gl->array[i];
+                   ENQUEUE(orig, gl->array[i]);
+                 }
+                 gl=gl->next;
+               } 
+             } 
+           }else{ //writebin
+             REntry *rentry=((WriteBinItem*)binItem)->val;
+             struct garbagelist * gl= (struct garbagelist *)&(((SESEcommon*)(rentry->seseRec))[1]);
+             updateAscendantSESE(gl);
+             while(gl!=NULL) {
+               int i;
+               for(i=0; i<gl->size; i++) {
+                 void * orig=gl->array[i];
+                 ENQUEUE(orig, gl->array[i]);
+               }
+               gl=gl->next;
+             } 
+           }
+           binItem=binItem->next;
+         }
+       }
+      }else if(memoryItem->type==VECTOR){
+       Vector *vt=(Vector*)memoryItem;
+       int idx;
+       for(idx=0; idx<vt->index; idx++){
+         REntry *rentry=vt->array[idx];
+         struct garbagelist * gl= (struct garbagelist *)&(((SESEcommon*)(rentry->seseRec))[1]);
+         updateAscendantSESE(gl);
+         while(gl!=NULL) {
+           int i;
+           for(i=0; i<gl->size; i++) {
+             void * orig=gl->array[i];
+             ENQUEUE(orig, gl->array[i]);
+           }
+           gl=gl->next;
+         } 
+       }
+      }else if(memoryItem->type==SINGLEITEM){
+       SCC *scc=(SCC*)memoryItem;
+       REntry *rentry=scc->val;
+       struct garbagelist * gl= (struct garbagelist *)&(((SESEcommon*)(rentry->seseRec))[1]);
+       updateAscendantSESE(gl);
+       while(gl!=NULL) {
+         int i;
+         for(i=0; i<gl->size; i++) {
+           void * orig=gl->array[i];
+           ENQUEUE(orig, gl->array[i]);
+         }
+         gl=gl->next;
+       } 
+      }
+      memoryItem=memoryItem->next;
+    }
+  }     
+ }
+updateAscendantSESE(struct garbagelist *gl){ 
+  int offsetsize=*((int*)((void*)gl-sizeof(int)));
+  int prevSESECount=*((int*)((void*)gl+offsetsize));
+  INTPTR tailaddr=(INTPTR)((void*)gl+offsetsize+sizeof(int));
+  int prevIdx;
+  for(prevIdx=0; prevIdx<prevSESECount; prevIdx++){
+    SESEcommon* prevSESE=(SESEcommon*)*((INTPTR*)(tailaddr+sizeof(void*)*prevIdx));
+    if(prevSESE!=NULL){
+      struct garbagelist * prevgl=(struct garbagelist *)&(((SESEcommon*)(prevSESE))[1]);
+      while(prevgl!=NULL) {
+       int i;
+       for(i=0; i<prevgl->size; i++) {
+         void * orig=prevgl->array[i];
+         ENQUEUE(orig, prevgl->array[i]);
+       }
+       prevgl=prevgl->next;
+      } 
+    }
+  }
+}
+#endif
+
+int within(void *ptr){ //debug function
+  if(ptr>curr_heapptr || ptr<curr_heapbase){
+    __asm__ __volatile__ ("int $3");  // breakpoint
+  }
+}
index 4be11adf9f41ffad0a28423821fdd968393f756e..d8b561260999dc525fdb941ee7eb30b6f6a29975 100644 (file)
@@ -3,16 +3,16 @@
 #ifdef STM
 #include "stmlookup.h"
 #endif
-struct garbagelist {
+struct garbagelist {  
   int size;
-  struct garbagelist *next;
-  void * array[];
+  struct garbagelist *next;  
+  void * array[]; 
 };
 
 struct listitem {
   struct listitem * prev;
   struct listitem * next;
-  struct garbagelist * stackptr;
+  struct garbagelist * stackptr;  
 #ifdef THREADS
   struct ___Object___ * locklist;
 #endif
@@ -29,6 +29,9 @@ struct listitem {
 #if defined(THREADS)||defined(STM)||defined(MLP)
   char **base;
 #endif
+#ifdef MLP
+  void *seseCommon;
+#endif
 };
 
 #ifdef TASK
@@ -49,3 +52,5 @@ void * mygcmalloc(struct garbagelist * ptr, int size);
 #ifdef STM
 void fixtable(chashlistnode_t **, chashlistnode_t **, cliststruct_t **, unsigned int);
 #endif
+
+int within(void *ptr);
index fc0fcef32befe021ff3de531db10b80c07a51071..7d6a72845639b80ab9eff37d1e47165d8edcbf54 100644 (file)
@@ -578,7 +578,7 @@ RETIREBIN(Hashtable *T, REntry *r, BinItem *b) {
     // at this point have locked bin
     BinItem *ptr=val;
     int haveread=FALSE;
-     int i;
+    int i;
     while (ptr!=NULL) {
        if (isReadBinItem(ptr)) {
        ReadBinItem* rptr=(ReadBinItem*)ptr;
@@ -805,3 +805,61 @@ resolvePointer(REntry* rentry){
     table->unresolvedQueue=val;//released lock;
   }  
 }
+
+void rehashMemoryQueue(SESEcommon_p seseParent){    
+  // update memory queue
+  int i,binidx;
+  for(i=0; i<seseParent->numMemoryQueue; i++){
+    MemoryQueue *memoryQueue=seseParent->memoryQueueArray[i];
+    MemoryQueueItem *memoryItem=memoryQueue->head;
+    MemoryQueueItem *prevItem=NULL;
+    while(memoryItem!=NULL){
+      if(memoryItem->type==HASHTABLE){
+       //do re-hash!
+       Hashtable* ht=(Hashtable*)memoryItem;
+       Hashtable* newht=createHashtable();     
+       int binidx;
+       for(binidx=0; binidx<NUMBINS; binidx++){
+         BinElement *bin=ht->array[binidx];
+         BinItem *binItem=bin->head;
+         //traverse over the list of each bin
+         while(binItem!=NULL){
+           if(binItem->type==READBIN){
+             ReadBinItem* readBinItem=(ReadBinItem*)binItem;
+             int ridx;
+             for(ridx=0; ridx<readBinItem->index; ridx++){
+               REntry *rentry=readBinItem->array[ridx];
+               int newkey=generateKey((unsigned int)(unsigned INTPTR)*(rentry->pointer));      
+               int status=rentry->binitem->status;           
+               ADDTABLEITEM(newht,rentry,TRUE);
+               rentry->binitem->status=status; // update bin status as before rehash
+             }
+           }else{//write bin
+             REntry *rentry=((WriteBinItem*)binItem)->val;
+             int newkey=generateKey((unsigned int)(unsigned INTPTR)*(rentry->pointer));        
+             int status=rentry->binitem->status;             
+             ADDTABLEITEM(newht,rentry,TRUE);                
+             int newstatus=rentry->binitem->status;
+             //printf("[%d]old status=%d new status=%d\n",i,status,newstatus);
+             rentry->binitem->status=status; // update bin status as before rehash
+           }
+           binItem=binItem->next;
+         }
+       }
+       newht->item.status=ht->item.status; // update hashtable status
+       if(prevItem!=NULL){
+         prevItem->next=(MemoryQueueItem*)newht;
+       }else{
+         if(memoryQueue->head==memoryQueue->tail){
+           memoryQueue->tail=(MemoryQueueItem*)newht;
+         }
+         memoryQueue->head=(MemoryQueueItem*)newht;
+       }
+       newht->item.next=ht->item.next; 
+      }
+      prevItem=memoryItem;
+      memoryItem=memoryItem->next;
+    }
+  }
+
+}
index 4348cd5cf3933e4eb42ab99c620949d9bb4986fc..7cf08a4c27dfc84cd638bdc8756dc60c28f8ee91 100644 (file)
@@ -158,7 +158,7 @@ typedef struct SESEcommon_t {
   struct MemoryQueue_t** memoryQueueArray;
   struct REntry_t* rentryArray[NUMRENTRY];
   struct REntry_t* unresolvedRentryArray[NUMRENTRY];
-
+  int offsetsize;
 } SESEcommon;
 
 // a thread-local stack of SESEs and function to
@@ -181,5 +181,6 @@ MemoryQueue** mlpCreateMemoryQueueArray(int numMemoryQueue);
 REntry* mlpCreateFineREntry(int type, void* seseToIssue, void* dynID);
 REntry* mlpCreateREntry(int type, void* seseToIssue);
 MemoryQueue* createMemoryQueue();
+void rehashMemoryQueue(SESEcommon_p seseParent);
 
 #endif /* __MLP_RUNTIME__ */
index 785704eca7abd1dfb7df4edad7dd151aec6823a3..451b8a2d0e6483f0c950408f03ab157e9c65dcc2 100644 (file)
@@ -58,13 +58,19 @@ pthread_mutex_t gclock;
 pthread_mutex_t gclistlock;
 pthread_cond_t gccond;
 
+extern struct listitem * list;
+extern __thread struct listitem litem;
+extern __thread SESEcommon* seseCommon;
+
+/*
 struct QI {
   struct QI * next;
   void * value;
 };
 
-struct QI * head;
-struct QI * tail;
+struct QI * headqi;
+struct QI * tailqi;
+*/
 
 /*
 // helper func
@@ -189,22 +195,47 @@ void* workerMain( void* arg ) {
     
     pthread_mutex_lock( &systemLockOut );
     // wait for work
-    if (head->next==NULL) {
+    if (headqi->next==NULL) {
       pthread_mutex_unlock( &systemLockOut );
       sched_yield();
       continue;
     }
-    struct QI * tmp=head;
-    head = head->next;
-    workUnit = head->value;
+    struct QI * tmp=headqi;
+    headqi = headqi->next;
+    workUnit = headqi->value;
     pthread_mutex_unlock( &systemLockOut );
     free(tmp);
     // yield processor before moving on, just to exercise
     // system's out-of-order correctness
     //if( sched_yield() == -1 ) { printf( "Error thread trying to yield.\n" ); exit( -1 ); }
     //if( sched_yield() == -1 ) { printf( "Error thread trying to yield.\n" ); exit( -1 ); }
+
+    
+    pthread_mutex_lock(&gclistlock);
+    threadcount++;
+    litem.seseCommon=(void*)workUnit;
+    litem.prev=NULL;
+    litem.next=list;
+    if(list!=NULL)
+      list->prev=&litem;
+    list=&litem;
+    seseCommon=(SESEcommon*)workUnit;   
+    pthread_mutex_unlock(&gclistlock);
     
     workFunc( workUnit );
+    
+    pthread_mutex_lock(&gclistlock);
+    threadcount--;
+    if (litem.prev==NULL) {
+      list=litem.next;
+    } else {
+      litem.prev->next=litem.next;
+    }
+    if (litem.next!=NULL) {
+      litem.next->prev=litem.prev;
+    }
+    pthread_mutex_unlock(&gclistlock);
+    
   }
 
   return NULL;
@@ -273,8 +304,8 @@ void workScheduleInit( int numProcessors,
 
   workFunc   = func;
 
-  head=tail=RUNMALLOC(sizeof(struct QI));
-  head->next=NULL;
+  headqi=tailqi=RUNMALLOC(sizeof(struct QI));
+  headqi->next=NULL;
   
   status = pthread_mutex_init( &systemLockIn, NULL );
   status = pthread_mutex_init( &systemLockOut, NULL );
@@ -324,14 +355,13 @@ void workScheduleSubmit( void* workUnit ) {
     }
     pthread_mutex_unlock( &systemLock );
   */
-  
   struct QI* item=RUNMALLOC(sizeof(struct QI));
   item->value=workUnit;
   item->next=NULL;
   
   pthread_mutex_lock  ( &systemLockIn );
-  tail->next=item;
-  tail=item;
+  tailqi->next=item;
+  tailqi=item;
   pthread_mutex_unlock( &systemLockIn );
 }
 
@@ -339,7 +369,8 @@ void workScheduleSubmit( void* workUnit ) {
 // really should be named "wait until work is finished"
 void workScheduleBegin() {
   
-  int i;
+  int i;  
+  workerMain(NULL);
 
   // tell all workers to begin
   for( i = 0; i < numWorkers; ++i ) {
index 41e26571a824d3caad15d56e36c438734ed8a1f2..da0e3581e6cf6761f6abe696c2a68047996d4f58 100644 (file)
@@ -28,6 +28,13 @@ extern pthread_mutex_t gclock;
 extern pthread_mutex_t gclistlock;
 extern pthread_cond_t gccond;
 
+struct QI {
+  struct QI * next;
+  void * value;
+};
+
+struct QI * headqi;
+struct QI * tailqi;
 
 
 #endif /* __WORK_SCHEDULE__ */