Search in sources :

Example 1 with NeverInline

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

the class VMThreadCounterOperation method getStackTrace.

@Substitute
@NeverInline("Immediate caller must show up in stack trace and so needs its own stack frame")
private StackTraceElement[] getStackTrace() {
    if (JavaThreads.fromTarget(this) == Thread.currentThread()) {
        /* We can walk our own stack without a VMOperation. */
        StackTraceBuilder stackTraceBuilder = new StackTraceBuilder();
        JavaStackWalker.walkCurrentThread(KnownIntrinsics.readCallerStackPointer(), KnownIntrinsics.readReturnAddress(), stackTraceBuilder);
        return stackTraceBuilder.getTrace();
    } else {
        return JavaThreads.getStackTrace(JavaThreads.fromTarget(this));
    }
}
Also used : StackTraceBuilder(com.oracle.svm.core.jdk.StackTraceBuilder) NeverInline(com.oracle.svm.core.annotate.NeverInline) Substitute(com.oracle.svm.core.annotate.Substitute)

Example 2 with NeverInline

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

the class Deoptimizer method deoptimizeFrame.

/**
 * Deoptimizes the given frame.
 *
 * @param ignoreNonDeoptimizable if set to true, a frame that cannot be deoptimized is ignored
 *            instead of raising an error (use for deoptimzation testing only).
 */
@NeverInline("Inlining of this method would require that we have deopt targets for callees of this method (SVM internals).")
public static void deoptimizeFrame(Pointer sourceSp, boolean ignoreNonDeoptimizable, SpeculationReason speculation) {
    DeoptimizedFrame deoptFrame = Deoptimizer.checkDeoptimized(sourceSp);
    if (deoptFrame != null) {
        /* Already deoptimized, so nothing to do. */
        registerSpeculationFailure(deoptFrame.getSourceInstalledCode(), speculation);
        return;
    }
    IsolateThread currentThread = CEntryPointContext.getCurrentIsolateThread();
    VMOperation.enqueueBlockingSafepoint("DeoptimizeFrame", () -> Deoptimizer.deoptimizeFrameOperation(sourceSp, ignoreNonDeoptimizable, speculation, currentThread));
}
Also used : IsolateThread(org.graalvm.nativeimage.IsolateThread) NeverInline(com.oracle.svm.core.annotate.NeverInline)

Example 3 with NeverInline

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

the class JavaLangSubstitutions method fillInStackTrace.

@Substitute
@NeverInline("Prevent inlining in Truffle compilations")
private Object fillInStackTrace() {
    Pointer sp = KnownIntrinsics.readCallerStackPointer();
    CodePointer ip = KnownIntrinsics.readReturnAddress();
    StackTraceBuilder stackTraceBuilder = new StackTraceBuilder();
    JavaStackWalker.walkCurrentThread(sp, ip, stackTraceBuilder);
    this.stackTrace = stackTraceBuilder.getTrace();
    return this;
}
Also used : CodePointer(org.graalvm.nativeimage.c.function.CodePointer) Pointer(org.graalvm.word.Pointer) CodePointer(org.graalvm.nativeimage.c.function.CodePointer) NeverInline(com.oracle.svm.core.annotate.NeverInline) Substitute(com.oracle.svm.core.annotate.Substitute)

Example 4 with NeverInline

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

the class SubstrateUtil method dumpJavaFrameAnchors.

@NeverInline("catch implicit exceptions")
private static void dumpJavaFrameAnchors(Log log) {
    log.string("JavaFrameAnchor dump:").newline();
    log.indent(true);
    JavaFrameAnchor anchor = JavaFrameAnchors.getFrameAnchor();
    if (anchor.isNull()) {
        log.string("No anchors").newline();
    }
    while (anchor.isNonNull()) {
        log.string("Anchor ").zhex(anchor.rawValue()).string(" LastJavaSP ").zhex(anchor.getLastJavaSP().rawValue()).newline();
        anchor = anchor.getPreviousAnchor();
    }
    log.indent(false);
}
Also used : JavaFrameAnchor(com.oracle.svm.core.stack.JavaFrameAnchor) NeverInline(com.oracle.svm.core.annotate.NeverInline)

Example 5 with NeverInline

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

the class SubstrateInspectedFrame method iterateFrames.

@NeverInline("Stack walking starts at the physical caller frame of this method")
@Override
public <T> T iterateFrames(ResolvedJavaMethod[] initialMethods, ResolvedJavaMethod[] matchingMethods, int initialSkip, InspectedFrameVisitor<T> visitor) {
    if (SubstrateUtil.HOSTED) {
        /*
             * During native-image generation we use HotSpotStackIntrospection to iterate frames.
             * `initialMethods` and `matchingMethods` are hosted versions of `ResolvedJavaMethod`
             * that we provide them in `SubstrateTruffleRuntime`.
             */
        StackIntrospection hostedStackIntrospection = JVMCI.getRuntime().getHostJVMCIBackend().getStackIntrospection();
        return hostedStackIntrospection.iterateFrames(initialMethods, matchingMethods, initialSkip, visitor);
    }
    /* Stack walking starts at the physical caller frame of this method. */
    Pointer startSP = KnownIntrinsics.readCallerStackPointer();
    CodePointer startIP = KnownIntrinsics.readReturnAddress();
    PhysicalStackFrameVisitor<T> physicalFrameVisitor = new PhysicalStackFrameVisitor<>(initialMethods, matchingMethods, initialSkip, visitor);
    JavaStackWalker.walkCurrentThread(startSP, startIP, physicalFrameVisitor);
    return physicalFrameVisitor.result;
}
Also used : CodePointer(org.graalvm.nativeimage.c.function.CodePointer) Pointer(org.graalvm.word.Pointer) CodePointer(org.graalvm.nativeimage.c.function.CodePointer) StackIntrospection(jdk.vm.ci.code.stack.StackIntrospection) NeverInline(com.oracle.svm.core.annotate.NeverInline)

Aggregations

NeverInline (com.oracle.svm.core.annotate.NeverInline)9 CodePointer (org.graalvm.nativeimage.c.function.CodePointer)5 Pointer (org.graalvm.word.Pointer)5 Substitute (com.oracle.svm.core.annotate.Substitute)2 JavaFrameAnchor (com.oracle.svm.core.stack.JavaFrameAnchor)2 IsolateThread (org.graalvm.nativeimage.IsolateThread)2 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)1 DeoptimizedFrame (com.oracle.svm.core.deopt.DeoptimizedFrame)1 StackTraceBuilder (com.oracle.svm.core.jdk.StackTraceBuilder)1 SubstrateForeignCallTarget (com.oracle.svm.core.snippets.SubstrateForeignCallTarget)1 StackIntrospection (jdk.vm.ci.code.stack.StackIntrospection)1 CCharPointer (org.graalvm.nativeimage.c.type.CCharPointer)1 CCharPointerPointer (org.graalvm.nativeimage.c.type.CCharPointerPointer)1