Search in sources :

Example 21 with UnsignedWord

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

the class AllocationSnippets method formatArraySnippet.

@Snippet
public static Object formatArraySnippet(Word memory, DynamicHub hub, int length, boolean rememberedSet, boolean unaligned) {
    DynamicHub hubNonNull = (DynamicHub) PiNode.piCastNonNull(hub, SnippetAnchorNode.anchor());
    int layoutEncoding = hubNonNull.getLayoutEncoding();
    UnsignedWord size = LayoutEncoding.getArraySize(layoutEncoding, length);
    emitPrefetchAllocate(memory, true);
    return formatArrayImpl(memory, hubNonNull, length, layoutEncoding, size, true, rememberedSet, unaligned);
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) DynamicHub(com.oracle.svm.core.hub.DynamicHub) Snippet(org.graalvm.compiler.api.replacements.Snippet)

Example 22 with UnsignedWord

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

the class AllocationSnippets method fastNewArray.

public static Object fastNewArray(DynamicHub hub, int length, int layoutEncoding, boolean fillContents, AllocationCounter counter) {
    checkHub(hub);
    /*
         * Note: layoutEncoding is passed in as a @ConstantParameter so that much of the array size
         * computation can be folded away early when preparing the snippet.
         */
    UnsignedWord size = LayoutEncoding.getArraySize(layoutEncoding, length);
    profileAllocation(size, counter);
    Object result = fastNewArrayUninterruptibly(hub, length, layoutEncoding, fillContents, size);
    if (result == null) {
        result = callSlowNewArray(SLOW_NEW_ARRAY, hub.asClass(), length);
    }
    return result;
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord)

Example 23 with UnsignedWord

use of org.graalvm.word.UnsignedWord 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)

Example 24 with UnsignedWord

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

the class AllocationSnippets method newInstance.

public static Object newInstance(DynamicHub hub, int encoding, @ConstantParameter boolean constantSize, @ConstantParameter boolean fillContents, AllocationCounter counter) {
    checkHub(hub);
    UnsignedWord size = LayoutEncoding.getInstanceSize(encoding);
    profileAllocation(size, counter);
    Pointer memory = ThreadLocalAllocation.allocateMemory(ThreadLocalAllocation.regularTLAB.getAddress(), size);
    Object result;
    if (BranchProbabilityNode.probability(BranchProbabilityNode.FAST_PATH_PROBABILITY, memory.isNonNull())) {
        result = formatObjectImpl(memory, hub, size, constantSize, fillContents, false);
    } else {
        result = callSlowNewInstance(SLOW_NEW_INSTANCE, hub.asClass());
    }
    return PiNode.piCastToSnippetReplaceeStamp(result);
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) Pointer(org.graalvm.word.Pointer)

Example 25 with UnsignedWord

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

the class BarrierSnippetCountersFeature method postWriteBarrierSnippet.

/**
 * Given an object, dirty the card for the object.
 *
 * @param object The object to which the write has been done.
 */
@Snippet
public static void postWriteBarrierSnippet(Object object) {
    counters().postWriteBarrier.inc();
    // Get the Object to which the write happened.
    final Object fixedObject = FixedValueAnchorNode.getObject(object);
    // Get the ObjectHeader from the Object.
    final UnsignedWord objectHeader = ObjectHeader.readHeaderFromObject(fixedObject);
    // Does the ObjectHeader indicate that I need a barrier?
    final boolean needsBarrier = ObjectHeaderImpl.hasRememberedSet(objectHeader);
    if (BranchProbabilityNode.probability(BranchProbabilityNode.FREQUENT_PROBABILITY, !needsBarrier)) {
        // Most likely (?): expect that no barrier is needed.
        return;
    }
    // The object needs a write-barrier. Is it aligned or unaligned?
    final boolean unaligned = ObjectHeaderImpl.isHeapObjectUnaligned(objectHeader);
    if (BranchProbabilityNode.probability(BranchProbabilityNode.LIKELY_PROBABILITY, !unaligned)) {
        // Next most likely (?): aligned objects.
        counters().postWriteBarrierAligned.inc();
        AlignedHeapChunk.dirtyCardForObjectOfAlignedHeapChunk(fixedObject);
        return;
    }
    // Least likely (?): object needs a write-barrier and is unaligned.
    counters().postWriteBarrierUnaligned.inc();
    UnalignedHeapChunk.dirtyCardForObjectOfUnalignedHeapChunk(fixedObject);
    return;
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) Snippet(org.graalvm.compiler.api.replacements.Snippet)

Aggregations

UnsignedWord (org.graalvm.word.UnsignedWord)137 Pointer (org.graalvm.word.Pointer)43 Log (com.oracle.svm.core.log.Log)30 DynamicHub (com.oracle.svm.core.hub.DynamicHub)11 Fold (org.graalvm.compiler.api.replacements.Fold)11 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)9 Snippet (org.graalvm.compiler.api.replacements.Snippet)9 CCharPointer (org.graalvm.nativeimage.c.type.CCharPointer)6 AlignedHeader (com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader)4 WordBase (org.graalvm.word.WordBase)4 AlwaysInline (com.oracle.svm.core.annotate.AlwaysInline)3 ValueInfo (com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo)3 UnalignedHeader (com.oracle.svm.core.genscavenge.UnalignedHeapChunk.UnalignedHeader)3 XOptions (com.oracle.svm.core.option.XOptions)3 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)3 ObjectLayout (com.oracle.svm.core.config.ObjectLayout)2 DeoptEntryInfopoint (com.oracle.svm.core.deopt.DeoptEntryInfopoint)2 SubstrateForeignCallTarget (com.oracle.svm.core.snippets.SubstrateForeignCallTarget)2 Infopoint (jdk.vm.ci.code.site.Infopoint)2 JavaKind (jdk.vm.ci.meta.JavaKind)2