Search in sources :

Example 26 with Uninterruptible

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

the class CompileQueue method canBeUsedForInlining.

protected boolean canBeUsedForInlining(Invoke invoke) {
    HostedMethod caller = (HostedMethod) invoke.asNode().graph().method();
    HostedMethod callee = (HostedMethod) invoke.callTarget().targetMethod();
    if (canDeoptForTesting(caller) && Modifier.isNative(callee.getModifiers())) {
        /*
             * We must not deoptimize in the stubs for native functions, since they don't have a
             * valid bytecode state.
             */
        return false;
    }
    if (canDeoptForTesting(caller) && universe.getMethodsWithStackValues().contains(callee.wrapped)) {
        /*
             * We must not inline a method that has stack values and can be deoptimized.
             */
        return false;
    }
    if (caller.compilationInfo.isDeoptTarget()) {
        if (caller.compilationInfo.isDeoptEntry(invoke.bci(), true, false)) {
            /*
                 * The call can be on the stack for a deoptimization, so we need an actual
                 * non-inlined invoke to deoptimize too.
                 *
                 * We could lift this restriction by providing an explicit deopt entry point (with
                 * the correct exception handling edges) in addition to the inlined method.
                 */
            return false;
        }
        if (CompilationInfoSupport.singleton().isDeoptInliningExclude(callee)) {
            /*
                 * The graphs for runtime compilation have an intrinisic for the callee, which might
                 * alter the behavior. Be safe and do not inline, otherwise we might optimize too
                 * aggressively.
                 *
                 * For example, the Truffle method CompilerDirectives.inCompiledCode is
                 * intrinisified to return a constant with the opposite value than returned by the
                 * method we would inline here, i.e., we would constant-fold away the compiled-code
                 * only code (which is the code we need deoptimization entry points for).
                 */
            return false;
        }
    }
    if (callee.getAnnotation(Specialize.class) != null) {
        return false;
    }
    if (callerAnnotatedWith(invoke, Specialize.class) && callee.getAnnotation(DeoptTest.class) != null) {
        return false;
    }
    Uninterruptible calleeUninterruptible = callee.getAnnotation(Uninterruptible.class);
    if (calleeUninterruptible != null && !calleeUninterruptible.mayBeInlined() && caller.getAnnotation(Uninterruptible.class) == null) {
        return false;
    }
    if (!mustNotAllocateCallee(caller) && mustNotAllocate(callee)) {
        return false;
    }
    if (isNotExecuted(caller) || isNotExecuted(callee)) {
        return false;
    }
    if (!callee.canBeInlined()) {
        return false;
    }
    return invoke.useForInlining();
}
Also used : Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible) HostedMethod(com.oracle.svm.hosted.meta.HostedMethod) Specialize(com.oracle.svm.core.annotate.Specialize)

Example 27 with Uninterruptible

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

the class VMErrorSubstitutions method shutdown.

@Uninterruptible(reason = "Allow use in uninterruptible code.", calleeMustBe = false)
static void shutdown(String msg) {
    Log log = Log.log();
    log.autoflush(true);
    log.string("VMError.shouldNotReachHere: ").string(msg).newline();
    doShutdown(log);
}
Also used : Log(com.oracle.svm.core.log.Log) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 28 with Uninterruptible

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

the class VMErrorSubstitutions method shutdown.

@Uninterruptible(reason = "Allow use in uninterruptible code.", calleeMustBe = false)
static void shutdown() {
    Log log = Log.log();
    log.autoflush(true);
    log.string("VMError.shouldNotReachHere").newline();
    doShutdown(log);
}
Also used : Log(com.oracle.svm.core.log.Log) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 29 with Uninterruptible

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

the class ArraycopySnippets method objectCopyBackwardsUninterruptibly.

@Uninterruptible(reason = "Only the first writeObject has a write-barrier.")
private static void objectCopyBackwardsUninterruptibly(Object fromArray, UnsignedWord fromOffset, Object toArray, UnsignedWord toOffset, UnsignedWord elementSize, UnsignedWord size) {
    // Loop-peel the first iteration so I can use BarrieredAccess
    // to put a write barrier on the destination.
    // TODO: I am explicitly not making the first read have a read barrier.
    UnsignedWord remaining = size;
    if (remaining.aboveThan(0)) {
        remaining = remaining.subtract(elementSize);
        BarrieredAccess.writeObject(toArray, toOffset.add(remaining), ObjectAccess.readObject(fromArray, fromOffset.add(remaining)));
        while (remaining.aboveThan(0)) {
            remaining = remaining.subtract(elementSize);
            ObjectAccess.writeObject(toArray, toOffset.add(remaining), ObjectAccess.readObject(fromArray, fromOffset.add(remaining)));
        }
    }
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 30 with Uninterruptible

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

the class ArraycopySnippets method objectCopyForwardUninterruptibly.

@Uninterruptible(reason = "Only the first writeObject has a write-barrier.")
private static void objectCopyForwardUninterruptibly(Object fromArray, UnsignedWord fromOffset, Object toArray, UnsignedWord toOffset, UnsignedWord elementSize, UnsignedWord size) {
    UnsignedWord copied = WordFactory.zero();
    // TODO: I am explicitly not making the first read have a read barrier.
    if (copied.belowThan(size)) {
        BarrieredAccess.writeObject(toArray, toOffset.add(copied), ObjectAccess.readObject(fromArray, fromOffset.add(copied)));
        copied = copied.add(elementSize);
        while (copied.belowThan(size)) {
            ObjectAccess.writeObject(toArray, toOffset.add(copied), ObjectAccess.readObject(fromArray, fromOffset.add(copied)));
            copied = copied.add(elementSize);
        }
    }
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) 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