Search in sources :

Example 11 with CodePointer

use of org.graalvm.nativeimage.c.function.CodePointer in project graal by oracle.

the class Deoptimizer method deoptimizeInRangeOperation.

/**
 * Deoptimize a specific method on all thread stacks.
 */
private static void deoptimizeInRangeOperation(CodePointer fromIp, CodePointer toIp, boolean deoptAll) {
    VMOperation.guaranteeInProgress("Deoptimizer.deoptimizeInRangeOperation, but not in VMOperation.");
    /* Handle my own thread specially, because I do not have a JavaFrameAnchor. */
    StackFrameVisitor currentThreadDeoptVisitor = getStackFrameVisitor((Pointer) fromIp, (Pointer) toIp, deoptAll, CEntryPointContext.getCurrentIsolateThread());
    Pointer sp = KnownIntrinsics.readCallerStackPointer();
    CodePointer ip = KnownIntrinsics.readReturnAddress();
    JavaStackWalker.walkCurrentThread(sp, ip, currentThreadDeoptVisitor);
    /* If I am multi-threaded, deoptimize this method on all the other stacks. */
    if (SubstrateOptions.MultiThreaded.getValue()) {
        for (IsolateThread vmThread = VMThreads.firstThread(); VMThreads.isNonNullThread(vmThread); vmThread = VMThreads.nextThread(vmThread)) {
            if (vmThread == CEntryPointContext.getCurrentIsolateThread()) {
                continue;
            }
            StackFrameVisitor deoptVisitor = getStackFrameVisitor((Pointer) fromIp, (Pointer) toIp, deoptAll, vmThread);
            JavaStackWalker.walkThread(vmThread, deoptVisitor);
        }
    }
    if (testGCinDeoptimizer) {
        Heap.getHeap().getGC().collect("from Deoptimizer.deoptimizeInRange because of testGCinDeoptimizer");
    }
}
Also used : StackFrameVisitor(com.oracle.svm.core.stack.StackFrameVisitor) IsolateThread(org.graalvm.nativeimage.IsolateThread) CodePointer(org.graalvm.nativeimage.c.function.CodePointer) Pointer(org.graalvm.word.Pointer) CodePointer(org.graalvm.nativeimage.c.function.CodePointer)

Example 12 with CodePointer

use of org.graalvm.nativeimage.c.function.CodePointer in project graal by oracle.

the class Deoptimizer method deoptimizeFrameOperation.

private static void deoptimizeFrameOperation(Pointer sourceSp, boolean ignoreNonDeoptimizable, SpeculationReason speculation, IsolateThread currentThread) {
    VMOperation.guaranteeInProgress("doDeoptimizeFrame");
    CodePointer returnAddress = FrameAccess.readReturnAddress(sourceSp);
    CodeInfoQueryResult info = CodeInfoTable.lookupCodeInfoQueryResult(returnAddress);
    Deoptimizer deoptimizer = new Deoptimizer(sourceSp, info);
    DeoptimizedFrame sourceFrame = deoptimizer.deoptSourceFrame(returnAddress, ignoreNonDeoptimizable, currentThread);
    if (sourceFrame != null) {
        registerSpeculationFailure(sourceFrame.getSourceInstalledCode(), speculation);
    }
}
Also used : CodeInfoQueryResult(com.oracle.svm.core.code.CodeInfoQueryResult) CodePointer(org.graalvm.nativeimage.c.function.CodePointer)

Example 13 with CodePointer

use of org.graalvm.nativeimage.c.function.CodePointer 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)

Example 14 with CodePointer

use of org.graalvm.nativeimage.c.function.CodePointer in project graal by oracle.

the class DeoptTester method deoptTest.

/**
 * Scans the stack frames and if there are some new (= so far not seen) PCs inside deoptimizable
 * methods, a deopt is done.
 *
 * Foreign call: {@link SnippetRuntime#DEOPTTEST}.
 */
@NeverInline("deoptTest must have a separate stack frame")
@SubstrateForeignCallTarget
public static void deoptTest() {
    if (inDeoptTest > 0) {
        return;
    }
    inDeoptTest++;
    try {
        if (Heap.getHeap().isAllocationDisallowed()) {
            return;
        }
        if (VMOperationControl.TestingBackdoor.isLocked()) {
            return;
        }
        if (VMOperation.isInProgress()) {
            return;
        }
        Pointer startSp = KnownIntrinsics.readCallerStackPointer();
        CodePointer startIp = KnownIntrinsics.readReturnAddress();
        int numHandledPCs = handledPCs.size();
        JavaStackWalker.walkCurrentThread(startSp, startIp, collectPcVisitor);
        if (handledPCs.size() > numHandledPCs) {
            Deoptimizer.deoptimizeAll();
        }
    } finally {
        inDeoptTest--;
    }
}
Also used : CodePointer(org.graalvm.nativeimage.c.function.CodePointer) Pointer(org.graalvm.word.Pointer) CodePointer(org.graalvm.nativeimage.c.function.CodePointer) SubstrateForeignCallTarget(com.oracle.svm.core.snippets.SubstrateForeignCallTarget) NeverInline(com.oracle.svm.core.annotate.NeverInline)

Aggregations

CodePointer (org.graalvm.nativeimage.c.function.CodePointer)14 Pointer (org.graalvm.word.Pointer)11 NeverInline (com.oracle.svm.core.annotate.NeverInline)4 KnownIntrinsics.readCallerStackPointer (com.oracle.svm.core.snippets.KnownIntrinsics.readCallerStackPointer)3 AlwaysInline (com.oracle.svm.core.annotate.AlwaysInline)2 CodeInfoQueryResult (com.oracle.svm.core.code.CodeInfoQueryResult)2 DeoptimizedFrame (com.oracle.svm.core.deopt.DeoptimizedFrame)2 Log (com.oracle.svm.core.log.Log)2 IsolateThread (org.graalvm.nativeimage.IsolateThread)2 Substitute (com.oracle.svm.core.annotate.Substitute)1 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)1 SubstrateInstalledCode (com.oracle.svm.core.deopt.SubstrateInstalledCode)1 SubstrateForeignCallTarget (com.oracle.svm.core.snippets.SubstrateForeignCallTarget)1 JavaFrameAnchor (com.oracle.svm.core.stack.JavaFrameAnchor)1 StackFrameVisitor (com.oracle.svm.core.stack.StackFrameVisitor)1 StackIntrospection (jdk.vm.ci.code.stack.StackIntrospection)1 DeoptimizationAction (jdk.vm.ci.meta.DeoptimizationAction)1 DeoptimizationReason (jdk.vm.ci.meta.DeoptimizationReason)1 Snippet (org.graalvm.compiler.api.replacements.Snippet)1 NodeSourcePosition (org.graalvm.compiler.graph.NodeSourcePosition)1