use of com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropType.Struct in project graal by oracle.
the class NativeMemSetNode method getAccessLength.
static long getAccessLength(LLVMManagedPointer pointer, long length, NativeTypeLibrary nativeTypes) {
Object object = pointer.getObject();
Object type = nativeTypes.getNativeType(object);
if (type instanceof LLVMInteropType.Array) {
long elementSize = ((LLVMInteropType.Array) type).elementSize;
if (length % elementSize == 0) {
return elementSize;
}
}
if (type instanceof LLVMInteropType.Struct) {
StructMember member = findMember((Struct) type, pointer.getOffset());
/*
* That's a bit of a guess: We assume that this tries to set 'n' members of the same
* size. So, we just take the size of the first member as the access length. If that
* isn't true, we will fail afterwards when doing actual access.
*/
if (member != null && member.type instanceof LLVMInteropType.Value && length % member.type.getSize() == 0) {
return member.type.getSize();
}
}
/*
* Fallback to byte-wise copy if either the type is unknown, not an array, or the length is
* not a multiple of the array element size.
*/
return 1;
}
use of com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropType.Struct in project graal by oracle.
the class LLVMResolveForeignClassChainNode method doClazzResolving.
@Specialization(replaces = "doClassResolvingCached")
public LLVMPointer doClazzResolving(LLVMPointer receiver, String ident, LLVMInteropType.Clazz clazz, @Cached LLVMForeignVirtualSuperElemPtrNode virtualSuperElemPtrNode, @Cached LLVMForeignDirectSuperElemPtrNode directSuperElemPtrNode) throws UnknownIdentifierException {
LLVMPointer curReceiver = receiver;
Pair<long[], Struct> p = clazz.getSuperOffsetInformation(ident);
for (long val : p.getLeft()) {
LLVMForeignGetSuperElemPtrNode access = (val & 1) == 1 ? virtualSuperElemPtrNode : directSuperElemPtrNode;
curReceiver = access.execute(curReceiver, val >> 1);
}
return curReceiver.export(p.getRight() == null ? clazz : p.getRight());
}
Aggregations