Search in sources :

Example 6 with SubstrateForeignCallTarget

use of com.oracle.svm.core.snippets.SubstrateForeignCallTarget in project graal by oracle.

the class PosixCEntryPointSnippets method enterIsolateMT.

@Uninterruptible(reason = "Thread state not set up yet")
@SubstrateForeignCallTarget
private static int enterIsolateMT(Isolate isolate) {
    int sanityError = PosixIsolates.checkSanity(isolate);
    if (sanityError != Errors.NO_ERROR) {
        return sanityError;
    }
    if (UseHeapBaseRegister.getValue()) {
        setHeapBase(PosixIsolates.getHeapBase(isolate));
    }
    if (!PosixVMThreads.isInitialized()) {
        return Errors.UNINITIALIZED_ISOLATE;
    }
    IsolateThread thread = PosixVMThreads.VMThreadTL.get();
    if (VMThreads.isNullThread(thread)) {
        return Errors.UNATTACHED_THREAD;
    }
    writeCurrentVMThread(thread);
    return Errors.NO_ERROR;
}
Also used : IsolateThread(org.graalvm.nativeimage.IsolateThread) Safepoint(com.oracle.svm.core.thread.Safepoint) SubstrateForeignCallTarget(com.oracle.svm.core.snippets.SubstrateForeignCallTarget) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 7 with SubstrateForeignCallTarget

use of com.oracle.svm.core.snippets.SubstrateForeignCallTarget in project graal by oracle.

the class ThreadLocalAllocation method slowPathNewArray.

/**
 * Slow path of array allocation snippet.
 */
@SubstrateForeignCallTarget
private static Object slowPathNewArray(DynamicHub hub, int length) {
    /*
         * Length check allocates an exception and so must be hoisted away from RestrictHeapAccess
         * code
         */
    if (length < 0) {
        throw new NegativeArraySizeException();
    }
    /* Allocation might cause a collection. */
    final UnsignedWord gcEpoch = HeapImpl.getHeapImpl().getGCImpl().possibleCollectionPrologue();
    /* Allocate the requested array. */
    final Object result = slowPathNewArrayWithoutAllocating(hub, length);
    /* Allow the collector to do stuff now that allocation, etc., is allowed. */
    HeapImpl.getHeapImpl().getGCImpl().possibleCollectionEpilogue(gcEpoch);
    return result;
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) SubstrateForeignCallTarget(com.oracle.svm.core.snippets.SubstrateForeignCallTarget)

Example 8 with SubstrateForeignCallTarget

use of com.oracle.svm.core.snippets.SubstrateForeignCallTarget in project graal by oracle.

the class ThreadLocalAllocation method slowPathNewInstance.

/**
 * Slow path of instance allocation snippet.
 */
@SubstrateForeignCallTarget
private static Object slowPathNewInstance(DynamicHub hub) {
    /* Allocation might cause a collection. */
    final UnsignedWord gcEpoch = HeapImpl.getHeapImpl().getGCImpl().possibleCollectionPrologue();
    /* Allocate the requested instance. */
    final Object result = slowPathNewInstanceWithoutAllocating(hub);
    /* Allow the collector to do stuff now that allocation, etc., is allowed. */
    HeapImpl.getHeapImpl().getGCImpl().possibleCollectionEpilogue(gcEpoch);
    return result;
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) SubstrateForeignCallTarget(com.oracle.svm.core.snippets.SubstrateForeignCallTarget)

Example 9 with SubstrateForeignCallTarget

use of com.oracle.svm.core.snippets.SubstrateForeignCallTarget in project graal by oracle.

the class PinnedAllocatorImpl method slowPathNewArray.

/* Slow path of the pinned new array allocation snippet. */
@SubstrateForeignCallTarget
private static Object slowPathNewArray(PinnedAllocatorImpl pinnedAllocator, DynamicHub hub, int length) {
    /*
         * Length check allocates an exception and so must be hoisted away from RestrictHeapAccess
         * code
         */
    if (length < 0) {
        throw new NegativeArraySizeException();
    }
    log().string("[PinnedAllocatorImpl.slowPathNewArray: ").object(pinnedAllocator).string("  hub: ").string(hub.getName()).string("  length: ").signed(length).newline();
    pinnedAllocator.ensureOpen();
    ThreadLocalAllocation.Descriptor tlab = ThreadLocalAllocation.pinnedTLAB.getAddress();
    Object result = ThreadLocalAllocation.allocateNewArray(hub, length, tlab, true);
    /* Register the new chunks that the slow path allocation might have created as pinned. */
    pinnedAllocator.pushPinnedChunks(tlab);
    log().string("  ]").newline();
    return result;
}
Also used : FastThreadLocalObject(com.oracle.svm.core.threadlocal.FastThreadLocalObject) SubstrateForeignCallTarget(com.oracle.svm.core.snippets.SubstrateForeignCallTarget)

Example 10 with SubstrateForeignCallTarget

use of com.oracle.svm.core.snippets.SubstrateForeignCallTarget in project graal by oracle.

the class PinnedAllocatorImpl method slowPathNewInstance.

/* Slow path of the pinned new instance allocation snippet. */
@SubstrateForeignCallTarget
private static Object slowPathNewInstance(PinnedAllocatorImpl pinnedAllocator, DynamicHub hub) {
    log().string("[PinnedAllocatorImpl.slowPathNewInstance: ").object(pinnedAllocator).string("  hub: ").string(hub.getName()).newline();
    pinnedAllocator.ensureOpen();
    ThreadLocalAllocation.Descriptor tlab = ThreadLocalAllocation.pinnedTLAB.getAddress();
    Object result = ThreadLocalAllocation.allocateNewInstance(hub, tlab, true);
    /* Register the new chunks that the slow path allocation might have created as pinned. */
    pinnedAllocator.pushPinnedChunks(tlab);
    log().string("  ]").newline();
    return result;
}
Also used : FastThreadLocalObject(com.oracle.svm.core.threadlocal.FastThreadLocalObject) SubstrateForeignCallTarget(com.oracle.svm.core.snippets.SubstrateForeignCallTarget)

Aggregations

SubstrateForeignCallTarget (com.oracle.svm.core.snippets.SubstrateForeignCallTarget)11 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)5 Safepoint (com.oracle.svm.core.thread.Safepoint)4 FastThreadLocalObject (com.oracle.svm.core.threadlocal.FastThreadLocalObject)2 IsolateThread (org.graalvm.nativeimage.IsolateThread)2 UnsignedWord (org.graalvm.word.UnsignedWord)2 NeverInline (com.oracle.svm.core.annotate.NeverInline)1 RestrictHeapAccess (com.oracle.svm.core.annotate.RestrictHeapAccess)1 DynamicHub (com.oracle.svm.core.hub.DynamicHub)1 FILE (com.oracle.svm.core.posix.headers.Stdio.FILE)1 CodePointer (org.graalvm.nativeimage.c.function.CodePointer)1 WordPointer (org.graalvm.nativeimage.c.type.WordPointer)1 Pointer (org.graalvm.word.Pointer)1