Search in sources :

Example 1 with ToEspressoNode

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);
    }
}
Also used : InvalidArrayIndexException(com.oracle.truffle.api.interop.InvalidArrayIndexException) UnsupportedMessageException(com.oracle.truffle.api.interop.UnsupportedMessageException) InteropLibrary(com.oracle.truffle.api.interop.InteropLibrary) ToEspressoNode(com.oracle.truffle.espresso.nodes.interop.ToEspressoNode) UnsupportedTypeException(com.oracle.truffle.api.interop.UnsupportedTypeException) StaticObject(com.oracle.truffle.espresso.runtime.StaticObject) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Aggregations

TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)1 InteropLibrary (com.oracle.truffle.api.interop.InteropLibrary)1 InvalidArrayIndexException (com.oracle.truffle.api.interop.InvalidArrayIndexException)1 UnsupportedMessageException (com.oracle.truffle.api.interop.UnsupportedMessageException)1 UnsupportedTypeException (com.oracle.truffle.api.interop.UnsupportedTypeException)1 ToEspressoNode (com.oracle.truffle.espresso.nodes.interop.ToEspressoNode)1 StaticObject (com.oracle.truffle.espresso.runtime.StaticObject)1