use of com.oracle.truffle.llvm.runtime.LLVMAddress in project sulong by graalvm.
the class LLVMLandingpadNode method executeGeneric.
@Override
public Object executeGeneric(VirtualFrame frame) {
try {
LLVMException exception = (LLVMException) frame.getObject(exceptionSlot);
Object unwindHeader = exception.getUnwindHeader();
LLVMStack.StackPointer stack = (LLVMStack.StackPointer) getStack.executeGeneric(frame);
int clauseId = getEntryIdentifier(frame, stack, unwindHeader);
if (clauseId == 0 && !cleanup) {
throw exception;
} else {
LLVMAddress executeLLVMAddress = allocateLandingPadValue.execute(frame);
LLVMAddress pair0 = executeLLVMAddress;
getMemory().putAddress(pair0, unwindHeaderToNative.executeWithTarget(unwindHeader));
getMemory().putI32(executeLLVMAddress.getVal() + LLVMExpressionNode.ADDRESS_SIZE_IN_BYTES, clauseId);
return executeLLVMAddress;
}
} catch (FrameSlotTypeException e) {
CompilerDirectives.transferToInterpreter();
throw new IllegalStateException(e);
}
}
use of com.oracle.truffle.llvm.runtime.LLVMAddress in project sulong by graalvm.
the class LLVMComplexDiv 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 denom = c * c + d * d;
double zReal = (a * c + b * d) / denom;
double zImag = (b * c - a * d) / denom;
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.llvm.runtime.LLVMAddress in project sulong by graalvm.
the class NativeAllocateStringNode method alloc.
@Specialization
protected Object alloc(String s, @Cached("getLLVMMemory()") LLVMMemory memory) {
LLVMAddress allocatedMemory = memory.allocateMemory(s.length() + 1);
long currentPtr = allocatedMemory.getVal();
for (byte b : s.getBytes()) {
memory.putI8(currentPtr, b);
currentPtr += 1;
}
memory.putI8(currentPtr, (byte) 0);
return allocatedMemory;
}
use of com.oracle.truffle.llvm.runtime.LLVMAddress in project sulong by graalvm.
the class LLVMAddressArrayLiteralNode method writeAddress.
@Specialization
@ExplodeLoop
protected LLVMAddress writeAddress(VirtualFrame frame, LLVMAddress addr, @Cached("getLLVMMemory()") LLVMMemory memory) {
long currentPtr = addr.getVal();
for (int i = 0; i < values.length; i++) {
LLVMAddress currentValue = values[i].execute(frame);
memory.putAddress(currentPtr, currentValue);
currentPtr += stride;
}
return addr;
}
use of com.oracle.truffle.llvm.runtime.LLVMAddress 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;
}
Aggregations