Search in sources :

Example 6 with LLVMTruffleObject

use of com.oracle.truffle.llvm.runtime.LLVMTruffleObject in project sulong by graalvm.

the class StructLiteralNode method doLLVMTruffleObject.

@ExplodeLoop
@Specialization
protected LLVMTruffleObject doLLVMTruffleObject(VirtualFrame frame, LLVMTruffleObject address) {
    for (int i = 0; i < offsets.length; i++) {
        LLVMTruffleObject currentAddr = address.increment(offsets[i]);
        Object value = values[i] == null ? null : values[i].executeGeneric(frame);
        elementWriteNodes[i].executeWithTarget(currentAddr, value);
    }
    return address;
}
Also used : LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) Specialization(com.oracle.truffle.api.dsl.Specialization) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

Example 7 with LLVMTruffleObject

use of com.oracle.truffle.llvm.runtime.LLVMTruffleObject in project sulong by graalvm.

the class LLVM80BitFloatArrayLiteralNode method foreignWrite.

@Specialization
@ExplodeLoop
protected LLVMTruffleObject foreignWrite(VirtualFrame frame, LLVMTruffleObject addr, @Cached("create80BitFloatStore()") LLVM80BitFloatStoreNode write) {
    LLVMTruffleObject currentPtr = addr;
    for (int i = 0; i < values.length; i++) {
        try {
            LLVM80BitFloat currentValue = values[i].executeLLVM80BitFloat(frame);
            write.executeWithTarget(addr, currentValue);
            currentPtr = currentPtr.increment(stride);
        } catch (UnexpectedResultException e) {
            CompilerDirectives.transferToInterpreter();
            throw new IllegalStateException(e);
        }
    }
    return addr;
}
Also used : UnexpectedResultException(com.oracle.truffle.api.nodes.UnexpectedResultException) LLVM80BitFloat(com.oracle.truffle.llvm.runtime.floating.LLVM80BitFloat) LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) Specialization(com.oracle.truffle.api.dsl.Specialization) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

Example 8 with LLVMTruffleObject

use of com.oracle.truffle.llvm.runtime.LLVMTruffleObject in project sulong by graalvm.

the class LLVMDoubleArrayLiteralNode method foreignWriteDouble.

@Specialization(guards = "addr.isManaged()")
@ExplodeLoop
protected LLVMTruffleObject foreignWriteDouble(VirtualFrame frame, LLVMTruffleObject addr, @Cached("createForeignWrite()") LLVMForeignWriteNode foreignWrite) {
    LLVMTruffleObject currentPtr = addr;
    for (int i = 0; i < values.length; i++) {
        double currentValue = LLVMTypesGen.asDouble(values[i].executeGeneric(frame));
        foreignWrite.execute(currentPtr, currentValue);
        currentPtr = currentPtr.increment(stride);
    }
    return addr;
}
Also used : LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) Specialization(com.oracle.truffle.api.dsl.Specialization) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

Example 9 with LLVMTruffleObject

use of com.oracle.truffle.llvm.runtime.LLVMTruffleObject in project sulong by graalvm.

the class LLVMFunctionArrayLiteralNode method handleTruffleObject.

@Specialization(guards = "array.isManaged()")
@ExplodeLoop
protected LLVMTruffleObject handleTruffleObject(VirtualFrame frame, LLVMTruffleObject array, @Cached("createForeignWrites()") LLVMForeignWriteNode[] foreignWrites) {
    LLVMTruffleObject currentPtr = array;
    for (int i = 0; i < values.length; i++) {
        try {
            LLVMFunctionDescriptor currentValue = (LLVMFunctionDescriptor) values[i].executeTruffleObject(frame);
            foreignWrites[i].execute(currentPtr, currentValue);
            currentPtr = currentPtr.increment(stride);
        } catch (UnexpectedResultException e) {
            CompilerDirectives.transferToInterpreter();
            throw new IllegalStateException(e);
        }
    }
    return array;
}
Also used : UnexpectedResultException(com.oracle.truffle.api.nodes.UnexpectedResultException) LLVMFunctionDescriptor(com.oracle.truffle.llvm.runtime.LLVMFunctionDescriptor) LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) Specialization(com.oracle.truffle.api.dsl.Specialization) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

Example 10 with LLVMTruffleObject

use of com.oracle.truffle.llvm.runtime.LLVMTruffleObject in project sulong by graalvm.

the class LLVMI16ArrayLiteralNode method foreignWriteI16.

@Specialization(guards = "addr.isManaged()")
@ExplodeLoop
protected LLVMTruffleObject foreignWriteI16(VirtualFrame frame, LLVMTruffleObject addr, @Cached("createForeignWrite()") LLVMForeignWriteNode foreignWrite) {
    LLVMTruffleObject currentPtr = addr;
    for (int i = 0; i < values.length; i++) {
        short currentValue = LLVMTypesGen.asShort(values[i].executeGeneric(frame));
        foreignWrite.execute(currentPtr, currentValue);
        currentPtr = currentPtr.increment(stride);
    }
    return addr;
}
Also used : LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) Specialization(com.oracle.truffle.api.dsl.Specialization) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

Aggregations

LLVMTruffleObject (com.oracle.truffle.llvm.runtime.LLVMTruffleObject)35 Specialization (com.oracle.truffle.api.dsl.Specialization)33 ExplodeLoop (com.oracle.truffle.api.nodes.ExplodeLoop)22 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)10 UnsupportedMessageException (com.oracle.truffle.api.interop.UnsupportedMessageException)5 UnknownIdentifierException (com.oracle.truffle.api.interop.UnknownIdentifierException)2 UnexpectedResultException (com.oracle.truffle.api.nodes.UnexpectedResultException)2 LLVMAddress (com.oracle.truffle.llvm.runtime.LLVMAddress)2 LLVM80BitFloat (com.oracle.truffle.llvm.runtime.floating.LLVM80BitFloat)2 LLVMTypedForeignObject (com.oracle.truffle.llvm.runtime.interop.LLVMTypedForeignObject)2 GuestLanguageRuntimeException (com.oracle.truffle.llvm.runtime.GuestLanguageRuntimeException)1 LLVMContext (com.oracle.truffle.llvm.runtime.LLVMContext)1 LLVMExitException (com.oracle.truffle.llvm.runtime.LLVMExitException)1 LLVMFunctionDescriptor (com.oracle.truffle.llvm.runtime.LLVMFunctionDescriptor)1 LLVMVarArgCompoundValue (com.oracle.truffle.llvm.runtime.LLVMVarArgCompoundValue)1 SulongRuntimeException (com.oracle.truffle.llvm.runtime.SulongRuntimeException)1 LLVMGlobal (com.oracle.truffle.llvm.runtime.global.LLVMGlobal)1 StackPointer (com.oracle.truffle.llvm.runtime.memory.LLVMStack.StackPointer)1 LLVMFloatVector (com.oracle.truffle.llvm.runtime.vector.LLVMFloatVector)1