Search in sources :

Example 11 with ExplodeLoop

use of com.oracle.truffle.api.nodes.ExplodeLoop 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 12 with ExplodeLoop

use of com.oracle.truffle.api.nodes.ExplodeLoop 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 13 with ExplodeLoop

use of com.oracle.truffle.api.nodes.ExplodeLoop in project sulong by graalvm.

the class LLVMFunctionArrayLiteralNode method handleAddress.

@Specialization
@ExplodeLoop
protected LLVMAddress handleAddress(VirtualFrame frame, LLVMAddress array, @Cached("createToNativeWithTarget()") LLVMToNativeNode toNative, @Cached("getLLVMMemory()") LLVMMemory memory) {
    long currentPtr = array.getVal();
    for (int i = 0; i < values.length; i++) {
        try {
            LLVMFunctionDescriptor currentValue = (LLVMFunctionDescriptor) values[i].executeTruffleObject(frame);
            memory.putFunctionPointer(currentPtr, toNative.executeWithTarget(currentValue).getVal());
            currentPtr += 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) Specialization(com.oracle.truffle.api.dsl.Specialization) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

Example 14 with ExplodeLoop

use of com.oracle.truffle.api.nodes.ExplodeLoop 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)

Example 15 with ExplodeLoop

use of com.oracle.truffle.api.nodes.ExplodeLoop in project sulong by graalvm.

the class LLVMI64ArrayLiteralNode method foreignWriteI64.

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

ExplodeLoop (com.oracle.truffle.api.nodes.ExplodeLoop)34 Specialization (com.oracle.truffle.api.dsl.Specialization)27 LLVMTruffleObject (com.oracle.truffle.llvm.runtime.LLVMTruffleObject)25 UnexpectedResultException (com.oracle.truffle.api.nodes.UnexpectedResultException)5 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)3 LLVMAddress (com.oracle.truffle.llvm.runtime.LLVMAddress)3 StackPointer (com.oracle.truffle.llvm.runtime.memory.LLVMStack.StackPointer)3 ArityException (com.oracle.truffle.api.interop.ArityException)2 UnsupportedMessageException (com.oracle.truffle.api.interop.UnsupportedMessageException)2 UnsupportedTypeException (com.oracle.truffle.api.interop.UnsupportedTypeException)2 LLVMContext (com.oracle.truffle.llvm.runtime.LLVMContext)2 LLVMFunctionDescriptor (com.oracle.truffle.llvm.runtime.LLVMFunctionDescriptor)2 LLVM80BitFloat (com.oracle.truffle.llvm.runtime.floating.LLVM80BitFloat)2 LLVMStack (com.oracle.truffle.llvm.runtime.memory.LLVMStack)2 GenericArrayType (java.lang.reflect.GenericArrayType)2 Type (java.lang.reflect.Type)2 Assumption (com.oracle.truffle.api.Assumption)1 UnknownIdentifierException (com.oracle.truffle.api.interop.UnknownIdentifierException)1 CodeAnnotationMirror (com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror)1 CodeAnnotationValue (com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue)1