Search in sources :

Example 46 with Uninterruptible

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

the class ThreadLocalAllocation method allocateMemory.

/**
 * The implementation of the AllocationSnippets.fastAllocateImpl(Unsigned).
 * <p>
 * This is bump-pointer allocation for the young generation, using a cached "top" and "end".
 * <p>
 * Since this is called from a snippet, it and all the methods it calls, must be able to be
 * inlined. The easy way to do that is to make this method, and all the methods it calls, final
 * or static.
 * <p>
 * This allocates *memory*, not an Object. The rest of the allocation path takes care of turning
 * the memory into an Object.
 * <p>
 * See also
 * {@linkplain AlignedHeapChunk#allocateMemory(AlignedHeapChunk.AlignedHeader, UnsignedWord)}.
 */
@Uninterruptible(reason = "returns uninitialized memory, modifies TLAB", callerMustBe = true)
public static Pointer allocateMemory(Descriptor allocator, UnsignedWord size) {
    Pointer top = KnownIntrinsics.nonNullPointer(allocator.getAllocationTop(TOP_IDENTITY));
    Pointer end = KnownIntrinsics.nonNullPointer(allocator.getAllocationEnd(END_IDENTITY));
    UnsignedWord available = end.subtract(top);
    if (BranchProbabilityNode.probability(BranchProbabilityNode.FAST_PATH_PROBABILITY, size.belowOrEqual(available))) {
        allocator.setAllocationTop(top.add(size), TOP_IDENTITY);
        return top;
    } else {
        return WordFactory.nullPointer();
    }
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) Pointer(org.graalvm.word.Pointer) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 47 with Uninterruptible

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

the class ThreadLocalAllocation method pushToThreadLocalFreeList.

/**
 * Push an aligned chunk on the thread-local list of free chunks.
 */
@Uninterruptible(reason = "Pushes the free list that is drained, at a safepoint, by garbage collections.")
private static void pushToThreadLocalFreeList(AlignedHeader alignedChunk) {
    log().string("[ThreadLocalAllocation.pushToThreadLocalFreeList:  alignedChunk: ").hex(alignedChunk).newline();
    log().string("  before freeList: ").hex(freeList.get()).newline();
    assert alignedChunk.isNonNull() : "Should not push a null chunk on the free list.";
    final AlignedHeader head = freeList.get();
    alignedChunk.setNext(head);
    freeList.set(alignedChunk);
    log().string("   after freeList: ").hex(freeList.get()).string("]").newline();
}
Also used : AlignedHeader(com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 48 with Uninterruptible

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

the class UnalignedHeapChunkMemoryWalkerAccessFeature method allocateMemory.

/*
     * Methods on UnalignedHeapChunk.
     */
/**
 * Allocate memory within this AlignedHeapChunk. No initialization of the memory happens here.
 */
@Uninterruptible(reason = "Returns uninitialized memory.", callerMustBe = true)
public static Pointer allocateMemory(UnalignedHeader that, UnsignedWord size) {
    final UnsignedWord available = availableObjectMemory(that);
    // Is memory available for the requested size?
    Pointer result = WordFactory.nullPointer();
    if (size.belowOrEqual(available)) {
        // Returned memory is at the start,
        result = that.getTop();
        final Pointer newTop = result.add(size);
        setTopCarefully(that, newTop);
    }
    return result;
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) Pointer(org.graalvm.word.Pointer) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 49 with Uninterruptible

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

the class AllocationSnippets method formatArrayImpl.

@Uninterruptible(reason = "Manipulates Objects via Pointers", callerMustBe = true)
private static Object formatArrayImpl(Pointer memory, DynamicHub hub, int length, int layoutEncoding, UnsignedWord size, boolean fillContents, boolean rememberedSet, boolean unaligned) {
    WordBase header = ObjectHeaderImpl.getObjectHeaderImpl().formatHub(hub, rememberedSet, unaligned);
    memory.writeWord(ConfigurationValues.getObjectLayout().getHubOffset(), header, LocationIdentity.INIT_LOCATION);
    memory.writeInt(ConfigurationValues.getObjectLayout().getArrayLengthOffset(), length, LocationIdentity.INIT_LOCATION);
    if (fillContents) {
        UnsignedWord offset = LayoutEncoding.getArrayBaseOffset(layoutEncoding);
        if ((!isWordAligned(offset)) && offset.belowThan(size)) {
            /*
                 * The first array element offset can be 4-byte aligned. Write an int in this case
                 * to zero any bytes before the Word writes below.
                 */
            memory.writeInt(offset, 0, LocationIdentity.INIT_LOCATION);
            offset = offset.add(4);
        }
        /* Assert that offset is now Word aligned, or past the end of the elements. */
        assert isWordAligned(offset) : "offset should be Word aligned";
        while (offset.belowThan(size)) {
            memory.writeWord(offset, WordFactory.zero(), LocationIdentity.INIT_LOCATION);
            offset = offset.add(ConfigurationValues.getTarget().wordSize);
        }
    }
    return memory.toObjectNonNull();
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) WordBase(org.graalvm.word.WordBase) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 50 with Uninterruptible

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

the class AllocationSnippets method fastNewArrayUninterruptibly.

@Uninterruptible(reason = "Holds uninitialized memory from allocateMemory through formatArryImpl")
private static Object fastNewArrayUninterruptibly(DynamicHub hub, int length, int layoutEncoding, boolean fillContents, UnsignedWord size) {
    Pointer memory = WordFactory.nullPointer();
    if (size.belowOrEqual(HeapPolicy.getLargeArrayThreshold()) && length >= 0) {
        memory = ThreadLocalAllocation.allocateMemory(ThreadLocalAllocation.regularTLAB.getAddress(), size);
    }
    Object result = null;
    if (memory.isNonNull()) {
        result = formatArrayImpl(memory, hub, length, layoutEncoding, size, fillContents, false, false);
    }
    return result;
}
Also used : 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