use of com.oracle.truffle.llvm.runtime.LLVMAddress in project sulong by graalvm.
the class LLVMTruffleHandleToManaged method doIntrinsic.
@Specialization
protected LLVMTruffleObject doIntrinsic(Object rawHandle, @Cached("getContextReference()") ContextReference<LLVMContext> context, @Cached("createToNativeWithTarget()") LLVMToNativeNode forceAddressNode) {
LLVMAddress handle = forceAddressNode.executeWithTarget(rawHandle);
TruffleObject object = context.get().getManagedObjectForHandle(handle);
return new LLVMTruffleObject(object);
}
use of com.oracle.truffle.llvm.runtime.LLVMAddress 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.llvm.runtime.LLVMAddress in project sulong by graalvm.
the class LLVMMemory method allocateCString.
public LLVMAddress allocateCString(String string) {
LLVMAddress baseAddress = allocateMemory(string.length() + 1);
long currentAddress = baseAddress.getVal();
for (int i = 0; i < string.length(); i++) {
byte c = (byte) string.charAt(i);
putI8(currentAddress, c);
currentAddress++;
}
putI8(currentAddress, (byte) 0);
return baseAddress;
}
use of com.oracle.truffle.llvm.runtime.LLVMAddress 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;
}
use of com.oracle.truffle.llvm.runtime.LLVMAddress in project sulong by graalvm.
the class LLVMSignal method setSignalHandler.
@TruffleBoundary
private static LLVMAddress setSignalHandler(LLVMContext context, Signal signal, LLVMAddress function) {
int signalId = signal.getNumber();
LLVMAddress returnFunction = context.getSigDfl();
try {
LLVMSignalHandler newSignalHandler = new LLVMSignalHandler(context, signal, function);
synchronized (registeredSignals) {
if (registeredSignals.containsKey(signalId)) {
LLVMSignalHandler currentFunction = registeredSignals.get(signalId);
if (currentFunction.isRunning()) {
returnFunction = currentFunction.getFunction();
/*
* the new signal handler already manages this signal, so we can safely
* deactivate the old one.
*/
currentFunction.setStopped();
}
}
registeredSignals.put(signalId, newSignalHandler);
}
} catch (IllegalArgumentException e) {
System.err.println("could not register signal with id " + signalId + " (" + signal + ")");
return context.getSigErr();
}
return returnFunction;
}
Aggregations