Search in sources :

Example 81 with Pointer

use of org.graalvm.word.Pointer in project graal by oracle.

the class UnalignedHeapChunkMemoryWalkerAccessFeature method usedObjectMemoryOfUnalignedHeapChunk.

/**
 * How much space is used for the objects in an UnalignedHeapChunk?
 */
public static UnsignedWord usedObjectMemoryOfUnalignedHeapChunk(UnalignedHeader that) {
    final Pointer start = getUnalignedHeapChunkStart(that);
    final Pointer top = that.getTop();
    return top.subtract(start);
}
Also used : Pointer(org.graalvm.word.Pointer)

Example 82 with Pointer

use of org.graalvm.word.Pointer in project graal by oracle.

the class UnalignedHeapChunkMemoryWalkerAccessFeature method committedObjectMemoryOfUnalignedHeapChunk.

/**
 * The committed object memory is the space between start and end.
 */
public static UnsignedWord committedObjectMemoryOfUnalignedHeapChunk(UnalignedHeader that) {
    final Pointer start = getUnalignedHeapChunkStart(that);
    final Pointer end = that.getEnd();
    final UnsignedWord result = end.subtract(start);
    return result;
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) Pointer(org.graalvm.word.Pointer)

Example 83 with Pointer

use of org.graalvm.word.Pointer in project graal by oracle.

the class AllocationSnippets method newPinnedInstanceSnippet.

@Snippet
public static Object newPinnedInstanceSnippet(PinnedAllocatorImpl pinnedAllocator, DynamicHub hub, @ConstantParameter int encoding, @ConstantParameter boolean fillContents, AllocationCounter counter) {
    pinnedAllocator.ensureOpen();
    UnsignedWord size = LayoutEncoding.getInstanceSize(encoding);
    profileAllocation(size, counter);
    Pointer memory = ThreadLocalAllocation.allocateMemory(ThreadLocalAllocation.pinnedTLAB.getAddress(), size);
    Object result;
    if (BranchProbabilityNode.probability(BranchProbabilityNode.FAST_PATH_PROBABILITY, memory.isNonNull())) {
        result = formatObjectImpl(memory, hub, size, true, fillContents, false);
    } else {
        result = callSlowNewPinnedInstance(SLOW_NEW_PINNED_INSTANCE, pinnedAllocator, hub.asClass());
    }
    return PiNode.piCastToSnippetReplaceeStamp(result);
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) Pointer(org.graalvm.word.Pointer) Snippet(org.graalvm.compiler.api.replacements.Snippet)

Example 84 with Pointer

use of org.graalvm.word.Pointer in project graal by oracle.

the class AllocationSnippets method newMultiArraySnippet.

@Snippet
public static Object newMultiArraySnippet(DynamicHub hub, @ConstantParameter int rank, @VarargsParameter int[] dimensions, AllocationCounter counter) {
    Pointer dims = DimensionsNode.allocaDimsArray(rank);
    ExplodeLoopNode.explodeLoop();
    for (int i = 0; i < rank; i++) {
        dims.writeInt(i * sizeOfDimensionElement, dimensions[i], LocationIdentity.INIT_LOCATION);
    }
    return callNewMultiArray(NEW_MULTI_ARRAY, hub.asClass(), rank, dims, counter);
}
Also used : Pointer(org.graalvm.word.Pointer) Snippet(org.graalvm.compiler.api.replacements.Snippet)

Example 85 with Pointer

use of org.graalvm.word.Pointer in project graal by oracle.

the class AllocationSnippets method doCloneSnippet.

/**
 * The actual implementation of {@link Object#clone}.
 */
@Snippet
private static Object doCloneSnippet(Object thisObj, AllocationCounter counter) throws CloneNotSupportedException {
    if (!(thisObj instanceof Cloneable)) {
        throw CLONE_NOT_SUPPORTED_EXCEPTION;
    }
    DynamicHub hub = KnownIntrinsics.readHub(thisObj);
    int layoutEncoding = hub.getLayoutEncoding();
    UnsignedWord size = LayoutEncoding.getSizeFromObject(thisObj);
    profileAllocation(size, counter);
    /*
         * The size of the clone is the same as the size of the original object. On the fast path we
         * try to allocate aligned memory, i.e., a block inside an aligned chunks, for the clone and
         * don't need to distinguish instance objects from arrays. If we fail, i.e., the returned
         * memory is null, then either the instance object or small array didn't fit in the
         * available space or it is a large array. In either case we go on the slow path.
         */
    Pointer memory = ThreadLocalAllocation.allocateMemory(ThreadLocalAllocation.regularTLAB.getAddress(), size);
    Object thatObject = null;
    if (BranchProbabilityNode.probability(BranchProbabilityNode.FAST_PATH_PROBABILITY, memory.isNonNull())) {
        WordBase header = ObjectHeaderImpl.getObjectHeaderImpl().formatHub(hub, false, false);
        memory.writeWord(ConfigurationValues.getObjectLayout().getHubOffset(), header, LocationIdentity.INIT_LOCATION);
        /*
             * For arrays the length initialization is handled by doCloneUninterruptibly since the
             * array length offset is the same as the first field offset.
             */
        thatObject = memory.toObjectNonNull();
    } else {
        if (LayoutEncoding.isArray(layoutEncoding)) {
            int length = KnownIntrinsics.readArrayLength(thisObj);
            thatObject = callSlowNewArray(SLOW_NEW_ARRAY, hub.asClass(), length);
        } else {
            thatObject = callSlowNewInstance(SLOW_NEW_INSTANCE, hub.asClass());
        }
    }
    if (LayoutEncoding.isArray(layoutEncoding)) {
        int length = KnownIntrinsics.readArrayLength(thisObj);
        thatObject = PiArrayNode.piArrayCastToSnippetReplaceeStamp(thatObject, length);
    } else {
        thatObject = PiNode.piCastToSnippetReplaceeStamp(thatObject);
    }
    UnsignedWord firstFieldOffset = WordFactory.signed(ConfigurationValues.getObjectLayout().getFirstFieldOffset());
    return doCloneUninterruptibly(thisObj, thatObject, firstFieldOffset, size);
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) DynamicHub(com.oracle.svm.core.hub.DynamicHub) WordBase(org.graalvm.word.WordBase) Pointer(org.graalvm.word.Pointer) Snippet(org.graalvm.compiler.api.replacements.Snippet)

Aggregations

Pointer (org.graalvm.word.Pointer)103 UnsignedWord (org.graalvm.word.UnsignedWord)45 Log (com.oracle.svm.core.log.Log)30 CodePointer (org.graalvm.nativeimage.c.function.CodePointer)17 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)15 Snippet (org.graalvm.compiler.api.replacements.Snippet)14 Word (org.graalvm.compiler.word.Word)12 CCharPointer (org.graalvm.nativeimage.c.type.CCharPointer)9 HotSpotReplacementsUtil.registerAsWord (org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord)7 AlwaysInline (com.oracle.svm.core.annotate.AlwaysInline)5 NeverInline (com.oracle.svm.core.annotate.NeverInline)5 KnownIntrinsics.readCallerStackPointer (com.oracle.svm.core.snippets.KnownIntrinsics.readCallerStackPointer)5 KlassPointer (org.graalvm.compiler.hotspot.word.KlassPointer)4 DynamicHub (com.oracle.svm.core.hub.DynamicHub)3 CCharPointerPointer (org.graalvm.nativeimage.c.type.CCharPointerPointer)3 CIntPointer (org.graalvm.nativeimage.c.type.CIntPointer)3 SignedWord (org.graalvm.word.SignedWord)3 DeoptimizedFrame (com.oracle.svm.core.deopt.DeoptimizedFrame)2 AlignedHeader (com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader)2 Dirent.direntPointer (com.oracle.svm.core.posix.headers.Dirent.direntPointer)2