use of com.oracle.truffle.llvm.runtime.LLVMTruffleObject in project sulong by graalvm.
the class LLVMStoreVectorNode method writeVector.
@Specialization(guards = "address.isManaged()")
@ExplodeLoop
protected Object writeVector(LLVMTruffleObject address, LLVMI8Vector value, @Cached("createForeignWrite()") LLVMForeignWriteNode foreignWrite) {
assert value.getLength() == vectorLength;
LLVMTruffleObject currentPtr = address;
for (int i = 0; i < vectorLength; i++) {
foreignWrite.execute(currentPtr, value.getValue(i));
currentPtr = currentPtr.increment(I8_SIZE_IN_BYTES);
}
return null;
}
use of com.oracle.truffle.llvm.runtime.LLVMTruffleObject in project sulong by graalvm.
the class LLVM80BitFloatStoreNode method doForeign.
// TODO (chaeubl): we could store this in a more efficient way (short + long)
@Specialization(guards = "address.isManaged()")
protected Object doForeign(LLVMTruffleObject address, LLVM80BitFloat value, @Cached("createForeignWrite()") LLVMForeignWriteNode foreignWrite) {
byte[] bytes = value.getBytes();
LLVMTruffleObject currentPtr = address;
for (int i = 0; i < bytes.length; i++) {
foreignWrite.execute(currentPtr, bytes[i]);
currentPtr = currentPtr.increment(I8_SIZE_IN_BYTES);
}
return null;
}
use of com.oracle.truffle.llvm.runtime.LLVMTruffleObject in project sulong by graalvm.
the class LLVMToDoubleNode method doTruffleObject.
@Specialization
protected double doTruffleObject(LLVMTruffleObject from) {
TruffleObject base = from.getObject();
if (ForeignAccess.sendIsNull(isNull, base)) {
return from.getOffset();
} else if (ForeignAccess.sendIsBoxed(isBoxed, base)) {
try {
double unboxed = (double) toDouble.executeWithTarget(ForeignAccess.sendUnbox(unbox, base));
return unboxed + from.getOffset();
} catch (UnsupportedMessageException e) {
CompilerDirectives.transferToInterpreter();
throw new IllegalStateException(e);
}
}
CompilerDirectives.transferToInterpreter();
throw new IllegalStateException("Not convertable");
}
use of com.oracle.truffle.llvm.runtime.LLVMTruffleObject in project sulong by graalvm.
the class LLVMToFloatNode method doTruffleObject.
@Specialization
protected float doTruffleObject(LLVMTruffleObject from) {
TruffleObject base = from.getObject();
if (ForeignAccess.sendIsNull(isNull, base)) {
return from.getOffset();
} else if (ForeignAccess.sendIsBoxed(isBoxed, base)) {
try {
float ptr = (float) toFloat.executeWithTarget(ForeignAccess.sendUnbox(unbox, base));
return ptr + from.getOffset();
} catch (UnsupportedMessageException e) {
CompilerDirectives.transferToInterpreter();
throw new IllegalStateException(e);
}
}
CompilerDirectives.transferToInterpreter();
throw new IllegalStateException("Not convertable");
}
use of com.oracle.truffle.llvm.runtime.LLVMTruffleObject in project sulong by graalvm.
the class LLVMToI1Node method doTruffleObject.
@Specialization
protected boolean doTruffleObject(LLVMTruffleObject from) {
TruffleObject base = from.getObject();
if (ForeignAccess.sendIsNull(isNull, base)) {
return (from.getOffset() & 1) != 0;
} else if (ForeignAccess.sendIsBoxed(isBoxed, base)) {
try {
boolean ptr = (boolean) toBool.executeWithTarget(ForeignAccess.sendUnbox(unbox, base));
return ptr ^ ((from.getOffset() & 1) != 0);
} catch (UnsupportedMessageException e) {
CompilerDirectives.transferToInterpreter();
throw new IllegalStateException(e);
}
}
CompilerDirectives.transferToInterpreter();
throw new IllegalStateException("Not convertable");
}
Aggregations