Search in sources :

Example 51 with Uninterruptible

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

the class HeapChunk method availableObjectMemory.

/**
 * How much space is available for objects in a HeapChunk?
 */
@Uninterruptible(reason = "Called from uninterruptible code.")
public static UnsignedWord availableObjectMemory(Header<?> that) {
    final Pointer top = that.getTop();
    final Pointer end = that.getEnd();
    return end.subtract(top);
}
Also used : Pointer(org.graalvm.word.Pointer) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 52 with Uninterruptible

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

the class Deoptimizer method rewriteStackAndJumpToTarget.

/**
 * Performs the actual stack rewriting. When this method is called the sp is already at the
 * bottom of the deopt target method.
 *
 * @param newSp Points to the bottom of the deopt target method (but above the return address
 *            slot).
 * @param frame The deopt frame handle.
 * @return The epilog of this method restores the return value registers from the returned frame
 *         handle. The instructions for restoring the return value registers must be generated
 *         in this method's epilog by a backend-specific FrameContext class.
 */
@DeoptStub(stubType = StubType.ExitStub)
@NeverInline("don't provoke the writeStackPointer devil with a non-trivial method")
@Uninterruptible(reason = "Frame holds Objects in unmanaged storage.")
private static DeoptimizedFrame rewriteStackAndJumpToTarget(Pointer newSp, DeoptimizedFrame frame) {
    /*
         * The first word of the new stack content is already the return address into the caller of
         * deoptimizeInRange(). So when this method returns we are inside the caller of
         * deoptimizeInRange().
         */
    Pointer bottomSp = newSp.subtract(FrameAccess.returnAddressSize());
    frame.getTargetContent().copyToPointer(bottomSp);
    if (DeoptimizationCounters.Options.ProfileDeoptimization.getValue()) {
        DeoptimizationCounters.counters().timeSpentInDeopt.add(System.nanoTime() - DeoptimizationCounters.startTime.get());
    }
    return frame;
}
Also used : CodePointer(org.graalvm.nativeimage.c.function.CodePointer) Pointer(org.graalvm.word.Pointer) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible) NeverInline(com.oracle.svm.core.annotate.NeverInline)

Example 53 with Uninterruptible

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

the class Deoptimizer method deoptStub.

/**
 * Performs the second step of deoptimization: the actual rewriting of a deoptimized method's
 * frame.
 * <p>
 * The pointer to the deopt stub code was installed in the return address slot by
 * {@link #deoptimizeInRange}. Therefore the stub is "called" when a method wants to return to a
 * deoptimized method.
 * <p>
 * When {@link #deoptStub} is "called", the stack looks like this:
 *
 * <pre>
 *    :                                :
 *    |                                |
 *    |                                |   frame of the
 *    +--------------------------------+   deoptimized method
 *    | pointer to DeoptimizedFrame    |
 *    +--------------------------------+--------- no return address between the frames!
 *    |                                |
 *    |                                |   frame of
 *    |                                |   {@link #deoptStub}
 *    :     ...                        :
 * </pre>
 *
 * @param frame This is the handle which was created in {@link #deoptimizeInRange}. It is
 *            fetched from the stack (the slot above the original return address) and passed as
 *            parameter. The instructions for fetching the frame handle must be generated in
 *            this method's prolog by a backend-specific FrameContext class. The prolog also
 *            stores the original return value registers in the {@code frame}.
 */
@DeoptStub(stubType = StubType.EntryStub)
@Uninterruptible(reason = "Frame holds Objects in unmanaged storage.")
public static void deoptStub(DeoptimizedFrame frame) {
    DeoptimizationCounters.counters().deoptCount.inc();
    if (DeoptimizationCounters.Options.ProfileDeoptimization.getValue()) {
        DeoptimizationCounters.startTime.set(System.nanoTime());
    }
    /* Build the content of the deopt target stack frames. */
    frame.buildContent();
    /*
         * The frame was pinned to keep it from moving during construction. I can unpin it now that
         * I am uninterruptible. (And I have to unpin it.)
         */
    frame.getPin().close();
    recentDeoptimizationEvents.append(frame.getCompletedMessage());
    Pointer sp = KnownIntrinsics.readStackPointer();
    /* Do the stack rewriting. Return directly to the deopt target. */
    final Pointer newSp = sp.add(WordFactory.unsigned(deoptStubFrameSize)).add(WordFactory.unsigned(frame.getSourceTotalFrameSize()).subtract(frame.getTargetContent().getSize()).subtract(FrameAccess.returnAddressSize()));
    rewriteStackStub(newSp, frame);
}
Also used : CodePointer(org.graalvm.nativeimage.c.function.CodePointer) Pointer(org.graalvm.word.Pointer) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 54 with Uninterruptible

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

the class RuntimeCodeInfoMemoryWalkerAccessFeature method binarySearch.

/* Copied and adapted from Arrays.binarySearch. */
@Uninterruptible(reason = "called from uninterruptible code")
private static int binarySearch(RuntimeMethodInfo[] a, int fromIndex, int toIndex, CodePointer key) {
    int low = fromIndex;
    int high = toIndex - 1;
    while (low <= high) {
        int mid = (low + high) >>> 1;
        CodePointer midVal = a[mid].getCodeStart();
        if (((UnsignedWord) midVal).belowThan((UnsignedWord) key)) {
            low = mid + 1;
        } else if (((UnsignedWord) midVal).aboveThan((UnsignedWord) key)) {
            high = mid - 1;
        } else {
            // key found
            return mid;
        }
    }
    // key not found.
    return -(low + 1);
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) CodePointer(org.graalvm.nativeimage.c.function.CodePointer) 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