Search in sources :

Example 16 with Uninterruptible

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

the class ThreadLocalAllocation method allocateSmallArray.

@Uninterruptible(reason = "Holds uninitialized memory, modifies TLAB")
private static Object allocateSmallArray(DynamicHub hub, int length, UnsignedWord size, ThreadLocalAllocation.Descriptor tlab, boolean rememberedSet, AlignedHeader newChunk) {
    registerNewAllocationChunk(tlab, newChunk);
    /*
         * Allocate the memory. We must have a chunk, because we just registered one and we are
         * still in the same block of uninterruptible code.
         */
    Pointer memory = allocateMemory(tlab, size);
    assert memory.isNonNull();
    /* Install the DynamicHub and length, and zero the elements. */
    return KnownIntrinsics.formatArray(memory, hub.asClass(), length, rememberedSet, false);
}
Also used : Pointer(org.graalvm.word.Pointer) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 17 with Uninterruptible

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

the class ThreadLocalAllocation method retireAllocationChunk.

/**
 * Retire the current allocation chunk of current TLAB.
 */
@Uninterruptible(reason = "Modifies TLAB")
private static void retireAllocationChunk(Descriptor tlab) {
    Pointer allocationTop = tlab.getAllocationTop(TOP_IDENTITY);
    if (allocationTop.isNonNull()) {
        AlignedHeader alignedChunk = tlab.getAlignedChunk();
        assert alignedChunk.getTop().isNull();
        assert alignedChunk.getEnd().equal(tlab.getAllocationEnd(END_IDENTITY));
        /*
             * While the aligned chunk is the allocation chunk its top value is always 'null' and it
             * doesn't reflect the upper limit of allocated memory. The 'top' is stored in the TLAB
             * and only set in the top aligned chunk when it is retired.
             */
        alignedChunk.setTop(allocationTop);
        tlab.setAllocationTop(WordFactory.nullPointer(), TOP_IDENTITY);
        tlab.setAllocationEnd(WordFactory.nullPointer(), END_IDENTITY);
    }
}
Also used : AlignedHeader(com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader) Pointer(org.graalvm.word.Pointer) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 18 with Uninterruptible

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

the class ThreadLocalAllocation method allocateNewInstanceUninterruptibly.

@Uninterruptible(reason = "Holds uninitialized memory, modifies TLAB")
private static Object allocateNewInstanceUninterruptibly(DynamicHub hub, ThreadLocalAllocation.Descriptor tlab, boolean rememberedSet, UnsignedWord size, AlignedHeader newChunk) {
    registerNewAllocationChunk(tlab, newChunk);
    /*
         * Allocate the memory. We must have a chunk, because we just registered one and we are
         * still in the same block of uninterruptible code.
         */
    Pointer memory = allocateMemory(tlab, size);
    assert memory.isNonNull();
    /* Install the DynamicHub and zero the fields. */
    return KnownIntrinsics.formatObject(memory, hub.asClass(), rememberedSet);
}
Also used : Pointer(org.graalvm.word.Pointer) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 19 with Uninterruptible

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

the class ThreadLocalAllocation method popFromThreadLocalFreeList.

/**
 * Pop an aligned chunk from the thread-local list of free chunks, or null if the list is empty.
 */
@Uninterruptible(reason = "Pops from the free list that is drained, at a safepoint, by garbage collections.")
private static AlignedHeader popFromThreadLocalFreeList() {
    final AlignedHeader result = freeList.get();
    if (result.isNonNull()) {
        final AlignedHeader next = result.getNext();
        result.setNext(WordFactory.nullPointer());
        freeList.set(next);
    }
    return result;
}
Also used : AlignedHeader(com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 20 with Uninterruptible

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

the class AllocationSnippets method doCloneUninterruptibly.

@Uninterruptible(reason = "Copies via Pointers")
private static // TODO: What if the bytes being written need remembered set operations?
Object doCloneUninterruptibly(Object thisObject, Object thatObject, UnsignedWord firstFieldOffset, UnsignedWord size) {
    Pointer thatMemory = Word.objectToUntrackedPointer(thatObject);
    /*
         * Copy the thisObj over thatMemory. Excluding the hub to make sure that no GC-relevant
         * header bits are transfered from thisObj to the clone.
         */
    Pointer thisMemory = Word.objectToUntrackedPointer(thisObject);
    UnsignedWord offset = firstFieldOffset;
    while (offset.belowThan(size)) {
        thatMemory.writeWord(offset, thisMemory.readWord(offset));
        offset = offset.add(ConfigurationValues.getTarget().wordSize);
    }
    final Object result = thatMemory.toObjectNonNull();
    return result;
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) Pointer(org.graalvm.word.Pointer) 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