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);
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations