use of com.oracle.truffle.espresso.nodes.interop.ToEspressoNode in project graal by oracle.
the class Target_java_lang_System method handleForeignArray.
@TruffleBoundary
private static void handleForeignArray(Object src, int srcPos, Object dest, int destPos, int length, Klass destType, Meta meta, SubstitutionProfiler profiler) {
InteropLibrary library = InteropLibrary.getUncached();
ToEspressoNode toEspressoNode = ToEspressoNodeGen.getUncached();
if (library.isNull(src) || library.isNull(dest)) {
throw throwNullPointerEx(meta, profiler);
}
if (!library.hasArrayElements(src) || !library.hasArrayElements(dest)) {
throw throwArrayStoreEx(meta, profiler);
}
try {
int srclen = (int) library.getArraySize(src);
int destlen = (int) library.getArraySize(dest);
boundsCheck(meta, srclen, srcPos, destlen, destPos, length, profiler);
for (int i = 0; i < length; i++) {
Object cpy = toEspressoNode.execute(library.readArrayElement(src, i + srcPos), destType);
library.writeArrayElement(dest, destPos + i, cpy);
}
} catch (UnsupportedMessageException | UnsupportedTypeException e) {
CompilerDirectives.transferToInterpreter();
throw EspressoError.shouldNotReachHere();
} catch (InvalidArrayIndexException e) {
throw throwArrayStoreEx(meta, profiler);
}
}
Aggregations