Search in sources :

Example 31 with AnalysisMethod

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);
}
Also used : AnalysisMethod(com.oracle.graal.pointsto.meta.AnalysisMethod) HashMap(java.util.HashMap) InvokeTypeFlow(com.oracle.graal.pointsto.flow.InvokeTypeFlow) LinkedList(java.util.LinkedList)

Aggregations

AnalysisMethod (com.oracle.graal.pointsto.meta.AnalysisMethod)31 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)7 AnalysisType (com.oracle.graal.pointsto.meta.AnalysisType)6 HostedMethod (com.oracle.svm.hosted.meta.HostedMethod)6 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 AnalysisField (com.oracle.graal.pointsto.meta.AnalysisField)5 Map (java.util.Map)5 JavaKind (jdk.vm.ci.meta.JavaKind)5 TypeState (com.oracle.graal.pointsto.typestate.TypeState)4 SubstrateMethod (com.oracle.svm.graal.meta.SubstrateMethod)4 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)4 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)3 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)3 UnsupportedFeatureException (com.oracle.graal.pointsto.constraints.UnsupportedFeatureException)2 InvokeTypeFlow (com.oracle.graal.pointsto.flow.InvokeTypeFlow)2 AnalysisMetaAccess (com.oracle.graal.pointsto.meta.AnalysisMetaAccess)2 AnalysisUniverse (com.oracle.graal.pointsto.meta.AnalysisUniverse)2 HostedProviders (com.oracle.graal.pointsto.meta.HostedProviders)2 SubstrateForeignCallsProvider (com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider)2