use of com.oracle.truffle.llvm.runtime.LLVMTruffleObject in project sulong by graalvm.
the class LLVMTruffleReadBytes method doIntrinsic.
@Specialization
protected Object doIntrinsic(LLVMAddress value, @Cached("getLLVMMemory()") LLVMMemory memory, @Cached("getContextReference()") ContextReference<LLVMContext> ctxRef) {
byte c;
long ptr = value.getVal();
int count = 0;
while ((c = memory.getI8(ptr)) != 0) {
count++;
ptr += Byte.BYTES;
}
byte[] bytes = new byte[count];
count = 0;
ptr = value.getVal();
while ((c = memory.getI8(ptr)) != 0) {
bytes[count++] = c;
ptr += Byte.BYTES;
}
TruffleObject ret = (TruffleObject) ctxRef.get().getEnv().asGuestValue(bytes);
return new LLVMTruffleObject(LLVMTypedForeignObject.createUnknown(ret));
}
use of com.oracle.truffle.llvm.runtime.LLVMTruffleObject in project sulong by graalvm.
the class LLVMTruffleWriteManagedToGlobal method doIntrinsic.
@Specialization
protected LLVMTruffleObject doIntrinsic(LLVMGlobal address, LLVMTruffleObject value, @Cached("getContextReference()") ContextReference<LLVMContext> context) {
LLVMTruffleObject typedValue = (LLVMTruffleObject) attachType.execute(value, address.getInteropType());
context.get().getGlobalFrame().setObject(address.getSlot(), typedValue);
return typedValue;
}
use of com.oracle.truffle.llvm.runtime.LLVMTruffleObject in project sulong by graalvm.
the class LLVMAddressArrayLiteralNode method foreignWriteRef.
// TODO: work around a DSL bug (GR-6493): remove cached int a and int b
@SuppressWarnings("unused")
@Specialization(guards = "addr.isManaged()")
@ExplodeLoop
protected LLVMTruffleObject foreignWriteRef(VirtualFrame frame, LLVMTruffleObject addr, @Cached("0") int a, @Cached("0") int b, @Cached("createForeignWrites()") LLVMForeignWriteNode[] foreignWrites) {
LLVMTruffleObject currentPtr = addr;
for (int i = 0; i < values.length; i++) {
Object currentValue = values[i].execute(frame);
foreignWrites[i].execute(currentPtr, currentValue);
currentPtr = currentPtr.increment(stride);
}
return addr;
}
use of com.oracle.truffle.llvm.runtime.LLVMTruffleObject in project sulong by graalvm.
the class LLVMFloatArrayLiteralNode method foreignWriteFloat.
@Specialization(guards = "addr.isManaged()")
@ExplodeLoop
protected LLVMTruffleObject foreignWriteFloat(VirtualFrame frame, LLVMTruffleObject addr, @Cached("createForeignWrite()") LLVMForeignWriteNode foreignWrite) {
LLVMTruffleObject currentPtr = addr;
for (int i = 0; i < values.length; i++) {
float currentValue = LLVMTypesGen.asFloat(values[i].executeGeneric(frame));
foreignWrite.execute(currentPtr, currentValue);
currentPtr = currentPtr.increment(stride);
}
return addr;
}
use of com.oracle.truffle.llvm.runtime.LLVMTruffleObject in project sulong by graalvm.
the class LLVMI1ArrayLiteralNode method foreignWriteI1.
@Specialization(guards = "addr.isManaged()")
@ExplodeLoop
protected LLVMTruffleObject foreignWriteI1(VirtualFrame frame, LLVMTruffleObject addr, @Cached("createForeignWrite()") LLVMForeignWriteNode foreignWrite) {
LLVMTruffleObject currentPtr = addr;
for (int i = 0; i < values.length; i++) {
boolean currentValue = LLVMTypesGen.asBoolean(values[i].executeGeneric(frame));
foreignWrite.execute(currentPtr, currentValue);
currentPtr = currentPtr.increment(stride);
}
return addr;
}
Aggregations