Search in sources :

Example 6 with HostedMethod

use of com.oracle.svm.hosted.meta.HostedMethod in project graal by oracle.

the class UninterruptibleAnnotationChecker method checkUninterruptibleCallees.

/**
 * Check that each method annotated with {@link Uninterruptible} calls only methods that are
 * also annotated with {@link Uninterruptible}, or methods annotated with {@link CFunction} that
 * specify "Transition = NO_TRANSITION".
 *
 * A caller can be annotated with "calleeMustBe = false" to allow calls to methods that are not
 * annotated with {@link Uninterruptible}, to allow the few cases where that should be allowed.
 */
@SuppressWarnings("try")
private void checkUninterruptibleCallees(DebugContext debug) {
    if (Options.PrintUninterruptibleCalleeDOTGraph.getValue()) {
        System.out.println("/* DOT */ digraph uninterruptible {");
    }
    for (HostedMethod caller : methodCollection) {
        try (DebugContext.Scope s = debug.scope("CheckUninterruptibleCallees", caller.compilationInfo.graph, caller, this)) {
            Uninterruptible callerAnnotation = caller.getAnnotation(Uninterruptible.class);
            StructuredGraph graph = caller.compilationInfo.getGraph();
            if (callerAnnotation != null) {
                if (callerAnnotation.calleeMustBe()) {
                    if (graph != null) {
                        for (Invoke invoke : graph.getInvokes()) {
                            HostedMethod callee = (HostedMethod) invoke.callTarget().targetMethod();
                            if (Options.PrintUninterruptibleCalleeDOTGraph.getValue()) {
                                printDotGraphEdge(caller, callee);
                            }
                            if (!isNotInterruptible(callee)) {
                                postUninterruptibleWarning("Unannotated callee: " + callee.format("%h.%n(%p)") + " called by annotated caller " + caller.format("%h.%n(%p)"));
                            }
                        }
                    }
                } else {
                    // Print DOT graph edge even if callee need not be annotated.
                    if (graph != null) {
                        for (Invoke invoke : graph.getInvokes()) {
                            HostedMethod callee = (HostedMethod) invoke.callTarget().targetMethod();
                            if (Options.PrintUninterruptibleCalleeDOTGraph.getValue()) {
                                printDotGraphEdge(caller, callee);
                            }
                        }
                    }
                }
            }
        } catch (Throwable t) {
            throw debug.handle(t);
        }
    }
    if (Options.PrintUninterruptibleCalleeDOTGraph.getValue()) {
        System.out.println("/* DOT */ }");
    }
}
Also used : Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HostedMethod(com.oracle.svm.hosted.meta.HostedMethod) DebugContext(org.graalvm.compiler.debug.DebugContext) Invoke(org.graalvm.compiler.nodes.Invoke)

Example 7 with HostedMethod

use of com.oracle.svm.hosted.meta.HostedMethod in project graal by oracle.

the class UninterruptibleAnnotationChecker method checkUninterruptibleCallers.

/**
 * Check that each method that calls a method annotated with {@linkplain Uninterruptible} that
 * has "callerMustBeUninterrutible = true" is also annotated with {@linkplain Uninterruptible}.
 */
@SuppressWarnings("try")
private void checkUninterruptibleCallers(DebugContext debug) {
    for (HostedMethod caller : methodCollection) {
        try (DebugContext.Scope s = debug.scope("CheckUninterruptibleCallers", caller.compilationInfo.graph, caller, this)) {
            Uninterruptible callerAnnotation = caller.getAnnotation(Uninterruptible.class);
            StructuredGraph graph = caller.compilationInfo.getGraph();
            if (callerAnnotation == null && graph != null) {
                for (Invoke invoke : graph.getInvokes()) {
                    HostedMethod callee = (HostedMethod) invoke.callTarget().targetMethod();
                    if (isCallerMustBe(callee)) {
                        postUninterruptibleWarning("Unannotated caller: " + caller.format("%h.%n(%p)") + " calls annotated callee " + callee.format("%h.%n(%p)"));
                    }
                }
            }
        } catch (Throwable t) {
            throw debug.handle(t);
        }
    }
}
Also used : Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HostedMethod(com.oracle.svm.hosted.meta.HostedMethod) DebugContext(org.graalvm.compiler.debug.DebugContext) Invoke(org.graalvm.compiler.nodes.Invoke)

Example 8 with HostedMethod

use of com.oracle.svm.hosted.meta.HostedMethod in project graal by oracle.

the class UninterruptibleAnnotationChecker method checkUninterruptibleAllocations.

/**
 * Check that each method that is annotated with {@linkplain Uninterruptible} contains no
 * allocations.
 */
