changes: 1) fixes problems in the original EyeTracking benchmark 2) fix a bug in...
[IRC.git] / Robust / src / Analysis / SSJava / DefinitelyWrittenCheck.java
index 1e31d7d6407ba0a4866edfc687219357423a17f3..c1f482419fe6af507ba347ac155485b36d79064e 100644 (file)
@@ -8,6 +8,7 @@ import java.util.LinkedList;
 import java.util.Set;
 import java.util.Stack;
 
+import Analysis.Liveness;
 import Analysis.CallGraph.CallGraph;
 import Analysis.Loops.LoopFinder;
 import IR.Descriptor;
@@ -37,12 +38,9 @@ public class DefinitelyWrittenCheck {
   State state;
   CallGraph callGraph;
 
-  int debugcount = 0;
+  Liveness liveness;
 
-  // maps a descriptor to its known dependents: namely
-  // methods or tasks that call the descriptor's method
-  // AND are part of this analysis (reachable from main)
-  private Hashtable<Descriptor, Set<MethodDescriptor>> mapDescriptorToSetDependents;
+  int debugcount = 0;
 
   // maps a flat node to its WrittenSet: this keeps all heap path overwritten
   // previously.
@@ -69,6 +67,8 @@ public class DefinitelyWrittenCheck {
   // written to but not overwritten by the higher value
   private Hashtable<FlatMethod, SharedLocMap> mapFlatMethodToDeleteSet;
 
+  private Hashtable<FlatMethod, SharedLocMap> mapFlatMethodToMustClearMap;
+
   // maps a flat method to the S SET that is a set of heap path to shared
   // locations that are overwritten by the higher value
   private Hashtable<FlatMethod, SharedLocMap> mapFlatMethodToSharedLocMap;
@@ -115,8 +115,7 @@ public class DefinitelyWrittenCheck {
 
   private Hashtable<FlatNode, SharedLocMap> mapFlatNodeToSharedLocMapping;
   private Hashtable<FlatNode, SharedLocMap> mapFlatNodeToDeleteSet;
-
-  private LinkedList<MethodDescriptor> sortedDescriptors;
+  private Hashtable<FlatNode, SharedLocMap> mapFlatNodeToMustClearMap;
 
   private LoopFinder ssjavaLoop;
   private Set<FlatNode> loopIncElements;
@@ -126,6 +125,9 @@ public class DefinitelyWrittenCheck {
   private Set<NTuple<Descriptor>> calleeUnionBoundMayWriteSet;
   private SharedLocMap calleeUnionBoundDeleteSet;
   private SharedLocMap calleeIntersectBoundSharedSet;
+  private SharedLocMap calleeIntersectBoundMustClearSet;
+
+  Set<TempDescriptor> liveInTempSetToEventLoop;
 
   private Hashtable<Descriptor, Location> mapDescToLocation;
 
@@ -138,7 +140,6 @@ public class DefinitelyWrittenCheck {
     this.ssjava = ssjava;
     this.callGraph = ssjava.getCallGraph();
     this.mapFlatNodeToMustWriteSet = new Hashtable<FlatNode, Set<NTuple<Descriptor>>>();
-    this.mapDescriptorToSetDependents = new Hashtable<Descriptor, Set<MethodDescriptor>>();
     this.mapHeapPath = new Hashtable<Descriptor, NTuple<Descriptor>>();
     this.mapDescriptorToLocationPath = new Hashtable<TempDescriptor, NTuple<Location>>();
     this.mapFlatMethodToReadSet = new Hashtable<FlatMethod, Set<NTuple<Descriptor>>>();
@@ -168,6 +169,11 @@ public class DefinitelyWrittenCheck {
     this.mapMethodToSharedLocCoverSet =
         new Hashtable<MethodDescriptor, MultiSourceMap<NTuple<Location>, NTuple<Descriptor>>>();
     this.mapFlatNodeToDeleteSet = new Hashtable<FlatNode, SharedLocMap>();
+    this.liveness = new Liveness();
+    this.liveInTempSetToEventLoop = new HashSet<TempDescriptor>();
+    this.mapFlatNodeToMustClearMap = new Hashtable<FlatNode, SharedLocMap>();
+    this.calleeIntersectBoundMustClearSet = new SharedLocMap();
+    this.mapFlatMethodToMustClearMap = new Hashtable<FlatMethod, SharedLocMap>();
   }
 
   public void definitelyWrittenCheck() {
@@ -177,10 +183,6 @@ public class DefinitelyWrittenCheck {
       methodReadWriteSetAnalysis();
       computeSharedCoverSet();
 
-      // System.out.println("$$$=" +
-      // mapMethodToSharedLocCoverSet.get(methodContainingSSJavaLoop));
-      // System.exit(0);
-
       sharedLocAnalysis();
 
       eventLoopAnalysis();
@@ -191,8 +193,7 @@ public class DefinitelyWrittenCheck {
   private void sharedLocAnalysis() {
 
     // perform method READ/OVERWRITE analysis
-    LinkedList<MethodDescriptor> descriptorListToAnalyze =
-        (LinkedList<MethodDescriptor>) sortedDescriptors.clone();
+    LinkedList<MethodDescriptor> descriptorListToAnalyze = ssjava.getSortedDescriptors();
 
     // current descriptors to visit in fixed-point interprocedural analysis,
     // prioritized by
@@ -217,19 +218,23 @@ public class DefinitelyWrittenCheck {
 
       SharedLocMap sharedLocMap = new SharedLocMap();
       SharedLocMap deleteSet = new SharedLocMap();
+      SharedLocMap mustClearMap = new SharedLocMap();
 
-      sharedLoc_analyzeMethod(fm, sharedLocMap, deleteSet);
+      sharedLoc_analyzeMethod(fm, sharedLocMap, deleteSet, mustClearMap);
       SharedLocMap prevSharedLocMap = mapFlatMethodToSharedLocMap.get(fm);
       SharedLocMap prevDeleteSet = mapFlatMethodToDeleteSet.get(fm);
+      SharedLocMap prevMustClearMap = mapFlatMethodToMustClearMap.get(fm);
 
-      if (!(deleteSet.equals(prevDeleteSet) && sharedLocMap.equals(prevSharedLocMap))) {
+      if (!(deleteSet.equals(prevDeleteSet) && sharedLocMap.equals(prevSharedLocMap) && mustClearMap
+          .equals(prevMustClearMap))) {
         mapFlatMethodToSharedLocMap.put(fm, sharedLocMap);
         mapFlatMethodToDeleteSet.put(fm, deleteSet);
+        mapFlatMethodToMustClearMap.put(fm, mustClearMap);
 
         // results for callee changed, so enqueue dependents caller for
         // further
         // analysis
-        Iterator<MethodDescriptor> depsItr = getDependents(md).iterator();
+        Iterator<MethodDescriptor> depsItr = ssjava.getDependents(md).iterator();
         while (depsItr.hasNext()) {
           MethodDescriptor methodNext = depsItr.next();
           if (!methodDescriptorsToVisitStack.contains(methodNext)
@@ -253,23 +258,24 @@ public class DefinitelyWrittenCheck {
     }
     SharedLocMap sharedLocMap = new SharedLocMap();
     SharedLocMap deleteSet = new SharedLocMap();
+    SharedLocMap mustClearMap = new SharedLocMap();
     sharedLoc_analyzeBody(state.getMethodFlat(methodContainingSSJavaLoop),
-        ssjava.getSSJavaLoopEntrance(), sharedLocMap, deleteSet, true);
+        ssjava.getSSJavaLoopEntrance(), sharedLocMap, deleteSet, mustClearMap, true);
 
   }
 
   private void sharedLoc_analyzeMethod(FlatMethod fm, SharedLocMap sharedLocMap,
-      SharedLocMap deleteSet) {
+      SharedLocMap deleteSet, SharedLocMap mustClearMap) {
     if (state.SSJAVADEBUG) {
       System.out.println("SSJAVA: Definite clearance for shared locations Analyzing: " + fm);
     }
 
-    sharedLoc_analyzeBody(fm, fm, sharedLocMap, deleteSet, false);
+    sharedLoc_analyzeBody(fm, fm, sharedLocMap, deleteSet, mustClearMap, false);
 
   }
 
   private void sharedLoc_analyzeBody(FlatMethod fm, FlatNode startNode, SharedLocMap sharedLocMap,
-      SharedLocMap deleteSet, boolean isEventLoopBody) {
+      SharedLocMap deleteSet, SharedLocMap mustClearMap, boolean isEventLoopBody) {
 
     // intraprocedural analysis
     Set<FlatNode> flatNodesToVisit = new HashSet<FlatNode>();
@@ -281,6 +287,7 @@ public class DefinitelyWrittenCheck {
 
       SharedLocMap currSharedSet = new SharedLocMap();
       SharedLocMap currDeleteSet = new SharedLocMap();
+      SharedLocMap currMustClearMap = new SharedLocMap();
 
       for (int i = 0; i < fn.numPrev(); i++) {
         FlatNode prevFn = fn.getPrev(i);
@@ -293,17 +300,26 @@ public class DefinitelyWrittenCheck {
         if (inDeleteLoc != null) {
           mergeDeleteSet(currDeleteSet, inDeleteLoc);
         }
+
+        SharedLocMap inMustClearMap = mapFlatNodeToMustClearMap.get(prevFn);
+        if (inMustClearMap != null) {
+          mergeSharedLocMap(currMustClearMap, inMustClearMap);
+        }
+
       }
 
-      sharedLoc_nodeActions(fm, fn, currSharedSet, currDeleteSet, sharedLocMap, deleteSet,
-          isEventLoopBody);
+      sharedLoc_nodeActions(fm, fn, currSharedSet, currDeleteSet, currMustClearMap, sharedLocMap,
+          deleteSet, mustClearMap, isEventLoopBody);
 
       SharedLocMap prevSharedSet = mapFlatNodeToSharedLocMapping.get(fn);
       SharedLocMap prevDeleteSet = mapFlatNodeToDeleteSet.get(fn);
+      SharedLocMap prevMustClearMap = mapFlatNodeToMustClearMap.get(fn);
 
-      if (!(currSharedSet.equals(prevSharedSet) && currDeleteSet.equals(prevDeleteSet))) {
+      if (!(currSharedSet.equals(prevSharedSet) && currDeleteSet.equals(prevDeleteSet) && currMustClearMap
+          .equals(prevMustClearMap))) {
         mapFlatNodeToSharedLocMapping.put(fn, currSharedSet);
         mapFlatNodeToDeleteSet.put(fn, currDeleteSet);
+        mapFlatNodeToMustClearMap.put(fn, currMustClearMap);
         for (int i = 0; i < fn.numNext(); i++) {
           FlatNode nn = fn.getNext(i);
           if ((!isEventLoopBody) || loopIncElements.contains(nn)) {
@@ -318,8 +334,8 @@ public class DefinitelyWrittenCheck {
   }
 
   private void sharedLoc_nodeActions(FlatMethod fm, FlatNode fn, SharedLocMap curr,
-      SharedLocMap currDeleteSet, SharedLocMap sharedLocMap, SharedLocMap deleteSet,
-      boolean isEventLoopBody) {
+      SharedLocMap currDeleteSet, SharedLocMap currMustClearMap, SharedLocMap sharedLocMap,
+      SharedLocMap deleteSet, SharedLocMap mustClearMap, boolean isEventLoopBody) {
 
     MethodDescriptor md = fm.getMethod();
 
@@ -330,6 +346,10 @@ public class DefinitelyWrittenCheck {
     TempDescriptor rhs;
     FieldDescriptor fld;
 
+    NTuple<Location> fieldLocTuple = null;
+    Location fieldLoc = null;
+    boolean isHigherWriteCase = false;
+
     switch (fn.kind()) {
 
     case FKind.FlatOpNode: {
@@ -344,31 +364,28 @@ public class DefinitelyWrittenCheck {
           if (!lhs.getSymbol().startsWith("neverused") && !lhs.getSymbol().startsWith("leftop")
               && !lhs.getSymbol().startsWith("rightop") && rhs.getType().isImmutable()) {
 
-            Location dstLoc = getLocation(lhs);
-            if (dstLoc != null && ssjava.isSharedLocation(dstLoc)) {
-              NTuple<Descriptor> lhsHeapPath = computePath(lhs);
-              NTuple<Location> lhsLocTuple = mapDescriptorToLocationPath.get(lhs);
+            if (mapHeapPath.containsKey(rhs)) {
+              Location dstLoc = getLocation(lhs);
+              if (dstLoc != null && ssjava.isSharedLocation(dstLoc)) {
+                NTuple<Descriptor> lhsHeapPath = computePath(lhs);
+                NTuple<Location> lhsLocTuple = mapDescriptorToLocationPath.get(lhs);
 
-              Location srcLoc = getLocation(lhs);
+                Location srcLoc = getLocation(lhs);
 
-              // computing gen/kill set
-              computeKILLSetForWrite(curr, killSet, lhsLocTuple, lhsHeapPath);
-              if (!dstLoc.equals(srcLoc)) {
-                computeGENSetForHigherWrite(curr, killSet, lhsLocTuple, lhsHeapPath);
-                updateDeleteSetForHigherWrite(currDeleteSet, lhsLocTuple, lhsHeapPath);
-              } else {
-                computeGENSetForSameHeightWrite(curr, killSet, lhsLocTuple, lhsHeapPath);
-                updateDeleteSetForSameHeightWrite(currDeleteSet, lhsLocTuple, lhsHeapPath);
-              }
+                // computing gen/kill set
+                computeKILLSetForWrite(curr, killSet, lhsLocTuple, lhsHeapPath);
 
-              // System.out.println("VAR WRITE:" + fn);
-              // System.out.println("lhsLocTuple=" + lhsLocTuple +
-              // " lhsHeapPath=" + lhsHeapPath);
-              // System.out.println("dstLoc=" + dstLoc + " srcLoc=" + srcLoc);
-              // System.out.println("KILLSET=" + killSet);
-              // System.out.println("GENSet=" + genSet);
-              // System.out.println("DELETESET=" + currDeleteSet);
+                if (!ssjava.isSameHeightWrite(fn)) {
+                  computeGENSetForHigherWrite(curr, killSet, lhsLocTuple, lhsHeapPath);
+                  updateDeleteSetForHigherWrite(currDeleteSet, lhsLocTuple, lhsHeapPath);
+                } else {
+                  computeGENSetForSameHeightWrite(curr, killSet, lhsLocTuple, lhsHeapPath);
+                  updateDeleteSetForSameHeightWrite(currDeleteSet, lhsLocTuple, lhsHeapPath);
+                }
 
+              }
+            } else {
+              break;
             }
 
           }
@@ -383,7 +400,6 @@ public class DefinitelyWrittenCheck {
     case FKind.FlatSetFieldNode:
     case FKind.FlatSetElementNode: {
 
-      Location fieldLoc;
       if (fn.kind() == FKind.FlatSetFieldNode) {
         FlatSetFieldNode fsfn = (FlatSetFieldNode) fn;
         lhs = fsfn.getDst();
@@ -400,7 +416,7 @@ public class DefinitelyWrittenCheck {
         break;
       }
 
-      NTuple<Location> fieldLocTuple = new NTuple<Location>();
+      fieldLocTuple = new NTuple<Location>();
       if (fld.isStatic()) {
         if (fld.isFinal()) {
           // in this case, fld has TOP location
@@ -438,22 +454,18 @@ public class DefinitelyWrittenCheck {
 
         // computing gen/kill set
         computeKILLSetForWrite(curr, killSet, fieldLocTuple, fldHeapPath);
-        if (!fieldLoc.equals(srcLoc)) {
+
+        if (!ssjava.isSameHeightWrite(fn)) {
           computeGENSetForHigherWrite(curr, genSet, fieldLocTuple, fldHeapPath);
           updateDeleteSetForHigherWrite(currDeleteSet, fieldLocTuple, fldHeapPath);
+
+          isHigherWriteCase = true;
+
         } else {
           computeGENSetForSameHeightWrite(curr, genSet, fieldLocTuple, fldHeapPath);
           updateDeleteSetForSameHeightWrite(currDeleteSet, fieldLocTuple, fldHeapPath);
         }
 
-        // System.out.println("################");
-        // System.out.println("FIELD WRITE:" + fn);
-        // System.out.println("FldHeapPath=" + fldHeapPath);
-        // System.out.println("fieldLocTuple=" + fieldLocTuple + " srcLoc=" +
-        // srcLoc);
-        // System.out.println("KILLSET=" + killSet);
-        // System.out.println("GENSet=" + genSet);
-        // System.out.println("DELETESET=" + currDeleteSet);
       }
 
     }
@@ -468,10 +480,11 @@ public class DefinitelyWrittenCheck {
       generateKILLSetForFlatCall(curr, killSet);
       generateGENSetForFlatCall(curr, genSet);
 
-      // System.out.println("#FLATCALL=" + fc);
-      // System.out.println("KILLSET=" + killSet);
-      // System.out.println("GENSet=" + genSet);
-      // System.out.println("bound DELETE Set=" + calleeUnionBoundDeleteSet);
+      Set<NTuple<Location>> locTupleSet = calleeIntersectBoundMustClearSet.keySet();
+      for (Iterator iterator = locTupleSet.iterator(); iterator.hasNext();) {
+        NTuple<Location> locTupleKey = (NTuple<Location>) iterator.next();
+        currMustClearMap.addWrite(locTupleKey, calleeIntersectBoundMustClearSet.get(locTupleKey));
+      }
 
     }
       break;
@@ -480,17 +493,38 @@ public class DefinitelyWrittenCheck {
       // merge the current delete/shared loc mapping
       mergeSharedLocMap(sharedLocMap, curr);
       mergeDeleteSet(deleteSet, currDeleteSet);
-
-      // System.out.println("#FLATEXIT sharedLocMap=" + sharedLocMap);
+      mergeSharedLocMap(mustClearMap, currMustClearMap);
     }
       break;
 
     }
 
     computeNewMapping(curr, killSet, genSet);
-    if (!curr.map.isEmpty()) {
-      // System.out.println(fn + "#######" + curr);
+    if (isHigherWriteCase) {
+      // check all locations with the same shared location are cleared out at this point
+      Set<NTuple<Descriptor>> writtenSet = curr.get(fieldLocTuple);
+      Set<Descriptor> requirementSet = ssjava.getSharedDescSet(fieldLoc);
+
+      if (checkAllSharedLocationsAreOverwritten(requirementSet, writtenSet)) {
+        currMustClearMap.addWrite(fieldLocTuple, writtenSet);
+      }
+    }
+  }
+
+  private boolean checkAllSharedLocationsAreOverwritten(Set<Descriptor> sharedDescSet,
+      Set<NTuple<Descriptor>> writtenSet) {
+
+    if (sharedDescSet == null || writtenSet == null) {
+      return false;
     }
+    Set<Descriptor> writtenDescSet = new HashSet<Descriptor>();
+    for (Iterator iterator = writtenSet.iterator(); iterator.hasNext();) {
+      NTuple<Descriptor> tuple = (NTuple<Descriptor>) iterator.next();
+      writtenDescSet.add(tuple.get(tuple.size() - 1));
+    }
+
+    return writtenDescSet.containsAll(sharedDescSet);
+    // return sharedDescSet.containsAll(writtenDescSet);
 
   }
 
@@ -552,7 +586,6 @@ public class DefinitelyWrittenCheck {
     if (currWriteSet != null) {
       genSet.addWrite(locTuple, currWriteSet);
     }
-
     genSet.addWrite(locTuple, hp);
   }
 
@@ -595,8 +628,7 @@ public class DefinitelyWrittenCheck {
   }
 
   private void computeSharedCoverSet() {
-    LinkedList<MethodDescriptor> descriptorListToAnalyze =
-        (LinkedList<MethodDescriptor>) sortedDescriptors.clone();
+    LinkedList<MethodDescriptor> descriptorListToAnalyze = ssjava.getSortedDescriptors();
 
     // current descriptors to visit in fixed-point interprocedural analysis,
     // prioritized by
@@ -630,8 +662,6 @@ public class DefinitelyWrittenCheck {
 
   private void computeSharedCoverSet_analyzeMethod(FlatMethod fm, boolean onlyVisitSSJavaLoop) {
 
-    System.out.println("\n###");
-    System.out.println("computeSharedCoverSet_analyzeMethod=" + fm);
     MethodDescriptor md = fm.getMethod();
 
     Set<FlatNode> flatNodesToVisit = new HashSet<FlatNode>();
@@ -705,54 +735,59 @@ public class DefinitelyWrittenCheck {
         if (!lhs.getSymbol().startsWith("neverused") && !lhs.getSymbol().startsWith("leftop")
             && !lhs.getSymbol().startsWith("rightop")) {
 
-          NTuple<Location> rhsLocTuple = new NTuple<Location>();
-          NTuple<Location> lhsLocTuple = new NTuple<Location>();
-          if (mapDescriptorToLocationPath.containsKey(rhs)) {
-            mapDescriptorToLocationPath.put(lhs, deriveLocationTuple(md, rhs));
-            lhsLocTuple = mapDescriptorToLocationPath.get(lhs);
-          } else {
-            // rhs side
-            if (rhs.getType().getExtension() != null
-                && rhs.getType().getExtension() instanceof SSJavaType) {
+          if (mapHeapPath.containsKey(rhs)) {
+            NTuple<Location> rhsLocTuple = new NTuple<Location>();
+            NTuple<Location> lhsLocTuple = new NTuple<Location>();
+            if (mapDescriptorToLocationPath.containsKey(rhs)) {
+              mapDescriptorToLocationPath.put(lhs, deriveLocationTuple(md, rhs));
+              lhsLocTuple = mapDescriptorToLocationPath.get(lhs);
+            } else {
+              // rhs side
+              if (rhs.getType().getExtension() != null
+                  && rhs.getType().getExtension() instanceof SSJavaType) {
 
-              if (((SSJavaType) rhs.getType().getExtension()).getCompLoc() != null) {
-                rhsLocTuple.addAll(((SSJavaType) rhs.getType().getExtension()).getCompLoc()
-                    .getTuple());
+                if (((SSJavaType) rhs.getType().getExtension()).getCompLoc() != null) {
+                  rhsLocTuple.addAll(((SSJavaType) rhs.getType().getExtension()).getCompLoc()
+                      .getTuple());
+                }
+
+              } else {
+                NTuple<Location> locTuple = deriveLocationTuple(md, rhs);
+                if (locTuple != null) {
+                  rhsLocTuple.addAll(locTuple);
+                }
+              }
+              if (rhsLocTuple.size() > 0) {
+                mapDescriptorToLocationPath.put(rhs, rhsLocTuple);
               }
 
-            } else {
-              NTuple<Location> locTuple = deriveLocationTuple(md, rhs);
-              if (locTuple != null) {
-                rhsLocTuple.addAll(locTuple);
+              // lhs side
+              if (lhs.getType().getExtension() != null
+                  && lhs.getType().getExtension() instanceof SSJavaType) {
+                lhsLocTuple.addAll(((SSJavaType) lhs.getType().getExtension()).getCompLoc()
+                    .getTuple());
+                mapDescriptorToLocationPath.put(lhs, lhsLocTuple);
+              } else if (mapDescriptorToLocationPath.get(rhs) != null) {
+                // propagate rhs's location to lhs
+                lhsLocTuple.addAll(mapDescriptorToLocationPath.get(rhs));
+                mapDescriptorToLocationPath.put(lhs, lhsLocTuple);
               }
             }
-            if (rhsLocTuple.size() > 0) {
-              mapDescriptorToLocationPath.put(rhs, rhsLocTuple);
-            }
 
-            // lhs side
-            if (lhs.getType().getExtension() != null
-                && lhs.getType().getExtension() instanceof SSJavaType) {
-              lhsLocTuple.addAll(((SSJavaType) lhs.getType().getExtension()).getCompLoc()
-                  .getTuple());
-              mapDescriptorToLocationPath.put(lhs, lhsLocTuple);
-            } else if (mapDescriptorToLocationPath.get(rhs) != null) {
-              // propagate rhs's location to lhs
-              lhsLocTuple.addAll(mapDescriptorToLocationPath.get(rhs));
-              mapDescriptorToLocationPath.put(lhs, lhsLocTuple);
-            }
-          }
+            if (isEventLoopBody && lhs.getType().isPrimitive()
+                && !lhs.getSymbol().startsWith("srctmp")) {
 
-          if (isEventLoopBody && lhs.getType().isPrimitive()
-              && !lhs.getSymbol().startsWith("srctmp")) {
+              NTuple<Descriptor> lhsHeapPath = computePath(lhs);
 
-            NTuple<Descriptor> lhsHeapPath = computePath(lhs);
+              if (lhsLocTuple != null) {
+                addMayWrittenSet(md, lhsLocTuple, lhsHeapPath);
+              }
 
-            if (lhsLocTuple != null) {
-              addMayWrittenSet(md, lhsLocTuple, lhsHeapPath);
             }
-
+          } else {
+            break;
           }
+
         }
 
       }
@@ -777,8 +812,24 @@ public class DefinitelyWrittenCheck {
         fld = getArrayField(td);
       }
 
+      NTuple<Location> lhsLocTuple = new NTuple<Location>();
+      if (fld.isStatic()) {
+        if (fld.isFinal()) {
+          // in this case, fld has TOP location
+          Location topLocation = Location.createTopLocation(md);
+          lhsLocTuple.add(topLocation);
+        } else {
+          lhsLocTuple.addAll(deriveGlobalLocationTuple(md));
+        }
+      } else {
+        lhsLocTuple.addAll(deriveLocationTuple(md, lhs));
+      }
+
+      mapDescriptorToLocationPath.put(lhs, lhsLocTuple);
+
       NTuple<Location> fieldLocTuple = new NTuple<Location>();
-      fieldLocTuple.addAll(deriveLocationTuple(md, lhs));
+      fieldLocTuple.addAll(lhsLocTuple);
+
       if (fn.kind() == FKind.FlatSetFieldNode) {
         fieldLocTuple.add((Location) fld.getType().getExtension());
       }
@@ -933,35 +984,33 @@ public class DefinitelyWrittenCheck {
       Hashtable<Integer, NTuple<Location>> mapArgIdx2CallerArgLocationPath =
           new Hashtable<Integer, NTuple<Location>>();
 
-      // arg idx is starting from 'this' arg
       if (fc.getThis() != null) {
-        // loc path for 'this'
-        NTuple<Location> thisLocationPath = deriveLocationTuple(mdCaller, fc.getThis());
-        if (thisLocationPath != null) {
-          mapArgIdx2CallerArgLocationPath.put(Integer.valueOf(0), thisLocationPath);
 
-          // heap path for 'this'
+        if (mapHeapPath.containsKey(fc.getThis())) {
+
+          // setup heap path for 'this'
           NTuple<Descriptor> thisHeapPath = new NTuple<Descriptor>();
-          if (mapHeapPath.containsKey(fc.getThis())) {
-            thisHeapPath.addAll(mapHeapPath.get(fc.getThis()));
-          } else {
-            // method is called without creating new flat node representing
-            // 'this'
-            thisHeapPath.add(fc.getThis());
-          }
+          thisHeapPath.addAll(mapHeapPath.get(fc.getThis()));
           mapArgIdx2CallerArgHeapPath.put(Integer.valueOf(0), thisHeapPath);
+
+          // setup location path for 'this'
+          NTuple<Location> thisLocationPath = deriveLocationTuple(mdCaller, fc.getThis());
+          mapArgIdx2CallerArgLocationPath.put(Integer.valueOf(0), thisLocationPath);
+
         }
       }
 
       for (int i = 0; i < fc.numArgs(); i++) {
         TempDescriptor arg = fc.getArg(i);
         // create mapping arg to loc path
-        NTuple<Location> argLocationPath = deriveLocationTuple(mdCaller, arg);
-        if (argLocationPath != null) {
-          mapArgIdx2CallerArgLocationPath.put(Integer.valueOf(i + 1), argLocationPath);
-          // create mapping arg to heap path
-          NTuple<Descriptor> argHeapPath = computePath(arg);
+
+        if (mapHeapPath.containsKey(arg)) {
+          // setup heap path
+          NTuple<Descriptor> argHeapPath = mapHeapPath.get(arg);
           mapArgIdx2CallerArgHeapPath.put(Integer.valueOf(i + 1), argHeapPath);
+          // setup loc path
+          NTuple<Location> argLocationPath = deriveLocationTuple(mdCaller, arg);
+          mapArgIdx2CallerArgLocationPath.put(Integer.valueOf(i + 1), argLocationPath);
         }
 
       }
@@ -1290,11 +1339,10 @@ public class DefinitelyWrittenCheck {
               hasWriteEffect = true;
             }
 
-            if (hasWriteEffect) {
+            if (hasWriteEffect && mapHeapPath.containsKey(lhs)) {
               // write(lhs)
-              NTuple<Descriptor> rhsHeapPath = computePath(rhs);
               NTuple<Descriptor> lhsHeapPath = new NTuple<Descriptor>();
-              lhsHeapPath.addAll(rhsHeapPath);
+              lhsHeapPath.addAll(mapHeapPath.get(lhs));
 
               Location lhsLoc = getLocation(lhs);
               if (ssjava.isSharedLocation(lhsLoc)) {
@@ -1305,7 +1353,10 @@ public class DefinitelyWrittenCheck {
                 Set<NTuple<Descriptor>> writtenSet =
                     mapFlatNodeToSharedLocMapping.get(fn).get(varLocTuple);
 
-                if (isCovered(varLocTuple, writtenSet)) {
+                Set<NTuple<Descriptor>> mustClearSet =
+                    mapFlatNodeToMustClearMap.get(fn).get(varLocTuple);
+
+                if (isCovered(varLocTuple, writtenSet, mustClearSet)) {
                   computeKILLSetForSharedWrite(curr, writtenSet, readWriteKillSet);
                   computeGENSetForSharedAllCoverWrite(curr, writtenSet, readWriteGenSet);
                 } else {
@@ -1318,10 +1369,6 @@ public class DefinitelyWrittenCheck {
                 computeGENSetForWrite(lhsHeapPath, readWriteGenSet);
               }
 
-              // System.out.println("write effect on =" + lhsHeapPath);
-              // System.out.println("#KILLSET=" + readWriteKillSet);
-              // System.out.println("#GENSet=" + readWriteGenSet + "\n");
-
               Set<WriteAge> writeAgeSet = curr.get(lhsHeapPath);
               checkWriteAgeSet(writeAgeSet, lhsHeapPath, fn);
             }
@@ -1383,70 +1430,67 @@ public class DefinitelyWrittenCheck {
           fld = getArrayField(td);
         }
 
-        // write(field)
-        NTuple<Descriptor> lhsHeapPath = computePath(lhs);
-        NTuple<Descriptor> fldHeapPath = new NTuple<Descriptor>(lhsHeapPath.getList());
-        if (fn.kind() == FKind.FlatSetFieldNode) {
-          fldHeapPath.add(fld);
-        }
-
-        // shared loc extension
-        Location fieldLoc;
-        if (fn.kind() == FKind.FlatSetFieldNode) {
-          fieldLoc = (Location) fld.getType().getExtension();
-        } else {
-          NTuple<Location> locTuple = mapDescriptorToLocationPath.get(lhs);
-          fieldLoc = locTuple.get(locTuple.size() - 1);
-        }
-
-        if (ssjava.isSharedLocation(fieldLoc)) {
+        // set up heap path
+        NTuple<Descriptor> lhsHeapPath = mapHeapPath.get(lhs);
+        if (lhsHeapPath != null) {
+          // write(field)
+          NTuple<Descriptor> fldHeapPath = new NTuple<Descriptor>(lhsHeapPath.getList());
+          if (fn.kind() == FKind.FlatSetFieldNode) {
+            fldHeapPath.add(fld);
+          }
 
-          NTuple<Location> fieldLocTuple = new NTuple<Location>();
-          fieldLocTuple.addAll(mapDescriptorToLocationPath.get(lhs));
+          // shared loc extension
+          Location fieldLoc;
           if (fn.kind() == FKind.FlatSetFieldNode) {
-            fieldLocTuple.add(fieldLoc);
+            fieldLoc = (Location) fld.getType().getExtension();
+          } else {
+            NTuple<Location> locTuple = mapDescriptorToLocationPath.get(lhs);
+            fieldLoc = locTuple.get(locTuple.size() - 1);
           }
 
-          Set<NTuple<Descriptor>> writtenSet =
-              mapFlatNodeToSharedLocMapping.get(fn).get(fieldLocTuple);
+          if (ssjava.isSharedLocation(fieldLoc)) {
+
+            NTuple<Location> fieldLocTuple = new NTuple<Location>();
+            fieldLocTuple.addAll(mapDescriptorToLocationPath.get(lhs));
+            if (fn.kind() == FKind.FlatSetFieldNode) {
+              fieldLocTuple.add(fieldLoc);
+            }
+
+            Set<NTuple<Descriptor>> writtenSet =
+                mapFlatNodeToSharedLocMapping.get(fn).get(fieldLocTuple);
+            if (isCovered(fieldLocTuple, writtenSet)) {
+              computeKILLSetForSharedWrite(curr, writtenSet, readWriteKillSet);
+              computeGENSetForSharedAllCoverWrite(curr, writtenSet, readWriteGenSet);
+            } else {
+              computeGENSetForSharedNonCoverWrite(curr, fldHeapPath, readWriteGenSet);
+            }
 
-          if (isCovered(fieldLocTuple, writtenSet)) {
-            computeKILLSetForSharedWrite(curr, writtenSet, readWriteKillSet);
-            computeGENSetForSharedAllCoverWrite(curr, writtenSet, readWriteGenSet);
           } else {
-            computeGENSetForSharedNonCoverWrite(curr, fldHeapPath, readWriteGenSet);
+            computeKILLSetForWrite(curr, fldHeapPath, readWriteKillSet);
+            computeGENSetForWrite(fldHeapPath, readWriteGenSet);
           }
 
-        } else {
-          computeKILLSetForWrite(curr, fldHeapPath, readWriteKillSet);
-          computeGENSetForWrite(fldHeapPath, readWriteGenSet);
         }
 
-        // System.out.println("KILLSET=" + readWriteKillSet);
-        // System.out.println("GENSet=" + readWriteGenSet);
-
       }
         break;
 
       case FKind.FlatCall: {
         FlatCall fc = (FlatCall) fn;
-
         SharedLocMap sharedLocMap = mapFlatNodeToSharedLocMapping.get(fc);
-        // System.out.println("FLATCALL:" + fn);
-        generateKILLSetForFlatCall(fc, curr, sharedLocMap, readWriteKillSet);
-        generateGENSetForFlatCall(fc, sharedLocMap, readWriteGenSet);
-
-        // System.out.println("KILLSET=" + readWriteKillSet);
-        // System.out.println("GENSet=" + readWriteGenSet);
+        SharedLocMap mustClearMap = mapFlatNodeToMustClearMap.get(fc);
+        generateKILLSetForFlatCall(fc, curr, sharedLocMap, mustClearMap, readWriteKillSet);
+        generateGENSetForFlatCall(fc, sharedLocMap, mustClearMap, readWriteGenSet);
 
-        checkManyRead(fc, curr);
       }
         break;
 
       }
 
       computeNewMapping(curr, readWriteKillSet, readWriteGenSet);
-      // System.out.println("#######" + curr);
+      if (fn instanceof FlatCall) {
+        checkManyRead((FlatCall) fn, curr);
+      }
 
     }
 
@@ -1494,22 +1538,37 @@ public class DefinitelyWrittenCheck {
 
   }
 
-  private boolean isCovered(NTuple<Location> locTuple, Set<NTuple<Descriptor>> inSet) {
+  private boolean isCovered(NTuple<Location> locTuple, Set<NTuple<Descriptor>> curWrittenSet) {
 
-    if (inSet == null) {
+    Set<NTuple<Descriptor>> coverSet =
+        mapMethodToSharedLocCoverSet.get(methodContainingSSJavaLoop).get(locTuple);
+
+    if (curWrittenSet == null) {
       return false;
     }
 
+    return curWrittenSet.containsAll(coverSet);
+  }
+
+  private boolean isCovered(NTuple<Location> locTuple, Set<NTuple<Descriptor>> curWrittenSet,
+      Set<NTuple<Descriptor>> mustClearSet) {
+
     Set<NTuple<Descriptor>> coverSet =
         mapMethodToSharedLocCoverSet.get(methodContainingSSJavaLoop).get(locTuple);
 
-    return inSet.containsAll(coverSet);
+    if (mustClearSet != null && mustClearSet.containsAll(coverSet)) {
+      return true;
+    }
+
+    if (curWrittenSet == null) {
+      return false;
+    }
+
+    return curWrittenSet.containsAll(coverSet);
   }
 
   private void checkManyRead(FlatCall fc, Hashtable<NTuple<Descriptor>, Set<WriteAge>> curr) {
-
     Set<NTuple<Descriptor>> boundReadSet = mapFlatNodeToBoundReadSet.get(fc);
-
     for (Iterator iterator = boundReadSet.iterator(); iterator.hasNext();) {
       NTuple<Descriptor> readHeapPath = (NTuple<Descriptor>) iterator.next();
       Set<WriteAge> writeAgeSet = curr.get(readHeapPath);
@@ -1520,9 +1579,6 @@ public class DefinitelyWrittenCheck {
 
   private void checkWriteAgeSet(Set<WriteAge> writeAgeSet, NTuple<Descriptor> path, FlatNode fn) {
 
-    // System.out.println("# CHECK WRITE AGE of " + path + " from set=" +
-    // writeAgeSet);
-
     if (writeAgeSet != null) {
       for (Iterator iterator = writeAgeSet.iterator(); iterator.hasNext();) {
         WriteAge writeAge = (WriteAge) iterator.next();
@@ -1558,10 +1614,9 @@ public class DefinitelyWrittenCheck {
   }
 
   private void generateGENSetForFlatCall(FlatCall fc, SharedLocMap sharedLocMap,
-      Hashtable<NTuple<Descriptor>, Set<WriteAge>> GENSet) {
+      SharedLocMap mustClearMap, Hashtable<NTuple<Descriptor>, Set<WriteAge>> GENSet) {
 
     Set<NTuple<Descriptor>> boundMayWriteSet = mapFlatNodeToBoundMayWriteSet.get(fc);
-    // System.out.println("boundMayWriteSet=" + boundMayWriteSet);
 
     for (Iterator iterator = boundMayWriteSet.iterator(); iterator.hasNext();) {
       NTuple<Descriptor> heapPath = (NTuple<Descriptor>) iterator.next();
@@ -1575,10 +1630,9 @@ public class DefinitelyWrittenCheck {
 
         Set<NTuple<Descriptor>> sharedWriteHeapPathSet = sharedLocMap.get(locTuple);
 
-        if (isCovered(locTuple, sharedLocMap.get(locTuple))) {
+        if (isCovered(locTuple, sharedLocMap.get(locTuple), mustClearMap.get(locTuple))) {
           // if it is covered, add all of heap paths belong to the same shared
           // loc with write age 0
-
           for (Iterator iterator2 = sharedWriteHeapPathSet.iterator(); iterator2.hasNext();) {
             NTuple<Descriptor> sharedHeapPath = (NTuple<Descriptor>) iterator2.next();
             addWriteAgeToSet(sharedHeapPath, GENSet, new WriteAge(0));
@@ -1610,10 +1664,9 @@ public class DefinitelyWrittenCheck {
 
   private void generateKILLSetForFlatCall(FlatCall fc,
       Hashtable<NTuple<Descriptor>, Set<WriteAge>> curr, SharedLocMap sharedLocMap,
-      Hashtable<NTuple<Descriptor>, Set<WriteAge>> KILLSet) {
+      SharedLocMap mustClearMap, Hashtable<NTuple<Descriptor>, Set<WriteAge>> KILLSet) {
 
     Set<NTuple<Descriptor>> boundMustWriteSet = mapFlatNodeToBoundMustWriteSet.get(fc);
-    System.out.println("boundMustWriteSet=" + boundMustWriteSet);
 
     for (Iterator iterator = boundMustWriteSet.iterator(); iterator.hasNext();) {
       NTuple<Descriptor> heapPath = (NTuple<Descriptor>) iterator.next();
@@ -1621,7 +1674,8 @@ public class DefinitelyWrittenCheck {
       if (isSharedLocation(heapPath)) {
         NTuple<Location> locTuple = getLocationTuple(heapPath);
 
-        if (isCovered(locTuple, sharedLocMap.get(locTuple))) {
+        if (isCovered(locTuple, sharedLocMap.get(locTuple), mustClearMap.get(locTuple))
+            && curr.containsKey(heapPath)) {
           // if it is shared loc and corresponding shared loc has been covered
           KILLSet.put(heapPath, curr.get(heapPath));
         }
@@ -1755,13 +1809,10 @@ public class DefinitelyWrittenCheck {
       // arg idx is starting from 'this' arg
       if (fc.getThis() != null) {
         NTuple<Descriptor> thisHeapPath = mapHeapPath.get(fc.getThis());
-        if (thisHeapPath == null) {
-          // method is called without creating new flat node representing 'this'
-          thisHeapPath = new NTuple<Descriptor>();
-          thisHeapPath.add(fc.getThis());
+        if (thisHeapPath != null) {
+          // if 'this' does not have heap path, it is local reference
+          mapArgIdx2CallerArgHeapPath.put(Integer.valueOf(0), thisHeapPath);
         }
-
-        mapArgIdx2CallerArgHeapPath.put(Integer.valueOf(0), thisHeapPath);
       }
 
       for (int i = 0; i < fc.numArgs(); i++) {
@@ -1932,6 +1983,7 @@ public class DefinitelyWrittenCheck {
           NTuple<Location> calleeLocationPath = deriveLocationTuple(mdCallee, calleeParam);
           SharedLocMap calleeDeleteSet = mapFlatMethodToDeleteSet.get(calleeFlatMethod);
           SharedLocMap calleeSharedLocMap = mapFlatMethodToSharedLocMap.get(calleeFlatMethod);
+          SharedLocMap calleeMustClearMap = mapFlatMethodToMustClearMap.get(calleeFlatMethod);
 
           if (calleeDeleteSet != null) {
             createNewMappingOfDeleteSet(callerArgLocationPath, callerArgHeapPath,
@@ -1943,6 +1995,11 @@ public class DefinitelyWrittenCheck {
                 calleeLocationPath, calleeSharedLocMap);
           }
 
+          if (calleeMustClearMap != null) {
+            createNewMappingOfMustClearMap(callerArgLocationPath, callerArgHeapPath,
+                calleeLocationPath, calleeMustClearMap);
+          }
+
         }
 
       }
@@ -1950,6 +2007,28 @@ public class DefinitelyWrittenCheck {
 
   }
 
+  private void createNewMappingOfMustClearMap(NTuple<Location> callerArgLocationPath,
+      NTuple<Descriptor> callerArgHeapPath, NTuple<Location> calleeLocationPath,
+      SharedLocMap calleeMustClearMap) {
+
+    SharedLocMap calleeParamSharedSet =
+        calleeMustClearMap.getHeapPathStartedWith(calleeLocationPath);
+
+    Set<NTuple<Location>> keySet = calleeParamSharedSet.keySet();
+    for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
+      NTuple<Location> calleeLocTupleKey = (NTuple<Location>) iterator.next();
+      Set<NTuple<Descriptor>> heapPathSet = calleeParamSharedSet.get(calleeLocTupleKey);
+      Set<NTuple<Descriptor>> boundHeapPathSet = new HashSet<NTuple<Descriptor>>();
+      for (Iterator iterator2 = heapPathSet.iterator(); iterator2.hasNext();) {
+        NTuple<Descriptor> calleeHeapPath = (NTuple<Descriptor>) iterator2.next();
+        boundHeapPathSet.add(bindHeapPath(callerArgHeapPath, calleeHeapPath));
+      }
+      calleeIntersectBoundMustClearSet.intersect(
+          bindLocationPath(callerArgLocationPath, calleeLocTupleKey), boundHeapPathSet);
+    }
+
+  }
+
   private void createNewMappingOfDeleteSet(NTuple<Location> callerArgLocationPath,
       NTuple<Descriptor> callerArgHeapPath, NTuple<Location> calleeLocationPath,
       SharedLocMap calleeDeleteSet) {
@@ -2058,15 +2137,19 @@ public class DefinitelyWrittenCheck {
 
     // perform topological sort over the set of methods accessed by the main
     // event loop
-    Set<MethodDescriptor> methodDescriptorsToAnalyze = new HashSet<MethodDescriptor>();
-    methodDescriptorsToAnalyze.addAll(ssjava.getAnnotationRequireSet());
-    sortedDescriptors = topologicalSort(methodDescriptorsToAnalyze);
+    // Set<MethodDescriptor> methodDescriptorsToAnalyze = new
+    // HashSet<MethodDescriptor>();
+    // methodDescriptorsToAnalyze.addAll(ssjava.getAnnotationRequireSet());
+    // sortedDescriptors = topologicalSort(methodDescriptorsToAnalyze);
+
+    liveInTempSetToEventLoop =
+        liveness.getLiveInTemps(state.getMethodFlat(methodContainingSSJavaLoop),
+            ssjava.getSSJavaLoopEntrance());
   }
 
   private void methodReadWriteSetAnalysis() {
     // perform method READ/OVERWRITE analysis
-    LinkedList<MethodDescriptor> descriptorListToAnalyze =
-        (LinkedList<MethodDescriptor>) sortedDescriptors.clone();
+    LinkedList<MethodDescriptor> descriptorListToAnalyze = ssjava.getSortedDescriptors();
 
     // current descriptors to visit in fixed-point interprocedural analysis,
     // prioritized by
@@ -2108,7 +2191,7 @@ public class DefinitelyWrittenCheck {
         // results for callee changed, so enqueue dependents caller for
         // further
         // analysis
-        Iterator<MethodDescriptor> depsItr = getDependents(md).iterator();
+        Iterator<MethodDescriptor> depsItr = ssjava.getDependents(md).iterator();
         while (depsItr.hasNext()) {
           MethodDescriptor methodNext = depsItr.next();
           if (!methodDescriptorsToVisitStack.contains(methodNext)
@@ -2155,6 +2238,13 @@ public class DefinitelyWrittenCheck {
     mapFlatMethodToMustWriteSet.put(flatMethodContainingSSJavaLoop, mustWriteSet);
     mapFlatMethodToMayWriteSet.put(flatMethodContainingSSJavaLoop, mayWriteSet);
 
+    for (Iterator iterator = liveInTempSetToEventLoop.iterator(); iterator.hasNext();) {
+      TempDescriptor liveIn = (TempDescriptor) iterator.next();
+      NTuple<Descriptor> heapPath = new NTuple<Descriptor>();
+      heapPath.add(liveIn);
+      mapHeapPath.put(liveIn, heapPath);
+    }
+
     methodReadWriteSet_analyzeBody(ssjava.getSSJavaLoopEntrance(), readSet, mustWriteSet,
         mayWriteSet, true);
 
@@ -2242,16 +2332,17 @@ public class DefinitelyWrittenCheck {
         // mapHeapPath.put(lhs, lhsHeapPath);
         // } else
 
-        if (rhsHeapPath != null) {
+        if (rhsHeapPath != null && (!lhs.getType().isPrimitive())) {
           mapHeapPath.put(lhs, mapHeapPath.get(rhs));
         } else {
-          if (isEventLoopBody) {
-            NTuple<Descriptor> heapPath = new NTuple<Descriptor>();
-            heapPath.add(rhs);
-            mapHeapPath.put(lhs, heapPath);
-          } else {
-            break;
-          }
+          break;
+          // if (isEventLoopBody) {
+          // NTuple<Descriptor> lhsHeapPath = new NTuple<Descriptor>();
+          // lhsHeapPath.add(rhs);
+          // mapHeapPath.put(lhs, lhsHeapPath);
+          // } else {
+          // break;
+          // }
         }
 
         // shared loc extension
@@ -2499,78 +2590,6 @@ public class DefinitelyWrittenCheck {
 
   }
 
-  // Borrowed it from disjoint analysis
-  private LinkedList<MethodDescriptor> topologicalSort(Set<MethodDescriptor> toSort) {
-
-    Set<MethodDescriptor> discovered = new HashSet<MethodDescriptor>();
-
-    LinkedList<MethodDescriptor> sorted = new LinkedList<MethodDescriptor>();
-
-    Iterator<MethodDescriptor> itr = toSort.iterator();
-    while (itr.hasNext()) {
-      MethodDescriptor d = itr.next();
-
-      if (!discovered.contains(d)) {
-        dfsVisit(d, toSort, sorted, discovered);
-      }
-    }
-
-    return sorted;
-  }
-
-  // While we're doing DFS on call graph, remember
-  // dependencies for efficient queuing of methods
-  // during interprocedural analysis:
-  //
-  // a dependent of a method decriptor d for this analysis is:
-  // 1) a method or task that invokes d
-  // 2) in the descriptorsToAnalyze set
-  private void dfsVisit(MethodDescriptor md, Set<MethodDescriptor> toSort,
-      LinkedList<MethodDescriptor> sorted, Set<MethodDescriptor> discovered) {
-
-    discovered.add(md);
-
-    Iterator itr = callGraph.getCallerSet(md).iterator();
-    while (itr.hasNext()) {
-      MethodDescriptor dCaller = (MethodDescriptor) itr.next();
-      // only consider callers in the original set to analyze
-      if (!toSort.contains(dCaller)) {
-        continue;
-      }
-      if (!discovered.contains(dCaller)) {
-        addDependent(md, // callee
-            dCaller // caller
-        );
-
-        dfsVisit(dCaller, toSort, sorted, discovered);
-      }
-    }
-
-    // for leaf-nodes last now!
-    sorted.addLast(md);
-  }
-
-  // a dependent of a method decriptor d for this analysis is:
-  // 1) a method or task that invokes d
-  // 2) in the descriptorsToAnalyze set
-  private void addDependent(MethodDescriptor callee, MethodDescriptor caller) {
-    Set<MethodDescriptor> deps = mapDescriptorToSetDependents.get(callee);
-    if (deps == null) {
-      deps = new HashSet<MethodDescriptor>();
-    }
-    deps.add(caller);
-    mapDescriptorToSetDependents.put(callee, deps);
-  }
-
-  private Set<MethodDescriptor> getDependents(MethodDescriptor callee) {
-    Set<MethodDescriptor> deps = mapDescriptorToSetDependents.get(callee);
-    if (deps == null) {
-      deps = new HashSet<MethodDescriptor>();
-      mapDescriptorToSetDependents.put(callee, deps);
-    }
-    return deps;
-  }
-
   private NTuple<Descriptor> computePath(Descriptor td) {
     // generate proper path fot input td
     // if td is local variable, it just generate one element tuple path