Skip to content
Snippets Groups Projects
Commit 1f73afcf authored by Lukas Stadler's avatar Lukas Stadler
Browse files

Merge pull request #684 in G/fastr from ~MICK.JORDAN_ORACLE.COM/fastr:feature/ffitb to master

* commit '76c6ecab':
  rffi: minor cleanup
parents 0ea9e88c 76c6ecab
No related branches found
No related tags found
No related merge requests found
...@@ -43,7 +43,7 @@ Java_com_oracle_truffle_r_runtime_ffi_jni_JNI_1DLL_native_1dlopen(JNIEnv *env, j ...@@ -43,7 +43,7 @@ Java_com_oracle_truffle_r_runtime_ffi_jni_JNI_1DLL_native_1dlopen(JNIEnv *env, j
if (handle == NULL) { if (handle == NULL) {
char *err = dlerror(); char *err = dlerror();
initUnsatisfiedLinkError(env); initUnsatisfiedLinkError(env);
// (*env)->ReleaseStringUTFChars(env, jpath, path); // N.B.throw doesn't happen until return, so path is released
(*env)->ThrowNew(env, unsatisfiedLinkError, err); (*env)->ThrowNew(env, unsatisfiedLinkError, err);
} }
(*env)->ReleaseStringUTFChars(env, jpath, path); (*env)->ReleaseStringUTFChars(env, jpath, path);
...@@ -58,7 +58,7 @@ Java_com_oracle_truffle_r_runtime_ffi_jni_JNI_1DLL_native_1dlsym(JNIEnv *env, jc ...@@ -58,7 +58,7 @@ Java_com_oracle_truffle_r_runtime_ffi_jni_JNI_1DLL_native_1dlsym(JNIEnv *env, jc
char *err = dlerror(); char *err = dlerror();
if (err != NULL) { if (err != NULL) {
initUnsatisfiedLinkError(env); initUnsatisfiedLinkError(env);
// (*env)->ReleaseStringUTFChars(env, jsymbol, symbol); // N.B.throw doesn't happen until return, so symbol is released
(*env)->ThrowNew(env, unsatisfiedLinkError, err); (*env)->ThrowNew(env, unsatisfiedLinkError, err);
} }
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
package com.oracle.truffle.r.runtime.ffi.jni; package com.oracle.truffle.r.runtime.ffi.jni;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.r.runtime.RInternalError;
import com.oracle.truffle.r.runtime.ffi.DLL; 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.DLLInfo;
import com.oracle.truffle.r.runtime.ffi.DLL.SymbolHandle; import com.oracle.truffle.r.runtime.ffi.DLL.SymbolHandle;
...@@ -33,21 +34,22 @@ import com.oracle.truffle.r.runtime.ffi.StatsRFFI; ...@@ -33,21 +34,22 @@ import com.oracle.truffle.r.runtime.ffi.StatsRFFI;
public class JNI_Stats implements StatsRFFI { public class JNI_Stats implements StatsRFFI {
public static class JNI_WorkNode extends WorkNode { public static class JNI_WorkNode extends WorkNode {
private static final String FFT_WORK = "fft_work";
@Child DLLRFFI.DLSymNode dlSymNode = RFFIFactory.getRFFI().getDLLRFFI().createDLSymNode(); @Child DLLRFFI.DLSymNode dlSymNode = RFFIFactory.getRFFI().getDLLRFFI().createDLSymNode();
private SymbolHandle fftWorkAddress; private SymbolHandle fftWorkAddress;
@Override @Override
@TruffleBoundary @TruffleBoundary
public int execute(double[] a, int nseg, int n, int nspn, int isn, double[] work, int[] iwork) { public int execute(double[] a, int nseg, int n, int nspn, int isn, double[] work, int[] iwork) {
if (fftWorkAddress == null) { if (fftWorkAddress == null) {
fftWorkAddress = fftAddress("fft_work", dlSymNode); fftWorkAddress = fftAddress(FFT_WORK, dlSymNode);
} }
return native_fft_work(fftWorkAddress.asAddress(), a, nseg, n, nspn, isn, work, iwork); return native_fft_work(fftWorkAddress.asAddress(), a, nseg, n, nspn, isn, work, iwork);
} }
} }
public static class JNI_FactorNode extends FactorNode { public static class JNI_FactorNode extends FactorNode {
private static final String FFT_FACTOR = "fft_factor";
@Child DLLRFFI.DLSymNode dlSymNode = RFFIFactory.getRFFI().getDLLRFFI().createDLSymNode(); @Child DLLRFFI.DLSymNode dlSymNode = RFFIFactory.getRFFI().getDLLRFFI().createDLSymNode();
private SymbolHandle fftFactorAddress; private SymbolHandle fftFactorAddress;
...@@ -55,7 +57,7 @@ public class JNI_Stats implements StatsRFFI { ...@@ -55,7 +57,7 @@ public class JNI_Stats implements StatsRFFI {
@TruffleBoundary @TruffleBoundary
public void execute(int n, int[] pmaxf, int[] pmaxp) { public void execute(int n, int[] pmaxf, int[] pmaxp) {
if (fftFactorAddress == null) { if (fftFactorAddress == null) {
fftFactorAddress = fftAddress("fft_factor", dlSymNode); fftFactorAddress = fftAddress(FFT_FACTOR, dlSymNode);
} }
native_fft_factor(fftFactorAddress.asAddress(), n, pmaxf, pmaxp); native_fft_factor(fftFactorAddress.asAddress(), n, pmaxf, pmaxp);
...@@ -67,8 +69,11 @@ public class JNI_Stats implements StatsRFFI { ...@@ -67,8 +69,11 @@ public class JNI_Stats implements StatsRFFI {
SymbolHandle fftAddress; SymbolHandle fftAddress;
DLLInfo dllInfo = DLL.findLibrary("stats"); DLLInfo dllInfo = DLL.findLibrary("stats");
assert dllInfo != null; assert dllInfo != null;
fftAddress = dlSymNode.execute(dllInfo.handle, symbol); try {
assert fftAddress != DLL.SYMBOL_NOT_FOUND; fftAddress = dlSymNode.execute(dllInfo.handle, symbol);
} catch (UnsatisfiedLinkError ex) {
throw RInternalError.shouldNotReachHere(ex);
}
return fftAddress; return fftAddress;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment