Search in sources :

Example 11 with Uninterruptible

use of com.oracle.svm.core.annotate.Uninterruptible 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 12 with Uninterruptible

use of com.oracle.svm.core.annotate.Uninterruptible 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 13 with Uninterruptible

use of com.oracle.svm.core.annotate.Uninterruptible 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 14 with Uninterruptible

use of com.oracle.svm.core.annotate.Uninterruptible in project graal by oracle.

the class ThreadLocalAllocation method allocateLargeArray.

@Uninterruptible(reason = "Holds uninitialized memory, modifies TLAB")
private static Object allocateLargeArray(DynamicHub hub, int length, UnsignedWord size, UnalignedHeapChunk.UnalignedHeader uChunk, ThreadLocalAllocation.Descriptor tlab, boolean rememberedSet) {
    /* Register the new chunk in the TLAB linked list of unaligned chunks. */
    uChunk.setNext(tlab.getUnalignedChunk());
    tlab.setUnalignedChunk(uChunk);
    /* Allocate the memory. We must have a chunk, otherwise we already threw an exception. */
    Pointer memory = UnalignedHeapChunk.allocateMemory(uChunk, size);
    assert memory.isNonNull();
    /* Install the DynamicHub and length, and zero the elements. */
    return KnownIntrinsics.formatArray(memory, hub.asClass(), length, rememberedSet, true);
}
Also used : Pointer(org.graalvm.word.Pointer) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 15 with Uninterruptible

use of com.oracle.svm.core.annotate.Uninterruptible in project graal by oracle.

the class ThreadLocalAllocation method resumeAllocationChunk.

/**
 * Add a new allocation chunk at the front of the TLAB's aligned chunks.
 */
@Uninterruptible(reason = "Modifies TLAB.")
static void resumeAllocationChunk(Descriptor tlab) {
    assert tlab.getAllocationTop(TOP_IDENTITY).isNull();
    assert tlab.getAllocationTop(END_IDENTITY).isNull();
    AlignedHeader alignedChunk = tlab.getAlignedChunk();
    if (alignedChunk.isNonNull()) {
        tlab.setAllocationTop(alignedChunk.getTop(), TOP_IDENTITY);
        tlab.setAllocationEnd(alignedChunk.getEnd(), END_IDENTITY);
        alignedChunk.setTop(WordFactory.nullPointer());
    }
}
Also used : AlignedHeader(com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Aggregations

Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)54 Pointer (org.graalvm.word.Pointer)15 UnsignedWord (org.graalvm.word.UnsignedWord)9 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)7 SubstrateForeignCallTarget (com.oracle.svm.core.snippets.SubstrateForeignCallTarget)5 IsolateThread (org.graalvm.nativeimage.IsolateThread)5 AlignedHeader (com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader)4 Safepoint (com.oracle.svm.core.thread.Safepoint)4 HostedMethod (com.oracle.svm.hosted.meta.HostedMethod)4 CodePointer (org.graalvm.nativeimage.c.function.CodePointer)4 CCharPointer (org.graalvm.nativeimage.c.type.CCharPointer)4 RestrictHeapAccess (com.oracle.svm.core.annotate.RestrictHeapAccess)3 Substitute (com.oracle.svm.core.annotate.Substitute)3 Log (com.oracle.svm.core.log.Log)3 Time.timespec (com.oracle.svm.core.posix.headers.Time.timespec)3 Time.timeval (com.oracle.svm.core.posix.headers.Time.timeval)3 Time.timezone (com.oracle.svm.core.posix.headers.Time.timezone)3 DebugContext (org.graalvm.compiler.debug.DebugContext)3 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)3 CIntPointer (org.graalvm.nativeimage.c.type.CIntPointer)3