use of com.oracle.graal.pointsto.meta.AnalysisMethod in project graal by oracle.
the class ShortestInvokeChainPrinter method print.
public static void print(BigBang bb, AnalysisMethod target, PrintStream out) {
Deque<AnalysisMethod> workList = new LinkedList<>();
Map<AnalysisMethod, Element> visited = new HashMap<>();
for (AnalysisMethod m : bb.getUniverse().getMethods()) {
if (m.isEntryPoint()) {
workList.addLast(m);
visited.put(m, new Element(m, null, null));
}
}
while (workList.size() > 0) {
AnalysisMethod method = workList.removeFirst();
Element methodElement = visited.get(method);
assert methodElement != null;
for (InvokeTypeFlow invoke : method.getTypeFlow().getInvokes()) {
for (AnalysisMethod callee : invoke.getCallees()) {
if (visited.containsKey(callee)) {
// We already had a shorter path to this method.
continue;
}
Element calleeElement = new Element(callee, methodElement, invoke);
visited.put(callee, calleeElement);
if (callee.equals(target)) {
// We found a path from an entry point to our target method.
printPath(calleeElement, out);
return;
} else {
workList.addLast(callee);
}
}
}
}
printNoPath(out);
}
Aggregations