Search in sources :

Example 71 with Specialization

use of com.oracle.truffle.api.dsl.Specialization in project sulong by graalvm.

the class LLVMToDoubleNode method doTruffleObject.

@Specialization
protected double doTruffleObject(LLVMTruffleObject from) {
    TruffleObject base = from.getObject();
    if (ForeignAccess.sendIsNull(isNull, base)) {
        return from.getOffset();
    } else if (ForeignAccess.sendIsBoxed(isBoxed, base)) {
        try {
            double unboxed = (double) toDouble.executeWithTarget(ForeignAccess.sendUnbox(unbox, base));
            return unboxed + from.getOffset();
        } catch (UnsupportedMessageException e) {
            CompilerDirectives.transferToInterpreter();
            throw new IllegalStateException(e);
        }
    }
    CompilerDirectives.transferToInterpreter();
    throw new IllegalStateException("Not convertable");
}
Also used : UnsupportedMessageException(com.oracle.truffle.api.interop.UnsupportedMessageException) TruffleObject(com.oracle.truffle.api.interop.TruffleObject) LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) Specialization(com.oracle.truffle.api.dsl.Specialization)

Example 72 with Specialization

use of com.oracle.truffle.api.dsl.Specialization in project sulong by graalvm.

the class LLVMToFloatNode method doTruffleObject.

@Specialization
protected float doTruffleObject(LLVMTruffleObject from) {
    TruffleObject base = from.getObject();
    if (ForeignAccess.sendIsNull(isNull, base)) {
        return from.getOffset();
    } else if (ForeignAccess.sendIsBoxed(isBoxed, base)) {
        try {
            float ptr = (float) toFloat.executeWithTarget(ForeignAccess.sendUnbox(unbox, base));
            return ptr + from.getOffset();
        } catch (UnsupportedMessageException e) {
            CompilerDirectives.transferToInterpreter();
            throw new IllegalStateException(e);
        }
    }
    CompilerDirectives.transferToInterpreter();
    throw new IllegalStateException("Not convertable");
}
Also used : UnsupportedMessageException(com.oracle.truffle.api.interop.UnsupportedMessageException) TruffleObject(com.oracle.truffle.api.interop.TruffleObject) LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) Specialization(com.oracle.truffle.api.dsl.Specialization)

Example 73 with Specialization

use of com.oracle.truffle.api.dsl.Specialization in project sulong by graalvm.

the class LLVMToI1Node method doTruffleObject.

@Specialization
protected boolean doTruffleObject(LLVMTruffleObject from) {
    TruffleObject base = from.getObject();
    if (ForeignAccess.sendIsNull(isNull, base)) {
        return (from.getOffset() & 1) != 0;
    } else if (ForeignAccess.sendIsBoxed(isBoxed, base)) {
        try {
            boolean ptr = (boolean) toBool.executeWithTarget(ForeignAccess.sendUnbox(unbox, base));
            return ptr ^ ((from.getOffset() & 1) != 0);
        } catch (UnsupportedMessageException e) {
            CompilerDirectives.transferToInterpreter();
            throw new IllegalStateException(e);
        }
    }
    CompilerDirectives.transferToInterpreter();
    throw new IllegalStateException("Not convertable");
}
Also used : UnsupportedMessageException(com.oracle.truffle.api.interop.UnsupportedMessageException) TruffleObject(com.oracle.truffle.api.interop.TruffleObject) LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) Specialization(com.oracle.truffle.api.dsl.Specialization)

Aggregations

Specialization (com.oracle.truffle.api.dsl.Specialization)73 LLVMTruffleObject (com.oracle.truffle.llvm.runtime.LLVMTruffleObject)35 ExplodeLoop (com.oracle.truffle.api.nodes.ExplodeLoop)27 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)16 UnsupportedMessageException (com.oracle.truffle.api.interop.UnsupportedMessageException)6 UnexpectedResultException (com.oracle.truffle.api.nodes.UnexpectedResultException)6 LLVMAddress (com.oracle.truffle.llvm.runtime.LLVMAddress)6 StackPointer (com.oracle.truffle.llvm.runtime.memory.LLVMStack.StackPointer)6 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)5 FileValue (cz.cuni.mff.d3s.trupple.language.runtime.customvalues.FileValue)3 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)3 Frame (com.oracle.truffle.api.frame.Frame)2 InteropException (com.oracle.truffle.api.interop.InteropException)2 UnknownIdentifierException (com.oracle.truffle.api.interop.UnknownIdentifierException)2 LLVMFunctionDescriptor (com.oracle.truffle.llvm.runtime.LLVMFunctionDescriptor)2 LLVM80BitFloat (com.oracle.truffle.llvm.runtime.floating.LLVM80BitFloat)2 SLRootNode (com.oracle.truffle.sl.nodes.SLRootNode)2 GenericArrayType (java.lang.reflect.GenericArrayType)2 Type (java.lang.reflect.Type)2 Assumption (com.oracle.truffle.api.Assumption)1