Search in sources :

Example 6 with Pointer

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

the class JavaStackWalker method walkThread.

@AlwaysInline("avoid virtual call to visitor")
public static boolean walkThread(IsolateThread thread, StackFrameVisitor visitor) {
    JavaFrameAnchor anchor = JavaFrameAnchors.getFrameAnchor(thread);
    Pointer sp = WordFactory.nullPointer();
    CodePointer ip = WordFactory.nullPointer();
    if (anchor.isNonNull()) {
        sp = anchor.getLastJavaSP();
        ip = FrameAccess.readReturnAddress(sp);
    }
    // always call doWalk() to invoke visitor's methods
    return doWalk(anchor, sp, ip, visitor);
}
Also used : CodePointer(org.graalvm.nativeimage.c.function.CodePointer) Pointer(org.graalvm.word.Pointer) CodePointer(org.graalvm.nativeimage.c.function.CodePointer) AlwaysInline(com.oracle.svm.core.annotate.AlwaysInline)

Example 7 with Pointer

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

the class SubstrateMemoryAccessProviderImpl method readPrimitiveConstant.

@Override
public JavaConstant readPrimitiveConstant(JavaKind kind, Constant baseConstant, long displacement, int bits) {
    SignedWord offset = WordFactory.signed(displacement);
    long rawValue;
    if (baseConstant instanceof SubstrateObjectConstant) {
        Object baseObject = ((SubstrateObjectConstant) baseConstant).getObject();
        assert baseObject != null : "SubstrateObjectConstant does not wrap null value";
        switch(bits) {
            case Byte.SIZE:
                rawValue = BarrieredAccess.readByte(baseObject, offset);
                break;
            case Short.SIZE:
                rawValue = BarrieredAccess.readShort(baseObject, offset);
                break;
            case Integer.SIZE:
                rawValue = BarrieredAccess.readInt(baseObject, offset);
                break;
            case Long.SIZE:
                rawValue = BarrieredAccess.readLong(baseObject, offset);
                break;
            default:
                throw shouldNotReachHere();
        }
    } else if (baseConstant instanceof PrimitiveConstant) {
        PrimitiveConstant prim = (PrimitiveConstant) baseConstant;
        if (!prim.getJavaKind().isNumericInteger()) {
            return null;
        }
        Pointer basePointer = WordFactory.unsigned(prim.asLong());
        if (basePointer.equal(0)) {
            return null;
        }
        switch(bits) {
            case Byte.SIZE:
                rawValue = basePointer.readByte(offset);
                break;
            case Short.SIZE:
                rawValue = basePointer.readShort(offset);
                break;
            case Integer.SIZE:
                rawValue = basePointer.readInt(offset);
                break;
            case Long.SIZE:
                rawValue = basePointer.readLong(offset);
                break;
            default:
                throw shouldNotReachHere();
        }
    } else {
        return null;
    }
    return toConstant(kind, rawValue);
}
Also used : PrimitiveConstant(jdk.vm.ci.meta.PrimitiveConstant) SubstrateObjectConstant(com.oracle.svm.core.meta.SubstrateObjectConstant) Pointer(org.graalvm.word.Pointer) SignedWord(org.graalvm.word.SignedWord)

Example 8 with Pointer

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

the class ClassHistogramVisitor method initializeClassList.

/*
     * This can be "interruptible" because all the pointers are to boot image heap objects, which do
     * not move. In particular, it can allocate.
     */
private void initializeClassList(Object firstObject, Object lastObject) {
    if ((firstObject == null) || (lastObject == null)) {
        return;
    }
    final Pointer firstPointer = Word.objectToUntrackedPointer(firstObject);
    final Pointer lastPointer = Word.objectToUntrackedPointer(lastObject);
    Pointer currentPointer = firstPointer;
    while (currentPointer.belowOrEqual(lastPointer)) {
        Object currentObject = KnownIntrinsics.convertUnknownValue(currentPointer.toObject(), Object.class);
        if ((currentObject != null) && (currentObject instanceof Class<?>)) {
            classList.add((Class<?>) currentObject);
        }
        currentPointer = LayoutEncoding.getObjectEnd(currentObject);
    }
}
Also used : Pointer(org.graalvm.word.Pointer)

Example 9 with Pointer

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

the class JavaLangSubstitutions method fillInStackTrace.

@Substitute
@NeverInline("Prevent inlining in Truffle compilations")
private Object fillInStackTrace() {
    Pointer sp = KnownIntrinsics.readCallerStackPointer();
    CodePointer ip = KnownIntrinsics.readReturnAddress();
    StackTraceBuilder stackTraceBuilder = new StackTraceBuilder();
    JavaStackWalker.walkCurrentThread(sp, ip, stackTraceBuilder);
    this.stackTrace = stackTraceBuilder.getTrace();
    return this;
}
Also used : CodePointer(org.graalvm.nativeimage.c.function.CodePointer) Pointer(org.graalvm.word.Pointer) CodePointer(org.graalvm.nativeimage.c.function.CodePointer) NeverInline(com.oracle.svm.core.annotate.NeverInline) Substitute(com.oracle.svm.core.annotate.Substitute)

Example 10 with Pointer

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

the class RealLog method hexdump.

@Override
public Log hexdump(PointerBase from, int wordSize, int numWords) {
    Pointer base = WordFactory.pointer(from.rawValue());
    int sanitizedWordsize = wordSize > 0 ? Integer.highestOneBit(Math.min(wordSize, 8)) : 2;
    for (int offset = 0; offset < sanitizedWordsize * numWords; offset += sanitizedWordsize) {
        if (offset % 16 == 0) {
            zhex(base.add(offset).rawValue());
            string(":");
        }
        string(" ");
        switch(sanitizedWordsize) {
            case 1:
                zhex(base.readByte(offset));
                break;
            case 2:
                zhex(base.readShort(offset));
                break;
            case 4:
                zhex(base.readInt(offset));
                break;
            case 8:
                zhex(base.readLong(offset));
                break;
        }
        if ((offset + sanitizedWordsize) % 16 == 0) {
            newline();
        }
    }
    return this;
}
Also used : Pointer(org.graalvm.word.Pointer) CCharPointer(org.graalvm.nativeimage.c.type.CCharPointer)

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