@SuppressWarnings("try")
private void checkUninterruptibleAllocations(DebugContext debug) {
    for (HostedMethod method : methodCollection) {
        try (DebugContext.Scope s = debug.scope("CheckUninterruptibleAllocations", method.compilationInfo.graph, method, this)) {
            Uninterruptible methodAnnotation = method.getAnnotation(Uninterruptible.class);
            StructuredGraph graph = method.compilationInfo.getGraph();
            if (methodAnnotation != null && graph != null) {
                for (Node node : graph.getNodes()) {
                    if (node instanceof AbstractNewObjectNode) {
                        postUninterruptibleWarning("Annotated method: " + method.format("%h.%n(%p)") + " allocates.");
                    }
                }
            }
        } catch (Throwable t) {
            throw debug.handle(t);
        }
    }
}
Also used : Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) AbstractNewObjectNode(org.graalvm.compiler.nodes.java.AbstractNewObjectNode) Node(org.graalvm.compiler.graph.Node) AbstractNewObjectNode(org.graalvm.compiler.nodes.java.AbstractNewObjectNode) HostedMethod(com.oracle.svm.hosted.meta.HostedMethod) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 9 with HostedMethod

use of com.oracle.svm.hosted.meta.HostedMethod in project graal by oracle.

the class JNIFunctionTablesFeature method buildInvokesInitializer.

private JNIStructFunctionsInitializer<JNIInvokeInterface> buildInvokesInitializer(CompilationAccessImpl access, CFunctionPointer unimplemented) {
    HostedType invokes = access.getMetaAccess().lookupJavaType(JNIInvocationInterface.class);
    HostedMethod[] methods = invokes.getDeclaredMethods();
    int index = 0;
    int[] offsets = new int[methods.length];
    CFunctionPointer[] pointers = new CFunctionPointer[offsets.length];
    for (HostedMethod method : methods) {
        StructFieldInfo field = findFieldFor(invokeInterfaceMetadata, method.getName());
        offsets[index] = field.getOffsetInfo().getProperty();
        pointers[index] = getStubFunctionPointer(access, method);
        index++;
    }
    VMError.guarantee(index == offsets.length && index == pointers.length);
    return new JNIStructFunctionsInitializer<>(JNIInvokeInterface.class, offsets, pointers, unimplemented);
}
Also used : HostedType(com.oracle.svm.hosted.meta.HostedType) HostedMethod(com.oracle.svm.hosted.meta.HostedMethod) StructFieldInfo(com.oracle.svm.hosted.c.info.StructFieldInfo) CFunctionPointer(org.graalvm.nativeimage.c.function.CFunctionPointer) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint)

Example 10 with HostedMethod

use of com.oracle.svm.hosted.meta.HostedMethod in project graal by oracle.

the class JNIFunctionTablesFeature method prepareCallTrampoline.

private static CFunctionPointer prepareCallTrampoline(CompilationAccessImpl access, CallVariant variant, boolean nonVirtual) {
    JNICallTrampolineMethod trampolineMethod = JNIAccessFeature.singleton().getCallTrampolineMethod(variant, nonVirtual);
    AnalysisMethod analysisTrampoline = access.getUniverse().getBigBang().getUniverse().lookup(trampolineMethod);
    HostedMethod hostedTrampoline = access.getUniverse().lookup(analysisTrampoline);
    hostedTrampoline.compilationInfo.setCustomParseFunction(trampolineMethod.createCustomParseFunction());
    hostedTrampoline.compilationInfo.setCustomCompileFunction(trampolineMethod.createCustomCompileFunction());
    return MethodPointer.factory(hostedTrampoline);
}
Also used : AnalysisMethod(com.oracle.graal.pointsto.meta.AnalysisMethod) HostedMethod(com.oracle.svm.hosted.meta.HostedMethod) JNICallTrampolineMethod(com.oracle.svm.jni.hosted.JNICallTrampolineMethod)

Aggregations

HostedMethod (com.oracle.svm.hosted.meta.HostedMethod)32 DebugContext (org.graalvm.compiler.debug.DebugContext)10 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)10 CompilationResult (org.graalvm.compiler.code.CompilationResult)8 Invoke (org.graalvm.compiler.nodes.Invoke)8 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)7 DeoptEntryInfopoint (com.oracle.svm.core.deopt.DeoptEntryInfopoint)7 Infopoint (jdk.vm.ci.code.site.Infopoint)7 Indent (org.graalvm.compiler.debug.Indent)6 HostedProviders (com.oracle.graal.pointsto.meta.HostedProviders)5 HostedOptionValues (com.oracle.svm.core.option.HostedOptionValues)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Call (jdk.vm.ci.code.site.Call)5 GraalError (org.graalvm.compiler.debug.GraalError)5 OptionValues (org.graalvm.compiler.options.OptionValues)5 AnalysisMethod (com.oracle.graal.pointsto.meta.AnalysisMethod)4 SubstrateIntrinsicGraphBuilder (com.oracle.graal.pointsto.phases.SubstrateIntrinsicGraphBuilder)4 Timer (com.oracle.graal.pointsto.util.Timer)4