From 1dd7a7ef3a248ef673225e444e03616491323b71 Mon Sep 17 00:00:00 2001 From: Florian Angerer <florian.angerer@oracle.com> Date: Thu, 10 Aug 2017 13:29:11 +0200 Subject: [PATCH] Using nodes for upcalls to dunif, qunif, and punif and added NFI upcalls. --- .../ffi/impl/common/JavaUpCallsRFFIImpl.java | 6 +- .../fficall/src/common/rffi_upcalls.h | 4 + .../fficall/src/common/rffi_upcallsindex.h | 101 +++++++++--------- .../fficall/src/truffle_nfi/Rmath.c | 12 +-- com.oracle.truffle.r.native/version.source | 2 +- 5 files changed, 65 insertions(+), 60 deletions(-) diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/JavaUpCallsRFFIImpl.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/JavaUpCallsRFFIImpl.java index cc47a945fc..ed489a3e28 100644 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/JavaUpCallsRFFIImpl.java +++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/JavaUpCallsRFFIImpl.java @@ -1585,17 +1585,17 @@ public abstract class JavaUpCallsRFFIImpl implements UpCallsRFFI { @Override public double Rf_dunif(double a, double b, double c, int d) { - return new Unif.DUnif().evaluate(a, b, c, RRuntime.fromLogical((byte) d)); + return (double) FFIUpCallRootNode.getCallTarget(RFFIUpCallTable.Rf_dunif).call(a, b, c, d); } @Override public double Rf_qunif(double a, double b, double c, int d, int e) { - return new Unif.QUnif().evaluate(a, b, c, RRuntime.fromLogical((byte) d), RRuntime.fromLogical((byte) e)); + return (double) FFIUpCallRootNode.getCallTarget(RFFIUpCallTable.Rf_qunif).call(a, b, c, d, e); } @Override public double Rf_punif(double a, double b, double c, int d, int e) { - return new Unif.PUnif().evaluate(a, b, c, RRuntime.fromLogical((byte) d), RRuntime.fromLogical((byte) e)); + return (double) FFIUpCallRootNode.getCallTarget(RFFIUpCallTable.Rf_punif).call(a, b, c, d, e); } @Override diff --git a/com.oracle.truffle.r.native/fficall/src/common/rffi_upcalls.h b/com.oracle.truffle.r.native/fficall/src/common/rffi_upcalls.h index 48d0c6dc45..44b8bf7102 100644 --- a/com.oracle.truffle.r.native/fficall/src/common/rffi_upcalls.h +++ b/com.oracle.truffle.r.native/fficall/src/common/rffi_upcalls.h @@ -277,6 +277,10 @@ typedef char *(*call_R_HomeDir)(); typedef void (*call_R_CleanUp)(int sa, int status, int runlast); typedef void (*call_Rf_gsetVar)(SEXP symbol, SEXP value, SEXP rho); typedef double (*call_unif_rand)(); +typedef double (*call_Rf_qunif)(double a, double b, double c, int d, int e); +typedef double (*call_Rf_dunif)(double a, double b, double c, int d); +typedef double (*call_Rf_punif)(double a, double b, double c, int d, int e); +typedef double (*call_Rf_runif)(double x, double y); typedef SEXP (*call_getvar)(); diff --git a/com.oracle.truffle.r.native/fficall/src/common/rffi_upcallsindex.h b/com.oracle.truffle.r.native/fficall/src/common/rffi_upcallsindex.h index a08f6c2192..f17d3f1c19 100644 --- a/com.oracle.truffle.r.native/fficall/src/common/rffi_upcallsindex.h +++ b/com.oracle.truffle.r.native/fficall/src/common/rffi_upcallsindex.h @@ -92,54 +92,59 @@ #define Rf_copyListMatrix_x 87 #define Rf_copyMatrix_x 88 #define Rf_defineVar_x 89 -#define Rf_duplicate_x 90 -#define Rf_error_x 91 -#define Rf_errorcall_x 92 -#define Rf_eval_x 93 -#define Rf_findFun_x 94 -#define Rf_findVar_x 95 -#define Rf_findVarInFrame_x 96 -#define Rf_findVarInFrame3_x 97 -#define Rf_getAttrib_x 98 -#define Rf_gsetVar_x 99 -#define Rf_inherits_x 100 -#define Rf_install_x 101 -#define Rf_installChar_x 102 -#define Rf_isNull_x 103 -#define Rf_isString_x 104 -#define Rf_lengthgets_x 105 -#define Rf_mkCharLenCE_x 106 -#define Rf_ncols_x 107 -#define Rf_nrows_x 108 -#define Rf_setAttrib_x 109 -#define Rf_str2type_x 110 -#define Rf_warning_x 111 -#define Rf_warningcall_x 112 -#define Rprintf_x 113 -#define SETCADR_x 114 -#define SETCAR_x 115 -#define SETCDR_x 116 -#define SET_NAMED_FASTR_x 117 -#define SET_RDEBUG_x 118 -#define SET_RSTEP_x 119 -#define SET_S4_OBJECT_x 120 -#define SET_STRING_ELT_x 121 -#define SET_SYMVALUE_x 122 -#define SET_TAG_x 123 -#define SET_TYPEOF_FASTR_x 124 -#define SET_VECTOR_ELT_x 125 -#define STRING_ELT_x 126 -#define SYMVALUE_x 127 -#define TAG_x 128 -#define TYPEOF_x 129 -#define UNSET_S4_OBJECT_x 130 -#define VECTOR_ELT_x 131 -#define getConnectionClassString_x 132 -#define getOpenModeString_x 133 -#define getSummaryDescription_x 134 -#define isSeekable_x 135 -#define unif_rand_x 136 +#define Rf_dunif_x 90 +#define Rf_duplicate_x 91 +#define Rf_error_x 92 +#define Rf_errorcall_x 93 +#define Rf_eval_x 94 +#define Rf_findFun_x 95 +#define Rf_findVar_x 96 +#define Rf_findVarInFrame_x 97 +#define Rf_findVarInFrame3_x 98 +#define Rf_getAttrib_x 99 +#define Rf_gsetVar_x 100 +#define Rf_inherits_x 101 +#define Rf_install_x 102 +#define Rf_installChar_x 103 +#define Rf_isNull_x 104 +#define Rf_isString_x 105 +#define Rf_lengthgets_x 106 +#define Rf_mkCharLenCE_x 107 +#define Rf_namesgets_x 108 +#define Rf_ncols_x 109 +#define Rf_nrows_x 110 +#define Rf_punif_x 111 +#define Rf_qunif_x 112 +#define Rf_runif_x 113 +#define Rf_setAttrib_x 114 +#define Rf_str2type_x 115 +#define Rf_warning_x 116 +#define Rf_warningcall_x 117 +#define Rprintf_x 118 +#define SETCADR_x 119 +#define SETCAR_x 120 +#define SETCDR_x 121 +#define SET_NAMED_FASTR_x 122 +#define SET_RDEBUG_x 123 +#define SET_RSTEP_x 124 +#define SET_S4_OBJECT_x 125 +#define SET_STRING_ELT_x 126 +#define SET_SYMVALUE_x 127 +#define SET_TAG_x 128 +#define SET_TYPEOF_FASTR_x 129 +#define SET_VECTOR_ELT_x 130 +#define STRING_ELT_x 131 +#define SYMVALUE_x 132 +#define TAG_x 133 +#define TYPEOF_x 134 +#define UNSET_S4_OBJECT_x 135 +#define VECTOR_ELT_x 136 +#define getConnectionClassString_x 137 +#define getOpenModeString_x 138 +#define getSummaryDescription_x 139 +#define isSeekable_x 140 +#define unif_rand_x 141 -#define UPCALLS_TABLE_SIZE 137 +#define UPCALLS_TABLE_SIZE 142 #endif // RFFI_UPCALLSINDEX_H diff --git a/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Rmath.c b/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Rmath.c index fd9580d182..493ae1d245 100644 --- a/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Rmath.c +++ b/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Rmath.c @@ -59,23 +59,19 @@ void Rf_pnorm_both(double a, double * b, double * c, int d, int e) { } double Rf_dunif(double a, double b, double c, int d) { - unimplemented("Rf_dunif"); - return 0; + return ((call_Rf_dunif) callbacks[Rf_dunif])(a, b, c, d); } double Rf_punif(double a, double b, double c, int d, int e) { - unimplemented("Rf_punif"); - return 0; + return ((call_Rf_punif) callbacks[Rf_punif])(a, b, c, d, e); } double Rf_qunif(double a, double b, double c, int d, int e) { - unimplemented("Rf_qunif"); - return 0; + return ((call_Rf_qunif) callbacks[Rf_qunif])(a, b, c, d, e); } double Rf_runif(double a, double b) { - unimplemented("Rf_runif"); - return 0; + return ((call_Rf_runif) callbacks[Rf_runif])(a, b); } double Rf_dgamma(double a, double b, double c, int d) { diff --git a/com.oracle.truffle.r.native/version.source b/com.oracle.truffle.r.native/version.source index bb95160cb6..a787364590 100644 --- a/com.oracle.truffle.r.native/version.source +++ b/com.oracle.truffle.r.native/version.source @@ -1 +1 @@ -33 +34 -- GitLab