Search in sources :

Example 61 with Specialization

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

the class LLVMFloatArrayLiteralNode method foreignWriteFloat.

@Specialization(guards = "addr.isManaged()")
@ExplodeLoop
protected LLVMTruffleObject foreignWriteFloat(VirtualFrame frame, LLVMTruffleObject addr, @Cached("createForeignWrite()") LLVMForeignWriteNode foreignWrite) {
    LLVMTruffleObject currentPtr = addr;
    for (int i = 0; i < values.length; i++) {
        float currentValue = LLVMTypesGen.asFloat(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 62 with Specialization

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

the class LLVMI1ArrayLiteralNode method foreignWriteI1.

@Specialization(guards = "addr.isManaged()")
@ExplodeLoop
protected LLVMTruffleObject foreignWriteI1(VirtualFrame frame, LLVMTruffleObject addr, @Cached("createForeignWrite()") LLVMForeignWriteNode foreignWrite) {
    LLVMTruffleObject currentPtr = addr;
    for (int i = 0; i < values.length; i++) {
        boolean currentValue = LLVMTypesGen.asBoolean(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 63 with Specialization

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

the class LLVMI32ArrayLiteralNode method foreignWriteI32.

@Specialization(guards = "addr.isManaged()")
@ExplodeLoop
protected LLVMTruffleObject foreignWriteI32(VirtualFrame frame, LLVMTruffleObject addr, @Cached("createForeignWrite()") LLVMForeignWriteNode foreignWrite) {
    LLVMTruffleObject currentPtr = addr;
    for (int i = 0; i < values.length; i++) {
        int currentValue = LLVMTypesGen.asInteger(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 64 with Specialization

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

the class LLVMI8ArrayLiteralNode method foreignWriteI8.

@Specialization(guards = "addr.isManaged()")
@ExplodeLoop
protected LLVMTruffleObject foreignWriteI8(VirtualFrame frame, LLVMTruffleObject addr, @Cached("createForeignWrite()") LLVMForeignWriteNode foreignWrite) {
    LLVMTruffleObject currentPtr = addr;
    for (int i = 0; i < values.length; i++) {
        byte currentValue = LLVMTypesGen.asByte(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 65 with Specialization

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

the class LLVMStructArrayLiteralNode method writeDouble.

@Specialization
@ExplodeLoop
protected LLVMAddress writeDouble(VirtualFrame frame, LLVMAddress addr) {
    long currentPtr = addr.getVal();
    for (int i = 0; i < values.length; i++) {
        try {
            LLVMAddress currentValue = values[i].executeLLVMAddress(frame);
            memMove.executeWithTarget(LLVMAddress.fromLong(currentPtr), currentValue, stride);
            currentPtr += stride;
        } catch (UnexpectedResultException e) {
            CompilerDirectives.transferToInterpreter();
            throw new IllegalStateException(e);
        }
    }
    return addr;
}
Also used : UnexpectedResultException(com.oracle.truffle.api.nodes.UnexpectedResultException) LLVMAddress(com.oracle.truffle.llvm.runtime.LLVMAddress) Specialization(com.oracle.truffle.api.dsl.Specialization) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

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