Search in sources :

Example 1 with UnexpectedResultException

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

the class LLVMComplexMul method executeGeneric.

@Override
public Object executeGeneric(VirtualFrame frame) {
    try {
        double a = aNode.executeDouble(frame);
        double b = bNode.executeDouble(frame);
        double c = cNode.executeDouble(frame);
        double d = dNode.executeDouble(frame);
        double ac = a * c;
        double bd = b * d;
        double ad = a * d;
        double bc = b * c;
        double zReal = ac - bd;
        double zImag = ad + bc;
        LLVMAddress allocatedMemory = alloc.executeLLVMAddress(frame);
        getMemory().putDouble(allocatedMemory, zReal);
        getMemory().putDouble(allocatedMemory.getVal() + LLVMExpressionNode.DOUBLE_SIZE_IN_BYTES, zImag);
        return allocatedMemory;
    } catch (UnexpectedResultException e) {
        CompilerDirectives.transferToInterpreter();
        throw new IllegalStateException(e);
    }
}
Also used : UnexpectedResultException(com.oracle.truffle.api.nodes.UnexpectedResultException) LLVMAddress(com.oracle.truffle.llvm.runtime.LLVMAddress)

Example 2 with UnexpectedResultException

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

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

Example 4 with UnexpectedResultException

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

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

Aggregations

UnexpectedResultException (com.oracle.truffle.api.nodes.UnexpectedResultException)10 Specialization (com.oracle.truffle.api.dsl.Specialization)6 ExplodeLoop (com.oracle.truffle.api.nodes.ExplodeLoop)5 LLVMAddress (com.oracle.truffle.llvm.runtime.LLVMAddress)3 LLVMFunctionDescriptor (com.oracle.truffle.llvm.runtime.LLVMFunctionDescriptor)2 LLVMTruffleObject (com.oracle.truffle.llvm.runtime.LLVMTruffleObject)2 LLVM80BitFloat (com.oracle.truffle.llvm.runtime.floating.LLVM80BitFloat)2 ArrayList (java.util.ArrayList)2 TypeMirror (javax.lang.model.type.TypeMirror)2 FrameSlotTypeException (com.oracle.truffle.api.frame.FrameSlotTypeException)1 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)1 SourceSection (com.oracle.truffle.api.source.SourceSection)1 CodeExecutableElement (com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement)1 CodeTreeBuilder (com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder)1 CodeTypeElement (com.oracle.truffle.dsl.processor.java.model.CodeTypeElement)1 CodeTypeMirror (com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror)1 CodeVariableElement (com.oracle.truffle.dsl.processor.java.model.CodeVariableElement)1 SpecializationData (com.oracle.truffle.dsl.processor.model.SpecializationData)1 SpecializationThrowsData (com.oracle.truffle.dsl.processor.model.SpecializationThrowsData)1 EnumValue (cz.cuni.mff.d3s.trupple.language.runtime.customvalues.EnumValue)1