Search in sources :

Example 6 with ExplodeLoop

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

the class LLVMTruffleExecute method doExecute.

@ExplodeLoop
private Object doExecute(VirtualFrame frame, TruffleObject value, LLVMContext context, LLVMGetStackNode getStack) {
    Object[] evaluatedArgs = new Object[args.length];
    for (int i = 0; i < args.length; i++) {
        evaluatedArgs[i] = prepareValuesForEscape[i].executeWithTarget(args[i].executeGeneric(frame));
    }
    try {
        LLVMStack stack = getStack.executeWithTarget(getThreadingStack(context), Thread.currentThread());
        Object rawValue;
        try (StackPointer save = stack.newFrame()) {
            rawValue = ForeignAccess.sendExecute(foreignExecute, value, evaluatedArgs);
        }
        return toLLVM.executeWithTarget(rawValue);
    } catch (UnsupportedMessageException | UnsupportedTypeException | ArityException e) {
        CompilerDirectives.transferToInterpreter();
        throw new IllegalStateException(e);
    }
}
Also used : UnsupportedMessageException(com.oracle.truffle.api.interop.UnsupportedMessageException) UnsupportedTypeException(com.oracle.truffle.api.interop.UnsupportedTypeException) TruffleObject(com.oracle.truffle.api.interop.TruffleObject) LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) StackPointer(com.oracle.truffle.llvm.runtime.memory.LLVMStack.StackPointer) ArityException(com.oracle.truffle.api.interop.ArityException) LLVMStack(com.oracle.truffle.llvm.runtime.memory.LLVMStack) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

Example 7 with ExplodeLoop

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

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

the class StructLiteralNode method doLLVMAddress.

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

Example 9 with ExplodeLoop

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

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

the class LLVM80BitFloatArrayLiteralNode method write80BitFloat.

@Specialization
@ExplodeLoop
protected LLVMAddress write80BitFloat(VirtualFrame frame, LLVMAddress addr, @Cached("getLLVMMemory()") LLVMMemory memory) {
    long currentPtr = addr.getVal();
    for (int i = 0; i < values.length; i++) {
        try {
            LLVM80BitFloat currentValue = values[i].executeLLVM80BitFloat(frame);
            memory.put80BitFloat(currentPtr, currentValue);
            currentPtr += 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) 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