Search in sources :

Example 46 with Word

use of org.graalvm.compiler.word.Word in project graal by oracle.

the class CreateExceptionStub method createException.

protected static Object createException(Register threadRegister, Class<? extends Throwable> exception, KlassPointer objKlass, KlassPointer targetKlass) {
    Word thread = registerAsWord(threadRegister);
    throwClassCastException(THROW_CLASS_CAST_EXCEPTION, thread, classAsCString(exception), objKlass, targetKlass);
    return clearPendingException(thread);
}
Also used : Word(org.graalvm.compiler.word.Word) HotSpotReplacementsUtil.registerAsWord(org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord)

Example 47 with Word

use of org.graalvm.compiler.word.Word in project graal by oracle.

the class ExceptionHandlerStub method exceptionHandler.

@Snippet
private static void exceptionHandler(Object exception, Word exceptionPc, @ConstantParameter Register threadRegister, @ConstantParameter OptionValues options) {
    Word thread = registerAsWord(threadRegister);
    checkNoExceptionInThread(thread, assertionsEnabled(INJECTED_VMCONFIG));
    checkExceptionNotNull(assertionsEnabled(INJECTED_VMCONFIG), exception);
    writeExceptionOop(thread, exception);
    writeExceptionPc(thread, exceptionPc);
    if (logging(options)) {
        printf("handling exception %p (", Word.objectToTrackedPointer(exception).rawValue());
        decipher(Word.objectToTrackedPointer(exception).rawValue());
        printf(") at %p (", exceptionPc.rawValue());
        decipher(exceptionPc.rawValue());
        printf(")\n");
    }
    // patch throwing pc into return address so that deoptimization finds the right debug info
    patchReturnAddress(exceptionPc);
    Word handlerPc = exceptionHandlerForPc(EXCEPTION_HANDLER_FOR_PC, thread);
    if (logging(options)) {
        printf("handler for exception %p at %p is at %p (", Word.objectToTrackedPointer(exception).rawValue(), exceptionPc.rawValue(), handlerPc.rawValue());
        decipher(handlerPc.rawValue());
        printf(")\n");
    }
    // patch the return address so that this stub returns to the exception handler
    jumpToExceptionHandler(handlerPc);
}
Also used : Word(org.graalvm.compiler.word.Word) HotSpotReplacementsUtil.registerAsWord(org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord) Snippet(org.graalvm.compiler.api.replacements.Snippet)

Example 48 with Word

use of org.graalvm.compiler.word.Word in project graal by oracle.

the class CreateExceptionStub method createException.

protected static Object createException(Register threadRegister, Class<? extends Throwable> exception, Word message) {
    Word thread = registerAsWord(threadRegister);
    throwAndPostJvmtiException(THROW_AND_POST_JVMTI_EXCEPTION, thread, classAsCString(exception), message);
    return clearPendingException(thread);
}
Also used : Word(org.graalvm.compiler.word.Word) HotSpotReplacementsUtil.registerAsWord(org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord)

Example 49 with Word

use of org.graalvm.compiler.word.Word in project graal by oracle.

the class PosixCEntryPointSnippets method enterSnippet.

@Snippet
public static int enterSnippet(IsolateThread thread) {
    Isolate isolate;
    if (MultiThreaded.getValue()) {
        if (thread.isNull()) {
            return Errors.NULL_ARGUMENT;
        }
        writeCurrentVMThread(thread);
        isolate = PosixVMThreads.IsolateTL.get(thread);
    } else {
        // single-threaded
        if (SpawnIsolates.getValue()) {
            if (thread.isNull()) {
                return Errors.NULL_ARGUMENT;
            }
        } else if (!thread.equal(CEntryPointSetup.SINGLE_THREAD_SENTINEL)) {
            return Errors.UNATTACHED_THREAD;
        }
        isolate = (Isolate) ((Word) thread).subtract(CEntryPointSetup.SINGLE_ISOLATE_TO_SINGLE_THREAD_ADDEND);
    }
    if (UseHeapBaseRegister.getValue()) {
        setHeapBase(PosixIsolates.getHeapBase(isolate));
    }
    if (MultiThreaded.getValue()) {
        Safepoint.transitionNativeToJava();
    }
    return Errors.NO_ERROR;
}
Also used : Word(org.graalvm.compiler.word.Word) Isolate(org.graalvm.nativeimage.Isolate) Snippet(org.graalvm.compiler.api.replacements.Snippet)

Example 50 with Word

use of org.graalvm.compiler.word.Word in project graal by oracle.

the class SubstrateMemoryAccessProviderImpl method readObjectConstant.

private static JavaConstant readObjectConstant(Constant baseConstant, long displacement, boolean requireCompressed) {
    SignedWord offset = WordFactory.signed(displacement);
    if (baseConstant instanceof SubstrateObjectConstant) {
        // always compressed (if enabled)
        assert !requireCompressed || ReferenceAccess.singleton().haveCompressedReferences();
        Object baseObject = ((SubstrateObjectConstant) baseConstant).getObject();
        assert baseObject != null : "SubstrateObjectConstant does not wrap null value";
        Object rawValue = BarrieredAccess.readObject(baseObject, offset);
        return SubstrateObjectConstant.forObject(rawValue, requireCompressed);
    }
    if (baseConstant instanceof PrimitiveConstant) {
        // never compressed
        assert !requireCompressed;
        PrimitiveConstant prim = (PrimitiveConstant) baseConstant;
        if (!prim.getJavaKind().isNumericInteger()) {
            return null;
        }
        Word baseAddress = WordFactory.unsigned(prim.asLong());
        if (baseAddress.equal(0)) {
            return null;
        }
        Word address = baseAddress.add(offset);
        Object rawValue = ReferenceAccess.singleton().readObjectAt(address, false);
        return SubstrateObjectConstant.forObject(rawValue, false);
    }
    return null;
}
Also used : Word(org.graalvm.compiler.word.Word) SignedWord(org.graalvm.word.SignedWord) PrimitiveConstant(jdk.vm.ci.meta.PrimitiveConstant) SubstrateObjectConstant(com.oracle.svm.core.meta.SubstrateObjectConstant) SignedWord(org.graalvm.word.SignedWord)

Aggregations

Word (org.graalvm.compiler.word.Word)53 HotSpotReplacementsUtil.registerAsWord (org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord)32 Snippet (org.graalvm.compiler.api.replacements.Snippet)22 Pointer (org.graalvm.word.Pointer)12 UnsignedWord (org.graalvm.word.UnsignedWord)7 MethodSubstitution (org.graalvm.compiler.api.replacements.MethodSubstitution)5 KlassPointer (org.graalvm.compiler.hotspot.word.KlassPointer)5 HotSpotReplacementsUtil.tlabIntArrayMarkWord (org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.tlabIntArrayMarkWord)4 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)2 HotSpotReplacementsUtil.loadKlassFromObject (org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.loadKlassFromObject)2 SignedWord (org.graalvm.word.SignedWord)2 Substitute (com.oracle.svm.core.annotate.Substitute)1 SubstrateObjectConstant (com.oracle.svm.core.meta.SubstrateObjectConstant)1 Pwd.passwd (com.oracle.svm.core.posix.headers.Pwd.passwd)1 Pwd.passwdPointer (com.oracle.svm.core.posix.headers.Pwd.passwdPointer)1 PrimitiveConstant (jdk.vm.ci.meta.PrimitiveConstant)1 HotSpotReplacementsUtil.arrayPrototypeMarkWord (org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.arrayPrototypeMarkWord)1 GuardingNode (org.graalvm.compiler.nodes.extended.GuardingNode)1 Isolate (org.graalvm.nativeimage.Isolate)1 PinnedObject (org.graalvm.nativeimage.PinnedObject)1