Search in sources :

Example 91 with Pointer

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

the class ObjectHeaderImpl method installForwardingPointer.

/*
     * Forwarding pointer methods.
     */
/**
 * Install in an Object, a forwarding pointer to a different Object.
 */
protected void installForwardingPointer(Object original, Object copy) {
    assert !isPointerToForwardedObject(Word.objectToUntrackedPointer(original));
    /* Turn the copy Object into a Pointer, and encode that as a forwarding pointer. */
    final Pointer unforwardedPointer = Word.objectToUntrackedPointer(copy);
    final UnsignedWord forwarder = createForwardingPointer(unforwardedPointer);
    writeHeaderToObject(original, forwarder);
    assert isPointerToForwardedObject(Word.objectToUntrackedPointer(original));
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) Pointer(org.graalvm.word.Pointer)

Example 92 with Pointer

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

the class PathExhibitor method findPathInStack.

protected StackElement findPathInStack(final Object obj) {
    stackFrameVisitor.initialize(obj);
    Pointer sp = readCallerStackPointer();
    CodePointer ip = readReturnAddress();
    JavaStackWalker.walkCurrentThread(sp, ip, stackFrameVisitor);
    final StackElement result = frameSlotVisitor.getElement();
    return result;
}
Also used : CodePointer(org.graalvm.nativeimage.c.function.CodePointer) KnownIntrinsics.readCallerStackPointer(com.oracle.svm.core.snippets.KnownIntrinsics.readCallerStackPointer) Pointer(org.graalvm.word.Pointer) CodePointer(org.graalvm.nativeimage.c.function.CodePointer)

Example 93 with Pointer

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

the class PathExhibitor method findPathInBootImageHeap.

protected PathElement findPathInBootImageHeap(final Object targetObject, final Object firstObject, final Object lastObject) {
    if ((firstObject == null) || (lastObject == null)) {
        return null;
    }
    final Pointer targetPointer = Word.objectToUntrackedPointer(targetObject);
    final Pointer firstPointer = Word.objectToUntrackedPointer(firstObject);
    final Pointer lastPointer = Word.objectToUntrackedPointer(lastObject);
    Pointer current = firstPointer;
    while (current.belowOrEqual(lastPointer)) {
        final Object bihObject = current.toObject();
        // I am not interested in references from path elements.
        if (!checkForInterference(bihObject)) {
            bootImageHeapObjRefVisitor.initialize(current, targetPointer);
            if (!InteriorObjRefWalker.walkObject(bihObject, bootImageHeapObjRefVisitor)) {
                break;
            }
        }
        current = LayoutEncoding.getObjectEnd(bihObject);
    }
    return bootImageHeapObjRefVisitor.getElement();
}
Also used : CodePointer(org.graalvm.nativeimage.c.function.CodePointer) KnownIntrinsics.readCallerStackPointer(com.oracle.svm.core.snippets.KnownIntrinsics.readCallerStackPointer) Pointer(org.graalvm.word.Pointer)

Example 94 with Pointer

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

the class GreyObjectsWalker method walkAlignedGreyObjects.

private boolean walkAlignedGreyObjects(final ObjectVisitor visitor) {
    final Log trace = Log.noopLog().string("[Space.GreyObjectsWalker.walkAlignedGreyObjects:");
    /* Locals that start from the snapshot. */
    AlignedHeapChunk.AlignedHeader aChunk = WordFactory.nullPointer();
    Pointer aOffset = WordFactory.nullPointer();
    if (getAlignedHeapChunk().isNull() && getAlignedTop().isNull()) {
        /* If the snapshot is empty, then I have to walk from the beginning of the Space. */
        aChunk = space.getFirstAlignedHeapChunk();
        aOffset = (aChunk.isNonNull() ? AlignedHeapChunk.getAlignedHeapChunkStart(aChunk) : WordFactory.nullPointer());
    } else {
        /* Otherwise walk Objects that arrived after the snapshot. */
        aChunk = getAlignedHeapChunk();
        aOffset = getAlignedTop();
    }
    /* Visit Objects in the AlignedChunks. */
    while (aChunk.isNonNull()) {
        trace.newline().string("  aChunk: ").hex(aChunk).string("  aOffset: ").hex(aOffset);
        if (!AlignedHeapChunk.walkObjectsFrom(aChunk, aOffset, visitor)) {
            /* Log the failure. */
            Log.log().string("[Space.GreyObjectsWalker.walkAlignedGreyObjects:  aChunk.walkObject fails.]").newline();
            return false;
        }
        /* Move the scan point. */
        setAlignedHeapChunk(aChunk);
        setAlignedTop(aChunk.getTop());
        trace.string("  moved aligned scan point to: ").string("  alignedChunk: ").hex(getAlignedHeapChunk()).string("  alignedTop: ").hex(getAlignedTop());
        /* Step to the next AlignedChunk. */
        aChunk = aChunk.getNext();
        aOffset = (aChunk.isNonNull() ? AlignedHeapChunk.getAlignedHeapChunkStart(aChunk) : WordFactory.nullPointer());
    }
    trace.string("  returns true").string("]").newline();
    return true;
}
Also used : Log(com.oracle.svm.core.log.Log) Pointer(org.graalvm.word.Pointer)

Example 95 with Pointer

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

the class HeapChunk method availableObjectMemory.

/**
 * How much space is available for objects in a HeapChunk?
 */
@Uninterruptible(reason = "Called from uninterruptible code.")
public static UnsignedWord availableObjectMemory(Header<?> that) {
    final Pointer top = that.getTop();
    final Pointer end = that.getEnd();
    return end.subtract(top);
}
Also used : Pointer(org.graalvm.word.Pointer) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

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