1 package Analysis.SSJava;
3 import java.io.BufferedWriter;
4 import java.io.FileWriter;
5 import java.io.IOException;
6 import java.util.ArrayList;
7 import java.util.Collections;
8 import java.util.Comparator;
9 import java.util.HashMap;
10 import java.util.HashSet;
11 import java.util.Hashtable;
12 import java.util.Iterator;
13 import java.util.LinkedList;
14 import java.util.List;
17 import java.util.StringTokenizer;
18 import java.util.Vector;
20 import Analysis.CallGraph.CallGraph;
21 import Analysis.Loops.GlobalFieldType;
22 import Analysis.Loops.LoopOptimize;
23 import Analysis.Loops.LoopTerminate;
24 import IR.AnnotationDescriptor;
25 import IR.ClassDescriptor;
27 import IR.FieldDescriptor;
28 import IR.MethodDescriptor;
30 import IR.SymbolTable;
32 import IR.Flat.BuildFlat;
33 import IR.Flat.FlatMethod;
34 import IR.Flat.FlatNode;
37 public class SSJavaAnalysis {
39 public static final String SSJAVA = "SSJAVA";
40 public static final String LATTICE = "LATTICE";
41 public static final String METHODDEFAULT = "METHODDEFAULT";
42 public static final String THISLOC = "THISLOC";
43 public static final String GLOBALLOC = "GLOBALLOC";
44 public static final String RETURNLOC = "RETURNLOC";
45 public static final String PCLOC = "PCLOC";
46 public static final String LOC = "LOC";
47 public static final String DELTA = "DELTA";
48 public static final String TERMINATE = "TERMINATE";
49 public static final String DELEGATE = "DELEGATE";
50 public static final String DELEGATETHIS = "DELEGATETHIS";
51 public static final String TRUST = "TRUST";
53 public static final String TOP = "_top_";
54 public static final String BOTTOM = "_bottom_";
58 FlowDownCheck flowDownChecker;
59 MethodAnnotationCheck methodAnnotationChecker;
62 // set containing method requires to be annoated
63 Set<MethodDescriptor> annotationRequireSet;
65 // class -> field lattice
66 Hashtable<ClassDescriptor, SSJavaLattice<String>> cd2lattice;
68 // class -> default local variable lattice
69 Hashtable<ClassDescriptor, MethodLattice<String>> cd2methodDefault;
71 // method -> local variable lattice
72 Hashtable<MethodDescriptor, MethodLattice<String>> md2lattice;
74 // method set that does not want to have loop termination analysis
75 Hashtable<MethodDescriptor, Integer> skipLoopTerminate;
77 // map shared location to its descriptors
78 Hashtable<Location, Set<Descriptor>> mapSharedLocation2DescriptorSet;
80 // set containing a class that has at least one annoated method
81 Set<ClassDescriptor> annotationRequireClassSet;
83 // the set of method descriptor required to check the linear type property
84 Set<MethodDescriptor> linearTypeCheckMethodSet;
86 // the set of method descriptors annotated as "TRUST"
87 Set<MethodDescriptor> trustWorthyMDSet;
89 // method -> the initial program counter location
90 Map<MethodDescriptor, CompositeLocation> md2pcLoc;
92 // points to method containing SSJAVA Loop
93 private MethodDescriptor methodContainingSSJavaLoop;
95 private FlatNode ssjavaLoopEntrance;
97 // keep the field ownership from the linear type checking
98 Hashtable<MethodDescriptor, Set<FieldDescriptor>> mapMethodToOwnedFieldSet;
100 Set<FlatNode> sameHeightWriteFlatNodeSet;
104 LinearTypeCheck checker;
106 // maps a descriptor to its known dependents: namely
107 // methods or tasks that call the descriptor's method
108 // AND are part of this analysis (reachable from main)
109 private Hashtable<Descriptor, Set<MethodDescriptor>> mapDescriptorToSetDependents;
111 private LinkedList<MethodDescriptor> sortedDescriptors;
113 public SSJavaAnalysis(State state, TypeUtil tu, BuildFlat bf, CallGraph callgraph) {
116 this.callgraph = callgraph;
117 this.cd2lattice = new Hashtable<ClassDescriptor, SSJavaLattice<String>>();
118 this.cd2methodDefault = new Hashtable<ClassDescriptor, MethodLattice<String>>();
119 this.md2lattice = new Hashtable<MethodDescriptor, MethodLattice<String>>();
120 this.annotationRequireSet = new HashSet<MethodDescriptor>();
121 this.annotationRequireClassSet = new HashSet<ClassDescriptor>();
122 this.skipLoopTerminate = new Hashtable<MethodDescriptor, Integer>();
123 this.mapSharedLocation2DescriptorSet = new Hashtable<Location, Set<Descriptor>>();
124 this.linearTypeCheckMethodSet = new HashSet<MethodDescriptor>();
126 this.trustWorthyMDSet = new HashSet<MethodDescriptor>();
127 this.mapMethodToOwnedFieldSet = new Hashtable<MethodDescriptor, Set<FieldDescriptor>>();
128 this.sameHeightWriteFlatNodeSet = new HashSet<FlatNode>();
129 this.mapDescriptorToSetDependents = new Hashtable<Descriptor, Set<MethodDescriptor>>();
130 this.sortedDescriptors = new LinkedList<MethodDescriptor>();
131 this.md2pcLoc = new HashMap<MethodDescriptor, CompositeLocation>();
134 public void doCheck() {
135 doMethodAnnotationCheck();
137 if (state.SSJAVA && !state.SSJAVAINFER) {
138 computeLinearTypeCheckMethodSet();
143 if (state.SSJAVADEBUG) {
144 // debug_printAnnotationRequiredSet();
146 if (state.SSJAVAINFER) {
150 parseLocationAnnotation();
152 doDefinitelyWrittenCheck();
158 // perform topological sort over the set of methods accessed by the main
160 Set<MethodDescriptor> methodDescriptorsToAnalyze = new HashSet<MethodDescriptor>();
161 methodDescriptorsToAnalyze.addAll(getAnnotationRequireSet());
162 sortedDescriptors = topologicalSort(methodDescriptorsToAnalyze);
165 public LinkedList<MethodDescriptor> getSortedDescriptors() {
166 return (LinkedList<MethodDescriptor>) sortedDescriptors.clone();
169 private void inference() {
170 LocationInference inferEngine = new LocationInference(this, state);
171 inferEngine.inference();
174 private void doLoopCheck() {
175 GlobalFieldType gft = new GlobalFieldType(callgraph, state, tu.getMain());
176 LoopOptimize lo = new LoopOptimize(gft, tu);
178 SymbolTable classtable = state.getClassSymbolTable();
180 List<ClassDescriptor> toanalyzeList = new ArrayList<ClassDescriptor>();
181 List<MethodDescriptor> toanalyzeMethodList = new ArrayList<MethodDescriptor>();
183 toanalyzeList.addAll(classtable.getValueSet());
184 Collections.sort(toanalyzeList, new Comparator<ClassDescriptor>() {
185 public int compare(ClassDescriptor o1, ClassDescriptor o2) {
186 return o1.getClassName().compareTo(o2.getClassName());
190 for (int i = 0; i < toanalyzeList.size(); i++) {
191 ClassDescriptor cd = toanalyzeList.get(i);
193 SymbolTable methodtable = cd.getMethodTable();
194 toanalyzeMethodList.clear();
195 toanalyzeMethodList.addAll(methodtable.getValueSet());
196 Collections.sort(toanalyzeMethodList, new Comparator<MethodDescriptor>() {
197 public int compare(MethodDescriptor o1, MethodDescriptor o2) {
198 return o1.getSymbol().compareTo(o2.getSymbol());
202 for (int mdIdx = 0; mdIdx < toanalyzeMethodList.size(); mdIdx++) {
203 MethodDescriptor md = toanalyzeMethodList.get(mdIdx);
204 if (needTobeAnnotated(md)) {
205 lo.analyze(state.getMethodFlat(md));
206 doLoopTerminationCheck(lo, state.getMethodFlat(md));
214 public void addTrustMethod(MethodDescriptor md) {
215 trustWorthyMDSet.add(md);
218 public boolean isTrustMethod(MethodDescriptor md) {
219 return trustWorthyMDSet.contains(md);
222 private void computeLinearTypeCheckMethodSet() {
224 Set<MethodDescriptor> allCalledSet = callgraph.getMethodCalls(tu.getMain());
225 linearTypeCheckMethodSet.addAll(allCalledSet);
227 Set<MethodDescriptor> trustedSet = new HashSet<MethodDescriptor>();
229 for (Iterator iterator = trustWorthyMDSet.iterator(); iterator.hasNext();) {
230 MethodDescriptor trustMethod = (MethodDescriptor) iterator.next();
231 Set<MethodDescriptor> calledFromTrustMethodSet = callgraph.getMethodCalls(trustMethod);
232 trustedSet.add(trustMethod);
233 trustedSet.addAll(calledFromTrustMethodSet);
236 linearTypeCheckMethodSet.removeAll(trustedSet);
238 // if a method is called only by trusted method, no need to check linear
239 // type & flow down rule
240 for (Iterator iterator = trustedSet.iterator(); iterator.hasNext();) {
241 MethodDescriptor md = (MethodDescriptor) iterator.next();
242 Set<MethodDescriptor> callerSet = callgraph.getCallerSet(md);
243 if (!trustedSet.containsAll(callerSet) && !trustWorthyMDSet.contains(md)) {
244 linearTypeCheckMethodSet.add(md);
250 private void doLinearTypeCheck() {
251 LinearTypeCheck checker = new LinearTypeCheck(this, state);
252 checker.linearTypeCheck();
255 public void debug_printAnnotationRequiredSet() {
256 System.out.println("SSJAVA: SSJava is checking the following methods:");
257 for (Iterator<MethodDescriptor> iterator = annotationRequireSet.iterator(); iterator.hasNext();) {
258 MethodDescriptor md = iterator.next();
259 System.out.println(md);
261 System.out.println();
264 private void doMethodAnnotationCheck() {
265 methodAnnotationChecker = new MethodAnnotationCheck(this, state, tu);
266 methodAnnotationChecker.methodAnnoatationCheck();
267 methodAnnotationChecker.methodAnnoataionInheritanceCheck();
268 if (state.SSJAVAINFER) {
269 annotationRequireClassSet.add(methodContainingSSJavaLoop.getClassDesc());
270 annotationRequireSet.add(methodContainingSSJavaLoop);
272 state.setAnnotationRequireSet(annotationRequireSet);
275 public void doFlowDownCheck() {
276 flowDownChecker = new FlowDownCheck(this, state);
277 flowDownChecker.flowDownCheck();
280 public void doDefinitelyWrittenCheck() {
281 DefinitelyWrittenCheck checker = new DefinitelyWrittenCheck(this, state);
282 checker.definitelyWrittenCheck();
285 private void parseLocationAnnotation() {
286 Iterator it = state.getClassSymbolTable().getDescriptorsIterator();
287 while (it.hasNext()) {
288 ClassDescriptor cd = (ClassDescriptor) it.next();
289 // parsing location hierarchy declaration for the class
290 Vector<AnnotationDescriptor> classAnnotations = cd.getModifier().getAnnotations();
291 for (int i = 0; i < classAnnotations.size(); i++) {
292 AnnotationDescriptor an = classAnnotations.elementAt(i);
293 String marker = an.getMarker();
294 if (marker.equals(LATTICE)) {
295 SSJavaLattice<String> locOrder =
296 new SSJavaLattice<String>(SSJavaAnalysis.TOP, SSJavaAnalysis.BOTTOM);
297 cd2lattice.put(cd, locOrder);
298 parseClassLatticeDefinition(cd, an.getValue(), locOrder);
300 if (state.SSJAVADEBUG) {
301 // generate lattice dot file
302 writeLatticeDotFile(cd, null, locOrder);
305 } else if (marker.equals(METHODDEFAULT)) {
306 MethodLattice<String> locOrder =
307 new MethodLattice<String>(SSJavaAnalysis.TOP, SSJavaAnalysis.BOTTOM);
308 cd2methodDefault.put(cd, locOrder);
309 parseMethodDefaultLatticeDefinition(cd, an.getValue(), locOrder);
313 for (Iterator method_it = cd.getMethods(); method_it.hasNext();) {
314 MethodDescriptor md = (MethodDescriptor) method_it.next();
315 // parsing location hierarchy declaration for the method
317 if (needTobeAnnotated(md)) {
318 Vector<AnnotationDescriptor> methodAnnotations = md.getModifiers().getAnnotations();
319 if (methodAnnotations != null) {
320 for (int i = 0; i < methodAnnotations.size(); i++) {
321 AnnotationDescriptor an = methodAnnotations.elementAt(i);
322 if (an.getMarker().equals(LATTICE)) {
323 // developer explicitly defines method lattice
324 MethodLattice<String> locOrder =
325 new MethodLattice<String>(SSJavaAnalysis.TOP, SSJavaAnalysis.BOTTOM);
326 md2lattice.put(md, locOrder);
327 parseMethodDefaultLatticeDefinition(cd, an.getValue(), locOrder);
328 } else if (an.getMarker().equals(TERMINATE)) {
329 // developer explicitly wants to skip loop termination analysis
330 String value = an.getValue();
331 int maxIteration = 0;
333 maxIteration = Integer.parseInt(value);
335 skipLoopTerminate.put(md, new Integer(maxIteration));
346 public <T> void writeLatticeDotFile(ClassDescriptor cd, MethodDescriptor md,
347 SSJavaLattice<T> locOrder) {
348 writeLatticeDotFile(cd, md, locOrder, "");
352 public <T> void writeLatticeDotFile(ClassDescriptor cd, MethodDescriptor md,
353 SSJavaLattice<T> locOrder, String nameSuffix) {
355 String fileName = "lattice_";
358 cd.getSymbol().replaceAll("[\\W_]", "") + "_" + md.toString().replaceAll("[\\W_]", "");
360 fileName += cd.getSymbol().replaceAll("[\\W_]", "");
363 fileName += nameSuffix;
365 Set<Pair<T, T>> pairSet = locOrder.getOrderingPairSet();
367 if (pairSet.size() > 0) {
369 BufferedWriter bw = new BufferedWriter(new FileWriter(fileName + ".dot"));
371 bw.write("digraph " + fileName + " {\n");
373 for (Iterator iterator = pairSet.iterator(); iterator.hasNext();) {
374 // pair is in the form of <higher, lower>
375 Pair<T, T> pair = (Pair<T, T>) iterator.next();
377 T highLocId = pair.getFirst();
378 String highLocStr, lowLocStr;
379 if (locOrder.isSharedLoc(highLocId)) {
380 highLocStr = "\"" + highLocId + "*\"";
382 highLocStr = highLocId.toString();
384 T lowLocId = pair.getSecond();
385 if (locOrder.isSharedLoc(lowLocId)) {
386 lowLocStr = "\"" + lowLocId + "*\"";
388 lowLocStr = lowLocId.toString();
390 bw.write(highLocStr + " -> " + lowLocStr + ";\n");
395 } catch (IOException e) {
403 private void parseMethodDefaultLatticeDefinition(ClassDescriptor cd, String value,
404 MethodLattice<String> locOrder) {
406 value = value.replaceAll(" ", ""); // remove all blank spaces
408 StringTokenizer tokenizer = new StringTokenizer(value, ",");
410 while (tokenizer.hasMoreTokens()) {
411 String orderElement = tokenizer.nextToken();
412 int idx = orderElement.indexOf("<");
413 if (idx > 0) {// relative order element
414 String lowerLoc = orderElement.substring(0, idx);
415 String higherLoc = orderElement.substring(idx + 1);
416 locOrder.put(higherLoc, lowerLoc);
417 if (locOrder.isIntroducingCycle(higherLoc)) {
418 throw new Error("Error: the order relation " + lowerLoc + " < " + higherLoc
419 + " introduces a cycle.");
421 } else if (orderElement.startsWith(THISLOC + "=")) {
422 String thisLoc = orderElement.substring(8);
423 locOrder.setThisLoc(thisLoc);
424 } else if (orderElement.startsWith(GLOBALLOC + "=")) {
425 String globalLoc = orderElement.substring(10);
426 locOrder.setGlobalLoc(globalLoc);
427 } else if (orderElement.startsWith(RETURNLOC + "=")) {
428 String returnLoc = orderElement.substring(10);
429 locOrder.setReturnLoc(returnLoc);
430 } else if (orderElement.endsWith("*")) {
431 // spin loc definition
432 locOrder.addSharedLoc(orderElement.substring(0, orderElement.length() - 1));
435 locOrder.put(orderElement);
440 if (locOrder.getThisLoc() != null && !locOrder.containsKey(locOrder.getThisLoc())) {
441 throw new Error("Variable 'this' location '" + locOrder.getThisLoc()
442 + "' is not defined in the local variable lattice at " + cd.getSourceFileName());
445 if (locOrder.getGlobalLoc() != null && !locOrder.containsKey(locOrder.getGlobalLoc())) {
446 throw new Error("Variable global location '" + locOrder.getGlobalLoc()
447 + "' is not defined in the local variable lattice at " + cd.getSourceFileName());
451 private void parseClassLatticeDefinition(ClassDescriptor cd, String value,
452 SSJavaLattice<String> locOrder) {
454 value = value.replaceAll(" ", ""); // remove all blank spaces
456 StringTokenizer tokenizer = new StringTokenizer(value, ",");
458 while (tokenizer.hasMoreTokens()) {
459 String orderElement = tokenizer.nextToken();
460 int idx = orderElement.indexOf("<");
462 if (idx > 0) {// relative order element
463 String lowerLoc = orderElement.substring(0, idx);
464 String higherLoc = orderElement.substring(idx + 1);
465 locOrder.put(higherLoc, lowerLoc);
466 if (locOrder.isIntroducingCycle(higherLoc)) {
467 throw new Error("Error: the order relation " + lowerLoc + " < " + higherLoc
468 + " introduces a cycle.");
470 } else if (orderElement.contains("*")) {
471 // spin loc definition
472 locOrder.addSharedLoc(orderElement.substring(0, orderElement.length() - 1));
475 locOrder.put(orderElement);
480 Set<String> spinLocSet = locOrder.getSharedLocSet();
481 for (Iterator iterator = spinLocSet.iterator(); iterator.hasNext();) {
482 String spinLoc = (String) iterator.next();
483 if (!locOrder.containsKey(spinLoc)) {
484 throw new Error("Spin location '" + spinLoc
485 + "' is not defined in the default local variable lattice at " + cd.getSourceFileName());
490 public Hashtable<ClassDescriptor, SSJavaLattice<String>> getCd2lattice() {
494 public Hashtable<ClassDescriptor, MethodLattice<String>> getCd2methodDefault() {
495 return cd2methodDefault;
498 public Hashtable<MethodDescriptor, MethodLattice<String>> getMd2lattice() {
502 public SSJavaLattice<String> getClassLattice(ClassDescriptor cd) {
503 return cd2lattice.get(cd);
506 public MethodLattice<String> getMethodDefaultLattice(ClassDescriptor cd) {
507 return cd2methodDefault.get(cd);
510 public MethodLattice<String> getMethodLattice(MethodDescriptor md) {
511 if (md2lattice.containsKey(md)) {
512 return md2lattice.get(md);
515 if (cd2methodDefault.containsKey(md.getClassDesc())) {
516 return cd2methodDefault.get(md.getClassDesc());
518 throw new Error("Method Lattice of " + md + " is not defined.");
524 public CompositeLocation getPCLocation(MethodDescriptor md) {
525 if (!md2pcLoc.containsKey(md)) {
526 // by default, the initial pc location is TOP
527 CompositeLocation pcLoc = new CompositeLocation(new Location(md, Location.TOP));
528 md2pcLoc.put(md, pcLoc);
530 return md2pcLoc.get(md);
533 public void setPCLocation(MethodDescriptor md, CompositeLocation pcLoc) {
534 md2pcLoc.put(md, pcLoc);
537 public boolean needToCheckLinearType(MethodDescriptor md) {
538 return linearTypeCheckMethodSet.contains(md);
541 public boolean needTobeAnnotated(MethodDescriptor md) {
542 return annotationRequireSet.contains(md);
545 public boolean needToBeAnnoated(ClassDescriptor cd) {
546 return annotationRequireClassSet.contains(cd);
549 public void addAnnotationRequire(ClassDescriptor cd) {
550 annotationRequireClassSet.add(cd);
553 public void addAnnotationRequire(MethodDescriptor md) {
555 ClassDescriptor cd = md.getClassDesc();
556 // if a method requires to be annotated, class containg that method also
557 // requires to be annotated
558 if (!isSSJavaUtil(cd)) {
559 annotationRequireClassSet.add(cd);
560 annotationRequireSet.add(md);
564 public Set<MethodDescriptor> getAnnotationRequireSet() {
565 return annotationRequireSet;
568 public void doLoopTerminationCheck(LoopOptimize lo, FlatMethod fm) {
569 LoopTerminate lt = new LoopTerminate(this, state);
570 if (needTobeAnnotated(fm.getMethod())) {
571 lt.terminateAnalysis(fm, lo.getLoopInvariant(fm));
575 public CallGraph getCallGraph() {
579 public SSJavaLattice<String> getLattice(Descriptor d) {
581 if (d instanceof MethodDescriptor) {
582 return getMethodLattice((MethodDescriptor) d);
584 return getClassLattice((ClassDescriptor) d);
589 public boolean isSharedLocation(Location loc) {
590 SSJavaLattice<String> lattice = getLattice(loc.getDescriptor());
591 return lattice.getSharedLocSet().contains(loc.getLocIdentifier());
594 public void mapSharedLocation2Descriptor(Location loc, Descriptor d) {
595 Set<Descriptor> set = mapSharedLocation2DescriptorSet.get(loc);
597 set = new HashSet<Descriptor>();
598 mapSharedLocation2DescriptorSet.put(loc, set);
603 public BuildFlat getBuildFlat() {
607 public MethodDescriptor getMethodContainingSSJavaLoop() {
608 return methodContainingSSJavaLoop;
611 public void setMethodContainingSSJavaLoop(MethodDescriptor methodContainingSSJavaLoop) {
612 this.methodContainingSSJavaLoop = methodContainingSSJavaLoop;
615 public boolean isSSJavaUtil(ClassDescriptor cd) {
616 if (cd.getSymbol().equals("SSJAVA")) {
622 public void setFieldOnwership(MethodDescriptor md, FieldDescriptor field) {
624 Set<FieldDescriptor> fieldSet = mapMethodToOwnedFieldSet.get(md);
625 if (fieldSet == null) {
626 fieldSet = new HashSet<FieldDescriptor>();
627 mapMethodToOwnedFieldSet.put(md, fieldSet);
632 public boolean isOwnedByMethod(MethodDescriptor md, FieldDescriptor field) {
633 Set<FieldDescriptor> fieldSet = mapMethodToOwnedFieldSet.get(md);
634 if (fieldSet != null) {
635 return fieldSet.contains(field);
640 public FlatNode getSSJavaLoopEntrance() {
641 return ssjavaLoopEntrance;
644 public void setSSJavaLoopEntrance(FlatNode ssjavaLoopEntrance) {
645 this.ssjavaLoopEntrance = ssjavaLoopEntrance;
648 public void addSameHeightWriteFlatNode(FlatNode fn) {
649 this.sameHeightWriteFlatNodeSet.add(fn);
652 public boolean isSameHeightWrite(FlatNode fn) {
653 return this.sameHeightWriteFlatNodeSet.contains(fn);
656 public LinkedList<MethodDescriptor> topologicalSort(Set<MethodDescriptor> toSort) {
658 Set<MethodDescriptor> discovered = new HashSet<MethodDescriptor>();
660 LinkedList<MethodDescriptor> sorted = new LinkedList<MethodDescriptor>();
662 Iterator<MethodDescriptor> itr = toSort.iterator();
663 while (itr.hasNext()) {
664 MethodDescriptor d = itr.next();
666 if (!discovered.contains(d)) {
667 dfsVisit(d, toSort, sorted, discovered);
674 // While we're doing DFS on call graph, remember
675 // dependencies for efficient queuing of methods
676 // during interprocedural analysis:
678 // a dependent of a method decriptor d for this analysis is:
679 // 1) a method or task that invokes d
680 // 2) in the descriptorsToAnalyze set
681 private void dfsVisit(MethodDescriptor md, Set<MethodDescriptor> toSort,
682 LinkedList<MethodDescriptor> sorted, Set<MethodDescriptor> discovered) {
686 Iterator itr2 = callgraph.getCalleeSet(md).iterator();
687 while (itr2.hasNext()) {
688 MethodDescriptor dCallee = (MethodDescriptor) itr2.next();
689 addDependent(dCallee, md);
692 Iterator itr = callgraph.getCallerSet(md).iterator();
693 while (itr.hasNext()) {
694 MethodDescriptor dCaller = (MethodDescriptor) itr.next();
695 // only consider callers in the original set to analyze
696 if (!toSort.contains(dCaller)) {
699 if (!discovered.contains(dCaller)) {
700 addDependent(md, // callee
704 dfsVisit(dCaller, toSort, sorted, discovered);
708 // for leaf-nodes last now!
712 public void addDependent(MethodDescriptor callee, MethodDescriptor caller) {
713 Set<MethodDescriptor> deps = mapDescriptorToSetDependents.get(callee);
715 deps = new HashSet<MethodDescriptor>();
718 mapDescriptorToSetDependents.put(callee, deps);
721 public Set<MethodDescriptor> getDependents(MethodDescriptor callee) {
722 Set<MethodDescriptor> deps = mapDescriptorToSetDependents.get(callee);
724 deps = new HashSet<MethodDescriptor>();
725 mapDescriptorToSetDependents.put(callee, deps);