diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/RFFIUtils.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/RFFIUtils.java index f70ecdd4b315ca6732d421585aa3fa1f6ec1165f..985b6c233001839fb3fd1714a2fb056d3b9bf692 100644 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/RFFIUtils.java +++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/RFFIUtils.java @@ -22,7 +22,6 @@ */ package com.oracle.truffle.r.ffi.impl.common; -import java.io.FileDescriptor; import java.io.FileOutputStream; import java.io.IOException; import java.nio.file.Path; @@ -89,25 +88,6 @@ public class RFFIUtils { } } - /** - * Upcalled from native when tracing to get FD of the {@link #traceStream}. Allows the same fd - * to be used on both sides of the JNI boundary. - */ - @SuppressWarnings("unused") - private static FileDescriptor getTraceFileDescriptor() { - try { - if (traceStream == null) { - // Happens if native has tracing enabled and Java does not - initTraceStream(); - } - return traceStream.getFD(); - } catch (IOException ex) { - System.err.println(ex.getMessage()); - System.exit(1); - return null; - } - } - private enum CallMode { UP("U"), UP_RETURN("UR"), diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/TracingUpCallsRFFIImpl.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/TracingUpCallsRFFIImpl.java deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/interop/package-info.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/interop/package-info.java index fbc35fd5b8e569580e0d4e09230646c916aab034..19ebc60087b43aa9e717c0a82e3ff6f7027e67be 100644 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/interop/package-info.java +++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/interop/package-info.java @@ -22,8 +22,7 @@ */ /** * A collection of types and {@link com.oracle.truffle.api.interop.MessageResolution} classes that - * support the implementations. Not all are used in every implementation, particularly JNI since - * that does not use Truffle interop. + * support the implementations. * * See {@link com.oracle.truffle.r.ffi.impl.interop.base} and * {@link com.oracle.truffle.r.ffi.impl.interop.pcre} for similar classes specific to the diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNIUpCallsRFFIImpl.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNIUpCallsRFFIImpl.java deleted file mode 100644 index bb34b527e9421d279638258710d9a1b7e6b8f6bd..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNIUpCallsRFFIImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.ffi.impl.jni; - -import static com.oracle.truffle.r.ffi.impl.common.RFFIUtils.guaranteeInstanceOf; - -import com.oracle.truffle.r.ffi.impl.common.JavaUpCallsRFFIImpl; -import com.oracle.truffle.r.runtime.RErrorHandling; -import com.oracle.truffle.r.runtime.RInternalError; -import com.oracle.truffle.r.runtime.data.RVector; -import com.oracle.truffle.r.runtime.ffi.CharSXPWrapper; -import com.oracle.truffle.r.runtime.ffi.DLL.DLLInfo; - -/** - * Some additional methods to support the native JNI side. - */ -public class JNIUpCallsRFFIImpl extends JavaUpCallsRFFIImpl { - // Checkstyle: stop method name check - - /** - * Helper function for {@code R_TopLevelExec}, see {@link #R_ToplevelExec()}, called after C - * function returns. - */ - public static void R_ToplevelExecRestoreErrorHandlerStacks(Object stacks) { - RErrorHandling.HandlerStacks handlerStacks = guaranteeInstanceOf(stacks, RErrorHandling.HandlerStacks.class); - RErrorHandling.restoreHandlerStacks(handlerStacks); - } - - /** - * Called to possibly update the "complete" status on {@code x}. N.B. {@code x} may not be an - * object with a concrete {@code setComplete} method, e.g. see {@link #INTEGER(Object)}. - */ - public static void setComplete(Object x, boolean complete) { - // only care about concrete vectors - if (x instanceof RVector) { - ((RVector<?>) x).setComplete(complete); - } - } - - /** - * Called when a {@link CharSXPWrapper} is expected and not found. - */ - public static void logNotCharSXPWrapper(Object x) { - System.out.println("object " + x); - System.out.println("class " + x.getClass()); - } - - @Override - public Object R_CHAR(Object x) { - throw RInternalError.shouldNotReachHere(); - } - - @Override - public Object getCCallable(String pkgName, String functionName) { - throw RInternalError.shouldNotReachHere(); - } - - @Override - protected Object setSymbol(DLLInfo dllInfo, int nstOrd, Object routines, int index) { - throw RInternalError.shouldNotReachHere(); - } -} diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Base.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Base.java deleted file mode 100644 index e45722e0c97dc72648074bfd67fa23564691c2a0..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Base.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.ffi.impl.jni; - -import java.io.IOException; -import java.util.ArrayList; - -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.r.runtime.ffi.BaseRFFI; - -public class JNI_Base implements BaseRFFI { - private static class JNI_GetpidNode extends Node implements GetpidNode { - @TruffleBoundary - @Override - public int execute() { - return native_getpid(); - } - } - - private static class JNI_GetwdNode extends Node implements GetwdNode { - @TruffleBoundary - @Override - public String execute() { - byte[] buf = new byte[4096]; - int rc = native_getwd(buf, buf.length); - if (rc == 0) { - return null; - } else { - int i = 0; - while (buf[i] != 0 && i < buf.length) { - i++; - } - return new String(buf, 0, i); - } - } - } - - private static class JNI_SetwdNode extends Node implements SetwdNode { - @TruffleBoundary - @Override - public int execute(String dir) { - return native_setwd(dir); - } - } - - private static class JNI_ReadlinkNode extends Node implements ReadlinkNode { - private static final int EINVAL = 22; - - @TruffleBoundary - @Override - public String execute(String path) throws IOException { - int[] errno = new int[]{0}; - String s = native_readlink(path, errno); - if (s == null) { - if (errno[0] == EINVAL) { - // not a link - } else { - // some other error - throw new IOException("readlink failed: " + errno[0]); - } - } - return s; - } - } - - private static class JNI_MkdtempNode extends Node implements MkdtempNode { - @TruffleBoundary - @Override - public String execute(String template) { - /* - * Not only must the (C) string end in XXXXXX it must also be null-terminated. Since it - * is modified by mkdtemp we must make a copy. - */ - byte[] bytes = template.getBytes(); - byte[] ztbytes = new byte[bytes.length + 1]; - System.arraycopy(bytes, 0, ztbytes, 0, bytes.length); - ztbytes[bytes.length] = 0; - long result = native_mkdtemp(ztbytes); - if (result == 0) { - return null; - } else { - return new String(ztbytes, 0, bytes.length); - } - } - } - - private static class JNI_MkdirNode extends Node implements MkdirNode { - @TruffleBoundary - @Override - public void execute(String dir, int mode) throws IOException { - int rc = native_mkdir(dir, mode); - if (rc != 0) { - throw new IOException("mkdir " + dir + " failed"); - } - } - } - - private static class JNI_ChmodNode extends Node implements ChmodNode { - @TruffleBoundary - @Override - public int execute(String path, int mode) { - return native_chmod(path, mode); - } - } - - private static class JNI_StrolNode extends Node implements StrolNode { - @TruffleBoundary - @Override - public long execute(String s, int base) throws IllegalArgumentException { - int[] errno = new int[]{0}; - long result = native_strtol(s, base, errno); - if (errno[0] != 0) { - throw new IllegalArgumentException("strtol failure"); - } else { - return result; - } - } - } - - private static class JNI_UnameNode extends Node implements UnameNode { - @TruffleBoundary - @Override - public UtsName execute() { - return JNI_UtsName.get(); - } - } - - private static class JNI_GlobNode extends Node implements GlobNode { - @TruffleBoundary - @Override - public ArrayList<String> glob(String pattern) { - return JNI_Glob.glob(pattern); - } - } - - // Checkstyle: stop method name - - private static native int native_getpid(); - - private static native int native_getwd(byte[] buf, int buflength); - - private static native int native_setwd(String dir); - - private static native int native_mkdtemp(byte[] template); - - private static native int native_mkdir(String dir, int mode); - - private static native int native_chmod(String dir, int mode); - - private static native long native_strtol(String s, int base, int[] errno); - - private static native String native_readlink(String s, int[] errno); - - @Override - public GetpidNode createGetpidNode() { - return new JNI_GetpidNode(); - } - - @Override - public GetwdNode createGetwdNode() { - return new JNI_GetwdNode(); - } - - @Override - public SetwdNode createSetwdNode() { - return new JNI_SetwdNode(); - } - - @Override - public MkdirNode createMkdirNode() { - return new JNI_MkdirNode(); - } - - @Override - public ReadlinkNode createReadlinkNode() { - return new JNI_ReadlinkNode(); - } - - @Override - public MkdtempNode createMkdtempNode() { - return new JNI_MkdtempNode(); - } - - @Override - public ChmodNode createChmodNode() { - return new JNI_ChmodNode(); - } - - @Override - public StrolNode createStrolNode() { - return new JNI_StrolNode(); - } - - @Override - public UnameNode createUnameNode() { - return new JNI_UnameNode(); - } - - @Override - public GlobNode createGlobNode() { - return new JNI_GlobNode(); - } -} diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_C.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_C.java deleted file mode 100644 index ac1e48042118e8b8ebae876e26126aec199f2ff6..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_C.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.ffi.impl.jni; - -import static com.oracle.truffle.r.ffi.impl.common.RFFIUtils.traceDownCall; -import static com.oracle.truffle.r.ffi.impl.common.RFFIUtils.traceEnabled; - -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.r.runtime.ffi.CRFFI; -import com.oracle.truffle.r.runtime.ffi.NativeCallInfo; - -public class JNI_C implements CRFFI { - private static class JNI_InvokeCNode extends InvokeCNode { - /** - * This is rather similar to {@link JNI_Call}, except the objects are guaranteed to be - * native array types, no upcalls are possible, and no result is returned. However, the - * receiving function expects actual native arrays (not SEXPs), so these have to be handled - * on the JNI side. - */ - @Override - @TruffleBoundary - public void execute(NativeCallInfo nativeCallInfo, Object[] args, boolean hasStrings) { - if (traceEnabled()) { - traceDownCall(nativeCallInfo.name, args); - } - c(nativeCallInfo.address.asAddress(), args, hasStrings); - } - } - - private static native void c(long address, Object[] args, boolean hasStrings); - - @Override - public InvokeCNode createInvokeCNode() { - return new JNI_InvokeCNode(); - } -} diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Call.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Call.java deleted file mode 100644 index 7f9acf474a8ee85c7b4db8a2c67e85cf4fc625f9..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Call.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.ffi.impl.jni; - -import static com.oracle.truffle.r.ffi.impl.common.RFFIUtils.traceDownCall; -import static com.oracle.truffle.r.ffi.impl.common.RFFIUtils.traceDownCallReturn; -import static com.oracle.truffle.r.ffi.impl.common.RFFIUtils.traceEnabled; - -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.r.ffi.impl.common.RFFIUtils; -import com.oracle.truffle.r.ffi.impl.upcalls.UpCallsRFFI; -import com.oracle.truffle.r.runtime.RInternalError; -import com.oracle.truffle.r.runtime.ffi.CallRFFI; -import com.oracle.truffle.r.runtime.ffi.NativeCallInfo; -import com.oracle.truffle.r.runtime.ffi.RFFIVariables; - -/** - * The only variety in the signatures for {@code .Call} is the number of arguments. GnuR supports a - * maximum number of args (64). This implementation passes up to 9 arguments explicitly; beyond 9 - * they are passed as an array and the JNI code has to call back to get the args (not very - * efficient). - * - * The JNI layer is not (currently) MT safe, so all calls are single threaded. N.B. Since the calls - * take place from nodes, and these may be duplicated in separate contexts, we must synchronize on - * the class. - */ -public class JNI_Call implements CallRFFI { - - private static class JNI_InvokeCallNode extends Node implements InvokeCallNode { - - @Override - @TruffleBoundary - public Object execute(NativeCallInfo nativeCallInfo, Object[] args) { - long address = nativeCallInfo.address.asAddress(); - Object result = null; - if (traceEnabled()) { - traceDownCall(nativeCallInfo.name, args); - } - try { - switch (args.length) { - case 0: - result = call0(address); - break; - case 1: - result = call1(address, args[0]); - break; - case 2: - result = call2(address, args[0], args[1]); - break; - case 3: - result = call3(address, args[0], args[1], args[2]); - break; - case 4: - result = call4(address, args[0], args[1], args[2], args[3]); - break; - case 5: - result = call5(address, args[0], args[1], args[2], args[3], args[4]); - break; - case 6: - result = call6(address, args[0], args[1], args[2], args[3], args[4], args[5]); - break; - case 7: - result = call7(address, args[0], args[1], args[2], args[3], args[4], args[5], args[6]); - break; - case 8: - result = call8(address, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); - break; - case 9: - result = call9(address, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]); - break; - default: - result = call(address, args); - break; - } - return result; - } finally { - if (traceEnabled()) { - traceDownCallReturn(nativeCallInfo.name, result); - } - } - } - } - - private static class JNI_InvokeVoidCallNode extends Node implements InvokeVoidCallNode { - - @Override - @TruffleBoundary - public void execute(NativeCallInfo nativeCallInfo, Object[] args) { - synchronized (JNI_Call.class) { - if (traceEnabled()) { - traceDownCall(nativeCallInfo.name, args); - } - long address = nativeCallInfo.address.asAddress(); - try { - switch (args.length) { - case 0: - callVoid0(address); - break; - case 1: - callVoid1(address, args[0]); - break; - default: - throw RInternalError.shouldNotReachHere(); - } - } finally { - if (traceEnabled()) { - traceDownCallReturn(nativeCallInfo.name, null); - } - } - } - } - } - - public JNI_Call() { - initialize(); - } - - @TruffleBoundary - private static void initialize() { - RFFIUtils.initializeTracing(); - - if (traceEnabled()) { - traceDownCall("initialize"); - } - try { - initialize(new JNIUpCallsRFFIImpl(), RFFIVariables.initialize()); - } finally { - if (traceEnabled()) { - traceDownCallReturn("initialize", null); - } - } - } - - private static native void initialize(UpCallsRFFI upCallRFFI, RFFIVariables[] variables); - - private static native void nativeSetTempDir(String tempDir); - - private static native void nativeSetInteractive(boolean interactive); - - private static native Object call(long address, Object[] args); - - private static native Object call0(long address); - - private static native Object call1(long address, Object arg1); - - private static native Object call2(long address, Object arg1, Object arg2); - - private static native Object call3(long address, Object arg1, Object arg2, Object arg3); - - private static native Object call4(long address, Object arg1, Object arg2, Object arg3, Object arg4); - - private static native Object call5(long address, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5); - - private static native Object call6(long address, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6); - - private static native Object call7(long address, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7); - - private static native Object call8(long address, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8); - - private static native Object call9(long address, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9); - - private static native void callVoid0(long address); - - private static native void callVoid1(long address, Object arg1); - - @Override - public InvokeCallNode createInvokeCallNode() { - return new JNI_InvokeCallNode(); - } - - @Override - public InvokeVoidCallNode createInvokeVoidCallNode() { - return new JNI_InvokeVoidCallNode(); - } -} diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_DLL.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_DLL.java deleted file mode 100644 index 08d72f24712217f3f0bfd0088fef79f332ab0b97..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_DLL.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.ffi.impl.jni; - -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.r.runtime.ffi.DLL.SymbolHandle; -import com.oracle.truffle.r.runtime.ffi.DLLRFFI; - -public class JNI_DLL implements DLLRFFI { - - private static class JNI_DLOpenNode extends Node implements DLOpenNode { - @Override - @TruffleBoundary - public Object execute(String path, boolean local, boolean now) throws UnsatisfiedLinkError { - long handle = native_dlopen(path, local, now); - return new Long(handle); - } - } - - private static class JNI_DLSymNode extends Node implements DLSymNode { - @Override - @TruffleBoundary - public SymbolHandle execute(Object handle, String symbol) throws UnsatisfiedLinkError { - long nativeHandle = (Long) handle; - long symv = native_dlsym(nativeHandle, symbol); - return new SymbolHandle(symv); - } - } - - private static class JNI_DLCloseNode extends Node implements DLCloseNode { - @Override - @TruffleBoundary - public int execute(Object handle) { - long nativeHandle = (Long) handle; - return native_dlclose(nativeHandle); - } - } - - // Checkstyle: stop method name check - - private static native long native_dlopen(String path, boolean local, boolean now); - - private static native int native_dlclose(long handle); - - private static native String native_dlerror(); - - private static native long native_dlsym(long handle, String symbol); - - @Override - public DLOpenNode createDLOpenNode() { - return new JNI_DLOpenNode(); - } - - @Override - public DLSymNode createDLSymNode() { - return new JNI_DLSymNode(); - } - - @Override - public DLCloseNode createDLCloseNode() { - return new JNI_DLCloseNode(); - } -} diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Glob.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Glob.java deleted file mode 100644 index a3e344944b5fcb6e7389f1bc279fd1cbce2f56ac..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Glob.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.ffi.impl.jni; - -import java.util.ArrayList; - -public class JNI_Glob { - private final ArrayList<String> paths = new ArrayList<>(); - - public static ArrayList<String> glob(String pattern) { - JNI_Glob jniGlob = new JNI_Glob(); - jniGlob.doglob(pattern); - return jniGlob.paths; - } - - private void addPath(String path) { - paths.add(path); - } - - private native void doglob(String pattern); -} diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Lapack.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Lapack.java deleted file mode 100644 index ac528594c16af414a6d0705f5093bed69452387d..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Lapack.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.ffi.impl.jni; - -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.r.runtime.ffi.LapackRFFI; - -public class JNI_Lapack implements LapackRFFI { - private static class JNI_IlaverNode extends Node implements IlaverNode { - @Override - @TruffleBoundary - public void execute(int[] version) { - native_ilaver(version); - } - } - - private static class JNI_DgeevNode extends Node implements DgeevNode { - @Override - @TruffleBoundary - public int execute(char jobVL, char jobVR, int n, double[] a, int lda, double[] wr, double[] wi, double[] vl, int ldvl, double[] vr, int ldvr, double[] work, int lwork) { - return native_dgeev(jobVL, jobVR, n, a, lda, wr, wi, vl, ldvl, vr, ldvr, work, lwork); - } - } - - private static class JNI_Dgeqp3Node extends Node implements Dgeqp3Node { - @Override - @TruffleBoundary - public int execute(int m, int n, double[] a, int lda, int[] jpvt, double[] tau, double[] work, int lwork) { - return native_dgeqp3(m, n, a, lda, jpvt, tau, work, lwork); - } - } - - private static class JNI_DormqrNode extends Node implements DormqrNode { - @Override - @TruffleBoundary - public int execute(char side, char trans, int m, int n, int k, double[] a, int lda, double[] tau, double[] c, int ldc, double[] work, int lwork) { - return native_dormqr(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork); - } - } - - private static class JNI_DtrtrsNode extends Node implements DtrtrsNode { - @Override - @TruffleBoundary - public int execute(char uplo, char trans, char diag, int n, int nrhs, double[] a, int lda, double[] b, int ldb) { - return native_dtrtrs(uplo, trans, diag, n, nrhs, a, lda, b, ldb); - } - } - - private static class JNI_DgetrfNode extends Node implements DgetrfNode { - @Override - @TruffleBoundary - public int execute(int m, int n, double[] a, int lda, int[] ipiv) { - return native_dgetrf(m, n, a, lda, ipiv); - } - } - - private static class JNI_DpotrfNode extends Node implements DpotrfNode { - @Override - @TruffleBoundary - public int execute(char uplo, int n, double[] a, int lda) { - return native_dpotrf(uplo, n, a, lda); - } - } - - private static class JNI_DpotriNode extends Node implements DpotriNode { - @Override - @TruffleBoundary - public int execute(char uplo, int n, double[] a, int lda) { - return native_dpotri(uplo, n, a, lda); - } - } - - private static class JNI_DpstrfNode extends Node implements DpstrfNode { - @Override - @TruffleBoundary - public int execute(char uplo, int n, double[] a, int lda, int[] piv, int[] rank, double tol, double[] work) { - return native_dpstrf(uplo, n, a, lda, piv, rank, tol, work); - } - } - - private static class JNI_DgesvNode extends Node implements DgesvNode { - @Override - @TruffleBoundary - public int execute(int n, int nrhs, double[] a, int lda, int[] ipiv, double[] b, int ldb) { - return native_dgesv(n, nrhs, a, lda, ipiv, b, ldb); - } - } - - private static class JNI_DlangeNode extends Node implements DlangeNode { - @Override - @TruffleBoundary - public double execute(char norm, int m, int n, double[] a, int lda, double[] work) { - return native_dlange(norm, m, n, a, lda, work); - } - } - - private static class JNI_DgeconNode extends Node implements DgeconNode { - @Override - @TruffleBoundary - public int execute(char norm, int n, double[] a, int lda, double anorm, double[] rcond, double[] work, int[] iwork) { - return native_dgecon(norm, n, a, lda, anorm, rcond, work, iwork); - } - } - - private static class JNI_DsyevrNode extends Node implements DsyevrNode { - @Override - public int execute(char jobz, char range, char uplo, int n, double[] a, int lda, double vl, double vu, int il, int iu, double abstol, int[] m, - double[] w, double[] z, int ldz, int[] isuppz, double[] work, int lwork, int[] iwork, int liwork) { - return native_dsyevr(jobz, range, uplo, n, a, lda, vl, vu, il, iu, abstol, m, w, z, ldz, isuppz, work, lwork, iwork, liwork); - } - } - - @Override - public IlaverNode createIlaverNode() { - return new JNI_IlaverNode(); - } - - @Override - public DgeevNode createDgeevNode() { - return new JNI_DgeevNode(); - } - - @Override - public Dgeqp3Node createDgeqp3Node() { - return new JNI_Dgeqp3Node(); - } - - @Override - public DormqrNode createDormqrNode() { - return new JNI_DormqrNode(); - } - - @Override - public DtrtrsNode createDtrtrsNode() { - return new JNI_DtrtrsNode(); - } - - @Override - public DgetrfNode createDgetrfNode() { - return new JNI_DgetrfNode(); - } - - @Override - public DpotrfNode createDpotrfNode() { - return new JNI_DpotrfNode(); - } - - @Override - public DpotriNode createDpotriNode() { - return new JNI_DpotriNode(); - } - - @Override - public DpstrfNode createDpstrfNode() { - return new JNI_DpstrfNode(); - } - - @Override - public DgesvNode createDgesvNode() { - return new JNI_DgesvNode(); - } - - @Override - public DlangeNode createDlangeNode() { - return new JNI_DlangeNode(); - } - - @Override - public DgeconNode createDgeconNode() { - return new JNI_DgeconNode(); - } - - @Override - public DsyevrNode createDsyevrNode() { - return new JNI_DsyevrNode(); - } - - // Checkstyle: stop method name - - private static native void native_ilaver(int[] version); - - private static native int native_dgeev(char jobVL, char jobVR, int n, double[] a, int lda, double[] wr, double[] wi, double[] vl, int ldvl, double[] vr, int ldvr, double[] work, int lwork); - - private static native int native_dgeqp3(int m, int n, double[] a, int lda, int[] jpvt, double[] tau, double[] work, int lwork); - - private static native int native_dormqr(char side, char trans, int m, int n, int k, double[] a, int lda, double[] tau, double[] c, int ldc, double[] work, int lwork); - - private static native int native_dtrtrs(char uplo, char trans, char diag, int n, int nrhs, double[] a, int lda, double[] b, int ldb); - - private static native int native_dgetrf(int m, int n, double[] a, int lda, int[] ipiv); - - private static native int native_dpotrf(char uplo, int n, double[] a, int lda); - - private static native int native_dpotri(char uplo, int n, double[] a, int lda); - - private static native int native_dpstrf(char uplo, int n, double[] a, int lda, int[] piv, int[] rank, double tol, double[] work); - - private static native int native_dgesv(int n, int nrhs, double[] a, int lda, int[] ipiv, double[] b, int ldb); - - private static native double native_dlange(char norm, int m, int n, double[] a, int lda, double[] work); - - private static native int native_dgecon(char norm, int n, double[] a, int lda, double anorm, double[] rcond, double[] work, int[] iwork); - - private static native int native_dsyevr(char jobz, char range, char uplo, int n, double[] a, int lda, double vl, double vu, int il, int iu, double abstol, int[] m, - double[] w, double[] z, int ldz, int[] isuppz, double[] work, int lwork, int[] iwork, int liwork); - -} diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Misc.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Misc.java deleted file mode 100644 index 57cc3b98b7fe4d96b83224ef34d09ad7587d949b..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Misc.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.ffi.impl.jni; - -import static com.oracle.truffle.r.ffi.impl.common.RFFIUtils.traceDownCall; -import static com.oracle.truffle.r.ffi.impl.common.RFFIUtils.traceDownCallReturn; -import static com.oracle.truffle.r.ffi.impl.common.RFFIUtils.traceEnabled; - -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.r.runtime.ffi.MiscRFFI; - -public class JNI_Misc implements MiscRFFI { - - private static class JNI_ExactSumNode extends Node implements ExactSumNode { - @Override - public double execute(double[] values, boolean hasNa, boolean naRm) { - if (traceEnabled()) { - traceDownCall("exactSum"); - } - try { - return exactSumFunc(values, hasNa, naRm); - } finally { - if (traceEnabled()) { - traceDownCallReturn("exactSum", null); - } - } - } - } - - @Override - public ExactSumNode createExactSumNode() { - return new JNI_ExactSumNode(); - } - - private static native double exactSumFunc(double[] values, boolean hasNa, boolean naRm); - -} diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_PCRE.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_PCRE.java deleted file mode 100644 index 6a5b359dce6ea904afd999f9d81521bbb4eec5f8..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_PCRE.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.ffi.impl.jni; - -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.r.runtime.RError; -import com.oracle.truffle.r.runtime.RInternalError; -import com.oracle.truffle.r.runtime.ffi.PCRERFFI; - -public class JNI_PCRE implements PCRERFFI { - private static class JNI_MaketablesNode extends Node implements MaketablesNode { - @Override - public long execute() { - return nativeMaketables(); - } - } - - private static class JNI_CompileNode extends Node implements CompileNode { - @Override - public Result execute(String pattern, int options, long tables) { - return nativeCompile(pattern, options, tables); - } - } - - private static class JNI_GetCaptureCountNode extends Node implements GetCaptureCountNode { - @Override - public int execute(long code, long extra) { - int res = nativeGetCaptureCount(code, extra); - if (res < 0) { - CompilerDirectives.transferToInterpreter(); - throw RError.error(RError.NO_CALLER, RError.Message.WRONG_PCRE_INFO, res); - } - return res; - } - } - - private static class JNI_GetCaptureNamesNode extends Node implements GetCaptureNamesNode { - @Override - public String[] execute(long code, long extra, int captureCount) { - String[] ret = new String[captureCount]; - int res = nativeGetCaptureNames(code, extra, ret); - if (res < 0) { - CompilerDirectives.transferToInterpreter(); - throw RError.error(RError.NO_CALLER, RError.Message.WRONG_PCRE_INFO, res); - } - return ret; - } - } - - private static class JNI_StudyNode extends Node implements StudyNode { - @Override - public Result execute(long code, int options) { - throw RInternalError.unimplemented("pcre_study"); - } - } - - private static class JNI_ExecNode extends Node implements ExecNode { - @Override - public int execute(long code, long extra, String subject, int offset, int options, int[] ovector) { - return nativeExec(code, extra, subject, offset, options, ovector, ovector.length); - } - } - - private static native long nativeMaketables(); - - private static native Result nativeCompile(String pattern, int options, long tables); - - private static native int nativeGetCaptureCount(long code, long extra); - - private static native int nativeGetCaptureNames(long code, long extra, String[] res); - - private static native int nativeExec(long code, long extra, String subject, int offset, - int options, int[] ovector, int ovectorLen); - - @Override - public MaketablesNode createMaketablesNode() { - return new JNI_MaketablesNode(); - } - - @Override - public CompileNode createCompileNode() { - return new JNI_CompileNode(); - } - - @Override - public GetCaptureCountNode createGetCaptureCountNode() { - return new JNI_GetCaptureCountNode(); - } - - @Override - public GetCaptureNamesNode createGetCaptureNamesNode() { - return new JNI_GetCaptureNamesNode(); - } - - @Override - public StudyNode createStudyNode() { - return new JNI_StudyNode(); - } - - @Override - public ExecNode createExecNode() { - return new JNI_ExecNode(); - } -} diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_PkgInit.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_PkgInit.java deleted file mode 100644 index 008a440d29686efb3fad1adea68b1b04ad3c0f4d..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_PkgInit.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.ffi.impl.jni; - -import com.oracle.truffle.r.runtime.RError; -import com.oracle.truffle.r.runtime.RError.Message; -import com.oracle.truffle.r.runtime.RInternalError; -import com.oracle.truffle.r.runtime.ffi.DLL; -import com.oracle.truffle.r.runtime.ffi.DLL.CEntry; -import com.oracle.truffle.r.runtime.ffi.DLL.DLLInfo; -import com.oracle.truffle.r.runtime.ffi.DLL.DotSymbol; -import com.oracle.truffle.r.runtime.ffi.DLL.SymbolHandle; - -/** - * The JNI-based implementation of the package init code. This is only up-called from JNI. - */ -final class JNI_PkgInit { - - private static void registerRoutines(DLLInfo dllInfo, int nstOrd, int num, long routines) { - DotSymbol[] array = new DotSymbol[num]; - for (int i = 0; i < num; i++) { - array[i] = setSymbol(nstOrd, routines, i); - } - dllInfo.setNativeSymbols(nstOrd, array); - } - - private static void registerCCallable(String pkgName, String functionName, long address) { - DLLInfo lib = DLL.safeFindLibrary(pkgName); - lib.registerCEntry(new CEntry(functionName, new SymbolHandle(address))); - } - - public static long getCCallable(String pkgName, String functionName) { - DLLInfo lib = DLL.safeFindLibrary(pkgName); - CEntry result = lib.lookupCEntry(functionName); - if (result == null) { - throw RError.error(RError.NO_CALLER, Message.UNKNOWN_OBJECT, functionName); - } - return result.address.asAddress(); - } - - /** - * Upcall from native to create a {@link DotSymbol} value. - */ - private static DotSymbol setDotSymbolValues(String name, long fun, int numArgs) { - return new DotSymbol(name, new SymbolHandle(fun), numArgs); - } - - private static native DotSymbol setSymbol(int nstOrd, long routines, int index); - - public static int useDynamicSymbols(DLLInfo dllInfo, int value) { - return DLL.useDynamicSymbols(dllInfo, value); - } - - public static int forceSymbols(DLLInfo dllInfo, int value) { - return DLL.forceSymbols(dllInfo, value); - } - - public static DLLInfo getEmbeddingDllInfo() { - return DLL.getEmbeddingDLLInfo(); - } - - @SuppressWarnings("unused") - public static int findSymbol(String name, String pkg, DLL.RegisteredNativeSymbol rns) { - throw RInternalError.unimplemented(); - } -} diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_RAppl.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_RAppl.java deleted file mode 100644 index a641c2d3411846ea7c71444b7a4e4f174cd0bc96..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_RAppl.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.ffi.impl.jni; - -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.r.runtime.ffi.RApplRFFI; - -public class JNI_RAppl implements RApplRFFI { - private static class JNI_Dqrdc2Node extends Node implements Dqrdc2Node { - @Override - @TruffleBoundary - public void execute(double[] x, int ldx, int n, int p, double tol, int[] rank, double[] qraux, int[] pivot, double[] work) { - native_dqrdc2(x, ldx, n, p, tol, rank, qraux, pivot, work); - } - } - - private static class JNI_DqrcfNode extends Node implements DqrcfNode { - - @Override - @TruffleBoundary - public void execute(double[] x, int n, int k, double[] qraux, double[] y, int ny, double[] b, int[] info) { - native_dqrcf(x, n, k, qraux, y, ny, b, info); - } - } - - private static class JNI_DqrlsNode extends Node implements DqrlsNode { - @Override - @TruffleBoundary - public void execute(double[] x, int n, int p, double[] y, int ny, double tol, double[] b, double[] rsd, double[] qty, int[] k, int[] jpvt, double[] qraux, double[] work) { - native_dqrls(x, n, p, y, ny, tol, b, rsd, qty, k, jpvt, qraux, work); - } - } - - private static class JNI_DqrqtyNode extends Node implements DqrqtyNode { - @Override - @TruffleBoundary - public void execute(double[] x, int n, int k, double[] qraux, double[] y, int ny, double[] qty) { - native_dqrqty(x, n, k, qraux, y, ny, qty); - } - } - - private static class JNI_DqrqyNode extends Node implements DqrqyNode { - @Override - @TruffleBoundary - public void execute(double[] x, int n, int k, double[] qraux, double[] y, int ny, double[] qy) { - native_dqrqy(x, n, k, qraux, y, ny, qy); - } - } - - private static class JNI_DqrrsdNode extends Node implements DqrrsdNode { - @Override - @TruffleBoundary - public void execute(double[] x, int n, int k, double[] qraux, double[] y, int ny, double[] rsd) { - native_dqrrsd(x, n, k, qraux, y, ny, rsd); - } - } - - private static class JNI_DqrxbNode extends Node implements DqrxbNode { - @Override - @TruffleBoundary - public void execute(double[] x, int n, int k, double[] qraux, double[] y, int ny, double[] xb) { - native_dqrxb(x, n, k, qraux, y, ny, xb); - } - } - - @Override - public Dqrdc2Node createDqrdc2Node() { - return new JNI_Dqrdc2Node(); - } - - @Override - public DqrcfNode createDqrcfNode() { - return new JNI_DqrcfNode(); - } - - @Override - public DqrlsNode createDqrlsNode() { - return new JNI_DqrlsNode(); - } - - @Override - public DqrqtyNode createDqrqtyNode() { - return new JNI_DqrqtyNode(); - } - - @Override - public DqrqyNode createDqrqyNode() { - return new JNI_DqrqyNode(); - } - - @Override - public DqrrsdNode createDqrrsdNode() { - return new JNI_DqrrsdNode(); - } - - @Override - public DqrxbNode createDqrxbNode() { - return new JNI_DqrxbNode(); - } - - // Checkstyle: stop method name - - private static native void native_dqrdc2(double[] x, int ldx, int n, int p, double tol, int[] rank, double[] qraux, int[] pivot, double[] work); - - private static native void native_dqrcf(double[] x, int n, int k, double[] qraux, double[] y, int ny, double[] b, int[] info); - - private static native void native_dqrls(double[] x, int n, int p, double[] y, int ny, double tol, double[] b, double[] rsd, double[] qty, int[] k, int[] jpvt, double[] qraux, double[] work); - - private static native void native_dqrqty(double[] x, int n, int k, double[] qraux, double[] y, int ny, double[] qty); - - private static native void native_dqrqy(double[] x, int n, int k, double[] qraux, double[] y, int ny, double[] qy); - - private static native void native_dqrrsd(double[] x, int n, int k, double[] qraux, double[] y, int ny, double[] rsd); - - private static native void native_dqrxb(double[] x, int n, int k, double[] qraux, double[] y, int ny, double[] xb); -} diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_REmbed.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_REmbed.java deleted file mode 100644 index 2837227abd626d9e932150a91c5e990ef4653669..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_REmbed.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.ffi.impl.jni; - -import com.oracle.truffle.r.runtime.ffi.REmbedRFFI; - -public class JNI_REmbed implements REmbedRFFI { - - @Override - public void suicide(String x) { - nativeSuicide(x); - } - - @Override - public void cleanUp(int type, int x, int y) { - nativeCleanUp(type, x, y); - } - - @Override - public String readConsole(String prompt) { - return nativeReadConsole(prompt); - } - - @Override - public void writeConsole(String x) { - nativeWriteConsole(x); - } - - @Override - public void writeErrConsole(String x) { - nativeWriteErrConsole(x); - } - - private static native void nativeSuicide(String x); - - private static native String nativeReadConsole(String prompt); - - private static native void nativeWriteConsole(String x); - - private static native void nativeWriteErrConsole(String x); - - private static native void nativeCleanUp(int type, int x, int y); - -} diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_RFFIFactory.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_RFFIFactory.java deleted file mode 100644 index 65b89a043a15c476fe69f3a099a52da511e3cf7e..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_RFFIFactory.java +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.ffi.impl.jni; - -import com.oracle.truffle.api.CompilerAsserts; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.r.ffi.impl.common.Generic_Tools; -import com.oracle.truffle.r.ffi.impl.common.LibPaths; -import com.oracle.truffle.r.runtime.context.RContext; -import com.oracle.truffle.r.runtime.context.RContext.ContextState; -import com.oracle.truffle.r.runtime.ffi.BaseRFFI; -import com.oracle.truffle.r.runtime.ffi.CRFFI; -import com.oracle.truffle.r.runtime.ffi.CallRFFI; -import com.oracle.truffle.r.runtime.ffi.DLL; -import com.oracle.truffle.r.runtime.ffi.DLLRFFI; -import com.oracle.truffle.r.runtime.ffi.LapackRFFI; -import com.oracle.truffle.r.runtime.ffi.MiscRFFI; -import com.oracle.truffle.r.runtime.ffi.PCRERFFI; -import com.oracle.truffle.r.runtime.ffi.RApplRFFI; -import com.oracle.truffle.r.runtime.ffi.REmbedRFFI; -import com.oracle.truffle.r.runtime.ffi.RFFI; -import com.oracle.truffle.r.runtime.ffi.RFFIFactory; -import com.oracle.truffle.r.runtime.ffi.StatsRFFI; -import com.oracle.truffle.r.runtime.ffi.ToolsRFFI; -import com.oracle.truffle.r.runtime.ffi.UserRngRFFI; -import com.oracle.truffle.r.runtime.ffi.ZipRFFI; - -/** - * JNI-based factory. The majority of the FFI instances are instantiated on demand. - */ -public class JNI_RFFIFactory extends RFFIFactory { - - private static class ContextStateImpl implements RContext.ContextState { - @Override - /** - * For the initial context, load the {@code libR} library. N.B. this library defines some - * non-JNI global symbols that are referenced by C code in R packages. Unfortunately, - * {@link System#load(String)} uses {@code RTLD_LOCAL} with {@code dlopen}, so we have to - * load the library manually and set {@code RTLD_GLOBAL}. However, a {@code dlopen} does not - * hook the JNI functions into the JVM, so we have to do an additional {@code System.load} - * to achieve that. - * - * Before we do that we must load {@code libjniboot} because the implementation of - * {@link DLLRFFI.DLLRFFINode#dlopen} is called by {@link DLL#loadLibR} which uses JNI! - */ - public ContextState initialize(RContext context) { - if (context.isInitial()) { - String libjnibootPath = LibPaths.getBuiltinLibPath("jniboot"); - System.load(libjnibootPath); - - String librffiPath = LibPaths.getBuiltinLibPath("R"); - DLL.loadLibR(librffiPath); - System.load(librffiPath); - } - return this; - } - } - - @Override - public ContextState newContextState() { - return new ContextStateImpl(); - } - - @Override - protected RFFI createRFFI() { - CompilerAsserts.neverPartOfCompilation(); - return new RFFI() { - - @CompilationFinal private BaseRFFI baseRFFI; - - @Override - public BaseRFFI getBaseRFFI() { - CompilerAsserts.neverPartOfCompilation(); - if (baseRFFI == null) { - baseRFFI = new JNI_Base(); - } - return baseRFFI; - } - - @CompilationFinal private LapackRFFI lapackRFFI; - - @Override - public LapackRFFI getLapackRFFI() { - CompilerAsserts.neverPartOfCompilation(); - if (lapackRFFI == null) { - lapackRFFI = new JNI_Lapack(); - } - return lapackRFFI; - } - - @CompilationFinal private RApplRFFI rApplRFFI; - - @Override - public RApplRFFI getRApplRFFI() { - CompilerAsserts.neverPartOfCompilation(); - if (rApplRFFI == null) { - rApplRFFI = new JNI_RAppl(); - } - return rApplRFFI; - } - - @CompilationFinal private StatsRFFI statsRFFI; - - @Override - public StatsRFFI getStatsRFFI() { - CompilerAsserts.neverPartOfCompilation(); - if (statsRFFI == null) { - statsRFFI = new JNI_Stats(); - } - return statsRFFI; - } - - @CompilationFinal private ToolsRFFI toolsRFFI; - - @Override - public ToolsRFFI getToolsRFFI() { - CompilerAsserts.neverPartOfCompilation(); - if (toolsRFFI == null) { - toolsRFFI = new Generic_Tools(); - } - return toolsRFFI; - } - - @CompilationFinal private UserRngRFFI userRngRFFI; - - @Override - public UserRngRFFI getUserRngRFFI() { - CompilerAsserts.neverPartOfCompilation(); - if (userRngRFFI == null) { - userRngRFFI = new JNI_UserRng(); - } - return userRngRFFI; - } - - @CompilationFinal private CRFFI cRFFI; - - @Override - public CRFFI getCRFFI() { - CompilerAsserts.neverPartOfCompilation(); - if (cRFFI == null) { - cRFFI = new JNI_C(); - } - return cRFFI; - } - - @CompilationFinal private CallRFFI callRFFI; - - @Override - public CallRFFI getCallRFFI() { - CompilerAsserts.neverPartOfCompilation(); - if (callRFFI == null) { - callRFFI = new JNI_Call(); - } - return callRFFI; - } - - @CompilationFinal private ZipRFFI zipRFFI; - - @Override - public ZipRFFI getZipRFFI() { - CompilerAsserts.neverPartOfCompilation(); - if (zipRFFI == null) { - zipRFFI = new JNI_Zip(); - } - return zipRFFI; - } - - @CompilationFinal private PCRERFFI pcreRFFI; - - @Override - public PCRERFFI getPCRERFFI() { - CompilerAsserts.neverPartOfCompilation(); - if (pcreRFFI == null) { - pcreRFFI = new JNI_PCRE(); - } - return pcreRFFI; - } - - private DLLRFFI dllRFFI; - - @Override - public DLLRFFI getDLLRFFI() { - CompilerAsserts.neverPartOfCompilation(); - if (dllRFFI == null) { - dllRFFI = new JNI_DLL(); - } - return dllRFFI; - } - - private REmbedRFFI rEmbedRFFI; - - @Override - public REmbedRFFI getREmbedRFFI() { - CompilerAsserts.neverPartOfCompilation(); - if (rEmbedRFFI == null) { - rEmbedRFFI = new JNI_REmbed(); - } - return rEmbedRFFI; - } - - private MiscRFFI miscRFFI; - - @Override - public MiscRFFI getMiscRFFI() { - CompilerAsserts.neverPartOfCompilation(); - if (miscRFFI == null) { - miscRFFI = new JNI_Misc(); - } - return miscRFFI; - } - }; - } -} diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Stats.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Stats.java deleted file mode 100644 index b9c0ee7e1d74ff714197b68791a2b4f1a65dcb21..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Stats.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.ffi.impl.jni; - -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.r.runtime.RInternalError; -import com.oracle.truffle.r.runtime.ffi.DLL; -import com.oracle.truffle.r.runtime.ffi.DLL.DLLInfo; -import com.oracle.truffle.r.runtime.ffi.DLL.SymbolHandle; -import com.oracle.truffle.r.runtime.ffi.DLLRFFI; -import com.oracle.truffle.r.runtime.ffi.RFFIFactory; -import com.oracle.truffle.r.runtime.ffi.StatsRFFI; - -public class JNI_Stats implements StatsRFFI { - - private static class JNI_WorkNode extends Node implements WorkNode { - private static final String FFT_WORK = "fft_work"; - @Child private DLLRFFI.DLSymNode dlSymNode = RFFIFactory.getDLLRFFI().createDLSymNode(); - private SymbolHandle fftWorkAddress; - - @Override - @TruffleBoundary - public int execute(double[] a, int nseg, int n, int nspn, int isn, double[] work, int[] iwork) { - if (fftWorkAddress == null) { - fftWorkAddress = fftAddress(FFT_WORK, dlSymNode); - } - return native_fft_work(fftWorkAddress.asAddress(), a, nseg, n, nspn, isn, work, iwork); - } - } - - private static class JNI_FactorNode extends Node implements FactorNode { - private static final String FFT_FACTOR = "fft_factor"; - @Child private DLLRFFI.DLSymNode dlSymNode = RFFIFactory.getDLLRFFI().createDLSymNode(); - private SymbolHandle fftFactorAddress; - - @Override - @TruffleBoundary - public void execute(int n, int[] pmaxf, int[] pmaxp) { - if (fftFactorAddress == null) { - fftFactorAddress = fftAddress(FFT_FACTOR, dlSymNode); - } - native_fft_factor(fftFactorAddress.asAddress(), n, pmaxf, pmaxp); - - } - } - - private static SymbolHandle fftAddress(String symbol, DLLRFFI.DLSymNode dlSymNode) { - SymbolHandle fftAddress; - DLLInfo dllInfo = DLL.findLibrary("stats"); - assert dllInfo != null; - try { - fftAddress = dlSymNode.execute(dllInfo.handle, symbol); - } catch (UnsatisfiedLinkError ex) { - throw RInternalError.shouldNotReachHere(ex); - } - return fftAddress; - } - - @Override - public FactorNode createFactorNode() { - return new JNI_FactorNode(); - } - - @Override - public WorkNode createWorkNode() { - return new JNI_WorkNode(); - } - - // Checkstyle: stop method name - private static native void native_fft_factor(long address, int n, int[] pmaxf, int[] pmaxp); - - private static native int native_fft_work(long address, double[] a, int nseg, int n, int nspn, int isn, double[] work, int[] iwork); - -} diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_UserRng.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_UserRng.java deleted file mode 100644 index b3ab9dd00af9ffbf479e8b002f09abd18771746d..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_UserRng.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.ffi.impl.jni; - -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.r.runtime.ffi.UserRngRFFI; -import com.oracle.truffle.r.runtime.rng.user.UserRNG.Function; - -public class JNI_UserRng implements UserRngRFFI { - - private static final class JNI_InitNode extends Node implements InitNode { - - @Override - public void execute(int seed) { - nativeInit(Function.Init.getSymbolHandle().asAddress(), seed); - } - } - - private static final class JNI_RandNode extends Node implements RandNode { - - @Override - public double execute() { - return nativeRand(Function.Rand.getSymbolHandle().asAddress()); - } - } - - private static final class JNI_NSeedNode extends Node implements NSeedNode { - - @Override - public int execute() { - return nativeNSeed(Function.NSeed.getSymbolHandle().asAddress()); - } - } - - private static final class JNI_SeedsNode extends Node implements SeedsNode { - - @Override - public void execute(int[] n) { - nativeSeeds(Function.Seedloc.getSymbolHandle().asAddress(), n); - } - } - - @Override - public InitNode createInitNode() { - return new JNI_InitNode(); - } - - @Override - public RandNode createRandNode() { - return new JNI_RandNode(); - } - - @Override - public NSeedNode createNSeedNode() { - return new JNI_NSeedNode(); - } - - @Override - public SeedsNode createSeedsNode() { - return new JNI_SeedsNode(); - } - - private static native void nativeInit(long address, int seed); - - private static native double nativeRand(long address); - - private static native int nativeNSeed(long address); - - private static native void nativeSeeds(long address, int[] n); - -} diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_UtsName.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_UtsName.java deleted file mode 100644 index fbdd602e975cd4fefe324562f19a17f91cb0bd2e..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_UtsName.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.ffi.impl.jni; - -import com.oracle.truffle.r.runtime.ffi.BaseRFFI.UtsName; - -public class JNI_UtsName implements UtsName { - String sysname; - String release; - String version; - String machine; - String nodename; - - private static JNI_UtsName singleton; - - public static UtsName get() { - if (singleton == null) { - singleton = new JNI_UtsName(); - } - singleton.getutsname(); - return singleton; - } - - @Override - public String sysname() { - return sysname; - } - - @Override - public String release() { - return release; - } - - @Override - public String version() { - return version; - } - - @Override - public String machine() { - return machine; - } - - @Override - public String nodename() { - return nodename; - } - - private native void getutsname(); - -} diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Zip.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Zip.java deleted file mode 100644 index 28de1e5ac7129b1064285bdb3dc551b32add060c..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/JNI_Zip.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.ffi.impl.jni; - -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.r.runtime.ffi.ZipRFFI; - -/** - * Zip support using JNI. - */ -public class JNI_Zip implements ZipRFFI { - - private static class JNI_CompressNode extends Node implements ZipRFFI.CompressNode { - @Override - @TruffleBoundary - public int execute(byte[] dest, byte[] source) { - int rc = native_compress(dest, dest.length, source, source.length); - return rc; - } - } - - private static class JNI_UncompressNode extends Node implements ZipRFFI.UncompressNode { - @Override - @TruffleBoundary - public int execute(byte[] dest, byte[] source) { - int rc = native_uncompress(dest, dest.length, source, source.length); - return rc; - } - } - - // Checkstyle: stop method name - - private static native int native_compress(byte[] dest, long destlen, byte[] source, long sourcelen); - - private static native int native_uncompress(byte[] dest, long destlen, byte[] source, long sourcelen); - - @Override - public CompressNode createCompressNode() { - return new JNI_CompressNode(); - } - - @Override - public UncompressNode createUncompressNode() { - return new JNI_UncompressNode(); - } -} diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/package-info.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/package-info.java deleted file mode 100644 index 841d7f3c65e351fe4d854743b535af1a758e2e75..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/jni/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -/** - * The JNI implementation of the {@link com.oracle.truffle.r.runtime.ffi.RFFI} interfaces. - */ -package com.oracle.truffle.r.ffi.impl.jni; diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/llvm/TruffleLLVM_CAccess.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/llvm/TruffleLLVM_CAccess.java index 50e1d83d9010edbed0b4c509eff6974d1c081ab7..89afe98ae10f5911640bf1ae224ed02c8a0689ee 100644 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/llvm/TruffleLLVM_CAccess.java +++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/llvm/TruffleLLVM_CAccess.java @@ -22,7 +22,6 @@ */ package com.oracle.truffle.r.ffi.impl.llvm; -import com.oracle.truffle.r.ffi.impl.jni.JNI_DLL; import com.oracle.truffle.r.runtime.ffi.DLL; import com.oracle.truffle.r.runtime.ffi.DLLRFFI; import com.oracle.truffle.r.runtime.rng.user.UserRNG; @@ -30,10 +29,6 @@ import com.oracle.truffle.r.runtime.rng.user.UserRNG; /** * Access to some primitive C operations. This is required by the {@link UserRNG} API which works * with {@code double *}. - * - * N.B. When {@code libR} is not completely in LLVM mode (as now), we have to look up the symbols - * using an explicitly created {@link TruffleLLVM_DLL.LLVM_Handle} and not go via generic lookup in - * {@link DLL} as that would use a {@link JNI_DLL} handle. */ public class TruffleLLVM_CAccess { private static final TruffleLLVM_DLL.LLVM_Handle handle = new TruffleLLVM_DLL.LLVM_Handle("libR", null); diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/ATTRIB.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/ATTRIB.java deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/FFIUpCallRootNode.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/FFIUpCallRootNode.java deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/com.oracle.truffle.r.native/fficall/Makefile b/com.oracle.truffle.r.native/fficall/Makefile index 26af0d4dc33b222419a910f1a2cf9138b41ac76f..e39458ddd05920190176f7da26c16fc2353bd88d 100644 --- a/com.oracle.truffle.r.native/fficall/Makefile +++ b/com.oracle.truffle.r.native/fficall/Makefile @@ -37,8 +37,6 @@ C_LIBNAME := libR$(DYLIB_EXT) C_LIB := $(FASTR_LIB_DIR)/$(C_LIBNAME) R_LIBNAME := libR$(DYLIB_EXT) R_LIB := $(FASTR_LIB_DIR)/$(R_LIBNAME) -JNIBOOT_LIBNAME := libjniboot$(DYLIB_EXT) -JNIBOOT_LIB := $(FASTR_LIB_DIR)/$(JNIBOOT_LIBNAME) ifeq ($(OS_NAME), Darwin) VERSION_FLAGS := -current_version $(R_VERSION) -compatibility_version $(R_VERSION) @@ -85,26 +83,8 @@ ifeq ($(FASTR_RFFI),llvm) fficall.done: common.done $(MAKE) -C src/truffle_llvm all touch fficall.done -else -ifeq ($(FASTR_RFFI),jni) -fficall.done: common.done $(JNIBOOT_LIB) - $(MAKE) -C src/jni all - touch fficall.done - -jniboot.done: - $(MAKE) -C src/jniboot all - touch jniboot.done - -$(JNIBOOT_LIB): jniboot.done - $(DYLIB_LD) $(DYLIB_LDFLAGS) -o $(JNIBOOT_LIB) src/jniboot/jniboot.o $(VERSION_FLAGS) -ifeq ($(OS_NAME),Darwin) -ifneq ($(FASTR_RFFI),llvm) - install_name_tool -id @rpath/libjniboot.dylib $(JNIBOOT_LIB) -endif -endif else $(error unknown value for FASTR_RFFI) -endif #jni endif #llvm endif #nfi endif #managed @@ -121,10 +101,9 @@ else ifeq ($(FASTR_RFFI),llvm) $(MAKE) -C src/truffle_llvm clean else - $(MAKE) -C src/jni clean + $(error unknown value for FASTR_RFFI) endif endif rm -rf $(R_LIB) - rm -rf $(JNIBOOT_LIB) rm -rf fficall.done diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Applic.c b/com.oracle.truffle.r.native/fficall/src/jni/Applic.c deleted file mode 100644 index 595dd6a9fa719fbccfdc2484bf6ad12154337ca2..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jni/Applic.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -#include <rffiutils.h> -#include <R_ext/Applic.h> - -void init_applic(JNIEnv *env) { - -} - -void Rdqags(integr_fn f, void *ex, double *a, double *b, - double *epsabs, double *epsrel, - double *result, double *abserr, int *neval, int *ier, - int *limit, int *lenw, int *last, int *iwork, double *work) { - unimplemented("Rdqags"); -} - - -void Rdqagi(integr_fn f, void *ex, double *bound, int *inf, - double *epsabs, double *epsrel, - double *result, double *abserr, int *neval, int *ier, - int *limit, int *lenw, int *last, - int *iwork, double *work) { - unimplemented("Rdqagi"); -} - -void vmmin(int n, double *x, double *Fmin, - optimfn fn, optimgr gr, int maxit, int trace, - int *mask, double abstol, double reltol, int nREPORT, - void *ex, int *fncount, int *grcount, int *fail) { - unimplemented("vmmin"); -} - -void -optif9(int nr, int n, double *x, fcn_p fcn, fcn_p d1fcn, d2fcn_p d2fcn, - void *state, double *typsiz, double fscale, int method, - int iexp, int *msg, int ndigit, int itnlim, int iagflg, int iahflg, - double dlt, double gradtl, double stepmx, double steptl, - double *xpls, double *fpls, double *gpls, int *itrmcd, double *a, - double *wrk, int *itncnt) { - unimplemented("optif9"); -} diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Makefile b/com.oracle.truffle.r.native/fficall/src/jni/Makefile deleted file mode 100644 index 1108df184f50021c2a65cecabccb3680cff33a2b..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jni/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -# -# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -ifneq ($(MAKECMDGOALS),clean) -include $(TOPDIR)/platform.mk -endif - -.PHONY: all clean - -# location of compiled code (.o files) -OBJ = ../../lib - -C_HDRS := $(wildcard *.h) - -C_SOURCES = $(wildcard *.c) -C_OBJECTS := $(patsubst %.c,$(OBJ)/%.o,$(C_SOURCES)) -#$(info C_OBJECTS=$(C_OBJECTS)) - -JNI_INCLUDES = -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/$(JDK_OS_DIR) -FFI_INCLUDES = -I$(TOPDIR)/include -I$(TOPDIR)/include/R_ext -LOCAL_INCLUDES = -I . -I $(abspath ../include) -I $(abspath ../common) - -INCLUDES := $(LOCAL_INCLUDES) $(JNI_INCLUDES) $(FFI_INCLUDES) - -# uncomment to see exactly where headers are being read from -#CFLAGS := $(CFLAGS) -H - -all: Makefile $(C_OBJECTS) - -$(C_OBJECTS): | $(OBJ) - -$(OBJ): - mkdir -p $(OBJ) - -$(OBJ)/%.o: %.c $(TOPDIR)/include/Rinternals.h $(C_HDRS) - $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ - -# for debugging, to see what's really being compiled -$(OBJ)/%.E: %.c $(TOPDIR)/include/Rinternals.h - $(CC) -E $(CFLAGS) $(INCLUDES) -c $< > $@ - -clean: - rm -rf $(OBJ) diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Memory.c b/com.oracle.truffle.r.native/fficall/src/jni/Memory.c deleted file mode 100644 index 126b773e45330d8dff0f219499c25731f1a5f254..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jni/Memory.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - * This material is distributed under the GNU General Public License - * Version 2. You may review the terms of this license at - * http://www.gnu.org/licenses/gpl-2.0.html - * - * Copyright (c) 1995-2015, The R Core Team - * Copyright (c) 2003, The R Foundation - * Copyright (c) 2015, 2016, Oracle and/or its affiliates - * - * All rights reserved. - */ -#include <rffiutils.h> -#include <stdlib.h> -#include <string.h> - -#define T_MEM_TABLE_INITIAL_SIZE 0 -// The table of transient objects that have been allocated dur the current FFI call -static void **tMemTable; -// hwm of tMemTable -static int tMemTableIndex; -static int tMemTableLength; - -void init_memory(JNIEnv *env) { - tMemTable = malloc(sizeof(void*) * T_MEM_TABLE_INITIAL_SIZE); - tMemTableLength = T_MEM_TABLE_INITIAL_SIZE; - tMemTableIndex = 0; -} - -void *R_chk_calloc(size_t nelem, size_t elsize); - -// Memory that is auto-reclaimed across FFI calls -char *R_alloc(size_t n, int size) { - void *p = R_chk_calloc(n, size); - if (tMemTableIndex >= tMemTableLength) { - int newLength = 2 * tMemTableLength; - void *newtMemTable = malloc(sizeof(void*) * newLength); - if (newtMemTable == NULL) { - fatalError("malloc failure"); - } - memcpy(newtMemTable, tMemTable, tMemTableLength * sizeof(void*)); - free(tMemTable); - tMemTable = newtMemTable; - tMemTableLength = newLength; - } - tMemTable[tMemTableIndex] = p; - return (char*) p; -} - -char* S_alloc(long n, int size) { - char *p = R_alloc(n, size); - memset(p, 0, n); - return p; -} - -char* S_realloc(char *p, long a, long b, int size) { - return unimplemented("S_realloc"); -} - -void allocExit() { - int i; - for (i = 0; i < tMemTableIndex; i++) { - free(tMemTable[i]); - } -} - -void *R_chk_calloc(size_t nelem, size_t elsize) { - void *p; -#ifndef HAVE_WORKING_CALLOC - if (nelem == 0) - return (NULL); -#endif - p = calloc(nelem, elsize); - if (!p) /* problem here is that we don't have a format for size_t. */ - error(_("'Calloc' could not allocate memory (%.0f of %u bytes)"), - (double) nelem, elsize); - return (p); -} - -void *R_chk_realloc(void *ptr, size_t size) { - void *p; - /* Protect against broken realloc */ - if(ptr) p = realloc(ptr, size); else p = malloc(size); - if(!p) - error(_("'Realloc' could not re-allocate memory (%.0f bytes)"), - (double) size); - return(p); -} - -void R_chk_free(void *ptr) { - if(ptr) { - free(ptr); - } -} - -int VMAX_MAGIC = 1234; - -void* vmaxget(void) { -// unimplemented("vmaxget"); - // ignored - return &VMAX_MAGIC; -} - -void vmaxset(const void * x) { -// unimplemented("vmaxget"); - if (x != &VMAX_MAGIC) { - unimplemented("vmaxset with different value"); - } -} - -void R_gc(void) { - unimplemented("R_gc"); -} - -int R_gc_running() { - unimplemented("R_gc_running"); - return 0; -} - -SEXP Rf_allocS4Object() { - unimplemented("Rf_allocS4Object unimplemented"); - return NULL; -} - diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Random.c b/com.oracle.truffle.r.native/fficall/src/jni/Random.c deleted file mode 100644 index 59276104123776465262e2ad4a4309b4f6732bb0..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jni/Random.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -#include <rffiutils.h> - -static jmethodID GetRNGstate_MethodID; -static jmethodID PutRNGstate_MethodID; -static jmethodID UnifRand_MethodID; - -void init_random(JNIEnv *env) { - GetRNGstate_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "GetRNGstate", "()I", 0); - PutRNGstate_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "PutRNGstate", "()I", 0); - UnifRand_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "unif_rand", "()D", 0); -} - -void GetRNGstate() { - JNIEnv *thisenv = getEnv(); - (*thisenv)->CallVoidMethod(thisenv, UpCallsRFFIObject, GetRNGstate_MethodID); -} - -void PutRNGstate() { - JNIEnv *thisenv = getEnv(); - (*thisenv)->CallVoidMethod(thisenv, UpCallsRFFIObject, PutRNGstate_MethodID); -} - -double unif_rand() { - JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallDoubleMethod(thisenv, UpCallsRFFIObject, UnifRand_MethodID); -} - -double norm_rand() { - unimplemented("norm_rand"); - return 0; -} - -double exp_rand() { - unimplemented("exp_rand"); - return 0; -} diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Rdynload_fastr.c b/com.oracle.truffle.r.native/fficall/src/jni/Rdynload_fastr.c deleted file mode 100644 index df4334d68d32c0db6f1bb09aa9ad22d112762a8b..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jni/Rdynload_fastr.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * This material is distributed under the GNU General Public License - * Version 2. You may review the terms of this license at - * http://www.gnu.org/licenses/gpl-2.0.html - * - * Copyright (c) 1995-2012, The R Core Team - * Copyright (c) 2003, The R Foundation - * Copyright (c) 2014, 2017, Oracle and/or its affiliates - * - * All rights reserved. - */ -#include <rffiutils.h> -#include <Rdynload.h> - -// Registering routines from loaded shared libraries -// Currently an exception to the rule that all upcalls go via CallRFFIHelper - -static jclass DLLClass; -static jclass JNI_PkgInitClass; -static jclass DotSymbolClass; -static jclass RegisteredNativeSymbolClass; - -static jmethodID registerRoutinesID; -static jmethodID registerCCallableID; -static jmethodID getCCallableID; -static jmethodID useDynamicSymbolsID; -static jmethodID forceSymbolsID; -static jmethodID setDotSymbolValuesID; -static jmethodID getEmbeddingDllInfoID; -static jmethodID findSymbolID; - -void init_dynload(JNIEnv *env) { - DLLClass = checkFindClass(env, "com/oracle/truffle/r/runtime/ffi/DLL"); - JNI_PkgInitClass = checkFindClass(env, "com/oracle/truffle/r/ffi/impl/jni/JNI_PkgInit"); - DotSymbolClass = checkFindClass(env, "com/oracle/truffle/r/runtime/ffi/DLL$DotSymbol"); - RegisteredNativeSymbolClass = checkFindClass(env, "com/oracle/truffle/r/runtime/ffi/DLL$RegisteredNativeSymbol"); - - registerRoutinesID = checkGetMethodID(env, JNI_PkgInitClass, "registerRoutines", "(Lcom/oracle/truffle/r/runtime/ffi/DLL$DLLInfo;IIJ)V", 1); - registerCCallableID = checkGetMethodID(env, JNI_PkgInitClass, "registerCCallable", "(Ljava/lang/String;Ljava/lang/String;J)V", 1); - getCCallableID = checkGetMethodID(env, JNI_PkgInitClass, "getCCallable", "(Ljava/lang/String;Ljava/lang/String;)J", 1); - useDynamicSymbolsID = checkGetMethodID(env, JNI_PkgInitClass, "useDynamicSymbols", "(Lcom/oracle/truffle/r/runtime/ffi/DLL$DLLInfo;I)I", 1); - forceSymbolsID = checkGetMethodID(env, JNI_PkgInitClass, "forceSymbols", "(Lcom/oracle/truffle/r/runtime/ffi/DLL$DLLInfo;I)I", 1); - setDotSymbolValuesID = checkGetMethodID(env, JNI_PkgInitClass, "setDotSymbolValues", "(Ljava/lang/String;JI)Lcom/oracle/truffle/r/runtime/ffi/DLL$DotSymbol;", 1); - getEmbeddingDllInfoID = checkGetMethodID(env, JNI_PkgInitClass, "getEmbeddingDllInfo", "()Lcom/oracle/truffle/r/runtime/ffi/DLL$DLLInfo;", 1); - findSymbolID = checkGetMethodID(env, JNI_PkgInitClass, "findSymbol", "(Ljava/lang/String;Ljava/lang/String;Lcom/oracle/truffle/r/runtime/ffi/DLL$RegisteredNativeSymbol;)I", 1); -} - -// Must match ordinal value for DLL.NativeSymbolType -#define C_NATIVE_TYPE 0 -#define CALL_NATIVE_TYPE 1 -#define FORTRAN_NATIVE_TYPE 2 -#define EXTERNAL_NATIVE_TYPE 3 - -int -R_registerRoutines(DllInfo *info, const R_CMethodDef * const croutines, - const R_CallMethodDef * const callRoutines, - const R_FortranMethodDef * const fortranRoutines, - const R_ExternalMethodDef * const externalRoutines) { - // In theory we could create all the data here and pass it up, but in practice there were inexplicable - // Hotspot SEGV crashes creating Java arrays and Java objects in this function - JNIEnv *thisenv = getEnv(); - int num; - if (croutines) { - for(num = 0; croutines[num].name != NULL; num++) {;} - (*thisenv)->CallStaticVoidMethod(thisenv, JNI_PkgInitClass, registerRoutinesID, info, C_NATIVE_TYPE, num, croutines); - } - if (callRoutines) { - for(num = 0; callRoutines[num].name != NULL; num++) {;} - (*thisenv)->CallStaticVoidMethod(thisenv, JNI_PkgInitClass, registerRoutinesID, info, CALL_NATIVE_TYPE, num, callRoutines); - } - if (fortranRoutines) { - for(num = 0; fortranRoutines[num].name != NULL; num++) {;} - (*thisenv)->CallStaticVoidMethod(thisenv, JNI_PkgInitClass, registerRoutinesID, info, FORTRAN_NATIVE_TYPE, num, fortranRoutines); - } - if (externalRoutines) { - for(num = 0; externalRoutines[num].name != NULL; num++) {;} - (*thisenv)->CallStaticVoidMethod(thisenv, JNI_PkgInitClass, registerRoutinesID, info, EXTERNAL_NATIVE_TYPE, num, externalRoutines); - } - return 1; -} - -void R_RegisterCCallable(const char *package, const char *name, DL_FUNC fptr) { - JNIEnv *thisenv = getEnv(); -// printf("pkgname %s, name %s\n", package, name); - jstring packageString = (*thisenv)->NewStringUTF(thisenv, package); - jstring nameString = (*thisenv)->NewStringUTF(thisenv, name); - (*thisenv)->CallStaticVoidMethod(thisenv, JNI_PkgInitClass, registerCCallableID, packageString, nameString, fptr); -} - -JNIEXPORT jobject JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1PkgInit_setSymbol(JNIEnv *env, jclass c, jint nstOrd, jlong routinesAddr, jint index) { - const char *name; - long fun; - int numArgs; - - switch (nstOrd) { - case C_NATIVE_TYPE: { - R_CMethodDef *croutines = (R_CMethodDef *) routinesAddr; - name = croutines[index].name; - fun = (long) croutines[index].fun; - numArgs = croutines[index].numArgs; - break; - } - case CALL_NATIVE_TYPE: { - R_CallMethodDef *callRoutines = (R_CallMethodDef *) routinesAddr; - name = callRoutines[index].name; - fun = (long) callRoutines[index].fun; - numArgs = callRoutines[index].numArgs; - break; - } - case FORTRAN_NATIVE_TYPE: { - R_FortranMethodDef * fortranRoutines = (R_FortranMethodDef *) routinesAddr; - name = fortranRoutines[index].name; - fun = (long) fortranRoutines[index].fun; - numArgs = fortranRoutines[index].numArgs; - break; - } - case EXTERNAL_NATIVE_TYPE: { - R_ExternalMethodDef * externalRoutines = (R_ExternalMethodDef *) routinesAddr; - name = externalRoutines[index].name; - fun = (long) externalRoutines[index].fun; - numArgs = externalRoutines[index].numArgs; - break; - } - default: (*env)->FatalError(env, "NativeSymbolType out of range"); - } -// printf("name %s, fun %0lx, numArgs %d\n", name, fun, numArgs); - jstring nameString = (*env)->NewStringUTF(env, name); - return (*env)->CallStaticObjectMethod(env, JNI_PkgInitClass, setDotSymbolValuesID, nameString, fun, numArgs); - -} - -Rboolean R_useDynamicSymbols(DllInfo *dllInfo, Rboolean value) { - JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallStaticIntMethod(thisenv, JNI_PkgInitClass, useDynamicSymbolsID, dllInfo, value); -} - -Rboolean R_forceSymbols(DllInfo *dllInfo, Rboolean value) { - JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallStaticIntMethod(thisenv, JNI_PkgInitClass, forceSymbolsID, dllInfo, value); -} - -DL_FUNC R_GetCCallable(const char *package, const char *name) { - JNIEnv *thisenv = getEnv(); - jstring packageString = (*thisenv)->NewStringUTF(thisenv, package); - jstring nameString = (*thisenv)->NewStringUTF(thisenv, name); - return (DL_FUNC) (*thisenv)->CallStaticObjectMethod(thisenv, JNI_PkgInitClass, getCCallableID, packageString, nameString); -} - -DL_FUNC R_FindSymbol(char const *name, char const *pkg, - R_RegisteredNativeSymbol *symbol) { - unimplemented("R_FindSymbol"); - return NULL; -} - -DllInfo *R_getEmbeddingDllInfo(void) { - JNIEnv *thisenv = getEnv(); - return (DllInfo*) (*thisenv)->CallStaticObjectMethod(thisenv, JNI_PkgInitClass, getEmbeddingDllInfoID); -} diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c b/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c deleted file mode 100644 index 5dcff7874a0572fb6df31c8bfb4e9d27f2c7e1f2..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c +++ /dev/null @@ -1,1617 +0,0 @@ -/* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -#include <rffiutils.h> -#include <string.h> -#include <Rinternals_common.h> - -// Most everything in RInternals.h - -// N.B. When implementing a new method that returns a SEXP, you MUST -// explicitly (or implicitly) return via "checkRef(thisenv, result)" -// to ensure that a global JNI handle is created (if necessary) and returned, -// otherwise a GC might reclaim the result. - -// N.B. ALL functions go via UpCallsRFFI to provide a single point of re-entry - -static jmethodID Rf_ScalarIntegerMethodID; -static jmethodID Rf_ScalarDoubleMethodID; -static jmethodID Rf_ScalarStringMethodID; -static jmethodID Rf_ScalarLogicalMethodID; -static jmethodID Rf_allocVectorMethodID; -static jmethodID Rf_allocArrayMethodID; -static jmethodID Rf_allocMatrixMethodID; -static jmethodID Rf_duplicateMethodID; -static jmethodID Rf_any_duplicatedMethodID; -static jmethodID Rf_consMethodID; -static jmethodID Rf_evalMethodID; -static jmethodID Rf_findFunMethodID; -static jmethodID Rf_defineVarMethodID; -static jmethodID Rf_findVarMethodID; -static jmethodID Rf_findVarInFrameMethodID; -static jmethodID Rf_findVarInFrame3MethodID; -static jmethodID ATTRIBMethodID; -static jmethodID Rf_getAttribMethodID; -static jmethodID Rf_setAttribMethodID; -static jmethodID Rf_isStringMethodID; -static jmethodID Rf_isNullMethodID; -static jmethodID Rf_installCharMethodID; -static jmethodID Rf_installMethodID; -static jmethodID Rf_warningcallMethodID; -static jmethodID Rf_errorcallMethodID; -static jmethodID Rf_warningMethodID; -static jmethodID Rf_errorMethodID; -static jmethodID R_NewHashedEnvMethodID; -static jmethodID Rf_classgetsMethodID; -static jmethodID Rf_rPsortMethodID; -static jmethodID Rf_iPsortMethodID; -static jmethodID RprintfMethodID; -static jmethodID R_FindNamespaceMethodID; -static jmethodID R_BindingIsLockedID; -static jmethodID Rf_GetOption1MethodID; -static jmethodID Rf_gsetVarMethodID; -static jmethodID Rf_inheritsMethodID; -static jmethodID Rf_lengthgetsMethodID; -static jmethodID CADR_MethodID; -static jmethodID CADDR_MethodID; -static jmethodID TAG_MethodID; -static jmethodID PRINTNAME_MethodID; -static jmethodID CAR_MethodID; -static jmethodID CDR_MethodID; -static jmethodID CDDR_MethodID; -static jmethodID SET_TAG_MethodID; -static jmethodID SETCAR_MethodID; -static jmethodID SETCDR_MethodID; -static jmethodID SETCADR_MethodID; -static jmethodID SYMVALUE_MethodID; -static jmethodID SET_SYMVALUE_MethodID; -static jmethodID SET_STRING_ELT_MethodID; -static jmethodID SET_VECTOR_ELT_MethodID; -jmethodID RAW_MethodID; -jmethodID INTEGER_MethodID; -jmethodID REAL_MethodID; -jmethodID LOGICAL_MethodID; -jmethodID logNotCharSXPWrapperMethodID; -static jmethodID STRING_ELT_MethodID; -static jmethodID VECTOR_ELT_MethodID; -static jmethodID LENGTH_MethodID; -static jmethodID R_do_slot_MethodID; -static jmethodID R_do_slot_assign_MethodID; -static jmethodID R_MethodsNamespaceMethodID; -static jmethodID Rf_str2type_MethodID; -static jmethodID Rf_asIntegerMethodID; -static jmethodID Rf_asRealMethodID; -static jmethodID Rf_asCharMethodID; -static jmethodID Rf_coerceVectorMethodID; -static jmethodID Rf_mkCharLenCEMethodID; -static jmethodID Rf_asLogicalMethodID; -static jmethodID Rf_PairToVectorListMethodID; -static jmethodID Rf_VectorToPairListMethodID; -static jmethodID Rf_asCharacterFactorMethodID; -static jmethodID gnuRCodeForObjectMethodID; -static jmethodID NAMED_MethodID; -static jmethodID SET_TYPEOF_FASTR_MethodID; -static jmethodID SET_NAMED_FASTR_MethodID; -static jmethodID TYPEOF_MethodID; -static jmethodID OBJECT_MethodID; -static jmethodID DUPLICATE_ATTRIB_MethodID; -static jmethodID IS_S4_OBJECTMethodID; -static jmethodID SET_S4_OBJECTMethodID; -static jmethodID UNSET_S4_OBJECTMethodID; -static jmethodID R_tryEvalMethodID; -static jmethodID RDEBUGMethodID; -static jmethodID SET_RDEBUGMethodID; -static jmethodID RSTEPMethodID; -static jmethodID SET_RSTEPMethodID; -static jmethodID ENCLOSMethodID; -static jmethodID PRVALUEMethodID; -static jmethodID R_lsInternal3MethodID; -static jmethodID R_do_MAKE_CLASS_MethodID; -static jmethodID R_do_new_object_MethodID; -static jmethodID PRSEENMethodID; -static jmethodID PRENVMethodID; -static jmethodID R_PromiseExprMethodID; -static jmethodID PRCODEMethodID; - -static jmethodID R_ToplevelExecMethodID; -static jmethodID restoreHandlerStacksMethodID; - -static jmethodID R_MakeExternalPtrMethodID; -static jmethodID R_ExternalPtrAddrMethodID; -static jmethodID R_ExternalPtrTagMethodID; -static jmethodID R_ExternalPtrProtectedMethodID; -static jmethodID R_SetExternalPtrAddrMethodID; -static jmethodID R_SetExternalPtrTagMethodID; -static jmethodID R_SetExternalPtrProtMethodID; - -static jmethodID R_compute_identicalMethodID; -static jmethodID Rf_copyListMatrixMethodID; -static jmethodID Rf_copyMatrixMethodID; -static jmethodID Rf_nrowsMethodID; -static jmethodID Rf_ncolsMethodID; -static jmethodID Rf_namesgetsMethodID; -static jmethodID Rf_copyMostAttribMethodID; - -static jclass CharSXPWrapperClass; -jclass JNIUpCallsRFFIImplClass; - -jmethodID setCompleteMethodID; - -void init_internals(JNIEnv *env) { - Rf_ScalarIntegerMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_ScalarInteger", "(I)Lcom/oracle/truffle/r/runtime/data/RIntVector;", 0); - Rf_ScalarDoubleMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_ScalarDouble", "(D)Lcom/oracle/truffle/r/runtime/data/RDoubleVector;", 0); - Rf_ScalarStringMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_ScalarString", "(Ljava/lang/Object;)Lcom/oracle/truffle/r/runtime/data/RStringVector;", 0); - Rf_ScalarLogicalMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_ScalarLogical", "(I)Lcom/oracle/truffle/r/runtime/data/RLogicalVector;", 0); - Rf_consMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_cons", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 0); - Rf_evalMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_eval", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 0); - Rf_findFunMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_findFun", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 0); - Rf_defineVarMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_defineVar", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)I", 0); - Rf_findVarMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_findVar", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 0); - Rf_findVarInFrameMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_findVarInFrame", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 0); - Rf_findVarInFrame3MethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_findVarInFrame3", "(Ljava/lang/Object;Ljava/lang/Object;I)Ljava/lang/Object;", 0); - ATTRIBMethodID = checkGetMethodID(env, UpCallsRFFIClass, "ATTRIB", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - Rf_getAttribMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_getAttrib", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 0); - Rf_setAttribMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_setAttrib", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)I", 0); - Rf_isStringMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_isString", "(Ljava/lang/Object;)I", 0); - Rf_isNullMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_isNull", "(Ljava/lang/Object;)I", 0); - Rf_installMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_install", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - Rf_installCharMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_installChar", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - Rf_warningMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_warning", "(Ljava/lang/Object;)I", 0); - Rf_warningcallMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_warningcall", "(Ljava/lang/Object;Ljava/lang/Object;)I", 0); - Rf_errorcallMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_errorcall", "(Ljava/lang/Object;Ljava/lang/Object;)I", 0); - Rf_errorMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_error", "(Ljava/lang/Object;)I", 0); - Rf_allocVectorMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_allocVector", "(IJ)Ljava/lang/Object;", 0); - Rf_allocMatrixMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_allocMatrix", "(III)Ljava/lang/Object;", 0); - Rf_allocArrayMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_allocArray", "(ILjava/lang/Object;)Ljava/lang/Object;", 0); - Rf_duplicateMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_duplicate", "(Ljava/lang/Object;I)Ljava/lang/Object;", 0); - Rf_any_duplicatedMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_any_duplicated", "(Ljava/lang/Object;I)J", 0); - R_NewHashedEnvMethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_NewHashedEnv", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 0); - Rf_classgetsMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_classgets", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 0); - RprintfMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rprintf", "(Ljava/lang/Object;)I", 0); - R_do_MAKE_CLASS_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_do_MAKE_CLASS", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - R_do_new_object_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_do_new_object", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - R_FindNamespaceMethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_FindNamespace", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - R_BindingIsLockedID = checkGetMethodID(env, UpCallsRFFIClass, "R_BindingIsLocked", "(Ljava/lang/Object;Ljava/lang/Object;)I", 0); - Rf_GetOption1MethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_GetOption1", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - Rf_gsetVarMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_gsetVar", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)I", 0); - Rf_inheritsMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_inherits", "(Ljava/lang/Object;Ljava/lang/Object;)I", 0); - Rf_lengthgetsMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_lengthgets", "(Ljava/lang/Object;I)Ljava/lang/Object;", 0); -// Rf_rPsortMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_rPsort", "(Lcom/oracle/truffle/r/runtime/data/RDoubleVector;II)", 0); -// Rf_iPsortMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_iPsort", "(Lcom/oracle/truffle/r/runtime/data/RIntVector;II)", 0); - CADR_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "CADR", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - CADDR_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "CADDR", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - TAG_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "TAG", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - PRINTNAME_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "PRINTNAME", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - CAR_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "CAR", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - CDR_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "CDR", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - CDDR_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "CDDR", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - SET_TAG_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "SET_TAG", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 0); - SETCAR_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "SETCAR", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 0); - SETCDR_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "SETCDR", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 0); - SETCADR_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "SETCADR", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 0); - SYMVALUE_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "SYMVALUE", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - SET_SYMVALUE_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "SET_SYMVALUE", "(Ljava/lang/Object;Ljava/lang/Object;)I", 0); - SET_STRING_ELT_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "SET_STRING_ELT", "(Ljava/lang/Object;JLjava/lang/Object;)I", 0); - SET_VECTOR_ELT_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "SET_VECTOR_ELT", "(Ljava/lang/Object;JLjava/lang/Object;)I", 0); - RAW_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "RAW", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - REAL_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "REAL", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - LOGICAL_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "LOGICAL", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - INTEGER_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "INTEGER", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - STRING_ELT_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "STRING_ELT", "(Ljava/lang/Object;J)Ljava/lang/Object;", 0); - VECTOR_ELT_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "VECTOR_ELT", "(Ljava/lang/Object;J)Ljava/lang/Object;", 0); - LENGTH_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "LENGTH", "(Ljava/lang/Object;)I", 0); - R_do_slot_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_do_slot", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 0); - R_do_slot_assign_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_do_slot_assign", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 0); - R_MethodsNamespaceMethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_MethodsNamespace", "()Ljava/lang/Object;", 0); - Rf_str2type_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_str2type", "(Ljava/lang/Object;)I", 0); - Rf_asIntegerMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_asInteger", "(Ljava/lang/Object;)I", 0); - Rf_asRealMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_asReal", "(Ljava/lang/Object;)D", 0); - Rf_asCharMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_asChar", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - Rf_mkCharLenCEMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_mkCharLenCE", "(Ljava/lang/Object;II)Ljava/lang/Object;", 0); - Rf_coerceVectorMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_coerceVector", "(Ljava/lang/Object;I)Ljava/lang/Object;", 0); - Rf_asLogicalMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_asLogical", "(Ljava/lang/Object;)I", 0); - Rf_PairToVectorListMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_PairToVectorList", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - Rf_VectorToPairListMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_VectorToPairList", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - Rf_asCharacterFactorMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_asCharacterFactor", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - NAMED_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "NAMED", "(Ljava/lang/Object;)I", 0); - SET_TYPEOF_FASTR_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "SET_TYPEOF_FASTR", "(Ljava/lang/Object;I)Ljava/lang/Object;", 0); - SET_NAMED_FASTR_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "SET_NAMED_FASTR", "(Ljava/lang/Object;I)Ljava/lang/Object;", 0); - TYPEOF_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "TYPEOF", "(Ljava/lang/Object;)I", 0); - OBJECT_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "OBJECT", "(Ljava/lang/Object;)I", 0); - DUPLICATE_ATTRIB_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "DUPLICATE_ATTRIB", "(Ljava/lang/Object;Ljava/lang/Object;)I", 0); - IS_S4_OBJECTMethodID = checkGetMethodID(env, UpCallsRFFIClass, "IS_S4_OBJECT", "(Ljava/lang/Object;)I", 0); - SET_S4_OBJECTMethodID = checkGetMethodID(env, UpCallsRFFIClass, "SET_S4_OBJECT", "(Ljava/lang/Object;)I", 0); - UNSET_S4_OBJECTMethodID = checkGetMethodID(env, UpCallsRFFIClass, "UNSET_S4_OBJECT", "(Ljava/lang/Object;)I", 0); - R_tryEvalMethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_tryEval", "(Ljava/lang/Object;Ljava/lang/Object;I)Ljava/lang/Object;", 0); - RDEBUGMethodID = checkGetMethodID(env, UpCallsRFFIClass, "RDEBUG", "(Ljava/lang/Object;)I", 0); - SET_RDEBUGMethodID = checkGetMethodID(env, UpCallsRFFIClass, "SET_RDEBUG", "(Ljava/lang/Object;I)I", 0); - RSTEPMethodID = checkGetMethodID(env, UpCallsRFFIClass, "RSTEP", "(Ljava/lang/Object;)I", 0); - SET_RSTEPMethodID = checkGetMethodID(env, UpCallsRFFIClass, "SET_RSTEP", "(Ljava/lang/Object;I)I", 0); - ENCLOSMethodID = checkGetMethodID(env, UpCallsRFFIClass, "ENCLOS", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - PRVALUEMethodID = checkGetMethodID(env, UpCallsRFFIClass, "PRVALUE", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - R_lsInternal3MethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_lsInternal3", "(Ljava/lang/Object;II)Ljava/lang/Object;", 0); - PRSEENMethodID = checkGetMethodID(env, UpCallsRFFIClass, "PRSEEN", "(Ljava/lang/Object;)I", 0); - PRENVMethodID = checkGetMethodID(env, UpCallsRFFIClass, "PRENV", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - R_PromiseExprMethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_PromiseExpr", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - PRCODEMethodID = checkGetMethodID(env, UpCallsRFFIClass, "PRCODE", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - - R_ToplevelExecMethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_ToplevelExec", "()Ljava/lang/Object;", 0); - - R_MakeExternalPtrMethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_MakeExternalPtr", "(JLjava/lang/Object;Ljava/lang/Object;)Lcom/oracle/truffle/r/runtime/data/RExternalPtr;", 0); - R_ExternalPtrAddrMethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_ExternalPtrAddr", "(Ljava/lang/Object;)J", 0); - R_ExternalPtrTagMethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_ExternalPtrTag", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - R_ExternalPtrProtectedMethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_ExternalPtrProtected", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); - R_SetExternalPtrAddrMethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_SetExternalPtrAddr", "(Ljava/lang/Object;J)I", 0); - R_SetExternalPtrTagMethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_SetExternalPtrTag", "(Ljava/lang/Object;Ljava/lang/Object;)I", 0); - R_SetExternalPtrProtMethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_SetExternalPtrProtected", "(Ljava/lang/Object;Ljava/lang/Object;)I", 0); - - R_compute_identicalMethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_compute_identical", "(Ljava/lang/Object;Ljava/lang/Object;I)I", 0); - Rf_copyListMatrixMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_copyListMatrix", "(Ljava/lang/Object;Ljava/lang/Object;I)I", 0); - Rf_copyMatrixMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_copyMatrix", "(Ljava/lang/Object;Ljava/lang/Object;I)I", 0); - Rf_nrowsMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_nrows", "(Ljava/lang/Object;)I", 0); - Rf_ncolsMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_ncols", "(Ljava/lang/Object;)I", 0); - Rf_namesgetsMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_namesgets", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 0); - Rf_copyMostAttribMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_copyMostAttrib", "(Ljava/lang/Object;Ljava/lang/Object;)I", 0); - - // static JNI-specific methods - JNIUpCallsRFFIImplClass = checkFindClass(env, "com/oracle/truffle/r/ffi/impl/jni/JNIUpCallsRFFIImpl"); - restoreHandlerStacksMethodID = checkGetMethodID(env, JNIUpCallsRFFIImplClass, "R_ToplevelExecRestoreErrorHandlerStacks", "(Ljava/lang/Object;)V", 1); - setCompleteMethodID = checkGetMethodID(env, JNIUpCallsRFFIImplClass, "setComplete", "(Ljava/lang/Object;Z)V", 1); - logNotCharSXPWrapperMethodID = checkGetMethodID(env, JNIUpCallsRFFIImplClass, "logNotCharSXPWrapper", "(Ljava/lang/Object;)V", 1); -} - -SEXP Rf_ScalarInteger(int value) { - TRACE(TARGp, value); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_ScalarIntegerMethodID, value); - return checkRef(thisenv, result); -} - -SEXP Rf_ScalarReal(double value) { - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_ScalarDoubleMethodID, value); - return checkRef(thisenv, result); -} - -SEXP Rf_ScalarString(SEXP value) { - TRACE(TARGp, value); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_ScalarStringMethodID, value); - return checkRef(thisenv, result); -} - -SEXP Rf_ScalarLogical(int value) { - TRACE(TARGp, value); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_ScalarLogicalMethodID, value); - return checkRef(thisenv, result); -} - -SEXP Rf_allocVector3(SEXPTYPE t, R_xlen_t len, R_allocator_t* allocator) { - if (allocator != NULL) { - unimplemented("RF_allocVector with custom allocator"); - return NULL; - } - TRACE(TARGpd, t, len); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_allocVectorMethodID, t, len); - return checkRef(thisenv, result); -} - -SEXP Rf_allocArray(SEXPTYPE t, SEXP dims) { - TRACE(TARGppd, t, dims); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_allocArrayMethodID, t, dims); - return checkRef(thisenv, result); -} - -SEXP Rf_alloc3DArray(SEXPTYPE t, int x, int y, int z) { - return unimplemented("Rf_alloc3DArray"); -} - -SEXP Rf_allocMatrix(SEXPTYPE mode, int nrow, int ncol) { - TRACE(TARGppd, mode, nrow, ncol); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_allocMatrixMethodID, mode, nrow, ncol); - return checkRef(thisenv, result); -} - -SEXP Rf_allocList(int x) { - unimplemented("Rf_allocList)"); - return NULL; -} - -SEXP Rf_allocSExp(SEXPTYPE t) { - return unimplemented("Rf_allocSExp"); -} - -SEXP Rf_cons(SEXP car, SEXP cdr) { - TRACE(TARGpp, car, cdr); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_consMethodID, car, cdr); - return checkRef(thisenv, result); -} - -void Rf_defineVar(SEXP symbol, SEXP value, SEXP rho) { - TRACE(TARGppp, symbol, value, rho); - JNIEnv *thisenv = getEnv(); - (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_defineVarMethodID, symbol, value, rho); -} - -void Rf_setVar(SEXP x, SEXP y, SEXP z) { - unimplemented("Rf_setVar"); -} - -SEXP Rf_dimgets(SEXP x, SEXP y) { - return unimplemented("Rf_dimgets"); -} - -SEXP Rf_dimnamesgets(SEXP x, SEXP y) { - return unimplemented("Rf_dimnamesgets"); -} - -SEXP Rf_eval(SEXP expr, SEXP env) { - TRACE(TARGpp, expr, env); - JNIEnv *thisenv = getEnv(); - updateJObjects(thisenv); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_evalMethodID, expr, env); - updateNativeArrays(thisenv); - return checkRef(thisenv, result); -} - -SEXP Rf_findFun(SEXP symbol, SEXP rho) { - TRACE(TARGpp, symbol, rho); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_findFunMethodID, symbol, rho); - return checkRef(thisenv, result); -} - -SEXP Rf_findVar(SEXP sym, SEXP rho) { - TRACE(TARGpp, sym, rho); - JNIEnv *thisenv = getEnv(); - SEXP result =(*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_findVarMethodID, sym, rho); - return checkRef(thisenv, result); -} - -SEXP Rf_findVarInFrame(SEXP rho, SEXP sym) { - TRACE(TARGpp, rho, sym); - JNIEnv *thisenv = getEnv(); - SEXP result =(*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_findVarInFrameMethodID, rho, sym); - return checkRef(thisenv, result); -} - -SEXP Rf_findVarInFrame3(SEXP rho, SEXP sym, Rboolean b) { - TRACE(TARGppd, rho, sym, b); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_findVarInFrame3MethodID, rho, sym, b); - return checkRef(thisenv, result); -} - -SEXP Rf_getAttrib(SEXP vec, SEXP name) { - TRACE(TARGpp, vec, name); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_getAttribMethodID, vec, name); - return checkRef(thisenv, result); -} - -SEXP Rf_setAttrib(SEXP vec, SEXP name, SEXP val) { - TRACE(TARGppp, vec,name, val); - JNIEnv *thisenv = getEnv(); - updateJObject(thisenv, val); - (*thisenv)->CallVoidMethod(thisenv, UpCallsRFFIObject, Rf_setAttribMethodID, vec, name, val); - return val; -} - -SEXP Rf_duplicate(SEXP x) { - TRACE(TARGp, x); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_duplicateMethodID, x, 1); - return checkRef(thisenv, result); -} - -SEXP Rf_shallow_duplicate(SEXP x) { - TRACE(TARGp, x); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_duplicateMethodID, x, 0); - return checkRef(thisenv, result); -} - -R_xlen_t Rf_any_duplicated(SEXP x, Rboolean from_last) { - TRACE(TARGpd, x, from_last); - if (!isVector(x)) error(_("'duplicated' applies only to vectors")); - JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallIntMethod(thisenv, UpCallsRFFIObject, Rf_any_duplicatedMethodID, x, from_last); -} - -SEXP Rf_duplicated(SEXP x, Rboolean y) { - unimplemented("Rf_duplicated"); - return NULL; -} - -SEXP Rf_applyClosure(SEXP x, SEXP y, SEXP z, SEXP a, SEXP b) { - return unimplemented("Rf_applyClosure"); -} - -void Rf_copyMostAttrib(SEXP x, SEXP y) { - TRACE(TARGpp, x, y); - JNIEnv *thisenv = getEnv(); - (*thisenv)->CallIntMethod(thisenv, UpCallsRFFIObject, Rf_copyMostAttribMethodID, x, y); -} - -void Rf_copyVector(SEXP x, SEXP y) { - unimplemented("Rf_copyVector"); -} - -int Rf_countContexts(int x, int y) { - return (int) unimplemented("Rf_countContexts"); -} - -Rboolean Rf_inherits(SEXP x, const char * klass) { - TRACE(TARGps, x, klass); - JNIEnv *thisenv = getEnv(); - jstring klazz = (*thisenv)->NewStringUTF(thisenv, klass); - return (*thisenv)->CallIntMethod(thisenv, UpCallsRFFIObject, Rf_inheritsMethodID, x, klazz); -} - - -Rboolean Rf_isObject(SEXP s) { - unimplemented("Rf_isObject"); - return FALSE; -} - -void Rf_PrintValue(SEXP x) { - unimplemented("Rf_PrintValue"); -} - -SEXP Rf_install(const char *name) { - TRACE(TARGs, name); - JNIEnv *thisenv = getEnv(); - jstring string = (*thisenv)->NewStringUTF(thisenv, name); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_installMethodID, string); - addGlobalRef(thisenv, result, 1); - return checkRef(thisenv, result); -} - -SEXP Rf_installChar(SEXP charsxp) { - TRACE(TARGp, charsxp); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_installCharMethodID, charsxp); - return checkRef(thisenv, result); -} - -Rboolean Rf_isNull(SEXP s) { - JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallIntMethod(thisenv, UpCallsRFFIObject, Rf_isNullMethodID, s); -} - -Rboolean Rf_isString(SEXP s) { - JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallIntMethod(thisenv, UpCallsRFFIObject, Rf_isStringMethodID, s); -} - -Rboolean R_cycle_detected(SEXP s, SEXP child) { - unimplemented("R_cycle_detected"); - return 0; -} - -cetype_t Rf_getCharCE(SEXP x) { - // unimplemented("Rf_getCharCE"); - // TODO: real implementation - return CE_NATIVE; -} - -SEXP Rf_mkChar(const char *x) { - return Rf_mkCharLenCE(x, strlen(x), CE_NATIVE); -} - -SEXP Rf_mkCharCE(const char *x, cetype_t y) { - return Rf_mkCharLenCE(x, strlen(x), y); -} - -SEXP Rf_mkCharLen(const char *x, int y) { - return Rf_mkCharLenCE(x, y, CE_NATIVE); -} - -SEXP Rf_mkCharLenCE(const char *x, int len, cetype_t enc) { - TRACE(TARGsdd, x, len, enc); - JNIEnv *thisenv = getEnv(); - jbyteArray bytes = (*thisenv)->NewByteArray(thisenv, len); - (*thisenv)->SetByteArrayRegion(thisenv, bytes, 0, len, (const jbyte *) x); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_mkCharLenCEMethodID, bytes, len, (int) enc); - return checkRef(thisenv, result); -} - -const char *Rf_reEnc(const char *x, cetype_t ce_in, cetype_t ce_out, int subst) { - // TODO proper implementation - return x; -} - -SEXP Rf_mkString(const char *s) { - return ScalarString(Rf_mkChar(s)); -} - -int Rf_ncols(SEXP x) { - TRACE(TARGs, x); - JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallIntMethod(thisenv, UpCallsRFFIObject, Rf_ncolsMethodID, x); -} - -int Rf_nrows(SEXP x) { - TRACE(TARGs, x); - JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallIntMethod(thisenv, UpCallsRFFIObject, Rf_nrowsMethodID, x); -} - - -SEXP Rf_protect(SEXP x) { - TRACE(TARGp, x); - return x; -} - -void Rf_unprotect(int x) { - TRACE(TARGp, x); -} - -void R_ProtectWithIndex(SEXP x, PROTECT_INDEX *y) { - TRACE(TARGpd, x,y); -} - -void R_Reprotect(SEXP x, PROTECT_INDEX y) { - TRACE(TARGpd, x,y); -} - - -void Rf_unprotect_ptr(SEXP x) { - TRACE(TARGp, x); -} - -#define BUFSIZE 8192 - -static int Rvsnprintf(char *buf, size_t size, const char *format, va_list ap) -{ - int val; - val = vsnprintf(buf, size, format, ap); - buf[size-1] = '\0'; - return val; -} - - -void Rf_error(const char *format, ...) { - // This is a bit tricky. The usual error handling model in Java is "throw RError.error(...)" but - // RError.error does quite a lot of stuff including potentially searching for R condition handlers - // and, if it finds any, does not return, but throws a different exception than RError. - // We definitely need to exit the FFI call and we certainly cannot return to our caller. - // So we call RFFIUpCallsObject.Rf_error to throw the RError exception. When the pending - // exception (whatever it is) is observed by JNI, the call to Rf_error will return where we do a - // non-local transfer of control back to the entry point (which will cleanup). - char buf[8192]; - va_list(ap); - va_start(ap,format); - Rvsnprintf(buf, BUFSIZE - 1, format, ap); - va_end(ap); - JNIEnv *thisenv = getEnv(); - jstring string = (*thisenv)->NewStringUTF(thisenv, buf); - // This will set a pending exception - (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_errorMethodID, string); - // just transfer back which will cleanup and exit the entire JNI call - longjmp(*getErrorJmpBuf(), 1); -} - -void Rf_errorcall(SEXP x, const char *format, ...) { - char buf[8192]; - va_list(ap); - va_start(ap,format); - Rvsnprintf(buf, BUFSIZE - 1, format, ap); - va_end(ap); - JNIEnv *thisenv = getEnv(); - jstring string = (*thisenv)->NewStringUTF(thisenv, buf); - (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_errorcallMethodID, x, string); -} - -void Rf_warningcall(SEXP x, const char *format, ...) { - char buf[8192]; - va_list(ap); - va_start(ap,format); - Rvsnprintf(buf, BUFSIZE - 1, format, ap); - va_end(ap); - JNIEnv *thisenv = getEnv(); - jstring string = (*thisenv)->NewStringUTF(thisenv, buf); - (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_warningcallMethodID, x, string); -} - -void Rf_warning(const char *format, ...) { - char buf[8192]; - va_list(ap); - va_start(ap,format); - Rvsnprintf(buf, BUFSIZE - 1, format, ap); - va_end(ap); - JNIEnv *thisenv = getEnv(); - jstring string = (*thisenv)->NewStringUTF(thisenv, buf); - (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_warningMethodID, string); -} - -void Rprintf(const char *format, ...) { - char buf[8192]; - va_list(ap); - va_start(ap,format); - Rvsnprintf(buf, BUFSIZE - 1, format, ap); - va_end(ap); - JNIEnv *thisenv = getEnv(); - jstring string = (*thisenv)->NewStringUTF(thisenv, buf); - (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, RprintfMethodID, string); -} - -/* - REprintf is used by the error handler do not add - anything unless you're sure it won't - cause problems -*/ -void REprintf(const char *format, ...) -{ - // TODO: determine correct target for this message - char buf[8192]; - va_list(ap); - va_start(ap,format); - Rvsnprintf(buf, BUFSIZE - 1, format, ap); - va_end(ap); - JNIEnv *thisenv = getEnv(); - jstring string = (*thisenv)->NewStringUTF(thisenv, buf); - (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, RprintfMethodID, string); -} - -void Rvprintf(const char *format, va_list args) { - unimplemented("Rvprintf"); -} -void REvprintf(const char *format, va_list args) { - unimplemented("REvprintf"); -} - -void R_FlushConsole(void) { - // ignored -} - -void R_ProcessEvents(void) { - unimplemented("R_ProcessEvents"); -} - -// Tools package support, not in public API -SEXP R_NewHashedEnv(SEXP parent, SEXP size) { - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, R_NewHashedEnvMethodID, parent, size); - return checkRef(thisenv, result); -} - -SEXP Rf_classgets(SEXP vec, SEXP klass) { - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_classgetsMethodID, vec, klass); - return checkRef(thisenv, result); -} - -const char *Rf_translateChar(SEXP x) { - // TODO: proper implementation - TRACE(TARGp, x); - const char *result = CHAR(x); - return result; -} - -const char *Rf_translateChar0(SEXP x) { - // TODO: proper implementation - TRACE(TARGp, x); - const char *result = CHAR(x); - return result; -} - -const char *Rf_translateCharUTF8(SEXP x) { - // TODO: proper implementation - TRACE(TARGp, x); - const char *result = CHAR(x); - return result; -} - -SEXP Rf_lengthgets(SEXP x, R_len_t y) { - TRACE(TARGp, x); - JNIEnv *thisenv = getEnv(); - invalidateNativeArray(thisenv, x); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_lengthgetsMethodID, x, y); - return checkRef(thisenv, result); -} - -SEXP Rf_xlengthgets(SEXP x, R_xlen_t y) { - return unimplemented("Rf_xlengthgets"); - -} - -SEXP R_lsInternal(SEXP env, Rboolean all) { - return R_lsInternal3(env, all, TRUE); -} - -SEXP R_lsInternal3(SEXP env, Rboolean all, Rboolean sorted) { - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, R_lsInternal3MethodID, env, all, sorted); - return checkRef(thisenv, result); -} - -SEXP Rf_namesgets(SEXP x, SEXP y) { - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_namesgetsMethodID, x, y); - return checkRef(thisenv, result); -} - -SEXP GetOption1(SEXP tag) -{ - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_GetOption1MethodID, tag); - return checkRef(thisenv, result); -} - -void Rf_gsetVar(SEXP symbol, SEXP value, SEXP rho) -{ - JNIEnv *thisenv = getEnv(); - (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_gsetVarMethodID, symbol, value, rho); -} - -SEXP TAG(SEXP e) { - TRACE(TARGp, e); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, TAG_MethodID, e); - return checkRef(thisenv, result); -} - -SEXP PRINTNAME(SEXP e) { - TRACE(TARGp, e); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, PRINTNAME_MethodID, e); - return checkRef(thisenv, result); -} - -SEXP CAR(SEXP e) { - TRACE(TARGp, e); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, CAR_MethodID, e); - return checkRef(thisenv, result); -} - -SEXP CDR(SEXP e) { - TRACE(TARGp, e); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, CDR_MethodID, e); - return checkRef(thisenv, result); -} - -SEXP CAAR(SEXP e) { - return CAR(CAR(e)); -} - -SEXP CDAR(SEXP e) { - return CDR(CAR(e)); -} - -SEXP CADR(SEXP e) { - TRACE(TARGp, e); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, CADR_MethodID, e); - return checkRef(thisenv, result); -} - -SEXP CDDR(SEXP e) { - TRACE(TARGp, e); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, CDDR_MethodID, e); - return checkRef(thisenv, result); -} - -SEXP CDDDR(SEXP e) { - unimplemented("CDDDR"); - return NULL; -} - -SEXP CADDR(SEXP e) { - TRACE(TARGp, e); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, CADDR_MethodID, e); - return checkRef(thisenv, result); -} - -SEXP CADDDR(SEXP e) { - unimplemented("CADDDR"); - return NULL; -} - -SEXP CAD4R(SEXP e) { - unimplemented("CAD4R"); - return NULL; -} - -int MISSING(SEXP x){ - unimplemented("MISSING"); - return 0; -} - -void SET_MISSING(SEXP x, int v) { - unimplemented("SET_MISSING"); -} - -void SET_TAG(SEXP x, SEXP y) { - TRACE(TARGpp, x, y); - JNIEnv *thisenv = getEnv(); - (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, SET_TAG_MethodID, x, y); -} - -SEXP SETCAR(SEXP x, SEXP y) { - TRACE(TARGpp, x, y); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, SETCAR_MethodID, x, y); - return checkRef(thisenv, result); -} - -SEXP SETCDR(SEXP x, SEXP y) { - TRACE(TARGpp, x, y); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, SETCDR_MethodID, x, y); - return checkRef(thisenv, result); -} - -SEXP SETCADR(SEXP x, SEXP y) { - TRACE(TARGpp, x, y); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, SETCADR_MethodID, x, y); - return checkRef(thisenv, result); -} - -SEXP SETCADDR(SEXP x, SEXP y) { - unimplemented("SETCADDR"); - return NULL; -} - -SEXP SETCADDDR(SEXP x, SEXP y) { - unimplemented("SETCADDDR"); - return NULL; -} - -SEXP SETCAD4R(SEXP e, SEXP y) { - unimplemented("SETCAD4R"); - return NULL; -} - -SEXP FORMALS(SEXP x) { - return unimplemented("FORMALS"); -} - -SEXP BODY(SEXP x) { - return unimplemented("BODY"); -} - -SEXP CLOENV(SEXP x) { - return unimplemented("CLOENV"); -} - -int RDEBUG(SEXP x) { - JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallIntMethod(thisenv, UpCallsRFFIObject, RDEBUGMethodID, x); -} - -int RSTEP(SEXP x) { - JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallIntMethod(thisenv, UpCallsRFFIObject, RSTEPMethodID, x); -} - -int RTRACE(SEXP x) { - unimplemented("RTRACE"); - return 0; -} - -void SET_RDEBUG(SEXP x, int v) { - JNIEnv *thisenv = getEnv(); - (*thisenv)->CallVoidMethod(thisenv, UpCallsRFFIObject, SET_RDEBUGMethodID, x, v); -} - -void SET_RSTEP(SEXP x, int v) { - JNIEnv *thisenv = getEnv(); - (*thisenv)->CallVoidMethod(thisenv, UpCallsRFFIObject, SET_RSTEPMethodID, x, v); -} - -void SET_RTRACE(SEXP x, int v) { - unimplemented("SET_RTRACE"); -} - -void SET_FORMALS(SEXP x, SEXP v) { - unimplemented("SET_FORMALS"); -} - -void SET_BODY(SEXP x, SEXP v) { - unimplemented("SET_BODY"); -} - -void SET_CLOENV(SEXP x, SEXP v) { - unimplemented("SET_CLOENV"); -} - -SEXP SYMVALUE(SEXP x) { - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, SYMVALUE_MethodID, x); - return checkRef(thisenv, result); -} - -SEXP INTERNAL(SEXP x) { - return unimplemented("INTERNAL"); -} - -int DDVAL(SEXP x) { - unimplemented("DDVAL"); - return 0; -} - -void SET_DDVAL(SEXP x, int v) { - unimplemented("SET_DDVAL"); -} - -void SET_SYMVALUE(SEXP x, SEXP v) { - JNIEnv *thisenv = getEnv(); - (*thisenv)->CallVoidMethod(thisenv, UpCallsRFFIObject, SET_SYMVALUE_MethodID, x, v); -} - -void SET_INTERNAL(SEXP x, SEXP v) { - unimplemented("SET_INTERNAL"); -} - -SEXP FRAME(SEXP x) { - return unimplemented("FRAME"); -} - -SEXP ENCLOS(SEXP x) { - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, ENCLOSMethodID, x); - return checkRef(thisenv, result); -} - -SEXP HASHTAB(SEXP x) { - return unimplemented("HASHTAB"); -} - -int ENVFLAGS(SEXP x) { - unimplemented("ENVFLAGS"); - return 0; -} - -void SET_ENVFLAGS(SEXP x, int v) { - unimplemented("SET_ENVFLAGS"); -} - -void SET_FRAME(SEXP x, SEXP v) { - unimplemented("SET_FRAME"); -} - -void SET_ENCLOS(SEXP x, SEXP v) { - unimplemented("SET_ENCLOS"); -} - -void SET_HASHTAB(SEXP x, SEXP v) { - unimplemented("SET_HASHTAB"); -} - -SEXP PRCODE(SEXP x) { - JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, PRCODEMethodID, x); -} - -SEXP PRENV(SEXP x) { - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, PRENVMethodID, x); - return checkRef(thisenv, result); -} - -SEXP PRVALUE(SEXP x) { - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, PRVALUEMethodID, x); - return checkRef(thisenv, result); -} - -int PRSEEN(SEXP x) { - JNIEnv *thisenv = getEnv(); - return (int) (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, PRSEENMethodID, x); -} - -void SET_PRSEEN(SEXP x, int v) { - unimplemented("SET_PRSEEN"); -} - -void SET_PRENV(SEXP x, SEXP v) { - unimplemented("SET_PRENV"); -} - -void SET_PRVALUE(SEXP x, SEXP v) { - unimplemented("SET_PRVALUE"); -} - -void SET_PRCODE(SEXP x, SEXP v) { - unimplemented("SET_PRCODE"); -} - -int LENGTH(SEXP x) { - TRACE(TARGp, x); - JNIEnv *thisenv = getEnv(); - return (int) (*thisenv)->CallIntMethod(thisenv, UpCallsRFFIObject, LENGTH_MethodID, x); -} - -int TRUELENGTH(SEXP x){ - unimplemented("unimplemented"); - return 0; -} - - -void SETLENGTH(SEXP x, int v){ - unimplemented("SETLENGTH"); -} - - -void SET_TRUELENGTH(SEXP x, int v){ - unimplemented("SET_TRUELENGTH"); -} - - -R_xlen_t XLENGTH(SEXP x){ - // xlength seems to be used for long vectors (no such thing in FastR at the moment) - return LENGTH(x); -} - - -R_xlen_t XTRUELENGTH(SEXP x){ - unimplemented("XTRUELENGTH"); - return 0; -} - - -int IS_LONG_VEC(SEXP x){ - unimplemented("IS_LONG_VEC"); - return 0; -} - - -int LEVELS(SEXP x){ - unimplemented("LEVELS"); - return 0; -} - - -int SETLEVELS(SEXP x, int v){ - unimplemented("SETLEVELS"); - return 0; -} - -int *LOGICAL(SEXP x){ - TRACE(TARGp, x); - JNIEnv *thisenv = getEnv(); - jint *data = (jint *) getNativeArray(thisenv, x, LGLSXP); - return data; -} - -int *INTEGER(SEXP x){ - TRACE(TARGp, x); - JNIEnv *thisenv = getEnv(); - jint *data = (jint *) getNativeArray(thisenv, x, INTSXP); - return data; -} - - -Rbyte *RAW(SEXP x){ - JNIEnv *thisenv = getEnv(); - Rbyte *data = (Rbyte*) getNativeArray(thisenv, x, RAWSXP); - return data; -} - - -double *REAL(SEXP x){ - JNIEnv *thisenv = getEnv(); - jdouble *data = (jdouble *) getNativeArray(thisenv, x, REALSXP); - return data; -} - - -Rcomplex *COMPLEX(SEXP x){ - unimplemented("COMPLEX"); - return NULL; -} - - -SEXP STRING_ELT(SEXP x, R_xlen_t i){ - TRACE(TARGpd, x, i); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, STRING_ELT_MethodID, x, i); - return checkRef(thisenv, result); -} - - -SEXP VECTOR_ELT(SEXP x, R_xlen_t i){ - TRACE(TARGpd, x, i); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, VECTOR_ELT_MethodID, x, i); - return checkRef(thisenv, result); -} - -void SET_STRING_ELT(SEXP x, R_xlen_t i, SEXP v){ - TRACE("%s(%p, %d, %p)\n", x, i, v); - JNIEnv *thisenv = getEnv(); - (*thisenv)->CallVoidMethod(thisenv, UpCallsRFFIObject, SET_STRING_ELT_MethodID, x, i, v); -} - - -SEXP SET_VECTOR_ELT(SEXP x, R_xlen_t i, SEXP v){ - TRACE("%s(%p, %d, %p)\n", x, i, v); - JNIEnv *thisenv = getEnv(); - (*thisenv)->CallVoidMethod(thisenv, UpCallsRFFIObject, SET_VECTOR_ELT_MethodID, x, i, v); - return v; -} - - -SEXP *STRING_PTR(SEXP x){ - unimplemented("STRING_PTR"); - return NULL; -} - - -SEXP * NORET VECTOR_PTR(SEXP x){ - unimplemented("VECTOR_PTR"); -} - -SEXP Rf_asChar(SEXP x){ - TRACE(TARGp, x); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_asCharMethodID, x); - return checkRef(thisenv, result); -} - -SEXP Rf_coerceVector(SEXP x, SEXPTYPE mode){ - TRACE(TARGp, x); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_coerceVectorMethodID, x, mode); - return checkRef(thisenv, result); -} - -SEXP Rf_PairToVectorList(SEXP x){ - TRACE(TARGp, x); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_PairToVectorListMethodID, x); - return checkRef(thisenv, result); -} - -SEXP Rf_VectorToPairList(SEXP x){ - TRACE(TARGp, x); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_VectorToPairListMethodID, x); - return checkRef(thisenv, result); -} - -SEXP Rf_asCharacterFactor(SEXP x){ - TRACE(TARGp, x); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_asCharacterFactorMethodID, x); - return checkRef(thisenv, result); -} - -int Rf_asLogical(SEXP x){ - TRACE(TARGp, x); - JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallIntMethod(thisenv, UpCallsRFFIObject, Rf_asLogicalMethodID, x); -} - -int Rf_asInteger(SEXP x) { - TRACE(TARGp, x); - JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallIntMethod(thisenv, UpCallsRFFIObject, Rf_asIntegerMethodID, x); -} - -double Rf_asReal(SEXP x) { - TRACE(TARGp, x); - JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallDoubleMethod(thisenv, UpCallsRFFIObject, Rf_asRealMethodID, x); -} - -Rcomplex Rf_asComplex(SEXP x){ - unimplemented("Rf_asComplex"); - Rcomplex c; return c; -} - -int TYPEOF(SEXP x) { - TRACE(TARGp, x); - JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallIntMethod(thisenv, UpCallsRFFIObject, TYPEOF_MethodID, x); -} - -SEXP ATTRIB(SEXP x) { - TRACE(TARGp, x); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, ATTRIBMethodID, x); - return checkRef(thisenv, result); -} - -int OBJECT(SEXP x){ - JNIEnv *env = getEnv(); - return (*env)->CallIntMethod(env, UpCallsRFFIObject, OBJECT_MethodID, x); -} - -int MARK(SEXP x){ - unimplemented("MARK"); - return 0; -} - -int NAMED(SEXP x){ - JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallIntMethod(thisenv, UpCallsRFFIObject, NAMED_MethodID, x); -} - -int REFCNT(SEXP x){ - unimplemented("REFCNT"); - return 0; -} - -void SET_OBJECT(SEXP x, int v){ - unimplemented("SET_OBJECT"); -} - -void SET_TYPEOF(SEXP x, int v){ - unimplemented("SET_TYPEOF"); -} - -SEXP SET_TYPEOF_FASTR(SEXP x, int v){ - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, SET_TYPEOF_FASTR_MethodID, x, v); - return checkRef(thisenv, result); -} - -void SET_NAMED(SEXP x, int v){ - JNIEnv *thisenv = getEnv(); - (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, SET_NAMED_FASTR_MethodID, x, v); -} - -void SET_ATTRIB(SEXP x, SEXP v){ - unimplemented("SET_ATTRIB"); -} - -void DUPLICATE_ATTRIB(SEXP to, SEXP from){ - JNIEnv *thisenv = getEnv(); - (*thisenv)->CallVoidMethod(thisenv, UpCallsRFFIObject, DUPLICATE_ATTRIB_MethodID, to, from); -} - -const char *R_CHAR(SEXP charsxp) { - TRACE("%s(%p)", charsxp); - JNIEnv *thisenv = getEnv(); - const char *copyChars = (const char *) getNativeArray(thisenv, charsxp, CHARSXP); - TRACE(" %s(%s)\n", copyChars); - return copyChars; -} - -void R_qsort_I (double *v, int *II, int i, int j) { - unimplemented("R_qsort_I"); -} - -void R_qsort_int_I(int *iv, int *II, int i, int j) { - unimplemented("R_qsort_int_I"); -} - -R_len_t R_BadLongVector(SEXP x, const char *y, int z) { - return (R_len_t) unimplemented("R_BadLongVector"); -} - -int IS_S4_OBJECT(SEXP x) { - JNIEnv *env = getEnv(); - return (*env)->CallIntMethod(env, UpCallsRFFIObject, IS_S4_OBJECTMethodID, x); -} - -void SET_S4_OBJECT(SEXP x) { - JNIEnv *env = getEnv(); - (*env)->CallVoidMethod(env, UpCallsRFFIObject, SET_S4_OBJECTMethodID, x); -} - -void UNSET_S4_OBJECT(SEXP x) { - JNIEnv *env = getEnv(); - (*env)->CallVoidMethod(env, UpCallsRFFIObject, UNSET_S4_OBJECTMethodID, x); -} - -Rboolean R_ToplevelExec(void (*fun)(void *), void *data) { - JNIEnv *env = getEnv(); - jobject handlerStacks = (*env)->CallObjectMethod(env, UpCallsRFFIObject, R_ToplevelExecMethodID); - fun(data); - (*env)->CallStaticVoidMethod(env, JNIUpCallsRFFIImplClass, restoreHandlerStacksMethodID, handlerStacks); - // TODO how do we detect error - return TRUE; -} - -SEXP R_ExecWithCleanup(SEXP (*fun)(void *), void *data, - void (*cleanfun)(void *), void *cleandata) { - return unimplemented("R_ExecWithCleanup"); -} - -/* Environment and Binding Features */ -void R_RestoreHashCount(SEXP rho) { - unimplemented("R_RestoreHashCount"); -} - -Rboolean R_IsPackageEnv(SEXP rho) { - unimplemented("R_IsPackageEnv"); -} - -SEXP R_PackageEnvName(SEXP rho) { - return unimplemented("R_PackageEnvName"); -} - -SEXP R_FindPackageEnv(SEXP info) { - return unimplemented("R_FindPackageEnv"); -} - -Rboolean R_IsNamespaceEnv(SEXP rho) { - return (Rboolean) unimplemented("R_IsNamespaceEnv"); -} - -SEXP R_NamespaceEnvSpec(SEXP rho) { - return unimplemented("R_NamespaceEnvSpec"); -} - -SEXP R_FindNamespace(SEXP info) { - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, R_FindNamespaceMethodID, info); - return checkRef(thisenv, result); -} - -void R_LockEnvironment(SEXP env, Rboolean bindings) { - unimplemented("R_LockEnvironment"); -} - -Rboolean R_EnvironmentIsLocked(SEXP env) { - unimplemented(""); -} - -void R_LockBinding(SEXP sym, SEXP env) { - unimplemented("R_LockBinding"); -} - -void R_unLockBinding(SEXP sym, SEXP env) { - unimplemented("R_unLockBinding"); -} - -void R_MakeActiveBinding(SEXP sym, SEXP fun, SEXP env) { - unimplemented("R_MakeActiveBinding"); -} - -Rboolean R_BindingIsLocked(SEXP sym, SEXP env) { - JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallIntMethod(thisenv, UpCallsRFFIObject, R_BindingIsLockedID, sym, env); -} - -Rboolean R_BindingIsActive(SEXP sym, SEXP env) { - // TODO: for now, I believe all bindings are false - return (Rboolean)0; -} - -Rboolean R_HasFancyBindings(SEXP rho) { - return (Rboolean) unimplemented("R_HasFancyBindings"); -} - -Rboolean Rf_isS4(SEXP x) { - return IS_S4_OBJECT(x); -} - -SEXP Rf_asS4(SEXP x, Rboolean b, int i) { - unimplemented("Rf_asS4"); -} - -static SEXP R_tryEvalInternal(SEXP x, SEXP y, int *ErrorOccurred, jboolean silent) { - JNIEnv *thisenv = getEnv(); - updateJObjects(thisenv); - jobject tryResult = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, R_tryEvalMethodID, x, y, (int) silent); - // If tryResult is NULL, an error occurred - if (ErrorOccurred) { - *ErrorOccurred = tryResult == NULL; - } - updateNativeArrays(thisenv); - return checkRef(thisenv, tryResult); -} - -SEXP R_tryEval(SEXP x, SEXP y, int *ErrorOccurred) { - return R_tryEvalInternal(x, y, ErrorOccurred, JNI_FALSE); -} - -SEXP R_tryEvalSilent(SEXP x, SEXP y, int *ErrorOccurred) { - return R_tryEvalInternal(x, y, ErrorOccurred, JNI_TRUE); -} - -double R_atof(const char *str) { - unimplemented("R_atof"); - return 0; -} - -double R_strtod(const char *c, char **end) { - unimplemented("R_strtod"); - return 0; -} - -SEXP R_PromiseExpr(SEXP x) { - JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, R_PromiseExprMethodID, x); -} - -SEXP R_ClosureExpr(SEXP x) { - return unimplemented("R_ClosureExpr"); -} - -SEXP R_forceAndCall(SEXP e, int n, SEXP rho) { - return unimplemented("R_forceAndCall"); -} - -SEXP R_MakeExternalPtr(void *p, SEXP tag, SEXP prot) { - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, R_MakeExternalPtrMethodID, (jlong) p, tag, prot); - return checkRef(thisenv, result); -} - -void *R_ExternalPtrAddr(SEXP s) { - JNIEnv *thisenv = getEnv(); - return (void *) (*thisenv)->CallLongMethod(thisenv, UpCallsRFFIObject, R_ExternalPtrAddrMethodID, s); -} - -SEXP R_ExternalPtrTag(SEXP s) { - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, R_ExternalPtrTagMethodID, s); - return checkRef(thisenv, result); -} - -SEXP R_ExternalPtrProt(SEXP s) { - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, R_ExternalPtrProtectedMethodID, s); - return checkRef(thisenv, result); -} - -void R_SetExternalPtrAddr(SEXP s, void *p) { - JNIEnv *thisenv = getEnv(); - (*thisenv)->CallVoidMethod(thisenv, UpCallsRFFIObject, R_SetExternalPtrAddrMethodID, s, (jlong) p); -} - -void R_SetExternalPtrTag(SEXP s, SEXP tag) { - JNIEnv *thisenv = getEnv(); - (*thisenv)->CallVoidMethod(thisenv, UpCallsRFFIObject, R_SetExternalPtrTagMethodID, s, tag); -} - -void R_SetExternalPtrProtected(SEXP s, SEXP p) { - JNIEnv *thisenv = getEnv(); - (*thisenv)->CallVoidMethod(thisenv, UpCallsRFFIObject, R_SetExternalPtrProtMethodID, s, p); -} - -void R_ClearExternalPtr(SEXP s) { - R_SetExternalPtrAddr(s, NULL); -} - -void R_RegisterFinalizer(SEXP s, SEXP fun) { - // TODO implement, but not fail for now -} -void R_RegisterCFinalizer(SEXP s, R_CFinalizer_t fun) { - // TODO implement, but not fail for now -} - -void R_RegisterFinalizerEx(SEXP s, SEXP fun, Rboolean onexit) { - // TODO implement, but not fail for now - -} - -void R_RegisterCFinalizerEx(SEXP s, R_CFinalizer_t fun, Rboolean onexit) { - // TODO implement, but not fail for now -} - -void R_RunPendingFinalizers(void) { - // TODO implement, but not fail for now -} - -SEXP R_MakeWeakRef(SEXP key, SEXP val, SEXP fin, Rboolean onexit) { - unimplemented("R_MakeWeakRef"); -} - -SEXP R_MakeWeakRefC(SEXP key, SEXP val, R_CFinalizer_t fin, Rboolean onexit) { - unimplemented("R_MakeWeakRefC"); -} - -SEXP R_WeakRefKey(SEXP w) { - unimplemented("R_WeakRefKey"); -} - -SEXP R_WeakRefValue(SEXP w) { - unimplemented("R_WeakRefValue"); -} - -void R_RunWeakRefFinalizer(SEXP w) { - // TODO implement, but not fail for now -} - -SEXP R_do_slot(SEXP obj, SEXP name) { - TRACE(TARGp, obj, name); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, R_do_slot_MethodID, obj, name); - return checkRef(thisenv, result); -} - -SEXP R_do_slot_assign(SEXP obj, SEXP name, SEXP value) { // Same like R_set_slot - TRACE(TARGp, obj, name, value); - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, R_do_slot_assign_MethodID, obj, name, value); - return checkRef(thisenv, result); -} - -int R_has_slot(SEXP obj, SEXP name) { - return (int) unimplemented("R_has_slot"); -} - -SEXP R_do_MAKE_CLASS(const char *what) { - JNIEnv *thisenv = getEnv(); - jstring string = (*thisenv)->NewStringUTF(thisenv, what); - return (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, R_do_MAKE_CLASS_MethodID, string); -} - -SEXP R_getClassDef (const char *what) { - return unimplemented("R_getClassDef"); -} - -SEXP R_do_new_object(SEXP class_def) { - JNIEnv *thisenv = getEnv(); - SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, R_do_new_object_MethodID, class_def); - return checkRef(thisenv, result); -} - -SEXPTYPE Rf_str2type(const char *name) { - JNIEnv *thisenv = getEnv(); - jstring jsName = (*thisenv)->NewStringUTF(thisenv, name); - return (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_str2type_MethodID, jsName); -} - -static SEXP jniGetMethodsNamespace() { - JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, R_MethodsNamespaceMethodID); -} - -int R_check_class_etc (SEXP x, const char **valid) { - return R_check_class_etc_helper(x, valid, jniGetMethodsNamespace); -} - -SEXP R_PreserveObject_FASTR(SEXP x) { - // convert to a JNI global ref until explicitly released - return createGlobalRef(getEnv(), x, 0); -} - -void R_ReleaseObject(SEXP x) { - releaseGlobalRef(getEnv(), x); -} - -void R_dot_Last(void) { - unimplemented("R_dot_Last"); -} - - -Rboolean R_compute_identical(SEXP x, SEXP y, int flags) { - JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallIntMethod(thisenv, UpCallsRFFIObject, R_compute_identicalMethodID, x, y, flags); -} - -void Rf_copyListMatrix(SEXP s, SEXP t, Rboolean byrow) { - JNIEnv *thisenv = getEnv(); - (*thisenv)->CallIntMethod(thisenv, UpCallsRFFIObject, Rf_copyListMatrixMethodID, s, t, byrow); -} - -void Rf_copyMatrix(SEXP s, SEXP t, Rboolean byrow) { - JNIEnv *thisenv = getEnv(); - (*thisenv)->CallIntMethod(thisenv, UpCallsRFFIObject, Rf_copyMatrixMethodID, s, t, byrow); -} diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Utils.c b/com.oracle.truffle.r.native/fficall/src/jni/Utils.c deleted file mode 100644 index a67edcbc049ce5caf8a800043702e8993eb2b7a9..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jni/Utils.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include <rffiutils.h> - -void R_CheckStack(void) { - // TODO: check for stack overflow - // ignored -} - -void R_CheckStack2(size_t extra) { - // TODO: check for stack overflow - // ignored -} - -void R_CheckUserInterrupt(void) { - // ignored -} - -void Rf_onintr() -{ - // TODO: implement interrupt handling, signal errors - // ignored -} diff --git a/com.oracle.truffle.r.native/fficall/src/jni/appl_rffi.c b/com.oracle.truffle.r.native/fficall/src/jni/appl_rffi.c deleted file mode 100644 index c47930bf89edfdb2e9eacd44b206bb5c8baf091e..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jni/appl_rffi.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include <rffiutils.h> - -extern void dqrdc2_(double *x, int *ldx, int *n, int *p, double *tol, int *rank, double *qraux, int* pivot, double *work); -extern void dqrcf_(double *x, int *n, int *k, double *qraux, double *y, int *ny, double *b, int* info); -extern void dqrls_(double *x, int *n, int *p, double *y, int *ny, double *tol, double *b, double *rsd, double *qty, int *k, int *jpvt, double *qraux, double *work); -extern void dqrqty_(double *x, int *n, int *k, double *qraux, double *y, int *ny, double *qty); -extern void dqrqy_(double *x, int *n, int *k, double *qraux, double *y, int *ny, double *qy); -extern void dqrrsd_(double *x, int *n, int *k, double *qraux, double *y, int *ny, double *rsd); -extern void dqrxb_(double *x, int *n, int *k, double *qraux, double *y, int *ny, double *xb); - -JNIEXPORT void JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1RAppl_native_1dqrdc2(JNIEnv *env, jclass c, - jdoubleArray jx, jint ldx, jint n, jint p, jdouble tol, jintArray jrank, jdoubleArray jqraux, - jintArray jpivot, jdoubleArray jwork) { - double *x = (*env)->GetPrimitiveArrayCritical(env, jx, NULL); - int *rank = (*env)->GetPrimitiveArrayCritical(env, jrank, NULL); - double *qraux = (*env)->GetPrimitiveArrayCritical(env, jqraux, NULL); - int *pivot = (*env)->GetPrimitiveArrayCritical(env, jpivot, NULL); - double *work = (*env)->GetPrimitiveArrayCritical(env, jwork, NULL); - dqrdc2_(x, &ldx, &n, &p, &tol, rank, qraux, pivot, work); - (*env)->ReleasePrimitiveArrayCritical(env, jx, x, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jrank, rank, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jqraux, qraux, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jpivot, pivot, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jwork, work, 0); -} - -JNIEXPORT void JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1RAppl_native_1dqrcf(JNIEnv *env, jclass c, - jdoubleArray jx, jint n, jint k, jdoubleArray jqraux, jdoubleArray jy, jint ny, jdoubleArray jb, jintArray jinfo) { - double *x = (*env)->GetPrimitiveArrayCritical(env, jx, NULL); - double *qraux = (*env)->GetPrimitiveArrayCritical(env, jqraux, NULL); - double *y = (*env)->GetPrimitiveArrayCritical(env, jy, NULL); - double *b = (*env)->GetPrimitiveArrayCritical(env, jb, NULL); - int *info = (*env)->GetPrimitiveArrayCritical(env, jinfo, NULL); - dqrcf_(x, &n, &k, qraux, y, &ny, b, info); - (*env)->ReleasePrimitiveArrayCritical(env, jx, x, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jqraux, qraux, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jy, y, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jb, b, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jinfo, info, 0); -} - -JNIEXPORT void JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1RAppl_native_1dqrls(JNIEnv *env, jclass c, - jdoubleArray jx, int n, int p, jdoubleArray jy, int ny, double tol, jdoubleArray jb, - jdoubleArray jrsd, jdoubleArray jqty, jintArray jk, jintArray jjpvt, jdoubleArray jqraux, jdoubleArray jwork) { - double *x = (*env)->GetPrimitiveArrayCritical(env, jx, NULL); - double *y = (*env)->GetPrimitiveArrayCritical(env, jy, NULL); - double *b = (*env)->GetPrimitiveArrayCritical(env, jb, NULL); - double *rsd = (*env)->GetPrimitiveArrayCritical(env, jrsd, NULL); - double *qty = (*env)->GetPrimitiveArrayCritical(env, jqty, NULL); - int *k = (*env)->GetPrimitiveArrayCritical(env, jk, NULL); - int *jpvt = (*env)->GetPrimitiveArrayCritical(env, jjpvt, NULL); - double *qraux = (*env)->GetPrimitiveArrayCritical(env, jqraux, NULL); - double *work = (*env)->GetPrimitiveArrayCritical(env, jwork, NULL); - dqrls_(x, &n, &p, y, &ny, &tol, b, rsd, qty, k, jpvt, qraux, work); - (*env)->ReleasePrimitiveArrayCritical(env, jx, x, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jy, y, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jb, b, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jrsd, rsd, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jqty, qty, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jk, k, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jjpvt, jpvt, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jqraux, qraux, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jwork, work, 0); -} - -JNIEXPORT void JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1RAppl_native_1dqrqty(JNIEnv *env, jclass c, - jdoubleArray jx, int n, int k, jdoubleArray jqraux, jdoubleArray jy, int ny, jdoubleArray jqty) { - double *x = (*env)->GetPrimitiveArrayCritical(env, jx, NULL); - double *qraux = (*env)->GetPrimitiveArrayCritical(env, jqraux, NULL); - double *y = (*env)->GetPrimitiveArrayCritical(env, jy, NULL); - double *qty = (*env)->GetPrimitiveArrayCritical(env, jqty, NULL); - dqrqty_(x, &n, &k, qraux, y, &ny, qty); - (*env)->ReleasePrimitiveArrayCritical(env, jx, x, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jqraux, qraux, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jy, y, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jqty, qty, 0); -} - -JNIEXPORT void JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1RAppl_native_1dqrqy(JNIEnv *env, jclass c, - jdoubleArray jx, int n, int k, jdoubleArray jqraux, jdoubleArray jy, int ny, jdoubleArray jqy) { - double *x = (*env)->GetPrimitiveArrayCritical(env, jx, NULL); - double *qraux = (*env)->GetPrimitiveArrayCritical(env, jqraux, NULL); - double *y = (*env)->GetPrimitiveArrayCritical(env, jy, NULL); - double *qy = (*env)->GetPrimitiveArrayCritical(env, jqy, NULL); - dqrqy_(x, &n, &k, qraux, y, &ny, qy); - (*env)->ReleasePrimitiveArrayCritical(env, jx, x, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jqraux, qraux, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jy, y, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jqy, qy, 0); -} - -JNIEXPORT void JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1RAppl_native_1dqrrsd(JNIEnv *env, jclass c, - jdoubleArray jx, int n, int k, jdoubleArray jqraux, jdoubleArray jy, int ny, jdoubleArray jrsd) { - double *x = (*env)->GetPrimitiveArrayCritical(env, jx, NULL); - double *qraux = (*env)->GetPrimitiveArrayCritical(env, jqraux, NULL); - double *y = (*env)->GetPrimitiveArrayCritical(env, jy, NULL); - double *rsd = (*env)->GetPrimitiveArrayCritical(env, jrsd, NULL); - dqrrsd_(x, &n, &k, qraux, y, &ny, rsd); - (*env)->ReleasePrimitiveArrayCritical(env, jx, x, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jqraux, qraux, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jy, y, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jrsd, rsd, 0); -} - -JNIEXPORT void JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1RAppl_native_1dqrxb(JNIEnv *env, jclass c, - jdoubleArray jx, int n, int k, jdoubleArray jqraux, jdoubleArray jy, int ny, jdoubleArray jxb) { - double *x = (*env)->GetPrimitiveArrayCritical(env, jx, NULL); - double *qraux = (*env)->GetPrimitiveArrayCritical(env, jqraux, NULL); - double *y = (*env)->GetPrimitiveArrayCritical(env, jy, NULL); - double *xb = (*env)->GetPrimitiveArrayCritical(env, jxb, NULL); - dqrxb_(x, &n, &k, qraux, y, &ny, xb); - (*env)->ReleasePrimitiveArrayCritical(env, jx, x, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jqraux, qraux, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jy, y, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jxb, xb, 0); -} diff --git a/com.oracle.truffle.r.native/fficall/src/jni/base_rffi.c b/com.oracle.truffle.r.native/fficall/src/jni/base_rffi.c deleted file mode 100644 index 1dfb0c1fbfb2f871181cd6e38c5690ccc83a92f8..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jni/base_rffi.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// JNI implementation of BaseRFFI - -#include <rffiutils.h> - -#include <sys/types.h> -#include <unistd.h> -#include <sys/stat.h> -#include <glob.h> -#include <sys/utsname.h> - -#include <errno.h> - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Base_native_1getpid(JNIEnv *env, jclass c) { - pid_t pid = getpid(); - return (jint) pid; -} - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Base_native_1getwd(JNIEnv *env, jclass c, jbyteArray jdest, int len) { - char *dest = (*env)->GetPrimitiveArrayCritical(env, jdest, NULL); - char *r = getcwd(dest, len); - if (r == NULL) return 0; - (*env)->ReleasePrimitiveArrayCritical(env, jdest, dest, 0); - return 1; -} - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Base_native_1setwd(JNIEnv *env, jclass c, jstring jdir) { - const char *dir = (*env)->GetStringUTFChars(env, jdir, NULL); - int rc = chdir(dir); - (*env)->ReleaseStringUTFChars(env, jdir, dir); - return rc; -} - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Base_native_1mkdtemp(JNIEnv *env, jclass c, jbyteArray jtemplate) { - char *template = (char*) (*env)->GetByteArrayElements(env, jtemplate, NULL); - char *r = mkdtemp(template); - int rc = 1; - if (r == NULL) { - // printf("mkdtemp errno: %d\n", errno); - rc = 0; - } - (*env)->ReleaseByteArrayElements(env, jtemplate, (jbyte*) template, rc == 1 ? 0 : JNI_ABORT); - return rc; -} - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Base_native_1mkdir(JNIEnv *env, jclass c, jstring jdir, jint mode) { - const char *dir = (*env)->GetStringUTFChars(env, jdir, NULL); - int rc = mkdir(dir, mode); - (*env)->ReleaseStringUTFChars(env, jdir, dir); - return rc; -} - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Base_native_1chmod(JNIEnv *env, jclass c, jstring jdir, jint mode) { - const char *dir = (*env)->GetStringUTFChars(env, jdir, NULL); - int rc = chmod(dir, mode); - (*env)->ReleaseStringUTFChars(env, jdir, dir); - return rc; -} - -JNIEXPORT jlong JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Base_native_1strtol(JNIEnv *env, jclass c, jstring js, jint base, jintArray jerrno) { - const char *s = (*env)->GetStringUTFChars(env, js, NULL); - jlong rc = strtol(s, NULL, base); - if (errno) { - int *cerrno = (*env)->GetPrimitiveArrayCritical(env, jerrno, NULL); - *cerrno = errno; - (*env)->ReleasePrimitiveArrayCritical(env, jerrno, cerrno, 0); - } - (*env)->ReleaseStringUTFChars(env, js, s); - return rc; -} - -JNIEXPORT jstring JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Base_native_1readlink(JNIEnv *env, jclass c, jstring jpath, jintArray jerrno) { - const char *path = (*env)->GetStringUTFChars(env, jpath, NULL); - char buf[4096]; - int len = readlink(path, buf, 4096); - jstring result = NULL; - if (len == -1) { - int *cerrno = (*env)->GetPrimitiveArrayCritical(env, jerrno, NULL); - *cerrno = errno; - (*env)->ReleasePrimitiveArrayCritical(env, jerrno, cerrno, 0); - } else { - buf[len] = 0; - result = (*env)->NewStringUTF(env, buf); - } - (*env)->ReleaseStringUTFChars(env, jpath, path); - return result; -} - - -static jmethodID addPathID = 0; - -JNIEXPORT void JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Glob_doglob(JNIEnv *env, jobject obj, jstring pattern) { - glob_t globstruct; - - if (addPathID == 0) { - addPathID = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, obj), "addPath", "(Ljava/lang/String;)V"); - } - - const char *patternChars = (*env)->GetStringUTFChars(env, pattern, NULL); - int rc = glob(patternChars, 0, NULL, &globstruct); - if (rc == 0) { - int i; - for (i = 0; i < globstruct.gl_pathc; i++) { - char *path = globstruct.gl_pathv[i]; - jstring pathString = (*env)->NewStringUTF(env, path); - (*env)->CallVoidMethod(env, obj, addPathID, pathString); - } - } -} - -JNIEXPORT void JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1UtsName_getutsname(JNIEnv *env, jobject obj) { - struct utsname name; - - uname(&name); - jstring sysname = (*env)->NewStringUTF(env, name.sysname); - jstring release = (*env)->NewStringUTF(env, name.release); - jstring version = (*env)->NewStringUTF(env, name.version); - jstring machine = (*env)->NewStringUTF(env, name.machine); - jstring nodename = (*env)->NewStringUTF(env, name.nodename); - - jclass klass = (*env)->GetObjectClass(env, obj); - - jfieldID sysnameId = checkGetFieldID(env, klass, "sysname", "Ljava/lang/String;", 0); - jfieldID releaseId = checkGetFieldID(env, klass, "release", "Ljava/lang/String;", 0); - jfieldID versionId = checkGetFieldID(env, klass, "version", "Ljava/lang/String;", 0); - jfieldID machineId = checkGetFieldID(env, klass, "machine", "Ljava/lang/String;", 0); - jfieldID nodenameId = checkGetFieldID(env, klass, "nodename", "Ljava/lang/String;", 0); - - (*env)->SetObjectField(env, obj, sysnameId, sysname); - (*env)->SetObjectField(env, obj, releaseId, release); - (*env)->SetObjectField(env, obj, versionId, version); - (*env)->SetObjectField(env, obj, machineId, machine); - (*env)->SetObjectField(env, obj, nodenameId, nodename); - -} diff --git a/com.oracle.truffle.r.native/fficall/src/jni/c_rffi.c b/com.oracle.truffle.r.native/fficall/src/jni/c_rffi.c deleted file mode 100644 index c4f9325efeaa0e4b01ac1e58a88b796c9610bcd7..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jni/c_rffi.c +++ /dev/null @@ -1,1011 +0,0 @@ -/* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include <rffiutils.h> -#include <stdbool.h> - -static jclass intArrayClass; -static jclass doubleArrayClass; - -void init_c(JNIEnv *env) { - intArrayClass = checkFindClass(env, "[I"); - doubleArrayClass = checkFindClass(env, "[D"); -} - -typedef void (*c0func)(); -typedef void (*c1func)(void *arg1); -typedef void (*c2func)(void *arg1, void *arg2); -typedef void (*c3func)(void *arg1, void *arg2, void *arg3); -typedef void (*c4func)(void *arg1, void *arg2, void *arg3, void *arg4); -typedef void (*c5func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5); -typedef void (*c6func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6); -typedef void (*c7func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7); -typedef void (*c8func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8); -typedef void (*c9func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9); -typedef void (*c10func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10); -typedef void (*c11func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11); -typedef void (*c12func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12); -typedef void (*c13func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13); -typedef void (*c14func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14); -typedef void (*c15func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15); -typedef void (*c16func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16); -typedef void (*c17func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17); -typedef void (*c18func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18); -typedef void (*c19func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19); -typedef void (*c20func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20); -typedef void (*c21func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21); -typedef void (*c22func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22); -typedef void (*c23func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23); -typedef void (*c24func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24); -typedef void (*c25func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25); -typedef void (*c26func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26); -typedef void (*c27func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27); -typedef void (*c28func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28); -typedef void (*c29func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29); -typedef void (*c30func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30); -typedef void (*c31func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31); -typedef void (*c32func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32); -typedef void (*c33func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33); -typedef void (*c34func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34); -typedef void (*c35func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35); -typedef void (*c36func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36); -typedef void (*c37func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37); -typedef void (*c38func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38); -typedef void (*c39func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39); -typedef void (*c40func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40); -typedef void (*c41func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41); -typedef void (*c42func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42); -typedef void (*c43func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43); -typedef void (*c44func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44); -typedef void (*c45func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45); -typedef void (*c46func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45, void *arg46); -typedef void (*c47func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45, void *arg46, void *arg47); -typedef void (*c48func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45, void *arg46, void *arg47, void *arg48); -typedef void (*c49func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45, void *arg46, void *arg47, void *arg48, - void *arg49); -typedef void (*c50func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45, void *arg46, void *arg47, void *arg48, - void *arg49, void *arg50); -typedef void (*c51func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45, void *arg46, void *arg47, void *arg48, - void *arg49, void *arg50, void *arg51); -typedef void (*c52func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45, void *arg46, void *arg47, void *arg48, - void *arg49, void *arg50, void *arg51, void *arg52); -typedef void (*c53func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45, void *arg46, void *arg47, void *arg48, - void *arg49, void *arg50, void *arg51, void *arg52, void *arg53); -typedef void (*c54func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45, void *arg46, void *arg47, void *arg48, - void *arg49, void *arg50, void *arg51, void *arg52, void *arg53, void *arg54); -typedef void (*c55func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45, void *arg46, void *arg47, void *arg48, - void *arg49, void *arg50, void *arg51, void *arg52, void *arg53, void *arg54, void *arg55); -typedef void (*c56func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45, void *arg46, void *arg47, void *arg48, - void *arg49, void *arg50, void *arg51, void *arg52, void *arg53, void *arg54, void *arg55, void *arg56); -typedef void (*c57func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45, void *arg46, void *arg47, void *arg48, - void *arg49, void *arg50, void *arg51, void *arg52, void *arg53, void *arg54, void *arg55, void *arg56, - void *arg57); -typedef void (*c58func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45, void *arg46, void *arg47, void *arg48, - void *arg49, void *arg50, void *arg51, void *arg52, void *arg53, void *arg54, void *arg55, void *arg56, - void *arg57, void *arg58); -typedef void (*c59func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45, void *arg46, void *arg47, void *arg48, - void *arg49, void *arg50, void *arg51, void *arg52, void *arg53, void *arg54, void *arg55, void *arg56, - void *arg57, void *arg58, void *arg59); -typedef void (*c60func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45, void *arg46, void *arg47, void *arg48, - void *arg49, void *arg50, void *arg51, void *arg52, void *arg53, void *arg54, void *arg55, void *arg56, - void *arg57, void *arg58, void *arg59, void *arg60); -typedef void (*c61func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45, void *arg46, void *arg47, void *arg48, - void *arg49, void *arg50, void *arg51, void *arg52, void *arg53, void *arg54, void *arg55, void *arg56, - void *arg57, void *arg58, void *arg59, void *arg60, void *arg61); -typedef void (*c62func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45, void *arg46, void *arg47, void *arg48, - void *arg49, void *arg50, void *arg51, void *arg52, void *arg53, void *arg54, void *arg55, void *arg56, - void *arg57, void *arg58, void *arg59, void *arg60, void *arg61, void *arg62); -typedef void (*c63func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45, void *arg46, void *arg47, void *arg48, - void *arg49, void *arg50, void *arg51, void *arg52, void *arg53, void *arg54, void *arg55, void *arg56, - void *arg57, void *arg58, void *arg59, void *arg60, void *arg61, void *arg62, void *arg63); -typedef void (*c64func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45, void *arg46, void *arg47, void *arg48, - void *arg49, void *arg50, void *arg51, void *arg52, void *arg53, void *arg54, void *arg55, void *arg56, - void *arg57, void *arg58, void *arg59, void *arg60, void *arg61, void *arg62, void *arg63, void *arg64); -typedef void (*c65func)(void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, - void *arg9, void *arg10, void *arg11, void *arg12, void *arg13, void *arg14, void *arg15, void *arg16, - void *arg17, void *arg18, void *arg19, void *arg20, void *arg21, void *arg22, void *arg23, void *arg24, - void *arg25, void *arg26, void *arg27, void *arg28, void *arg29, void *arg30, void *arg31, void *arg32, - void *arg33, void *arg34, void *arg35, void *arg36, void *arg37, void *arg38, void *arg39, void *arg40, - void *arg41, void *arg42, void *arg43, void *arg44, void *arg45, void *arg46, void *arg47, void *arg48, - void *arg49, void *arg50, void *arg51, void *arg52, void *arg53, void *arg54, void *arg55, void *arg56, - void *arg57, void *arg58, void *arg59, void *arg60, void *arg61, void *arg62, void *arg63, void *arg64, - void *arg65); - -static void doCall(jlong address, int len, void** cargs) { - switch (len) { - case 0: { - c0func c0 = (c0func) address; - (*c0)(); - break; - } - - case 1: { - c1func c1 = (c1func) address; - (*c1)(cargs[0]); - break; - } - - case 2: { - c2func c2 = (c2func) address; - (*c2)(cargs[0], cargs[1]); - break; - } - - case 3: { - c3func c3 = (c3func) address; - (*c3)(cargs[0], cargs[1], cargs[2]); - break; - } - - case 4: { - c4func c4 = (c4func) address; - (*c4)(cargs[0], cargs[1], cargs[2], cargs[3]); - break; - } - - case 5: { - c5func c5 = (c5func) address; - (*c5)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4]); - break; - } - - case 6: { - c6func c6 = (c6func) address; - (*c6)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5]); - break; - } - - case 7: { - c7func c7 = (c7func) address; - (*c7)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6]); - break; - } - - case 8: { - c8func c8 = (c8func) address; - (*c8)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7]); - break; - } - - case 9: { - c9func c9 = (c9func) address; - (*c9)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8]); - break; - } - - case 10: { - c10func c10 = (c10func) address; - (*c10)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9]); - break; - } - - case 11: { - c11func c11 = (c11func) address; - (*c11)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10]); - break; - } - - case 12: { - c12func c12 = (c12func) address; - (*c12)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11]); - break; - } - - case 13: { - c13func c13 = (c13func) address; - (*c13)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12]); - break; - } - - case 14: { - c14func c14 = (c14func) address; - (*c14)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13]); - break; - } - - case 15: { - c15func c15 = (c15func) address; - (*c15)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14]); - break; - } - - case 16: { - c16func c16 = (c16func) address; - (*c16)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15]); - break; - } - - case 17: { - c17func c17 = (c17func) address; - (*c17)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16]); - break; - } - - case 18: { - c18func c18 = (c18func) address; - (*c18)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17]); - break; - } - - case 19: { - c19func c19 = (c19func) address; - (*c19)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18]); - break; - } - - case 20: { - c20func c20 = (c20func) address; - (*c20)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19]); - break; - } - - case 21: { - c21func c21 = (c21func) address; - (*c21)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20]); - break; - } - - case 22: { - c22func c22 = (c22func) address; - (*c22)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21]); - break; - } - - case 23: { - c23func c23 = (c23func) address; - (*c23)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22]); - break; - } - - case 24: { - c24func c24 = (c24func) address; - (*c24)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23]); - break; - } - - case 25: { - c25func c25 = (c25func) address; - (*c25)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24]); - break; - } - - case 26: { - c26func c26 = (c26func) address; - (*c26)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25]); - break; - } - - case 27: { - c27func c27 = (c27func) address; - (*c27)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26]); - break; - } - - case 28: { - c28func c28 = (c28func) address; - (*c28)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27]); - break; - } - - case 29: { - c29func c29 = (c29func) address; - (*c29)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28]); - break; - } - - case 30: { - c30func c30 = (c30func) address; - (*c30)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29]); - break; - } - - case 31: { - c31func c31 = (c31func) address; - (*c31)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30]); - break; - } - - case 32: { - c32func c32 = (c32func) address; - (*c32)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31]); - break; - } - - case 33: { - c33func c33 = (c33func) address; - (*c33)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32]); - break; - } - - case 34: { - c34func c34 = (c34func) address; - (*c34)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33]); - break; - } - - case 35: { - c35func c35 = (c35func) address; - (*c35)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34]); - break; - } - - case 36: { - c36func c36 = (c36func) address; - (*c36)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35]); - break; - } - - case 37: { - c37func c37 = (c37func) address; - (*c37)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36]); - break; - } - - case 38: { - c38func c38 = (c38func) address; - (*c38)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37]); - break; - } - - case 39: { - c39func c39 = (c39func) address; - (*c39)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38]); - break; - } - - case 40: { - c40func c40 = (c40func) address; - (*c40)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39]); - break; - } - - case 41: { - c41func c41 = (c41func) address; - (*c41)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40]); - break; - } - - case 42: { - c42func c42 = (c42func) address; - (*c42)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41]); - break; - } - - case 43: { - c43func c43 = (c43func) address; - (*c43)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42]); - break; - } - - case 44: { - c44func c44 = (c44func) address; - (*c44)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43]); - break; - } - - case 45: { - c45func c45 = (c45func) address; - (*c45)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44]); - break; - } - - case 46: { - c46func c46 = (c46func) address; - (*c46)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44], cargs[45]); - break; - } - - case 47: { - c47func c47 = (c47func) address; - (*c47)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44], cargs[45], cargs[46]); - break; - } - - case 48: { - c48func c48 = (c48func) address; - (*c48)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44], cargs[45], cargs[46], cargs[47]); - break; - } - - case 49: { - c49func c49 = (c49func) address; - (*c49)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44], cargs[45], cargs[46], cargs[47], - cargs[48]); - break; - } - - case 50: { - c50func c50 = (c50func) address; - (*c50)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44], cargs[45], cargs[46], cargs[47], - cargs[48], cargs[49]); - break; - } - - case 51: { - c51func c51 = (c51func) address; - (*c51)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44], cargs[45], cargs[46], cargs[47], - cargs[48], cargs[49], cargs[50]); - break; - } - - case 52: { - c52func c52 = (c52func) address; - (*c52)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44], cargs[45], cargs[46], cargs[47], - cargs[48], cargs[49], cargs[50], cargs[51]); - break; - } - - case 53: { - c53func c53 = (c53func) address; - (*c53)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44], cargs[45], cargs[46], cargs[47], - cargs[48], cargs[49], cargs[50], cargs[51], cargs[52]); - break; - } - - case 54: { - c54func c54 = (c54func) address; - (*c54)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44], cargs[45], cargs[46], cargs[47], - cargs[48], cargs[49], cargs[50], cargs[51], cargs[52], cargs[53]); - break; - } - - case 55: { - c55func c55 = (c55func) address; - (*c55)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44], cargs[45], cargs[46], cargs[47], - cargs[48], cargs[49], cargs[50], cargs[51], cargs[52], cargs[53], cargs[54]); - break; - } - - case 56: { - c56func c56 = (c56func) address; - (*c56)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44], cargs[45], cargs[46], cargs[47], - cargs[48], cargs[49], cargs[50], cargs[51], cargs[52], cargs[53], cargs[54], cargs[55]); - break; - } - - case 57: { - c57func c57 = (c57func) address; - (*c57)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44], cargs[45], cargs[46], cargs[47], - cargs[48], cargs[49], cargs[50], cargs[51], cargs[52], cargs[53], cargs[54], cargs[55], - cargs[56]); - break; - } - - case 58: { - c58func c58 = (c58func) address; - (*c58)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44], cargs[45], cargs[46], cargs[47], - cargs[48], cargs[49], cargs[50], cargs[51], cargs[52], cargs[53], cargs[54], cargs[55], - cargs[56], cargs[57]); - break; - } - - case 59: { - c59func c59 = (c59func) address; - (*c59)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44], cargs[45], cargs[46], cargs[47], - cargs[48], cargs[49], cargs[50], cargs[51], cargs[52], cargs[53], cargs[54], cargs[55], - cargs[56], cargs[57], cargs[58]); - break; - } - - case 60: { - c60func c60 = (c60func) address; - (*c60)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44], cargs[45], cargs[46], cargs[47], - cargs[48], cargs[49], cargs[50], cargs[51], cargs[52], cargs[53], cargs[54], cargs[55], - cargs[56], cargs[57], cargs[58], cargs[59]); - break; - } - - case 61: { - c61func c61 = (c61func) address; - (*c61)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44], cargs[45], cargs[46], cargs[47], - cargs[48], cargs[49], cargs[50], cargs[51], cargs[52], cargs[53], cargs[54], cargs[55], - cargs[56], cargs[57], cargs[58], cargs[59], cargs[60]); - break; - } - - case 62: { - c62func c62 = (c62func) address; - (*c62)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44], cargs[45], cargs[46], cargs[47], - cargs[48], cargs[49], cargs[50], cargs[51], cargs[52], cargs[53], cargs[54], cargs[55], - cargs[56], cargs[57], cargs[58], cargs[59], cargs[60], cargs[61]); - break; - } - - case 63: { - c63func c63 = (c63func) address; - (*c63)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44], cargs[45], cargs[46], cargs[47], - cargs[48], cargs[49], cargs[50], cargs[51], cargs[52], cargs[53], cargs[54], cargs[55], - cargs[56], cargs[57], cargs[58], cargs[59], cargs[60], cargs[61], cargs[62]); - break; - } - - case 64: { - c64func c64 = (c64func) address; - (*c64)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44], cargs[45], cargs[46], cargs[47], - cargs[48], cargs[49], cargs[50], cargs[51], cargs[52], cargs[53], cargs[54], cargs[55], - cargs[56], cargs[57], cargs[58], cargs[59], cargs[60], cargs[61], cargs[62], cargs[63]); - break; - } - - case 65: { - c65func c65 = (c65func) address; - (*c65)(cargs[0], cargs[1], cargs[2], cargs[3], cargs[4], cargs[5], cargs[6], cargs[7], - cargs[8], cargs[9], cargs[10], cargs[11], cargs[12], cargs[13], cargs[14], cargs[15], - cargs[16], cargs[17], cargs[18], cargs[19], cargs[20], cargs[21], cargs[22], cargs[23], - cargs[24], cargs[25], cargs[26], cargs[27], cargs[28], cargs[29], cargs[30], cargs[31], - cargs[32], cargs[33], cargs[34], cargs[35], cargs[36], cargs[37], cargs[38], cargs[39], - cargs[40], cargs[41], cargs[42], cargs[43], cargs[44], cargs[45], cargs[46], cargs[47], - cargs[48], cargs[49], cargs[50], cargs[51], cargs[52], cargs[53], cargs[54], cargs[55], - cargs[56], cargs[57], cargs[58], cargs[59], cargs[60], cargs[61], cargs[62], cargs[63], - cargs[64]); - break; - } - } -} - -// Note: hasStrings indicates that the args array may contain 2 dimensional byte arrays, which represent string vectors. -JNIEXPORT void JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1C_c(JNIEnv *env, jclass c, jlong address, jobjectArray args, jboolean hasStrings) { - int len = (*env)->GetArrayLength(env, args); - void *cargs[len]; // pointers to primitive arrays suitable for the actual c call - jobject jarrays[len]; // jarray instances corresponding to cargs native counterparts - jobject *dim2[len]; // if corresponding jarray[i] is 2-dimensional, this holds the array of jarrays, otherwise NULL - jclass byteArrayClass = NULL; - if (hasStrings) { - byteArrayClass = (*env)->FindClass(env, "[[B"); - } - - for (int i = 0; i < len; i++) { - jarrays[i] = (*env)->GetObjectArrayElement(env, args, i); - bool isString = hasStrings && (*env)->IsInstanceOf(env, jarrays[i], byteArrayClass); - if (isString) { - int len2 = (*env)->GetArrayLength(env, jarrays[i]); - dim2[i] = calloc(sizeof(jobject), len2); - const char **strArgs = calloc(sizeof(const char*), len2); - cargs[i] = strArgs; - for (int j = 0; j < len2; j++) { - dim2[i][j] = (*env)->GetObjectArrayElement(env, jarrays[i], j); - strArgs[j] = (*env)->GetPrimitiveArrayCritical(env, dim2[i][j], NULL); - } - } else { - dim2[i] = NULL; - cargs[i] = (*env)->GetPrimitiveArrayCritical(env, jarrays[i], NULL); - } - } - - doCall(address, len, cargs); - - for (int i = 0; i < len; i++) { - if (dim2[i] != NULL) { - int len2 = (*env)->GetArrayLength(env, jarrays[i]); - const char **strArgs = (const char**) cargs[i]; - for (int j = 0; j < len2; j++) { - (*env)->ReleasePrimitiveArrayCritical(env, dim2[i][j], (void*) strArgs[j], 0); - } - free(dim2[i]); - free(cargs[i]); - } else { - (*env)->ReleasePrimitiveArrayCritical(env, jarrays[i], cargs[i], 0); - } - } -} diff --git a/com.oracle.truffle.r.native/fficall/src/jni/call_rffi.c b/com.oracle.truffle.r.native/fficall/src/jni/call_rffi.c deleted file mode 100644 index cb031ad01cace44fb384e1d4f1c7486deaa968b1..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jni/call_rffi.c +++ /dev/null @@ -1,1254 +0,0 @@ -/* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include <rffiutils.h> -#include <string.h> -#include <setjmp.h> - -// The entry point from JNI_Call that initializes the system -JNIEXPORT void JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Call_initialize(JNIEnv *env, jclass c, - jobject upCallInstance, jobjectArray initialValues) { - init_utils(env, upCallInstance); // must be first - init_variables(env, initialValues); - init_dynload(env); - init_internals(env); - init_connections(env); - init_rmath(env); - init_random(env); - init_parse(env); - init_pcre(env); - init_c(env); -} - -JNIEXPORT void JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Call_nativeSetTempDir(JNIEnv *env, jclass c, jstring tempDir) { - setTempDir(env, tempDir); -} - - -// Boilerplate methods for the actual calls - -typedef SEXP (*call0func)(); -typedef SEXP (*call1func)(SEXP arg1); -typedef SEXP (*call2func)(SEXP arg1, SEXP arg2); -typedef SEXP (*call3func)(SEXP arg1, SEXP arg2, SEXP arg3); -typedef SEXP (*call4func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4); -typedef SEXP (*call5func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5); -typedef SEXP (*call6func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6); -typedef SEXP (*call7func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7); -typedef SEXP (*call8func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8); -typedef SEXP (*call9func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, SEXP arg9); -typedef SEXP (*call10func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, SEXP arg9, SEXP arg10); -typedef SEXP (*call11func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11); -typedef SEXP (*call12func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12); -typedef SEXP (*call13func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13); -typedef SEXP (*call14func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14); -typedef SEXP (*call15func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15); -typedef SEXP (*call16func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16 - ); -typedef SEXP (*call17func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17); -typedef SEXP (*call18func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18); -typedef SEXP (*call19func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19); -typedef SEXP (*call20func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20); -typedef SEXP (*call21func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21); -typedef SEXP (*call22func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22); -typedef SEXP (*call23func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23); -typedef SEXP (*call24func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24 - ); -typedef SEXP (*call25func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25); -typedef SEXP (*call26func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26); -typedef SEXP (*call27func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27); -typedef SEXP (*call28func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28); -typedef SEXP (*call29func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29); -typedef SEXP (*call30func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30); -typedef SEXP (*call31func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31); -typedef SEXP (*call32func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32 - ); -typedef SEXP (*call33func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33); -typedef SEXP (*call34func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34); -typedef SEXP (*call35func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35); -typedef SEXP (*call36func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36); -typedef SEXP (*call37func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37); -typedef SEXP (*call38func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38); -typedef SEXP (*call39func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39); -typedef SEXP (*call40func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40 - ); -typedef SEXP (*call41func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41); -typedef SEXP (*call42func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42); -typedef SEXP (*call43func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43); -typedef SEXP (*call44func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44); -typedef SEXP (*call45func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44, SEXP arg45); -typedef SEXP (*call46func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44, SEXP arg45, SEXP arg46); -typedef SEXP (*call47func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44, SEXP arg45, SEXP arg46, SEXP arg47); -typedef SEXP (*call48func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44, SEXP arg45, SEXP arg46, SEXP arg47, SEXP arg48 - ); -typedef SEXP (*call49func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44, SEXP arg45, SEXP arg46, SEXP arg47, SEXP arg48, - SEXP arg49); -typedef SEXP (*call50func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44, SEXP arg45, SEXP arg46, SEXP arg47, SEXP arg48, - SEXP arg49, SEXP arg50); -typedef SEXP (*call51func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44, SEXP arg45, SEXP arg46, SEXP arg47, SEXP arg48, - SEXP arg49, SEXP arg50, SEXP arg51); -typedef SEXP (*call52func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44, SEXP arg45, SEXP arg46, SEXP arg47, SEXP arg48, - SEXP arg49, SEXP arg50, SEXP arg51, SEXP arg52); -typedef SEXP (*call53func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44, SEXP arg45, SEXP arg46, SEXP arg47, SEXP arg48, - SEXP arg49, SEXP arg50, SEXP arg51, SEXP arg52, SEXP arg53); -typedef SEXP (*call54func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44, SEXP arg45, SEXP arg46, SEXP arg47, SEXP arg48, - SEXP arg49, SEXP arg50, SEXP arg51, SEXP arg52, SEXP arg53, SEXP arg54); -typedef SEXP (*call55func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44, SEXP arg45, SEXP arg46, SEXP arg47, SEXP arg48, - SEXP arg49, SEXP arg50, SEXP arg51, SEXP arg52, SEXP arg53, SEXP arg54, SEXP arg55); -typedef SEXP (*call56func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44, SEXP arg45, SEXP arg46, SEXP arg47, SEXP arg48, - SEXP arg49, SEXP arg50, SEXP arg51, SEXP arg52, SEXP arg53, SEXP arg54, SEXP arg55, SEXP arg56 - ); -typedef SEXP (*call57func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44, SEXP arg45, SEXP arg46, SEXP arg47, SEXP arg48, - SEXP arg49, SEXP arg50, SEXP arg51, SEXP arg52, SEXP arg53, SEXP arg54, SEXP arg55, SEXP arg56, - SEXP arg57); -typedef SEXP (*call58func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44, SEXP arg45, SEXP arg46, SEXP arg47, SEXP arg48, - SEXP arg49, SEXP arg50, SEXP arg51, SEXP arg52, SEXP arg53, SEXP arg54, SEXP arg55, SEXP arg56, - SEXP arg57, SEXP arg58); -typedef SEXP (*call59func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44, SEXP arg45, SEXP arg46, SEXP arg47, SEXP arg48, - SEXP arg49, SEXP arg50, SEXP arg51, SEXP arg52, SEXP arg53, SEXP arg54, SEXP arg55, SEXP arg56, - SEXP arg57, SEXP arg58, SEXP arg59); -typedef SEXP (*call60func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44, SEXP arg45, SEXP arg46, SEXP arg47, SEXP arg48, - SEXP arg49, SEXP arg50, SEXP arg51, SEXP arg52, SEXP arg53, SEXP arg54, SEXP arg55, SEXP arg56, - SEXP arg57, SEXP arg58, SEXP arg59, SEXP arg60); -typedef SEXP (*call61func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44, SEXP arg45, SEXP arg46, SEXP arg47, SEXP arg48, - SEXP arg49, SEXP arg50, SEXP arg51, SEXP arg52, SEXP arg53, SEXP arg54, SEXP arg55, SEXP arg56, - SEXP arg57, SEXP arg58, SEXP arg59, SEXP arg60, SEXP arg61); -typedef SEXP (*call62func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44, SEXP arg45, SEXP arg46, SEXP arg47, SEXP arg48, - SEXP arg49, SEXP arg50, SEXP arg51, SEXP arg52, SEXP arg53, SEXP arg54, SEXP arg55, SEXP arg56, - SEXP arg57, SEXP arg58, SEXP arg59, SEXP arg60, SEXP arg61, SEXP arg62); -typedef SEXP (*call63func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44, SEXP arg45, SEXP arg46, SEXP arg47, SEXP arg48, - SEXP arg49, SEXP arg50, SEXP arg51, SEXP arg52, SEXP arg53, SEXP arg54, SEXP arg55, SEXP arg56, - SEXP arg57, SEXP arg58, SEXP arg59, SEXP arg60, SEXP arg61, SEXP arg62, SEXP arg63); -typedef SEXP (*call64func)(SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, - SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, - SEXP arg17, SEXP arg18, SEXP arg19, SEXP arg20, SEXP arg21, SEXP arg22, SEXP arg23, SEXP arg24, - SEXP arg25, SEXP arg26, SEXP arg27, SEXP arg28, SEXP arg29, SEXP arg30, SEXP arg31, SEXP arg32, - SEXP arg33, SEXP arg34, SEXP arg35, SEXP arg36, SEXP arg37, SEXP arg38, SEXP arg39, SEXP arg40, - SEXP arg41, SEXP arg42, SEXP arg43, SEXP arg44, SEXP arg45, SEXP arg46, SEXP arg47, SEXP arg48, - SEXP arg49, SEXP arg50, SEXP arg51, SEXP arg52, SEXP arg53, SEXP arg54, SEXP arg55, SEXP arg56, - SEXP arg57, SEXP arg58, SEXP arg59, SEXP arg60, SEXP arg61, SEXP arg62, SEXP arg63, SEXP arg64 - ); - -JNIEXPORT jobject JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Call_call0(JNIEnv *env, jclass c, jlong address) { - jmp_buf error_jmpbuf; - jobject result = NULL; - callEnter(env, &error_jmpbuf); - if (!setjmp(error_jmpbuf)) { - call0func call0 = (call0func) address; - result = (*call0)(); - } - callExit(env); - return result; -} - -JNIEXPORT jobject JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Call_call1(JNIEnv *env, jclass c, jlong address, jobject arg1) { - jmp_buf error_jmpbuf; - jobject result = NULL; - callEnter(env, &error_jmpbuf); - if (!setjmp(error_jmpbuf)) { - call1func call1 = (call1func) address; - result = (*call1)(checkRef(env, arg1)); - } - callExit(env); - return result; -} - -JNIEXPORT jobject JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Call_call2(JNIEnv *env, jclass c, jlong address, jobject arg1, jobject arg2) { - jmp_buf error_jmpbuf; - jobject result = NULL; - callEnter(env, &error_jmpbuf); - if (!setjmp(error_jmpbuf)) { - call2func call2 = (call2func) address; - result = (*call2)(checkRef(env, arg1), checkRef(env, arg2)); - } - callExit(env); - return result; -} - -JNIEXPORT jobject JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Call_call3(JNIEnv *env, jclass c, jlong address, jobject arg1, jobject arg2, - jobject arg3) { - jmp_buf error_jmpbuf; - jobject result = NULL; - callEnter(env, &error_jmpbuf); - if (!setjmp(error_jmpbuf)) { - call3func call3 = (call3func) address; - result = (*call3)(checkRef(env, arg1), checkRef(env, checkRef(env, arg2)), checkRef(env, arg3)); - } - callExit(env); - return result; -} - -JNIEXPORT jobject JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Call_call4(JNIEnv *env, jclass c, jlong address, jobject arg1, jobject arg2, - jobject arg3, jobject arg4) { - jmp_buf error_jmpbuf; - jobject result = NULL; - callEnter(env, &error_jmpbuf); - if (!setjmp(error_jmpbuf)) { - call4func call4 = (call4func) address; - result = (*call4)(checkRef(env, arg1), checkRef(env, arg2), checkRef(env, arg3), checkRef(env, arg4)); - } - callExit(env); - return result; -} - -JNIEXPORT jobject JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Call_call5(JNIEnv *env, jclass c, jlong address, jobject arg1, jobject arg2, - jobject arg3, jobject arg4, jobject arg5) { - jmp_buf error_jmpbuf; - jobject result = NULL; - callEnter(env, &error_jmpbuf); - if (!setjmp(error_jmpbuf)) { - call5func call5 = (call5func) address; - result = (*call5)(checkRef(env, arg1), checkRef(env, arg2), checkRef(env, arg3), checkRef(env, arg4), checkRef(env, arg5)); - } - callExit(env); - return result; -} - -JNIEXPORT jobject JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Call_call6(JNIEnv *env, jclass c, jlong address, jobject arg1, jobject arg2, - jobject arg3, jobject arg4, jobject arg5, jobject arg6) { - jmp_buf error_jmpbuf; - jobject result = NULL; - callEnter(env, &error_jmpbuf); - if (!setjmp(error_jmpbuf)) { - call6func call6 = (call6func) address; - result = (*call6)(checkRef(env, arg1), checkRef(env, arg2), checkRef(env, arg3), checkRef(env, arg4), checkRef(env, arg5), checkRef(env, arg6)); - } - callExit(env); - return result; -} - -JNIEXPORT jobject JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Call_call7(JNIEnv *env, jclass c, jlong address, jobject arg1, jobject arg2, - jobject arg3, jobject arg4, jobject arg5, jobject arg6, jobject arg7) { - jmp_buf error_jmpbuf; - jobject result = NULL; - callEnter(env, &error_jmpbuf); - if (!setjmp(error_jmpbuf)) { - call7func call7 = (call7func) address; - result = (*call7)(checkRef(env, arg1), checkRef(env, arg2), checkRef(env, arg3), checkRef(env, arg4), checkRef(env, arg5), checkRef(env, arg6), checkRef(env, arg7)); - } - callExit(env); - return result; -} - -JNIEXPORT jobject JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Call_call8(JNIEnv *env, jclass c, jlong address, jobject arg1, jobject arg2, - jobject arg3, jobject arg4, jobject arg5, jobject arg6, jobject arg7, jobject arg8) { - jmp_buf error_jmpbuf; - jobject result = NULL; - callEnter(env, &error_jmpbuf); - if (!setjmp(error_jmpbuf)) { - call8func call8 = (call8func) address; - result = (*call8)(checkRef(env, arg1), checkRef(env, arg2), checkRef(env, arg3), checkRef(env, arg4), checkRef(env, arg5), checkRef(env, arg6), checkRef(env, arg7), checkRef(env, arg8)); - } - callExit(env); - return result; -} - -JNIEXPORT jobject JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Call_call9(JNIEnv *env, jclass c, jlong address, jobject arg1, jobject arg2, - jobject arg3, jobject arg4, jobject arg5, jobject arg6, jobject arg7, jobject arg8, jobject arg9) { - jmp_buf error_jmpbuf; - jobject result = NULL; - callEnter(env, &error_jmpbuf); - if (!setjmp(error_jmpbuf)) { - call9func call9 = (call9func) address; - result = (*call9)(checkRef(env, arg1), checkRef(env, arg2), checkRef(env, arg3), checkRef(env, arg4), checkRef(env, arg5), checkRef(env, arg6), checkRef(env, arg7), checkRef(env, arg8), checkRef(env, arg9)); - } - callExit(env); - return result; -} - -JNIEXPORT jobject JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Call_call(JNIEnv *env, jclass c, jlong address, jobjectArray args) { - jmp_buf error_jmpbuf; - jobject result = NULL; - callEnter(env, &error_jmpbuf); - jsize len = (*env)->GetArrayLength(env, args); - SEXP jargs[64]; - for (int i = 0; i < len; i++) { - jargs[i] = checkRef(env, (*env)->GetObjectArrayElement(env, args, i)); - } - switch (len) { - case 10: { - if (!setjmp(error_jmpbuf)) { - call10func call10 = (call10func) address; - result = (*call10)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9]); - } - callExit(env); - return result; - } - - case 11: { - if (!setjmp(error_jmpbuf)) { - call11func call11 = (call11func) address; - result = (*call11)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10]); - } - callExit(env); - return result; - } - - case 12: { - if (!setjmp(error_jmpbuf)) { - call12func call12 = (call12func) address; - result = (*call12)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11]); - } - callExit(env); - return result; - } - - case 13: { - if (!setjmp(error_jmpbuf)) { - call13func call13 = (call13func) address; - result = (*call13)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12]); - } - callExit(env); - return result; - } - - case 14: { - if (!setjmp(error_jmpbuf)) { - call14func call14 = (call14func) address; - result = (*call14)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13]); - } - callExit(env); - return result; - } - - case 15: { - if (!setjmp(error_jmpbuf)) { - call15func call15 = (call15func) address; - result = (*call15)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14]); - } - callExit(env); - return result; - } - - case 16: { - if (!setjmp(error_jmpbuf)) { - call16func call16 = (call16func) address; - result = (*call16)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15] - ); - } - callExit(env); - return result; - } - - case 17: { - if (!setjmp(error_jmpbuf)) { - call17func call17 = (call17func) address; - result = (*call17)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16]); - } - callExit(env); - return result; - } - - case 18: { - if (!setjmp(error_jmpbuf)) { - call18func call18 = (call18func) address; - result = (*call18)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17]); - } - callExit(env); - return result; - } - - case 19: { - if (!setjmp(error_jmpbuf)) { - call19func call19 = (call19func) address; - result = (*call19)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18]); - } - callExit(env); - return result; - } - - case 20: { - if (!setjmp(error_jmpbuf)) { - call20func call20 = (call20func) address; - result = (*call20)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19]); - } - callExit(env); - return result; - } - - case 21: { - if (!setjmp(error_jmpbuf)) { - call21func call21 = (call21func) address; - result = (*call21)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20]); - } - callExit(env); - return result; - } - - case 22: { - if (!setjmp(error_jmpbuf)) { - call22func call22 = (call22func) address; - result = (*call22)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21]); - } - callExit(env); - return result; - } - - case 23: { - if (!setjmp(error_jmpbuf)) { - call23func call23 = (call23func) address; - result = (*call23)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22]); - } - callExit(env); - return result; - } - - case 24: { - if (!setjmp(error_jmpbuf)) { - call24func call24 = (call24func) address; - result = (*call24)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23] - ); - } - callExit(env); - return result; - } - - case 25: { - if (!setjmp(error_jmpbuf)) { - call25func call25 = (call25func) address; - result = (*call25)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24]); - } - callExit(env); - return result; - } - - case 26: { - if (!setjmp(error_jmpbuf)) { - call26func call26 = (call26func) address; - result = (*call26)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25]); - } - callExit(env); - return result; - } - - case 27: { - if (!setjmp(error_jmpbuf)) { - call27func call27 = (call27func) address; - result = (*call27)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26]); - } - callExit(env); - return result; - } - - case 28: { - if (!setjmp(error_jmpbuf)) { - call28func call28 = (call28func) address; - result = (*call28)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27]); - } - callExit(env); - return result; - } - - case 29: { - if (!setjmp(error_jmpbuf)) { - call29func call29 = (call29func) address; - result = (*call29)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28]); - } - callExit(env); - return result; - } - - case 30: { - if (!setjmp(error_jmpbuf)) { - call30func call30 = (call30func) address; - result = (*call30)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29]); - } - callExit(env); - return result; - } - - case 31: { - if (!setjmp(error_jmpbuf)) { - call31func call31 = (call31func) address; - result = (*call31)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30]); - } - callExit(env); - return result; - } - - case 32: { - if (!setjmp(error_jmpbuf)) { - call32func call32 = (call32func) address; - result = (*call32)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31] - ); - } - callExit(env); - return result; - } - - case 33: { - if (!setjmp(error_jmpbuf)) { - call33func call33 = (call33func) address; - result = (*call33)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32]); - } - callExit(env); - return result; - } - - case 34: { - if (!setjmp(error_jmpbuf)) { - call34func call34 = (call34func) address; - result = (*call34)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33]); - } - callExit(env); - return result; - } - - case 35: { - if (!setjmp(error_jmpbuf)) { - call35func call35 = (call35func) address; - result = (*call35)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34]); - } - callExit(env); - return result; - } - - case 36: { - if (!setjmp(error_jmpbuf)) { - call36func call36 = (call36func) address; - result = (*call36)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35]); - } - callExit(env); - return result; - } - - case 37: { - if (!setjmp(error_jmpbuf)) { - call37func call37 = (call37func) address; - result = (*call37)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36]); - } - callExit(env); - return result; - } - - case 38: { - if (!setjmp(error_jmpbuf)) { - call38func call38 = (call38func) address; - result = (*call38)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37]); - } - callExit(env); - return result; - } - - case 39: { - if (!setjmp(error_jmpbuf)) { - call39func call39 = (call39func) address; - result = (*call39)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38]); - } - callExit(env); - return result; - } - - case 40: { - if (!setjmp(error_jmpbuf)) { - call40func call40 = (call40func) address; - result = (*call40)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39] - ); - } - callExit(env); - return result; - } - - case 41: { - if (!setjmp(error_jmpbuf)) { - call41func call41 = (call41func) address; - result = (*call41)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40]); - } - callExit(env); - return result; - } - - case 42: { - if (!setjmp(error_jmpbuf)) { - call42func call42 = (call42func) address; - result = (*call42)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41]); - } - callExit(env); - return result; - } - - case 43: { - if (!setjmp(error_jmpbuf)) { - call43func call43 = (call43func) address; - result = (*call43)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42]); - } - callExit(env); - return result; - } - - case 44: { - if (!setjmp(error_jmpbuf)) { - call44func call44 = (call44func) address; - result = (*call44)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43]); - } - callExit(env); - return result; - } - - case 45: { - if (!setjmp(error_jmpbuf)) { - call45func call45 = (call45func) address; - result = (*call45)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43], jargs[44]); - } - callExit(env); - return result; - } - - case 46: { - if (!setjmp(error_jmpbuf)) { - call46func call46 = (call46func) address; - result = (*call46)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43], jargs[44], jargs[45]); - } - callExit(env); - return result; - } - - case 47: { - if (!setjmp(error_jmpbuf)) { - call47func call47 = (call47func) address; - result = (*call47)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43], jargs[44], jargs[45], jargs[46]); - } - callExit(env); - return result; - } - - case 48: { - if (!setjmp(error_jmpbuf)) { - call48func call48 = (call48func) address; - result = (*call48)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43], jargs[44], jargs[45], jargs[46], jargs[47] - ); - } - callExit(env); - return result; - } - - case 49: { - if (!setjmp(error_jmpbuf)) { - call49func call49 = (call49func) address; - result = (*call49)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43], jargs[44], jargs[45], jargs[46], jargs[47], - jargs[48]); - } - callExit(env); - return result; - } - - case 50: { - if (!setjmp(error_jmpbuf)) { - call50func call50 = (call50func) address; - result = (*call50)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43], jargs[44], jargs[45], jargs[46], jargs[47], - jargs[48], jargs[49]); - } - callExit(env); - return result; - } - - case 51: { - if (!setjmp(error_jmpbuf)) { - call51func call51 = (call51func) address; - result = (*call51)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43], jargs[44], jargs[45], jargs[46], jargs[47], - jargs[48], jargs[49], jargs[50]); - } - callExit(env); - return result; - } - - case 52: { - if (!setjmp(error_jmpbuf)) { - call52func call52 = (call52func) address; - result = (*call52)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43], jargs[44], jargs[45], jargs[46], jargs[47], - jargs[48], jargs[49], jargs[50], jargs[51]); - } - callExit(env); - return result; - } - - case 53: { - if (!setjmp(error_jmpbuf)) { - call53func call53 = (call53func) address; - result = (*call53)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43], jargs[44], jargs[45], jargs[46], jargs[47], - jargs[48], jargs[49], jargs[50], jargs[51], jargs[52]); - } - callExit(env); - return result; - } - - case 54: { - if (!setjmp(error_jmpbuf)) { - call54func call54 = (call54func) address; - result = (*call54)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43], jargs[44], jargs[45], jargs[46], jargs[47], - jargs[48], jargs[49], jargs[50], jargs[51], jargs[52], jargs[53]); - } - callExit(env); - return result; - } - - case 55: { - if (!setjmp(error_jmpbuf)) { - call55func call55 = (call55func) address; - result = (*call55)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43], jargs[44], jargs[45], jargs[46], jargs[47], - jargs[48], jargs[49], jargs[50], jargs[51], jargs[52], jargs[53], jargs[54]); - } - callExit(env); - return result; - } - - case 56: { - if (!setjmp(error_jmpbuf)) { - call56func call56 = (call56func) address; - result = (*call56)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43], jargs[44], jargs[45], jargs[46], jargs[47], - jargs[48], jargs[49], jargs[50], jargs[51], jargs[52], jargs[53], jargs[54], jargs[55] - ); - } - callExit(env); - return result; - } - - case 57: { - if (!setjmp(error_jmpbuf)) { - call57func call57 = (call57func) address; - result = (*call57)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43], jargs[44], jargs[45], jargs[46], jargs[47], - jargs[48], jargs[49], jargs[50], jargs[51], jargs[52], jargs[53], jargs[54], jargs[55], - jargs[56]); - } - callExit(env); - return result; - } - - case 58: { - if (!setjmp(error_jmpbuf)) { - call58func call58 = (call58func) address; - result = (*call58)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43], jargs[44], jargs[45], jargs[46], jargs[47], - jargs[48], jargs[49], jargs[50], jargs[51], jargs[52], jargs[53], jargs[54], jargs[55], - jargs[56], jargs[57]); - } - callExit(env); - return result; - } - - case 59: { - if (!setjmp(error_jmpbuf)) { - call59func call59 = (call59func) address; - result = (*call59)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43], jargs[44], jargs[45], jargs[46], jargs[47], - jargs[48], jargs[49], jargs[50], jargs[51], jargs[52], jargs[53], jargs[54], jargs[55], - jargs[56], jargs[57], jargs[58]); - } - callExit(env); - return result; - } - - case 60: { - if (!setjmp(error_jmpbuf)) { - call60func call60 = (call60func) address; - result = (*call60)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43], jargs[44], jargs[45], jargs[46], jargs[47], - jargs[48], jargs[49], jargs[50], jargs[51], jargs[52], jargs[53], jargs[54], jargs[55], - jargs[56], jargs[57], jargs[58], jargs[59]); - } - callExit(env); - return result; - } - - case 61: { - if (!setjmp(error_jmpbuf)) { - call61func call61 = (call61func) address; - result = (*call61)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43], jargs[44], jargs[45], jargs[46], jargs[47], - jargs[48], jargs[49], jargs[50], jargs[51], jargs[52], jargs[53], jargs[54], jargs[55], - jargs[56], jargs[57], jargs[58], jargs[59], jargs[60]); - } - callExit(env); - return result; - } - - case 62: { - if (!setjmp(error_jmpbuf)) { - call62func call62 = (call62func) address; - result = (*call62)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43], jargs[44], jargs[45], jargs[46], jargs[47], - jargs[48], jargs[49], jargs[50], jargs[51], jargs[52], jargs[53], jargs[54], jargs[55], - jargs[56], jargs[57], jargs[58], jargs[59], jargs[60], jargs[61]); - } - callExit(env); - return result; - } - - case 63: { - if (!setjmp(error_jmpbuf)) { - call63func call63 = (call63func) address; - result = (*call63)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43], jargs[44], jargs[45], jargs[46], jargs[47], - jargs[48], jargs[49], jargs[50], jargs[51], jargs[52], jargs[53], jargs[54], jargs[55], - jargs[56], jargs[57], jargs[58], jargs[59], jargs[60], jargs[61], jargs[62]); - } - callExit(env); - return result; - } - - case 64: { - if (!setjmp(error_jmpbuf)) { - call64func call64 = (call64func) address; - result = (*call64)(jargs[0], jargs[1], jargs[2], jargs[3], jargs[4], jargs[5], jargs[6], jargs[7], - jargs[8], jargs[9], jargs[10], jargs[11], jargs[12], jargs[13], jargs[14], jargs[15], - jargs[16], jargs[17], jargs[18], jargs[19], jargs[20], jargs[21], jargs[22], jargs[23], - jargs[24], jargs[25], jargs[26], jargs[27], jargs[28], jargs[29], jargs[30], jargs[31], - jargs[32], jargs[33], jargs[34], jargs[35], jargs[36], jargs[37], jargs[38], jargs[39], - jargs[40], jargs[41], jargs[42], jargs[43], jargs[44], jargs[45], jargs[46], jargs[47], - jargs[48], jargs[49], jargs[50], jargs[51], jargs[52], jargs[53], jargs[54], jargs[55], - jargs[56], jargs[57], jargs[58], jargs[59], jargs[60], jargs[61], jargs[62], jargs[63] - ); - } - callExit(env); - return result; - } - - - default: - (*env)->FatalError(env, "call(JNI): unimplemented number of arguments"); - return NULL; - } -} - -typedef void (*callVoid1func)(SEXP arg1); - -JNIEXPORT void JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Call_callVoid1(JNIEnv *env, jclass c, jlong address, jobject arg1) { - jmp_buf error_jmpbuf; - callEnter(env, &error_jmpbuf); - if (!setjmp(error_jmpbuf)) { - callVoid1func call1 = (callVoid1func) address; - (*call1)(arg1); - } - callExit(env); -} - -typedef void (*callVoid0func)(); - -JNIEXPORT void JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Call_callVoid0(JNIEnv *env, jclass c, jlong address) { - jmp_buf error_jmpbuf; - callEnter(env, &error_jmpbuf); - if (!setjmp(error_jmpbuf)) { - callVoid0func call1 = (callVoid0func) address; - (*call1)(); - } - callExit(env); -} - - - diff --git a/com.oracle.truffle.r.native/fficall/src/jni/lapack_rffi.c b/com.oracle.truffle.r.native/fficall/src/jni/lapack_rffi.c deleted file mode 100644 index 83606709d3d4a3d85239ff64ec81144e25566b74..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jni/lapack_rffi.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include <rffiutils.h> - -extern void ilaver_(int *major, int *minor, int *patch); - -JNIEXPORT void JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Lapack_native_1ilaver(JNIEnv *env, jclass klass, jintArray jversion) { - int major; - int minor; - int patch; - ilaver_(&major, &minor, &patch); - int *version = (*env)->GetPrimitiveArrayCritical(env, jversion, NULL); - version[0] = major; - version[1] = minor; - version[2] = patch; - (*env)->ReleasePrimitiveArrayCritical(env, jversion, version, 0); -} - - -extern int dgeev_(char *jobVL, char *jobVR, int *n, double *a, int *lda, double *wr, double *wi, double *vl, int *ldvl, double *vr, int *ldvr, double *work, int *lwork, int *info); - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Lapack_native_1dgeev(JNIEnv *env, jclass klass, - char jobVL, char jobVR, int n, jdoubleArray ja, int lda, jdoubleArray jwr, jdoubleArray jwi, jdoubleArray jvl, int ldvl, jdoubleArray jvr, int ldvr, jdoubleArray jwork, int lwork) { - double *a = (*env)->GetPrimitiveArrayCritical(env, ja, NULL); - double *wr = (*env)->GetPrimitiveArrayCritical(env, jwr, NULL); - double *wi = (*env)->GetPrimitiveArrayCritical(env, jwi, NULL); - double *vl = jvl == NULL ? NULL : (*env)->GetPrimitiveArrayCritical(env, jvl, NULL); - double *vr = jvr == NULL ? NULL : (*env)->GetPrimitiveArrayCritical(env, jvr, NULL); - double *work = (*env)->GetPrimitiveArrayCritical(env, jwork, NULL); - int info; - dgeev_(&jobVL, &jobVR, &n, a, &lda, wr, wi, vl, &ldvl, vr, &ldvr, work, &lwork, &info); - (*env)->ReleasePrimitiveArrayCritical(env, ja, a, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jwr, wr, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jwi, wi, 0); - if (jvl != NULL) (*env)->ReleasePrimitiveArrayCritical(env, jvl, vl, 0); - if (jvr != NULL) (*env)->ReleasePrimitiveArrayCritical(env, jvr, vr, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jwork, work, 0); - return info; -} - -extern int dgeqp3_(int *m, int *n, double *a, int *lda, int *jpvt, double *tau, double *work, int *lwork, int *info); - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Lapack_native_1dgeqp3(JNIEnv *env, jclass klass, - int m, int n, jdoubleArray ja, int lda, jintArray jjpvt, jdoubleArray jtau, jdoubleArray jwork, int lwork) { - double *a = (*env)->GetPrimitiveArrayCritical(env, ja, NULL); - int *jpvt = (*env)->GetPrimitiveArrayCritical(env, jjpvt, NULL); - double *tau = (*env)->GetPrimitiveArrayCritical(env, jtau, NULL); - double *work = (*env)->GetPrimitiveArrayCritical(env, jwork, NULL); - int info; - dgeqp3_(&m, &n, a, &lda, jpvt, tau, work, &lwork, &info); - (*env)->ReleasePrimitiveArrayCritical(env, ja, a, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jjpvt, jpvt, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jtau, tau, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jwork, work, 0); - return info; -} - -extern int dormqr_(char *side, char *trans, int *m, int *n, int *k, double *a, int *lda, double *tau, double *c, int *ldc, double *work, int *lwork, int *info); - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Lapack_native_1dormqr(JNIEnv *env, jclass klass, - char side, char trans, int m, int n, int k, jdoubleArray ja, int lda, jdoubleArray jtau, jdoubleArray jc, int ldc, jdoubleArray jwork, int lwork) { - double *a = (*env)->GetPrimitiveArrayCritical(env, ja, NULL); - double *tau = (*env)->GetPrimitiveArrayCritical(env, jtau, NULL); - double *c = (*env)->GetPrimitiveArrayCritical(env, jc, NULL); - double *work = (*env)->GetPrimitiveArrayCritical(env, jwork, NULL); - int info; - dormqr_(&side, &trans, &m, &n, &k, a, &lda, tau, c, &ldc, work, &lwork, &info); - (*env)->ReleasePrimitiveArrayCritical(env, ja, a, JNI_ABORT); - (*env)->ReleasePrimitiveArrayCritical(env, jtau, tau, JNI_ABORT); - (*env)->ReleasePrimitiveArrayCritical(env, jc, c, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jwork, work, 0); - return info; -} - -extern int dtrtrs_(char *uplo, char *trans, char *diag, int *n, int *nrhs, double *a, int *lda, double *b, int *ldb, int *info); - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Lapack_native_1dtrtrs(JNIEnv *env, jclass klass, - char uplo, char trans, char diag, int n, int nrhs, jdoubleArray ja, int lda, jdoubleArray jb, int ldb) { - double *a = (*env)->GetPrimitiveArrayCritical(env, ja, NULL); - double *b = (*env)->GetPrimitiveArrayCritical(env, jb, NULL); - int info; - dtrtrs_(&uplo, &trans, &diag, &n, &nrhs, a, &lda, b, &ldb, &info); - (*env)->ReleasePrimitiveArrayCritical(env, ja, a, JNI_ABORT); - (*env)->ReleasePrimitiveArrayCritical(env, jb, b, 0); - return info; -} - -extern int dgetrf_(int *m, int *n, double *a, int *lda, int *ipiv, int *info); - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Lapack_native_1dgetrf(JNIEnv *env, jclass klass, - int m, int n, jdoubleArray ja, int lda, jintArray jipiv) { - double *a = (*env)->GetPrimitiveArrayCritical(env, ja, NULL); - int *ipiv = (*env)->GetPrimitiveArrayCritical(env, jipiv, NULL); - int info; - dgetrf_(&m, &n, a, &lda, ipiv, &info); - (*env)->ReleasePrimitiveArrayCritical(env, ja, a, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jipiv, ipiv, 0); - return info; -} - -extern int dpotrf_(char *uplo, int *n, double *a, int *lda, int *info); - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Lapack_native_1dpotrf(JNIEnv *env, jclass klass, - char uplo, int n, jdoubleArray ja, int lda) { - double *a = (*env)->GetPrimitiveArrayCritical(env, ja, NULL); - int info; - dpotrf_(&uplo, &n, a, &lda, &info); - (*env)->ReleasePrimitiveArrayCritical(env, ja, a, 0); - return info; -} - -extern int dpotri_(char *uplo, int *n, double *a, int *lda, int *info); - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Lapack_native_1dpotri(JNIEnv *env, jclass klass, - char uplo, int n, jdoubleArray ja, int lda) { - double *a = (*env)->GetPrimitiveArrayCritical(env, ja, NULL); - int info; - dpotri_(&uplo, &n, a, &lda, &info); - (*env)->ReleasePrimitiveArrayCritical(env, ja, a, 0); - return info; -} - -extern int dpstrf_(char *uplo, int *n, double *a, int *lda, int *piv, int *rank, double *tol, double *work, int *info); - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Lapack_native_1dpstrf(JNIEnv *env, jclass klass, - char uplo, int n, jdoubleArray ja, int lda, jintArray jpiv, jintArray jrank, double tol, jdoubleArray jwork) { - double *a = (*env)->GetPrimitiveArrayCritical(env, ja, NULL); - int *piv = (*env)->GetPrimitiveArrayCritical(env, jpiv, NULL); - int *rank = (*env)->GetPrimitiveArrayCritical(env, jrank, NULL); - double *work = (*env)->GetPrimitiveArrayCritical(env, jwork, NULL); - int info; - dpstrf_(&uplo, &n, a, &lda, piv, rank, &tol, work, &info); - (*env)->ReleasePrimitiveArrayCritical(env, ja, a, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jpiv, piv, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jrank, rank, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jwork, work, 0); - return info; -} - -extern int dgesv_(int *n, int *nrhs, double *a, int *lda, int *ipiv, double *b, int *ldb, int *info); - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Lapack_native_1dgesv(JNIEnv *env, jclass klass, - int n, int nrhs, jdoubleArray ja, int lda, jintArray jipiv, jdoubleArray jb, int ldb) { - double *a = (*env)->GetPrimitiveArrayCritical(env, ja, NULL); - int *ipiv = (*env)->GetPrimitiveArrayCritical(env, jipiv, NULL); - double *b = (*env)->GetPrimitiveArrayCritical(env, jb, NULL); - int info; - dgesv_(&n, &nrhs, a, &lda, ipiv, b, &ldb, &info); - (*env)->ReleasePrimitiveArrayCritical(env, ja, a, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jipiv, ipiv, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jb, b, 0); - return info; -} - -extern double dlange_(char *norm, int *m, int *n, double *a, int *lda, double *work); - -JNIEXPORT jdouble JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Lapack_native_1dlange(JNIEnv *env, jclass klass, - char norm, int m, int n, jdoubleArray ja, int lda, jdoubleArray jwork) { - double *a = (*env)->GetPrimitiveArrayCritical(env, ja, NULL); - double *work = jwork == NULL ? NULL : (*env)->GetPrimitiveArrayCritical(env, jwork, NULL); - double info = dlange_(&norm, &m, &n, a, &lda, work); - (*env)->ReleasePrimitiveArrayCritical(env, ja, a, JNI_ABORT); - if (jwork != NULL) (*env)->ReleasePrimitiveArrayCritical(env, jwork, work, JNI_ABORT); - return info; -} - -extern int dgecon_(char *norm, int *n, double *a, int *lda, double *anorm, double *rcond, double *work, int *iwork, int *info); - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Lapack_native_1dgecon(JNIEnv *env, jclass klass, - char norm, int n, jdoubleArray ja, int lda, double anorm, jdoubleArray jrcond, jdoubleArray jwork, jintArray jiwork) { - double *a = (*env)->GetPrimitiveArrayCritical(env, ja, NULL); - double *rcond = (*env)->GetPrimitiveArrayCritical(env, jrcond, NULL); - double *work = (*env)->GetPrimitiveArrayCritical(env, jwork, NULL); - int *iwork = (*env)->GetPrimitiveArrayCritical(env, jiwork, NULL); - int info; - dgecon_(&norm, &n, a, &lda, &anorm, rcond, work, iwork, &info); - (*env)->ReleasePrimitiveArrayCritical(env, ja, a, JNI_ABORT); - (*env)->ReleasePrimitiveArrayCritical(env, jrcond, rcond, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jwork, work, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jiwork, iwork, 0); - return info; -} - -extern int dsyevr_(char *jobz, char *range, char *uplo, int *n, double* a, int *lda, double *vl, double *vu, int *il, int *iu, double *abstol, int* m, double* w, - double* z, int *ldz, int* isuppz, double* work, int *lwork, int* iwork, int *liwork, int* info); - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Lapack_native_1dsyevr(JNIEnv *env, jclass klass, - char jobz, char range, char uplo, int n, jdoubleArray ja, int lda, double vl, double vu, int il, int iu, double abstol, jintArray jm, jdoubleArray jw, - jdoubleArray jz, int ldz, jintArray jisuppz, jdoubleArray jwork, int lwork, jintArray jiwork, int liwork) { - double *a = (*env)->GetPrimitiveArrayCritical(env, ja, NULL); - int *m = (*env)->GetPrimitiveArrayCritical(env, jm, NULL); - double *w = (*env)->GetPrimitiveArrayCritical(env, jw, NULL); - double *z = jz == NULL ? NULL : (*env)->GetPrimitiveArrayCritical(env, jz, NULL); - int *isuppz = (*env)->GetPrimitiveArrayCritical(env, jisuppz, NULL); - double *work = (*env)->GetPrimitiveArrayCritical(env, jwork, NULL); - int *iwork = (*env)->GetPrimitiveArrayCritical(env, jiwork, NULL); - int info; - dsyevr_(&jobz, &range, &uplo, &n, a, &lda, &vl, &vu, &il, &iu, &abstol, m, w, - z, &ldz, isuppz, work, &lwork, iwork, &liwork, &info); - (*env)->ReleasePrimitiveArrayCritical(env, ja, a, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jm, m, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jw, w, 0); - if (jz != NULL) (*env)->ReleasePrimitiveArrayCritical(env, jz, z, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jisuppz, isuppz, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jwork, work, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jiwork, iwork, 0); - return info; -} diff --git a/com.oracle.truffle.r.native/fficall/src/jni/misc_rffi.c b/com.oracle.truffle.r.native/fficall/src/jni/misc_rffi.c deleted file mode 100644 index baef3889374ddf4129114528356cc8c67532154b..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jni/misc_rffi.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include <rffiutils.h> - -JNIEXPORT jdouble JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Misc_exactSumFunc(JNIEnv *env, jclass c, jdoubleArray values, jboolean hasNa, jboolean naRm) { - jint length = (*env)->GetArrayLength(env, values); - jdouble* contents = (jdouble*) (*env)->GetPrimitiveArrayCritical(env, values, NULL); - - long double sum = 0; - int i = 0; - if (!hasNa) { - for (; i < length - 3; i+= 4) { - sum += contents[i]; - sum += contents[i + 1]; - sum += contents[i + 2]; - sum += contents[i + 3]; - } - } - for (; i < length; i++) { - jdouble value = contents[i]; - if (R_IsNA(value)) { - if (!naRm) { - (*env)->ReleasePrimitiveArrayCritical(env, values, contents, JNI_ABORT); - return R_NaReal; - } - } else { - sum += value; - } - } - - (*env)->ReleasePrimitiveArrayCritical(env, values, contents, JNI_ABORT); - return sum; -} diff --git a/com.oracle.truffle.r.native/fficall/src/jni/pcre_rffi.c b/com.oracle.truffle.r.native/fficall/src/jni/pcre_rffi.c deleted file mode 100644 index 8f804e4c4eedeab65aa4ce2393ddb13277d16aa7..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jni/pcre_rffi.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This material is distributed under the GNU General Public License - * Version 2. You may review the terms of this license at - * http://www.gnu.org/licenses/gpl-2.0.html - * - * Copyright (c) 1995, 1996 Robert Gentleman and Ross Ihaka - * Copyright (c) 1997-2015, The R Core Team - * Copyright (c) 2016, 2017, Oracle and/or its affiliates - * - * All rights reserved. - */ - -#include <rffiutils.h> - -#define PCRE_INFO_CAPTURECOUNT 2 -#define PCRE_INFO_NAMEENTRYSIZE 7 -#define PCRE_INFO_NAMECOUNT 8 -#define PCRE_INFO_NAMETABLE 9 - -char *pcre_maketables(); -void *pcre_compile(char *pattern, int options, char **errorMessage, int *errOffset, char *tables); -int pcre_exec(void *code, void *extra, char* subject, int subjectLength, int startOffset, int options, int *ovector, int ovecSize); -int pcre_fullinfo(void *code, void *extra, int what, void *where); -void pcre_free(void *code); - -jclass JNI_PCRE_ResultClass; -jmethodID ResultClassConstructorID; - -void init_pcre(JNIEnv *env) { - JNI_PCRE_ResultClass = checkFindClass(env, "com/oracle/truffle/r/runtime/ffi/PCRERFFI$Result"); - ResultClassConstructorID = checkGetMethodID(env, JNI_PCRE_ResultClass, "<init>", "(JLjava/lang/String;I)V", 0); -} - -JNIEXPORT jlong JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1PCRE_nativeMaketables(JNIEnv *env, jclass c) { - return (jlong) pcre_maketables(); -} - -JNIEXPORT jobject JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1PCRE_nativeCompile(JNIEnv *env, jclass c, jstring pattern, jint options, jlong tables) { - const char *patternChars = (*env)->GetStringUTFChars(env, pattern, NULL); - char *errorMessage; - int errOffset; - void *pcre_result = pcre_compile((char *) patternChars, options, &errorMessage, &errOffset, (char*) tables); - jstring stringErrorMessage = NULL; - if (pcre_result == NULL) { - stringErrorMessage = (*env)->NewStringUTF(env, errorMessage); - } - jobject result = (*env)->NewObject(env, JNI_PCRE_ResultClass, ResultClassConstructorID, pcre_result, stringErrorMessage, errOffset); - return result; -} - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1PCRE_nativeGetCaptureCount(JNIEnv *env, jclass c, jlong code, jlong extra) { - int captureCount; - int rc = pcre_fullinfo((void *)code, (void *)extra, PCRE_INFO_CAPTURECOUNT, &captureCount); - return rc < 0 ? rc : captureCount; -} - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1PCRE_nativeGetCaptureNames(JNIEnv *env, jclass c, jlong code, jlong extra, jobjectArray ret) { - int nameCount; - int nameEntrySize; - char* nameTable; - int res; - res = pcre_fullinfo((void *) code, (void *) extra, PCRE_INFO_NAMECOUNT, &nameCount); - if (res < 0) { - return res; - } - res = pcre_fullinfo((void *) code, (void *) extra, PCRE_INFO_NAMEENTRYSIZE, &nameEntrySize); - if (res < 0) { - return res; - } - res = pcre_fullinfo((void *) code,(void *) extra, PCRE_INFO_NAMETABLE, &nameTable); - if (res < 0) { - return res; - } - // from GNU R's grep.c - for(int i = 0; i < nameCount; i++) { - char* entry = nameTable + nameEntrySize * i; - int captureNum = (entry[0] << 8) + entry[1] - 1; - (*env)->SetObjectArrayElement(env, ret, captureNum, (*env)->NewStringUTF(env, entry + 2)); - } - return res; -} - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1PCRE_nativeExec(JNIEnv *env, jclass c, jlong code, jlong extra, jstring subject, - jint startOffset, jint options, jintArray ovector, jint ovectorLen) { - const char *subjectChars = (*env)->GetStringUTFChars(env, subject, NULL); - int subjectLength = (*env)->GetStringUTFLength(env, subject); - int* ovectorElems = (*env)->GetIntArrayElements(env, ovector, NULL); - - int rc = pcre_exec((void *) code,(void *) extra, (char *) subjectChars, subjectLength, startOffset, options, - ovectorElems, ovectorLen); - (*env)->ReleaseIntArrayElements(env, ovector, ovectorElems, 0); - (*env)->ReleaseStringUTFChars(env, subject, subjectChars); - return rc; -} diff --git a/com.oracle.truffle.r.native/fficall/src/jni/rffiutils.c b/com.oracle.truffle.r.native/fficall/src/jni/rffiutils.c deleted file mode 100644 index 0049e90276011528e5e091a589bf3388ecf676eb..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jni/rffiutils.c +++ /dev/null @@ -1,714 +0,0 @@ -/* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -#include <rffiutils.h> -#include <string.h> -#include <stdlib.h> -#include <errno.h> -#include <assert.h> - -/* - * All calls pass through one of the call(N) methods in rfficall.c, which carry the JNIEnv value, - * that needs to be saved for reuse in the many R functions such as Rf_allocVector. - * Currently only single threaded access is permitted (via a semaphore in CallRFFIWithJNI) - * so we are safe to use static variables. TODO Figure out where to store such state - * (portably) for MT use. JNI provides no help. - */ -jclass UpCallsRFFIClass; -jobject UpCallsRFFIObject; -jclass CharSXPWrapperClass; - -static JNIEnv *curenv = NULL; - -// default for trace output when enabled -FILE *traceFile = NULL; - -typedef struct globalRefTable_struct { - int permanent; - SEXP gref; // The jobject (SEXP) global ref -} GlobalRefElem; - -#define CACHED_GLOBALREFS_INITIAL_SIZE 64 -static GlobalRefElem *cachedGlobalRefs; -static int cachedGlobalRefsHwm; -static int cachedGlobalRefsLength; - -// Data structure for managing the required copying of -// Java arrays to return C arrays, e.g, int*. -// N.B. There are actually two levels to this as FastR -// wraps, e.g., int[] in an RIntVector. -typedef struct nativeArrayTable_struct { - SEXPTYPE type; - SEXP obj; // The jobject (SEXP) that data is derived from (e.g, RIntVector) - void *jArray; // the jarray corresponding to obj - void *data; // the (possibly) copied (or pinned) data from JNI GetXXXArrayElements -} NativeArrayElem; - -#define NATIVE_ARRAY_TABLE_INITIAL_SIZE 64 -// A table of vectors that have been accessed and whose contents, e.g. the actual data -// as a primitive array have been copied and handed out to the native code. -static NativeArrayElem *nativeArrayTable; -// hwm of nativeArrayTable -static int nativeArrayTableHwm; -static int nativeArrayTableLastIndex; -static int nativeArrayTableLength; -static void releaseNativeArray(JNIEnv *env, int index); -static NativeArrayElem *findNativeArray(JNIEnv *env, SEXP x); -static void updateNativeArray(JNIEnv *env, int index); - -static jfieldID CharSXPWrapperContentsFieldID; -extern jmethodID logNotCharSXPWrapperMethodID; - -static int isEmbedded = 0; -void setEmbedded() { - isEmbedded = 1; -} - -#ifdef TRACE_ENABLED -// Helper for debugging purposes: prints out (into the trace file) the java -// class name for given SEXP -static void fastRInspect(JNIEnv *env, SEXP v) { - // this invokes getClass().getName() - jclass cls = (*env)->GetObjectClass(env, v); - jmethodID getClassMethodID = checkGetMethodID(env, cls, "getClass", "()Ljava/lang/Class;", 0); - jobject classObj = (*env)->CallObjectMethod(env, v, getClassMethodID); - jclass javaClassClass = (*env)->GetObjectClass(env, classObj); - jmethodID getNameMethodID = checkGetMethodID(env, javaClassClass, "getName", "()Ljava/lang/String;", 0); - jstring nameJString = (jstring)(*env)->CallObjectMethod(env, javaClassClass, getNameMethodID); - - // This gets us the C string - const char* result = (*env)->GetStringUTFChars(env, nameJString, NULL); - fprintf(traceFile, "fastRInspect(%p): %s\n", v, result); - - // Release the memory - (*env)->ReleaseStringUTFChars(env, nameJString, result); -} -#endif - -static int isValidJNIRef(JNIEnv *env, SEXP ref) { -#if VALIDATE_REFS - return (*env)->GetObjectRefType(env, ref) != JNIInvalidRefType; -#else - return TRUE; -#endif -} - -static jboolean fast_IsSameObject(jobject a, jobject b) { - // this takes some assumptions about jni handles, but it is much faster - void** pA = (void**) a; - void** pB = (void**) b; - if (pA == NULL && pB == NULL) { - return TRUE; - } else if (pA == NULL || pB == NULL) { - return FALSE; - } else { - return *pA == *pB; - } -} - -// native down call depth, indexes nativeArrayTableHwmStack -int callDepth = 0; - -#define CALLDEPTH_STACK_SIZE 16 -static int nativeArrayTableHwmStack[CALLDEPTH_STACK_SIZE]; - -// stack of jmp_buf ptrs for non-local control transfer on error -static jmp_buf* callErrorJmpBufTable[CALLDEPTH_STACK_SIZE]; - - -void init_utils(JNIEnv *env, jobject upCallsInstance) { - curenv = env; - UpCallsRFFIClass = (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, upCallsInstance)); - UpCallsRFFIObject = (*env)->NewGlobalRef(env, upCallsInstance); - if (TRACE_ENABLED && traceFile == NULL) { - if (!isEmbedded) { - traceFile = stdout; - } else { - jclass RFFIUtilsClass = checkFindClass(env, "com/oracle/truffle/r/runtime/ffi/RFFIUtils"); - jclass FileDescriptorClass = checkFindClass(env, "java/io/FileDescriptor"); - jmethodID getTraceFileDescriptorMethodID = checkGetMethodID(env, RFFIUtilsClass, "getTraceFileDescriptor", "()Ljava/io/FileDescriptor;", 1); - // ASSUMPTION: FileDescriptor has an "fd" field - jobject tfd = (*env)->CallStaticObjectMethod(env, RFFIUtilsClass, getTraceFileDescriptorMethodID); - jfieldID fdField = checkGetFieldID(env, FileDescriptorClass, "fd", "I", 0); - int fd = (*env)->GetIntField(env, tfd, fdField); - traceFile = fdopen(fd, "w"); - if (traceFile == NULL) { - fprintf(stderr, "%s, %d", "failed to fdopen trace file on JNI side\n", errno); - exit(1); - } - // no buffering - setvbuf(traceFile, (char*) NULL, _IONBF, 0); - } - } - cachedGlobalRefs = calloc(CACHED_GLOBALREFS_INITIAL_SIZE, sizeof(GlobalRefElem)); - cachedGlobalRefsLength = CACHED_GLOBALREFS_INITIAL_SIZE; - cachedGlobalRefsHwm = 0; - nativeArrayTable = calloc(NATIVE_ARRAY_TABLE_INITIAL_SIZE, sizeof(NativeArrayElem)); - nativeArrayTableLength = NATIVE_ARRAY_TABLE_INITIAL_SIZE; - nativeArrayTableHwm = 0; - - CharSXPWrapperClass = checkFindClass(env, "com/oracle/truffle/r/runtime/ffi/CharSXPWrapper"); - CharSXPWrapperContentsFieldID = checkGetFieldID(env, CharSXPWrapperClass, "contents", "Ljava/lang/String;", 0); -} - -const char *stringToChars(JNIEnv *jniEnv, jstring string) { - // This is nasty: - // 1. the resulting character array has to be copied and zero-terminated. - // 2. It causes an (inevitable?) memory leak - jsize len = (*jniEnv)->GetStringUTFLength(jniEnv, string); - const char *stringChars = (*jniEnv)->GetStringUTFChars(jniEnv, string, NULL); - char *copyChars = malloc(len + 1); - memcpy(copyChars, stringChars, len); - copyChars[len] = 0; - return copyChars; -} - -void callEnter(JNIEnv *env, jmp_buf *jmpbuf) { - setEnv(env); - //printf("callEnter: callDepth %d, jmpbufptr %p\n", callDepth, jmpbuf); - callErrorJmpBufTable[callDepth] = jmpbuf; - if (callDepth >= CALLDEPTH_STACK_SIZE) { - fatalError("call stack overflow\n"); - } - nativeArrayTableHwmStack[callDepth] = nativeArrayTableHwm; - callDepth++; -} - -jmp_buf *getErrorJmpBuf() { - // printf("getErrorJmpBuf: callDepth %d, jmpbufptr %p\n", callDepth, callErrorJmpBufTable[callDepth - 1]); - return callErrorJmpBufTable[callDepth - 1]; -} - -void callExit(JNIEnv *env) { - int oldHwm = nativeArrayTableHwmStack[callDepth - 1]; - for (int i = oldHwm; i < nativeArrayTableHwm; i++) { - releaseNativeArray(env, i); - } - nativeArrayTableHwm = oldHwm; - callDepth--; -} - -void invalidateNativeArray(JNIEnv *env, SEXP oldObj) { - assert(isValidJNIRef(env, oldObj)); - for (int i = 0; i < nativeArrayTableHwm; i++) { - NativeArrayElem cv = nativeArrayTable[i]; - if (fast_IsSameObject(cv.obj, oldObj)) { -#if TRACE_NATIVE_ARRAYS - fprintf(traceFile, "invalidateNativeArray(%p): found\n", oldObj); -#endif - releaseNativeArray(env, i); - } - } -#if TRACE_NATIVE_ARRAYS - fprintf(traceFile, "invalidateNativeArray(%p): not found\n", oldObj); -#endif -} - -void updateJObjects(JNIEnv *env) { - int oldHwm = nativeArrayTableHwmStack[callDepth - 1]; - for (int i = oldHwm; i < nativeArrayTableHwm; i++) { - NativeArrayElem cv = nativeArrayTable[i]; - if (cv.obj != NULL) { - updateJObject(env, cv.obj); - } - } -} - -// Updates the data on the Java side from the data on the native side -void updateJObject(JNIEnv *env, SEXP x) { -#if TRACE_NATIVE_ARRAYS - fprintf(traceFile, "updateJObject(%p)\n", x); -#endif - NativeArrayElem *cv = findNativeArray(env, x); - if (cv != NULL && cv->data != NULL && cv->type != CHARSXP) { -#if TRACE_NATIVE_ARRAYS - fprintf(traceFile, "updateJObject(%p): updating\n", x); -#endif - int len = (*env)->GetArrayLength(env, cv->jArray); - switch (cv->type) { - case INTSXP: - (*env)->SetIntArrayRegion(env, cv->jArray, 0, len, cv->data); - break; - case REALSXP: - (*env)->SetDoubleArrayRegion(env, cv->jArray, 0, len, cv->data); - break; - case RAWSXP: - (*env)->SetByteArrayRegion(env, cv->jArray, 0, len, cv->data); - break; - case LGLSXP: { - int *data = (int*) cv->data; - jbyte *byteData = malloc(len * sizeof(jbyte)); - for (int i = 0; i < len; ++i) { - byteData[i] = data[i]; - } - (*env)->SetByteArrayRegion(env, cv->jArray, 0, len, byteData); - free(byteData); - break; - } - default: - fatalError("updateJObject: unexpected type"); - } - } -} - -static NativeArrayElem *findNativeArray(JNIEnv *env, SEXP x) { - if (nativeArrayTableLastIndex < nativeArrayTableHwm) { - NativeArrayElem *cv = &nativeArrayTable[nativeArrayTableLastIndex]; - if (cv->obj != NULL && (cv->obj == x || fast_IsSameObject(cv->obj, x))) { - void *data = cv->data; -#if TRACE_NATIVE_ARRAYS - fprintf(traceFile, "findNativeArray(%p): found %p (cached)\n", x, data); -#endif - return cv; - } - } - int i; - assert(isValidJNIRef(env, x)); - for (i = 0; i < nativeArrayTableHwm; i++) { - NativeArrayElem *cv = &nativeArrayTable[i]; - if (cv->obj != NULL) { - assert(isValidJNIRef(env, cv->obj)); - if (fast_IsSameObject(cv->obj, x)) { - nativeArrayTableLastIndex = i; - void *data = cv->data; -#if TRACE_NATIVE_ARRAYS - fprintf(traceFile, "findNativeArray(%p): found %p\n", x, data); -#endif - return cv; - } - } - } -#if TRACE_NATIVE_ARRAYS - fprintf(traceFile, "findNativeArray(%p): not found\n", x); -#endif - return NULL; -} - - -static void addNativeArray(JNIEnv *env, SEXP x, SEXPTYPE type, void *jArray, void *data) { -#if TRACE_NATIVE_ARRAYS - fprintf(traceFile, "addNativeArray(x=%p, t=%p, ix=%d, type=%d)\n", x, data, nativeArrayTableHwm, type); -#endif - // check for overflow - if (nativeArrayTableHwm >= nativeArrayTableLength) { - int newLength = 2 * nativeArrayTableLength; - NativeArrayElem *newnativeArrayTable = calloc(newLength, sizeof(NativeArrayElem)); - if (newnativeArrayTable == NULL) { - fatalError("FFI copied vectors table expansion failure"); - } - memcpy(newnativeArrayTable, nativeArrayTable, nativeArrayTableLength * sizeof(NativeArrayElem)); - free(nativeArrayTable); - nativeArrayTable = newnativeArrayTable; - nativeArrayTableLength = newLength; - } - nativeArrayTable[nativeArrayTableHwm].obj = x; - nativeArrayTable[nativeArrayTableHwm].data = data; - nativeArrayTable[nativeArrayTableHwm].type = type; - nativeArrayTable[nativeArrayTableHwm].jArray = jArray; - nativeArrayTableHwm++; -} - -static void* extractVectorNativeArray(JNIEnv *thisenv, jarray jArray, SEXPTYPE type) { - jboolean isCopy; - int len = (*thisenv)->GetArrayLength(thisenv, jArray); - switch (type) { - case INTSXP: - return (*thisenv)->GetIntArrayElements(thisenv, (jintArray) jArray, &isCopy); - - case REALSXP: - return (*thisenv)->GetDoubleArrayElements(thisenv, (jdoubleArray) jArray, &isCopy); - - case RAWSXP: - return (*thisenv)->GetByteArrayElements(thisenv, (jbyteArray) jArray, &isCopy); - - case LGLSXP: { - // Special treatment because R FFI wants int* and FastR represents using byte[] - jbyteArray byteArray = (jbyteArray) jArray; - jbyte* internalData = (*thisenv)->GetByteArrayElements(thisenv, byteArray, &isCopy); - int* idata = malloc(len * sizeof(int)); - for (int i = 0; i < len; i++) { - char value = internalData[i]; - idata[i] = value == 0 ? FALSE : value == 1 ? TRUE : NA_INTEGER; - } - (*thisenv)->ReleaseByteArrayElements(thisenv, byteArray, internalData, JNI_ABORT); - return idata; - } - } -} - -static jarray getJArray(JNIEnv *thisenv, SEXP x, SEXPTYPE type) { - switch (type) { - case INTSXP: - return (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, INTEGER_MethodID, x); - case REALSXP: - return (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, REAL_MethodID, x); - case RAWSXP: - return (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, RAW_MethodID, x); - case LGLSXP: - return (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, LOGICAL_MethodID, x); - default: - fatalError("getNativeArray: unexpected type"); - } -} - -void *getNativeArray(JNIEnv *thisenv, SEXP x, SEXPTYPE type) { -#if TRACE_NATIVE_ARRAYS - fprintf(traceFile, "getNativeArray(%p)\n", x); -#endif - NativeArrayElem *cv = findNativeArray(thisenv, x); - void *data = NULL; - if (cv != NULL) { - data = cv->data; - } - if (data == NULL) { - jarray jArray; - switch (type) { - case INTSXP: - case REALSXP: - case RAWSXP: - case LGLSXP: { - jArray = getJArray(thisenv, x, type); - data = extractVectorNativeArray(thisenv, jArray, type); - break; - } - case CHARSXP: { - jstring string = stringFromCharSXP(thisenv, x); - data = (void *) stringToChars(thisenv, string); - jArray = string; - break; - } - default: - fatalError("getNativeArray: unexpected type"); - } - addNativeArray(thisenv, x, type, jArray, data); - } - return data; -} - -void updateNativeArrays(JNIEnv *env) { - int oldHwm = nativeArrayTableHwmStack[callDepth - 1]; - for (int i = oldHwm; i < nativeArrayTableHwm; i++) { - updateNativeArray(env, i); - } -} - -int getTypeSize(SEXPTYPE type) { - switch (type) { - case INTSXP: - case LGLSXP: - return sizeof(jint); - case RAWSXP: - return sizeof(jbyte); - case REALSXP: - return sizeof(jdouble); - default: - fatalError("getNativeArray: unexpected type"); - } -} - -static void updateNativeArray(JNIEnv *env, int i) { - NativeArrayElem cv = nativeArrayTable[i]; - if (cv.obj != NULL && cv.type != CHARSXP) { - jarray current = getJArray(env, cv.obj, cv.type); - if (fast_IsSameObject(current, cv.jArray)) { -#if TRACE_NATIVE_ARRAYS - fprintf(traceFile, "updateNativeArray(x=%p, t=%p, ix=%d, type=%d): copying data from Java\n", cv.obj, cv.data, i, cv.type); -#endif - // same array, copy back the contents - int len = (*env)->GetArrayLength(env, cv.jArray); - switch (cv.type) { - case INTSXP: - (*env)->GetIntArrayRegion(env, cv.jArray, 0, len, cv.data); - break; - case REALSXP: - (*env)->GetDoubleArrayRegion(env, cv.jArray, 0, len, cv.data); - break; - case RAWSXP: - (*env)->GetByteArrayRegion(env, cv.jArray, 0, len, cv.data); - break; - case LGLSXP: { - jbyte *byteData = malloc(len * sizeof(jbyte)); - (*env)->GetByteArrayRegion(env, cv.jArray, 0, len, byteData); - for (int i = 0; i < len; ++i) { - ((int*) cv.data)[i] = byteData[i]; - } - free(byteData); - break; - } - default: - fatalError("updateJObject: unexpected type"); - } - } else { - // not the same array: this could happen if temporary vector got re-used for re-allocated copy. - // If the user now attempts at accessing a previously acquired data pointer, it's an error anyway, - // We invalidate the native "mirror", it's not reflecting the same jobject, anymore and if user now - // attempts to get the data pointer, she should get the right one -- for the new array, not the old one. -#if TRACE_NATIVE_ARRAYS - fprintf(traceFile, "updateNativeArray(x=%p, t=%p, ix=%d, type=%d): data in Java have changed, invalidating the cached pointer.\n", cv.obj, cv.data, index, cv.type); -#endif - nativeArrayTable[i].obj = NULL; - } - } -} - -// Updates the Java counterpart object with the contents of the native array and -// releases the native array. Use updateJObject to only update the java counterpart, -// but do not release. -static void releaseNativeArray(JNIEnv *env, int i) { - NativeArrayElem cv = nativeArrayTable[i]; -#if TRACE_NATIVE_ARRAYS - fprintf(traceFile, "releaseNativeArray(x=%p, ix=%d, type=%d)\n", cv.obj, i, cv.type); -#endif - if (cv.obj != NULL) { - assert(isValidJNIRef(env, cv.obj)); - jboolean complete = JNI_FALSE; // pessimal - switch (cv.type) { - case INTSXP: { - jintArray intArray = (jintArray) cv.jArray; - (*env)->ReleaseIntArrayElements(env, intArray, (jint *)cv.data, 0); - break; - } - - case LGLSXP: { - // for LOGICAL, we need to convert back to 1-byte elements - jintArray byteArray = (jbyteArray) cv.jArray; - int len = (*env)->GetArrayLength(env, byteArray); - jbyte* internalData = (*env)->GetByteArrayElements(env, byteArray, NULL); - int* data = (int*) cv.data; - complete = JNI_TRUE; // since we going to look at each element anyway - for (int i = 0; i < len; i++) { - int isNA = data[i] == NA_INTEGER ? JNI_TRUE : JNI_FALSE; - if (isNA) { - internalData[i] = 255; - complete = JNI_FALSE; - } else { - internalData[i] = (jbyte) data[i]; - } - - } - // note: internalData is used only as temp array here, no need to honor "mode" - (*env)->ReleaseByteArrayElements(env, byteArray, internalData, 0); - free(data); // was malloc'ed in addNativeArray - break; - } - - case REALSXP: { - jdoubleArray doubleArray = (jdoubleArray) cv.jArray; - (*env)->ReleaseDoubleArrayElements(env, doubleArray, (jdouble *)cv.data, 0); - break; - - } - - case RAWSXP: { - jbyteArray byteArray = (jbyteArray) cv.jArray; - (*env)->ReleaseByteArrayElements(env, byteArray, (jbyte *)cv.data, 0); - break; - - } - - case CHARSXP: { - jstring string = (jstring) cv.jArray; - (*env)->ReleaseStringUTFChars(env, string, (const char *)cv.data); - break; - - } - default: - fatalError("updateManagedVector type"); - } - // update complete status - (*env)->CallStaticVoidMethod(env, JNIUpCallsRFFIImplClass, setCompleteMethodID, cv.obj, complete); - - nativeArrayTable[i].obj = NULL; - } -#if TRACE_NATIVE_ARRAYS - fprintf(traceFile, "updateManagedVector(x=%p, ix=%d): DONE\n", cv.obj, i); -#endif -} - -static SEXP findCachedGlobalRef(JNIEnv *env, SEXP obj) { - // TODO: this assert fails in test RFFI: assert(isValidJNIRef(env, obj)); - for (int i = 0; i < cachedGlobalRefsHwm; i++) { - GlobalRefElem elem = cachedGlobalRefs[i]; - if (elem.gref == NULL) { - continue; - } - if (fast_IsSameObject(elem.gref, obj)) { -#if TRACE_REF_CACHE - fprintf(traceFile, "gref: cache hit: %d\n", i); -#endif - return elem.gref; - } - } - return NULL; -} - -SEXP addGlobalRef(JNIEnv *env, SEXP obj, int permanent) { - SEXP gref; - assert(isValidJNIRef(env, obj)); - if (cachedGlobalRefsHwm >= cachedGlobalRefsLength) { - int newLength = cachedGlobalRefsLength * 2; -#if TRACE_REF_CACHE - fprintf(traceFile, "gref: extending table to %d\n", newLength); -#endif - SEXP newCachedGlobalRefs = calloc(newLength, sizeof(GlobalRefElem)); - if (newCachedGlobalRefs == NULL) { - fatalError("FFI global refs table expansion failure"); - } - memcpy(newCachedGlobalRefs, cachedGlobalRefs, cachedGlobalRefsLength * sizeof(GlobalRefElem)); - free(cachedGlobalRefs); - cachedGlobalRefs = newCachedGlobalRefs; - cachedGlobalRefsLength = newLength; - } - gref = (*env)->NewGlobalRef(env, obj); - cachedGlobalRefs[cachedGlobalRefsHwm].gref = gref; - cachedGlobalRefs[cachedGlobalRefsHwm].permanent = permanent; -#if TRACE_REF_CACHE - fprintf(traceFile, "gref: add: index %d, ref %p\n", cachedGlobalRefsHwm, gref); -#endif - cachedGlobalRefsHwm++; - return gref; -} - -SEXP checkRef(JNIEnv *env, SEXP obj) { - SEXP gref = findCachedGlobalRef(env, obj); - TRACE(TARGpp, obj, gref); - if (gref == NULL) { - return obj; - } else { - return gref; - } -} - -SEXP createGlobalRef(JNIEnv *env, SEXP obj, int permanent) { - SEXP gref = findCachedGlobalRef(env, obj); - if (gref == NULL) { - gref = addGlobalRef(env, obj, permanent); - } - return gref; -} - -void releaseGlobalRef(JNIEnv *env, SEXP obj) { - for (int i = 0; i < cachedGlobalRefsHwm; i++) { - GlobalRefElem elem = cachedGlobalRefs[i]; - if (elem.gref == NULL || elem.permanent) { - continue; - } - if (fast_IsSameObject(elem.gref, obj)) { -#if TRACE_REF_CACHE - fprintf(traceFile, "gref: release: index %d, gref: %p\n", i, elem.gref); -#endif - (*env)->DeleteGlobalRef(env, elem.gref); - cachedGlobalRefs[i].gref = NULL; - } - } -} - -void validateRef(JNIEnv *env, SEXP x, const char *msg) { -#ifdef VALIDATE_REFS - jobjectRefType t = (*env)->GetObjectRefType(env, x); - if (t == JNIInvalidRefType) { - char buf[1000]; - sprintf(buf, "%s %p", msg,x); - fatalError(buf); - } -#endif -} - -JNIEnv *getEnv() { -// fprintf(traceFile, "getEnv()=%p\n", curenv); - return curenv; -} - -void setEnv(JNIEnv *env) { -// printf("setEnv(%p)\n", env); - curenv = env; -} - -void *unimplemented(char *msg) { - JNIEnv *thisenv = getEnv(); - char buf[1024]; - strcpy(buf, "unimplemented "); - strcat(buf, msg); - (*thisenv)->FatalError(thisenv, buf); - return NULL; -} - -void fatalError(char *msg) { - JNIEnv *thisenv = getEnv(); - (*thisenv)->FatalError(thisenv, msg); -} - -// Class/method search -jclass checkFindClass(JNIEnv *env, const char *name) { - jclass klass = (*env)->FindClass(env, name); - if (klass == NULL) { - char buf[1024]; - strcpy(buf, "failed to find class "); - strcat(buf, name); - (*env)->FatalError(env, buf); - } - return (*env)->NewGlobalRef(env, klass); -} - -jmethodID checkGetMethodID(JNIEnv *env, jclass klass, const char *name, const char *sig, int isStatic) { - jmethodID methodID = isStatic ? (*env)->GetStaticMethodID(env, klass, name, sig) : (*env)->GetMethodID(env, klass, name, sig); - if (methodID == NULL) { - char buf[1024]; - strcpy(buf, "failed to find "); - strcat(buf, isStatic ? "static" : "instance"); - strcat(buf, " method "); - strcat(buf, name); - strcat(buf, "("); - strcat(buf, sig); - strcat(buf, ")"); - (*env)->FatalError(env, buf); - } - return methodID; -} - -jfieldID checkGetFieldID(JNIEnv *env, jclass klass, const char *name, const char *sig, int isStatic) { - jfieldID fieldID = isStatic ? (*env)->GetStaticFieldID(env, klass, name, sig) : (*env)->GetFieldID(env, klass, name, sig); - if (fieldID == NULL) { - char buf[1024]; - strcpy(buf, "failed to find "); - strcat(buf, isStatic ? "static" : "instance"); - strcat(buf, " field "); - strcat(buf, name); - strcat(buf, "("); - strcat(buf, sig); - strcat(buf, ")"); - (*env)->FatalError(env, buf); - } - return fieldID; -} - -jstring stringFromCharSXP(JNIEnv *thisenv, SEXP charsxp) { -#if VALIDATE_REFS - validateRef(thisenv, charsxp, "stringFromCharSXP"); - if (!(*thisenv)->IsInstanceOf(thisenv, charsxp, CharSXPWrapperClass)) { - - (*thisenv)->CallStaticVoidMethod(thisenv, JNIUpCallsRFFIImplClass, logNotCharSXPWrapperMethodID, charsxp); - fatalError("only CharSXPWrapper expected in stringFromCharSXP"); - } -#endif - return (*thisenv)->GetObjectField(thisenv, charsxp, CharSXPWrapperContentsFieldID); -} diff --git a/com.oracle.truffle.r.native/fficall/src/jni/rffiutils.h b/com.oracle.truffle.r.native/fficall/src/jni/rffiutils.h deleted file mode 100644 index 077dad811e2b06169583d995213ae93b62309083..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jni/rffiutils.h +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -#ifndef RFFIUTILS_H -#define RFFIUTILS_H - -#include <jni.h> -#include <stdlib.h> -#include <string.h> -#include <limits.h> -#include <Rinternals.h> -#include <setjmp.h> -#include <Connections.h> - -#define VALIDATE_REFS 0 - -JNIEnv *getEnv(); -void setEnv(JNIEnv *env); - -jclass checkFindClass(JNIEnv *env, const char *name); -jmethodID checkGetMethodID(JNIEnv *env, jclass klass, const char *name, const char *sig, int isStatic); -jfieldID checkGetFieldID(JNIEnv *env, jclass klass, const char *name, const char *sig, int isStatic); - -// use for an unimplemented API function -void *unimplemented(char *msg) __attribute__((noreturn)); -// use for any fatal error -void fatalError(char *msg) __attribute__((noreturn)); -// makes a call to the VM with x as an argument (for debugger validation) -void validate(SEXP x); -// checks x against the list of global JNI refs, returning the global version if x matches (IsSameObject) -SEXP checkRef(JNIEnv *env, SEXP x); -// creates a global JNI global ref from x. If permanent is non-zero, calls to -// releaseGlobalRef are ignored and the global ref persists for the entire execution -// (used for the R global variables such as R_NilValue). -SEXP createGlobalRef(JNIEnv *env, SEXP x, int permanent); -// release a previously created JNI global ref -void releaseGlobalRef(JNIEnv *env, SEXP x); -// validate a JNI reference -void validateRef(JNIEnv *env, SEXP x, const char *msg); - -// entering a top-level JNI call -void callEnter(JNIEnv *env, jmp_buf *error_exit); -// exiting a top-level JNI call -void callExit(JNIEnv *env); -// called by callExit to deallocate transient memory -void allocExit(); - -// returns the jmp_buf at the current call depth -jmp_buf *getErrorJmpBuf(); - -// Given the x denotes an R vector type, return a pointer to -// the data as a C array -void *getNativeArray(JNIEnv *env, SEXP x, SEXPTYPE type); -// Rare case where an operation changes the internal -// data and thus the old C array should be invalidated, -// unlike updateJObjects this really frees the native array. -void invalidateNativeArray(JNIEnv *env, SEXP oldObj); -// Should be called before up calling to arbitrary code, e.g. Rf_eval, -// to copy back the arrays into their Java counterparts. The native arrays -// are not freed and stay around. -void updateJObjects(JNIEnv *env); -// Should be called after up calling to arbitrary code, e.g. Rf_eval, -// to copy back the java side arrays into their native counterparts. -void updateNativeArrays(JNIEnv *env); - - -// Copies back the array to the Java counterpart -void updateJObject(JNIEnv *env, SEXP obj); - -SEXP addGlobalRef(JNIEnv *env, SEXP obj, int permanent); - -void init_utils(JNIEnv *env, jobject upCallsInstance); -void init_rmath(JNIEnv *env); -void init_variables(JNIEnv *env, jobjectArray initialValues); -void init_dynload(JNIEnv *env); -void init_internals(JNIEnv *env); -void init_random(JNIEnv *env); -void init_parse(JNIEnv *env); -void init_pcre(JNIEnv *env); -void init_c(JNIEnv *env); -void init_connections(JNIEnv *env); - -void setEmbedded(void); - -void setTempDir(JNIEnv *, jstring tempDir); - -extern jclass UpCallsRFFIClass; -extern jclass JNIUpCallsRFFIImplClass; -extern jobject UpCallsRFFIObject; -extern FILE *traceFile; - -// tracing/debugging support, set to 1 and recompile to enable -#define TRACE_UPCALLS 0 // trace upcalls -#define TRACE_REF_CACHE 0 // trace JNI reference cache -#define TRACE_NATIVE_ARRAYS 0 // trace generation of internal arrays -#define TRACE_ENABLED TRACE_UPCALLS || TRACE_REF_CACHE || TRACE_NATIVE_ARRAYS - -#define TARGp "%s(%p)\n" -#define TARGpp "%s(%p, %p)\n" -#define TARGppp "%s(%p, %p, %p)\n" -#define TARGpd "%s(%p, %d)\n" -#define TARGppd "%s(%p, %p, %d)\n" -#define TARGs "%s(\"%s\")\n" -#define TARGps "%s(%p, \"%s\")\n" -#define TARGsdd "%s(\"%s\", %d, %d)\n" - -#if TRACE_UPCALLS -#define TRACE(format, ...) fprintf(traceFile, format, __FUNCTION__, __VA_ARGS__) -#else -#define TRACE(format, ...) -#endif - -#define _(Source) (Source) - -// convert a string into a char* -jstring stringFromCharSXP(JNIEnv *thisenv, SEXP charsxp); -const char *stringToChars(JNIEnv *jniEnv, jstring string); - - -extern jmethodID INTEGER_MethodID; -extern jmethodID LOGICAL_MethodID; -extern jmethodID REAL_MethodID; -extern jmethodID RAW_MethodID; -extern jmethodID setCompleteMethodID; - -extern int callDepth; - -#endif /* RFFIUTILS_H */ diff --git a/com.oracle.truffle.r.native/fficall/src/jni/stats_fft.c b/com.oracle.truffle.r.native/fficall/src/jni/stats_fft.c deleted file mode 100644 index fbc776789592fb6d000f9128bf94ce572e88e5a3..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jni/stats_fft.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include <rffiutils.h> - -typedef void (*fft_factor)(int n, int *pmaxf, int *pmaxp); -typedef Rboolean (*fft_work)(double *a, int nseg, int n, int nspn, int isn, - double *work, int *iwork); - -JNIEXPORT void JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Stats_native_1fft_1factor(JNIEnv *env, jclass c, jlong address, - jint n, jintArray jpmaxf, jintArray jpmaxp) { - fft_factor f = (fft_factor) address; - int *pmaxf = (*env)->GetPrimitiveArrayCritical(env, jpmaxf, NULL); - int *pmaxp = (*env)->GetPrimitiveArrayCritical(env, jpmaxp, NULL); - f(n, pmaxp, pmaxf); - (*env)->ReleasePrimitiveArrayCritical(env, jpmaxf, pmaxf, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jpmaxp, pmaxp, 0); -} - -JNIEXPORT int JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Stats_native_1fft_1work(JNIEnv *env, jclass c, jlong address, - jdoubleArray ja, int nseg, int n, int nsps, int isn, jdoubleArray jwork, jintArray jiwork) { - fft_work f = (fft_work) address; - double *a = (*env)->GetPrimitiveArrayCritical(env, ja, NULL); - double *work = (*env)->GetPrimitiveArrayCritical(env, jwork, NULL); - int *iwork = (*env)->GetPrimitiveArrayCritical(env, jiwork, NULL); - int res = f(a, nseg, n, nsps, isn, work, iwork); - (*env)->ReleasePrimitiveArrayCritical(env, ja, a, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jwork, work, JNI_ABORT); - (*env)->ReleasePrimitiveArrayCritical(env, jiwork, iwork, JNI_ABORT); - return res; -} diff --git a/com.oracle.truffle.r.native/fficall/src/jni/userrng_rffi.c b/com.oracle.truffle.r.native/fficall/src/jni/userrng_rffi.c deleted file mode 100644 index dda2cf2db82235b6a5f98b925f49cb7a7c5d5d87..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jni/userrng_rffi.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include <rffiutils.h> - -typedef void (*call_init)(int seed); -typedef double* (*call_rand)(void); -typedef int* (*call_nSeed)(void); -typedef int* (*call_seeds)(void); - -JNIEXPORT void JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1UserRng_nativeInit(JNIEnv *env, jclass c, jlong address, jint seed) { - call_init f = (call_init) address; - f(seed); -} - -JNIEXPORT double JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1UserRng_nativeRand(JNIEnv *env, jclass c, jlong address) { - call_rand f = (call_rand) address; - double* dp = f(); - return *dp; -} - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1UserRng_nativeNSeed(JNIEnv *env, jclass c, jlong address) { - call_nSeed f = (call_nSeed) address; - int *pn = f(); - return *pn; -} - -JNIEXPORT void JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1UserRng_nativeSeeds(JNIEnv *env, jclass c, jlong address, jintArray seedsArray) { - call_seeds f = (call_seeds) address; - int *pseeds = f(); - int seedslen = (*env)->GetArrayLength(env, seedsArray); - int *data = (*env)->GetIntArrayElements(env, seedsArray, NULL); - for (int i = 0; i < seedslen; i++) { - data[i] = pseeds[i]; - } - (*env)->ReleaseIntArrayElements(env, seedsArray, data, 0); -} diff --git a/com.oracle.truffle.r.native/fficall/src/jni/variables.c b/com.oracle.truffle.r.native/fficall/src/jni/variables.c deleted file mode 100644 index 1af98efddf3776ed4fe0d4f17f04a39cfcaf9615..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jni/variables.c +++ /dev/null @@ -1,453 +0,0 @@ -/* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// Rinternals defines lots of extern variables that we set here (eventually) -// Everything here must be a JNI Global Reference, and must be canonical because -// C code compares then with "==" (a JNI no-no really). - -#include <string.h> -#include <jni.h> -#include <Rinterface.h> -#include <rffiutils.h> - -jmethodID R_GlobalEnvMethodID; -jmethodID R_BaseEnvMethodID; -jmethodID R_BaseNamespaceMethodID; -jmethodID R_NamespaceRegistryMethodID; -jmethodID R_InteractiveMethodID; -jmethodID R_GlobalContextMethodID; - -// The variables have been rewritten as functions in Rinternals.h -// Apart from those that are RContext specific in FastR, the rest are -// stored here as JNI globals refs. - -static SEXP R_EmptyEnv_static; -static SEXP R_Srcref_static; -static SEXP R_NilValue_static; -static SEXP R_UnboundValue_static; -static SEXP R_MissingArg_static; -static SEXP R_BaseSymbol_static; -static SEXP R_Bracket2Symbol_static; /* "[[" */ -static SEXP R_BracketSymbol_static; /* "[" */ -static SEXP R_BraceSymbol_static; /* "{" */ -static SEXP R_DoubleColonSymbol_static; /* "::" */ -static SEXP R_ClassSymbol_static; /* "class" */ -static SEXP R_DeviceSymbol_static; /* ".Device" */ -static SEXP R_DevicesSymbol_static; /* ".Devices" */ -static SEXP R_DimNamesSymbol_static; /* "dimnames" */ -static SEXP R_DimSymbol_static; /* "dim" */ -static SEXP R_DollarSymbol_static; /* "$" */ -static SEXP R_DotsSymbol_static; /* "..." */ -static SEXP R_DropSymbol_static; /* "drop" */ -static SEXP R_LastvalueSymbol_static; /* ".Last.value" */ -static SEXP R_LevelsSymbol_static; /* "levels" */ -static SEXP R_ModeSymbol_static; /* "mode" */ -static SEXP R_NameSymbol_static; /* "name" */ -static SEXP R_NamesSymbol_static; /* "names" */ -static SEXP R_NaRmSymbol_static; /* "na.rm" */ -static SEXP R_PackageSymbol_static; /* "package" */ -static SEXP R_QuoteSymbol_static; /* "quote" */ -static SEXP R_RowNamesSymbol_static; /* "row.names" */ -static SEXP R_SeedsSymbol_static; /* ".Random.seed" */ -static SEXP R_SourceSymbol_static; /* "source" */ -static SEXP R_TspSymbol_static; /* "tsp" */ -static SEXP R_dot_defined_static; /* ".defined" */ -static SEXP R_dot_Method_static; /* ".Method" */ -static SEXP R_dot_target_static; /* ".target" */ -static SEXP R_NaString_static; /* NA_STRING as a CHARSXP */ -static SEXP R_BlankString_static; /* "" as a CHARSXP */ -static SEXP R_BlankScalarString_static; /* "" as a STRSXP */ -static SEXP R_NamespaceEnvSymbol_static; // ".__NAMESPACE__." - -// Symbols not part of public API but used in FastR tools implementation -static SEXP R_SrcrefSymbol_static; -static SEXP R_SrcfileSymbol_static; -static SEXP R_RestartToken_static; - -static const char *R_Home_static; -static const char *R_TempDir_static; - -// Arith.h -double R_NaN; /* IEEE NaN */ -double R_PosInf; /* IEEE Inf */ -double R_NegInf; /* IEEE -Inf */ -double R_NaReal; /* NA_REAL: IEEE */ -int R_NaInt; /* NA_INTEGER:= INT_MIN currently */ - -// various ignored flags and variables nevertheless needed to resolve symbols -Rboolean R_Visible; -Rboolean R_interrupts_suspended; -int R_interrupts_pending; -Rboolean mbcslocale; -Rboolean useaqua; -char* OutDec = "."; -Rboolean utf8locale = FALSE; -Rboolean mbcslocale = FALSE; -Rboolean latin1locale = FALSE; -int R_dec_min_exponent = -308; -int max_contour_segments = 25000; - -// from sys-std.c -#include <R_ext/eventloop.h> - -static InputHandler BasicInputHandler = {2, -1, NULL}; -InputHandler *R_InputHandlers = &BasicInputHandler; - -// R_GlobalEnv et al are not a variables in FASTR as they are RContext specific -SEXP FASTR_R_GlobalEnv() { - JNIEnv *env = getEnv(); - return (*env)->CallObjectMethod(env, UpCallsRFFIObject, R_GlobalEnvMethodID); -} - -SEXP FASTR_R_BaseEnv() { - JNIEnv *env = getEnv(); - return (*env)->CallObjectMethod(env, UpCallsRFFIObject, R_BaseEnvMethodID); -} - -SEXP FASTR_R_BaseNamespace() { - JNIEnv *env = getEnv(); - return (*env)->CallObjectMethod(env, UpCallsRFFIObject, R_BaseNamespaceMethodID); -} - -SEXP FASTR_R_NamespaceRegistry() { - JNIEnv *env = getEnv(); - return (*env)->CallObjectMethod(env, UpCallsRFFIObject, R_NamespaceRegistryMethodID); -} - -CTXT FASTR_GlobalContext() { - JNIEnv *env = getEnv(); - CTXT res = (*env)->CallObjectMethod(env, UpCallsRFFIObject, R_GlobalContextMethodID); - return addGlobalRef(env, res, 0); -} - -char *FASTR_R_Home() { - return (char *) R_Home_static; -} - -char *FASTR_R_TempDir() { - return (char *) R_TempDir_static; -} - -Rboolean FASTR_R_Interactive() { - JNIEnv *env = getEnv(); - int res = (int) (*env)->CallObjectMethod(env, UpCallsRFFIObject, R_InteractiveMethodID); - return (Rboolean) res; -} - -SEXP FASTR_R_EmptyEnv() { - return R_EmptyEnv_static; -} - -SEXP FASTR_R_Srcref() { - return R_Srcref_static; -} - -SEXP FASTR_R_NilValue() { - return R_NilValue_static; -} - -SEXP FASTR_R_UnboundValue() { - return R_UnboundValue_static; -} - -SEXP FASTR_R_MissingArg() { - return R_MissingArg_static; -} - -SEXP FASTR_R_BaseSymbol() { - return R_BaseSymbol_static; -} - - -SEXP FASTR_R_BraceSymbol() { - return R_BraceSymbol_static; -} - -SEXP FASTR_R_DoubleColonSymbol() { - return R_DoubleColonSymbol_static; -} - -SEXP FASTR_R_Bracket2Symbol() { - return R_Bracket2Symbol_static; -} - -SEXP FASTR_R_BracketSymbol() { - return R_BracketSymbol_static; -} - -SEXP FASTR_R_ClassSymbol() { - return R_ClassSymbol_static; -} - -SEXP FASTR_R_DimNamesSymbol() { - return R_DimNamesSymbol_static; -} - -SEXP FASTR_R_DimSymbol() { - return R_DimSymbol_static; -} - - -SEXP FASTR_R_DollarSymbol() { - return R_DollarSymbol_static; -} - -SEXP FASTR_R_DotsSymbol() { - return R_DotsSymbol_static; -} - - -SEXP FASTR_R_DropSymbol() { - return R_DropSymbol_static; -} - -SEXP FASTR_R_LastvalueSymbol() { - return R_LastvalueSymbol_static; -} - - -SEXP FASTR_R_LevelsSymbol() { - return R_LevelsSymbol_static; -} - -SEXP FASTR_R_ModeSymbol() { - return R_ModeSymbol_static; -} - -SEXP FASTR_R_NaRmSymbol() { - return R_NaRmSymbol_static; -} - - -SEXP FASTR_R_NameSymbol() { - return R_NameSymbol_static; -} - -SEXP FASTR_R_NamesSymbol() { - return R_NamesSymbol_static; -} - - -SEXP FASTR_R_NamespaceEnvSymbol() { - return R_NamespaceEnvSymbol_static; -} - -SEXP FASTR_R_PackageSymbol() { - return R_PackageSymbol_static; -} - -SEXP FASTR_R_QuoteSymbol() { - return R_QuoteSymbol_static; -} - -SEXP FASTR_R_RowNamesSymbol() { - return R_RowNamesSymbol_static; -} - -SEXP FASTR_R_SeedsSymbol() { - return R_SeedsSymbol_static; -} - -SEXP FASTR_R_SourceSymbol() { - return R_SourceSymbol_static; -} - -SEXP FASTR_R_TspSymbol() { - return R_TspSymbol_static; -} - -SEXP FASTR_R_dot_defined() { - return R_dot_defined_static; -} - -SEXP FASTR_R_dot_Method() { - return R_dot_Method_static; -} - -SEXP FASTR_R_dot_target() { - return R_dot_target_static; -} - -SEXP FASTR_R_NaString() { - return R_NaString_static; -} - - -SEXP FASTR_R_BlankString() { - return R_BlankString_static; -} - -SEXP FASTR_R_BlankScalarString() { - return R_BlankScalarString_static; -} - -SEXP FASTR_R_DevicesSymbol() { - return R_DevicesSymbol_static; -} - -SEXP FASTR_R_DeviceSymbol() { - return R_DeviceSymbol_static; -} - -SEXP FASTR_R_SrcrefSymbol() { - return R_SrcrefSymbol_static; -} - -SEXP FASTR_R_SrcfileSymbol() { - return R_SrcfileSymbol_static; -} - -void init_variables(JNIEnv *env, jobjectArray initialValues) { - // initialValues is an array of enums - jclass enumClass = (*env)->GetObjectClass(env, (*env)->GetObjectArrayElement(env, initialValues, 0)); - jmethodID nameMethodID = checkGetMethodID(env, enumClass, "name", "()Ljava/lang/String;", 0); - jmethodID ordinalMethodID = checkGetMethodID(env, enumClass, "ordinal", "()I", 0); - jmethodID getValueMethodID = checkGetMethodID(env, enumClass, "getValue", "()Ljava/lang/Object;", 0); - - jclass doubleClass = checkFindClass(env, "java/lang/Double"); - jclass intClass = checkFindClass(env, "java/lang/Integer"); - jmethodID doubleValueMethodID = checkGetMethodID(env, doubleClass, "doubleValue", "()D", 0); - jmethodID intValueMethodID = checkGetMethodID(env, intClass, "intValue", "()I", 0); - - R_GlobalEnvMethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_GlobalEnv", "()Ljava/lang/Object;", 0); - R_BaseEnvMethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_BaseEnv", "()Ljava/lang/Object;", 0); - R_BaseNamespaceMethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_BaseNamespace", "()Ljava/lang/Object;", 0); - R_NamespaceRegistryMethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_NamespaceRegistry", "()Ljava/lang/Object;", 0); - R_InteractiveMethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_Interactive", "()I", 0); - R_GlobalContextMethodID = checkGetMethodID(env, UpCallsRFFIClass, "R_GlobalContext", "()Ljava/lang/Object;", 0); - - int length = (*env)->GetArrayLength(env, initialValues); - int index; - for (index = 0; index < length; index++) { - jobject variable = (*env)->GetObjectArrayElement(env, initialValues, index); - jstring nameString = (*env)->CallObjectMethod(env, variable, nameMethodID); - const char *nameChars = (*env)->GetStringUTFChars(env, nameString, NULL); - jobject value = (*env)->CallObjectMethod(env, variable, getValueMethodID); - if (value != NULL) { - if (strcmp(nameChars, "R_Home") == 0) { - R_Home_static = (*env)->GetStringUTFChars(env, value, NULL); - } else if (strcmp(nameChars, "R_NaN") == 0) { - R_NaN = (*env)->CallDoubleMethod(env, value, doubleValueMethodID); - } else if (strcmp(nameChars, "R_PosInf") == 0) { - R_PosInf = (*env)->CallDoubleMethod(env, value, doubleValueMethodID); - } else if (strcmp(nameChars, "R_NegInf") == 0) { - R_NegInf = (*env)->CallDoubleMethod(env, value, doubleValueMethodID); - } else if (strcmp(nameChars, "R_NaReal") == 0) { - R_NaReal = (*env)->CallDoubleMethod(env, value, doubleValueMethodID); - } else if (strcmp(nameChars, "R_NaInt") == 0) { - R_NaInt = (*env)->CallIntMethod(env, value, intValueMethodID); - } else if (strcmp(nameChars, "R_TempDir") == 0) { - R_TempDir_static = (*env)->GetStringUTFChars(env, value, NULL); - } else { - SEXP ref = createGlobalRef(env, value, 1); - if (strcmp(nameChars, "R_EmptyEnv") == 0) { - R_EmptyEnv_static = ref; - } else if (strcmp(nameChars, "R_NilValue") == 0) { - R_NilValue_static = ref; - } else if (strcmp(nameChars, "R_UnboundValue") == 0) { - R_UnboundValue_static = ref; - } else if (strcmp(nameChars, "R_MissingArg") == 0) { - R_MissingArg_static = ref; - } else if (strcmp(nameChars, "R_BaseSymbol") == 0) { - R_BaseSymbol_static = ref; - } else if (strcmp(nameChars, "R_Bracket2Symbol") == 0) { - R_Bracket2Symbol_static = ref; - } else if (strcmp(nameChars, "R_BracketSymbol") == 0) { - R_BracketSymbol_static = ref; - } else if (strcmp(nameChars, "R_BraceSymbol") == 0) { - R_BraceSymbol_static = ref; - } else if (strcmp(nameChars, "R_DoubleColonSymbol") == 0) { - R_DoubleColonSymbol_static = ref; - } else if (strcmp(nameChars, "R_ClassSymbol") == 0) { - R_ClassSymbol_static = ref; - } else if (strcmp(nameChars, "R_DeviceSymbol") == 0) { - R_DeviceSymbol_static = ref; - } else if (strcmp(nameChars, "R_DevicesSymbol") == 0) { - R_DevicesSymbol_static = ref; - } else if (strcmp(nameChars, "R_DimNamesSymbol") == 0) { - R_DimNamesSymbol_static = ref; - } else if (strcmp(nameChars, "R_DimSymbol") == 0) { - R_DimSymbol_static = ref; - } else if (strcmp(nameChars, "R_DollarSymbol") == 0) { - R_DollarSymbol_static = ref; - } else if (strcmp(nameChars, "R_DotsSymbol") == 0) { - R_DotsSymbol_static = ref; - } else if (strcmp(nameChars, "R_DropSymbol") == 0) { - R_DropSymbol_static = ref; - } else if (strcmp(nameChars, "R_LastvalueSymbol") == 0) { - R_LastvalueSymbol_static = ref; - } else if (strcmp(nameChars, "R_LevelsSymbol") == 0) { - R_LevelsSymbol_static = ref; - } else if (strcmp(nameChars, "R_ModeSymbol") == 0) { - R_ModeSymbol_static = ref; - } else if (strcmp(nameChars, "R_NameSymbol") == 0) { - R_NameSymbol_static = ref; - } else if (strcmp(nameChars, "R_NamesSymbol") == 0) { - R_NamesSymbol_static = ref; - } else if (strcmp(nameChars, "R_NaRmSymbol") == 0) { - R_NaRmSymbol_static = ref; - } else if (strcmp(nameChars, "R_PackageSymbol") == 0) { - R_PackageSymbol_static = ref; - } else if (strcmp(nameChars, "R_QuoteSymbol") == 0) { - R_QuoteSymbol_static = ref; - } else if (strcmp(nameChars, "R_RowNamesSymbol") == 0) { - R_RowNamesSymbol_static = ref; - } else if (strcmp(nameChars, "R_SeedsSymbol") == 0) { - R_SeedsSymbol_static = ref; - } else if (strcmp(nameChars, "R_SourceSymbol") == 0) { - R_SourceSymbol_static = ref; - } else if (strcmp(nameChars, "R_TspSymbol") == 0) { - R_TspSymbol_static = ref; - } else if (strcmp(nameChars, "R_dot_defined") == 0) { - R_dot_defined_static = ref; - } else if (strcmp(nameChars, "R_dot_Method") == 0) { - R_dot_Method_static = ref; - } else if (strcmp(nameChars, "R_dot_target") == 0) { - R_dot_target_static = ref; - } else if (strcmp(nameChars, "R_SrcfileSymbol") == 0) { - R_SrcfileSymbol_static = ref; - } else if (strcmp(nameChars, "R_SrcrefSymbol") == 0) { - R_SrcrefSymbol_static = ref; - } else if (strcmp(nameChars, "R_DimSymbol") == 0) { - R_DimSymbol_static = ref; - } else if (strcmp(nameChars, "R_DimNamesSymbol") == 0) { - R_DimNamesSymbol_static = ref; - } else if (strcmp(nameChars, "R_NaString") == 0) { - R_NaString_static = ref; - } else if (strcmp(nameChars, "R_BlankString") == 0) { - R_BlankString_static = ref; - } else if (strcmp(nameChars, "R_BlankScalarString") == 0) { - R_BlankScalarString_static = ref; - } else if (strcmp(nameChars, "R_NamespaceEnvSymbol") == 0) { - R_NamespaceEnvSymbol_static = ref; - } else { - char msg[128]; - strcpy(msg, "non-null R variable not assigned: "); - strcat(msg, nameChars); - fatalError(msg); - } - } - } - } -} - diff --git a/com.oracle.truffle.r.native/fficall/src/jni/zip_rffi.c b/com.oracle.truffle.r.native/fficall/src/jni/zip_rffi.c deleted file mode 100644 index ffde19de4d11b1204a8929518249fc83eac2f877..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jni/zip_rffi.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include <rffiutils.h> - -extern int compress(char *dest, long *destlen, char *source, long sourcelen); -extern int uncompress(char *dest, long *destlen, char *source, long sourcelen); - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Zip_native_1compress(JNIEnv *env, jclass c, - jbyteArray jdest, jlong destlen, jbyteArray jsource, jlong sourcelen) { - char *dest = (*env)->GetPrimitiveArrayCritical(env, jdest, NULL); - char *source = (*env)->GetPrimitiveArrayCritical(env, jsource, NULL); - int rc = compress(dest, &destlen, source, sourcelen); - (*env)->ReleasePrimitiveArrayCritical(env, jdest, dest, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jsource, source, JNI_ABORT); - return rc; -} - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1Zip_native_1uncompress(JNIEnv *env, jclass c, - jbyteArray jdest, jlong destlen, jbyteArray jsource, jlong sourcelen) { - char *dest = (*env)->GetPrimitiveArrayCritical(env, jdest, NULL); - char *source = (*env)->GetPrimitiveArrayCritical(env, jsource, NULL); - int rc = uncompress(dest, &destlen, source, sourcelen); - (*env)->ReleasePrimitiveArrayCritical(env, jdest, dest, 0); - (*env)->ReleasePrimitiveArrayCritical(env, jsource, source, JNI_ABORT); - return rc; -} diff --git a/com.oracle.truffle.r.native/fficall/src/jniboot/Makefile b/com.oracle.truffle.r.native/fficall/src/jniboot/Makefile deleted file mode 100644 index 951610837a51d0497f2692f460b1cab72c99bbfb..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jniboot/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -# -# Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -ifneq ($(MAKECMDGOALS),clean) -include $(TOPDIR)/platform.mk -endif - - -.PHONY: all - -JNI_INCLUDES = -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/$(JDK_OS_DIR) - -all: jniboot.o - -jniboot.o: jniboot.c - $(CC) $(CFLAGS) $(JNI_INCLUDES) -c jniboot.c -o $@ diff --git a/com.oracle.truffle.r.native/fficall/src/jniboot/jniboot.c b/com.oracle.truffle.r.native/fficall/src/jniboot/jniboot.c deleted file mode 100644 index b313815395ca29ab8d4e1a8f03c247cfee66d721..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/fficall/src/jniboot/jniboot.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// These functions, while defined in JNI_Base are stored in a seperate library, jniboot -// in order to be able to bootstrap the system as libR has to be loaded using these functions. - -#include <dlfcn.h> -#include <jni.h> - -static jclass unsatisfiedLinkError; - -static void initUnsatisfiedLinkError(JNIEnv *env) { - if (unsatisfiedLinkError == NULL) { - unsatisfiedLinkError = (jclass) (*env)->NewGlobalRef(env, (*env)->FindClass(env, "java/lang/UnsatisfiedLinkError")); - } -} - -JNIEXPORT jlong JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1DLL_native_1dlopen(JNIEnv *env, jclass c, jstring jpath, jboolean local, jboolean now) { - const char *path = (*env)->GetStringUTFChars(env, jpath, NULL); - int flags = (local ? RTLD_LOCAL : RTLD_GLOBAL) | (now ? RTLD_NOW : RTLD_LAZY); - void *handle = dlopen(path, flags); - if (handle == NULL) { - char *err = dlerror(); - initUnsatisfiedLinkError(env); - // N.B.throw doesn't happen until return, so path is released - (*env)->ThrowNew(env, unsatisfiedLinkError, err); - } - (*env)->ReleaseStringUTFChars(env, jpath, path); - return (jlong) handle; -} - -JNIEXPORT jlong JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1DLL_native_1dlsym(JNIEnv *env, jclass c, jlong handle, jstring jsymbol) { - const char *symbol = (*env)->GetStringUTFChars(env, jsymbol, NULL); - void *address = dlsym((void *)handle, symbol); - if (address == NULL) { - char *err = dlerror(); - if (err != NULL) { - initUnsatisfiedLinkError(env); - // N.B.throw doesn't happen until return, so symbol is released - (*env)->ThrowNew(env, unsatisfiedLinkError, err); - } - } - (*env)->ReleaseStringUTFChars(env, jsymbol, symbol); - return (jlong) address; -} - -JNIEXPORT jint JNICALL -Java_com_oracle_truffle_r_ffi_impl_jni_JNI_1DLL_native_1dlclose(JNIEnv *env, jclass c, jlong handle) { - int rc = dlclose((void *)handle); - return rc; -} - - diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Connections.c b/com.oracle.truffle.r.native/fficall/src/truffle_common/Connections.c similarity index 99% rename from com.oracle.truffle.r.native/fficall/src/jni/Connections.c rename to com.oracle.truffle.r.native/fficall/src/truffle_common/Connections.c index f642af5f5bfc1ba2fcc4e0023bb6fcd77010d9de..ffdf80fde5bb6b61c71205c1ec10bdee621d9bf9 100644 --- a/com.oracle.truffle.r.native/fficall/src/jni/Connections.c +++ b/com.oracle.truffle.r.native/fficall/src/truffle_common/Connections.c @@ -21,6 +21,8 @@ * questions. */ + +#if FALSE #include <assert.h> #include <rffiutils.h> #include <R_ext/Connections.h> @@ -427,3 +429,4 @@ Rconnection R_GetConnection(SEXP sConn) { return new; } +#endif diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Parse.c b/com.oracle.truffle.r.native/fficall/src/truffle_common/Parse.c similarity index 99% rename from com.oracle.truffle.r.native/fficall/src/jni/Parse.c rename to com.oracle.truffle.r.native/fficall/src/truffle_common/Parse.c index c6509c52bb13b0824bd4ce330cec8dda3b45c8c2..41aabde10d90f0d486e90eee8588d8010c49d7e2 100644 --- a/com.oracle.truffle.r.native/fficall/src/jni/Parse.c +++ b/com.oracle.truffle.r.native/fficall/src/truffle_common/Parse.c @@ -20,6 +20,10 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + + +#if FALSE + #include <rffiutils.h> #include <R_ext/Parse.h> @@ -42,3 +46,4 @@ SEXP R_ParseVector(SEXP text, int n, ParseStatus *z, SEXP srcfile) { *z = (*env)->GetIntField(env, result, parseStatusFieldID); return (*env)->GetObjectField(env, result, parseExprFieldID); } +#endif diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Rembedded.c b/com.oracle.truffle.r.native/fficall/src/truffle_common/Rembedded.c similarity index 100% rename from com.oracle.truffle.r.native/fficall/src/jni/Rembedded.c rename to com.oracle.truffle.r.native/fficall/src/truffle_common/Rembedded.c diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Riconv.c b/com.oracle.truffle.r.native/fficall/src/truffle_common/Riconv.c similarity index 95% rename from com.oracle.truffle.r.native/fficall/src/jni/Riconv.c rename to com.oracle.truffle.r.native/fficall/src/truffle_common/Riconv.c index 3d54c1d6bf2bffd47476a35e3067c6f9ec9405e3..455826794f5edee7adea978787d72a1839d411d0 100644 --- a/com.oracle.truffle.r.native/fficall/src/jni/Riconv.c +++ b/com.oracle.truffle.r.native/fficall/src/truffle_common/Riconv.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Rmath.c b/com.oracle.truffle.r.native/fficall/src/truffle_common/Rmath.c similarity index 100% rename from com.oracle.truffle.r.native/fficall/src/jni/Rmath.c rename to com.oracle.truffle.r.native/fficall/src/truffle_common/Rmath.c diff --git a/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Utils.c b/com.oracle.truffle.r.native/fficall/src/truffle_common/Utils.c similarity index 98% rename from com.oracle.truffle.r.native/fficall/src/truffle_nfi/Utils.c rename to com.oracle.truffle.r.native/fficall/src/truffle_common/Utils.c index 0c491038318775d0c723d6e87553fd5b8fe97b91..6c0a8d482cb9556b55b8475a0cd61c8c016d41b7 100644 --- a/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Utils.c +++ b/com.oracle.truffle.r.native/fficall/src/truffle_common/Utils.c @@ -37,8 +37,7 @@ void R_CheckUserInterrupt(void) { // ignored } -void Rf_onintr() -{ +void Rf_onintr() { // TODO: implement interrupt handling, signal errors // ignored } diff --git a/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Memory.c b/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Memory.c index e97023c600b722162bf93d7e39cdbfe96442639b..5d123026a11ec833a1caf21bd7760ee036ca6c0e 100644 --- a/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Memory.c +++ b/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Memory.c @@ -30,6 +30,8 @@ void *R_chk_calloc(size_t nelem, size_t elsize); // Memory that is auto-reclaimed across FFI calls char *R_alloc(size_t n, int size) { + unimplemented("R_alloc should be implementd as UpCall functions to be thread safe"); + void *p = R_chk_calloc(n, size); if (tMemTableIndex >= tMemTableLength) { int newLength = 2 * tMemTableLength; diff --git a/com.oracle.truffle.r.native/library/tools/Makefile b/com.oracle.truffle.r.native/library/tools/Makefile index 9c415e7f92e967f064f4844ba8170c6043556189..a9cc40115ed7e943cff1c865efb126ecf96e89de 100644 --- a/com.oracle.truffle.r.native/library/tools/Makefile +++ b/com.oracle.truffle.r.native/library/tools/Makefile @@ -43,11 +43,6 @@ XTRA_C_OBJECTS += $(OBJ)/gramRd_llvm.o SULONG_DIR = $(abspath $(FASTR_R_HOME)/../sulong) SULONG_INCLUDES = -I$(SULONG_DIR)/include -else -ifeq ($(FASTR_RFFI),jni) -XTRA_C_SOURCES += $(SRC)/jni/gramRd_jni.c -XTRA_C_OBJECTS += $(OBJ)/gramRd_jni.o -endif endif endif @@ -70,8 +65,5 @@ $(OBJ)/gramRd_nfi.o: $(SRC)/truffle_nfi/gramRd_nfi.c $(OBJ)/gramRd_llvm.o: $(SRC)/truffle_llvm/gramRd_llvm.c $(CC) $(CFLAGS) $(FFI_INCLUDES) $(SULONG_INCLUDES) -c $< -o $@ -$(OBJ)/gramRd_jni.o: $(SRC)/jni/gramRd_jni.c - $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ - rm_gramRd: rm -f $(SRC)/gramRd.c diff --git a/com.oracle.truffle.r.native/library/tools/src/jni/gramRd_jni.c b/com.oracle.truffle.r.native/library/tools/src/jni/gramRd_jni.c deleted file mode 100644 index 14eb60c2e94a38f78acba3bf9e61fd706ace85b9..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.native/library/tools/src/jni/gramRd_jni.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -#include "../gramRd_fastr.h" -#include <jni.h> - -extern JNIEnv *getEnv(); - -static jmethodID getcMethodID = NULL; - -static void findGetCMethod(JNIEnv *env) { - jclass klass = (*env)->FindClass(env, "com/oracle/truffle/r/runtime/conn/RConnection"); - getcMethodID = (*env)->GetMethodID(env, klass, "getc", "()I"); -} - -int callGetCMethod(void *conn) { - JNIEnv *env = getEnv(); - if (getcMethodID == NULL) { - findGetCMethod(env); - } - int c = (*env)->CallIntMethod(env, conn, getcMethodID, conn); - return c; -} diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/RFFIFactory.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/RFFIFactory.java index 605a94203f6d1c8c1b0318ffa34f38849cfd5e5c..9311022ead992538ab143b22a1fba3540124f248 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/RFFIFactory.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/RFFIFactory.java @@ -39,7 +39,6 @@ import com.oracle.truffle.r.runtime.context.RContext.ContextState; */ public abstract class RFFIFactory { public enum Type { - JNI("com.oracle.truffle.r.ffi.impl.jni.JNI_RFFIFactory"), LLVM("com.oracle.truffle.r.ffi.impl.llvm.TruffleLLVM_RFFIFactory"), MANAGED("com.oracle.truffle.r.ffi.impl.managed.Managed_RFFIFactory"), NFI("com.oracle.truffle.r.ffi.impl.nfi.TruffleNFI_RFFIFactory"); diff --git a/mx.fastr/copyrights/overrides b/mx.fastr/copyrights/overrides index f60ee24560486de96d77da711e89c731d5d37674..aad66d1261a32dca7cff1751c40d5b9910e9b5dc 100644 --- a/mx.fastr/copyrights/overrides +++ b/mx.fastr/copyrights/overrides @@ -76,10 +76,6 @@ com.oracle.truffle.r.native/fficall/src/include/nmath.h,gnu_r.copyright com.oracle.truffle.r.native/fficall/src/include/Print.h,gnu_r_gentleman_ihaka.copyright com.oracle.truffle.r.native/fficall/src/include/Rgraphics.h,gnu_r_gentleman_ihaka.copyright com.oracle.truffle.r.native/fficall/src/include/rlocale.h,gnu_r_gentleman_ihaka.copyright -com.oracle.truffle.r.native/fficall/src/jni/Memory.c,gnu_r.copyright -com.oracle.truffle.r.native/fficall/src/jni/pcre_rffi.c,gnu_r_gentleman_ihaka2.copyright -com.oracle.truffle.r.native/fficall/src/jni/Rdynload_fastr.c,gnu_r.copyright -com.oracle.truffle.r.native/fficall/src/jni/Rembedded.c,gnu_r.copyright com.oracle.truffle.r.native/fficall/src/truffle_llvm/Memory.c,gnu_r.copyright com.oracle.truffle.r.native/fficall/src/truffle_nfi/Memory.c,gnu_r.copyright com.oracle.truffle.r.native/library/base/src/registration.c,no.copyright