From 5558da926c7e0c7e5f5e28dda63c64a2950ae860 Mon Sep 17 00:00:00 2001 From: stepan <stepan.sindelar@oracle.com> Date: Fri, 23 Feb 2018 14:54:24 +0100 Subject: [PATCH] RFFI: implement SETCADDR, SETCADDDR and SETCAD4R macros --- .../ffi/impl/common/JavaUpCallsRFFIImpl.java | 15 ++++ .../r/ffi/impl/nodes/ListAccessNodes.java | 46 ++++++++++++ .../r/ffi/impl/upcalls/StdUpCallsRFFI.java | 12 +++ .../fficall/src/common/rffi_upcallsindex.h | 75 ++++++++++--------- .../Rinternals_truffle_common.h | 9 ++- com.oracle.truffle.r.native/version.source | 2 +- 6 files changed, 118 insertions(+), 41 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 ecb9e56080..c7984a2e49 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 @@ -740,6 +740,21 @@ public abstract class JavaUpCallsRFFIImpl implements UpCallsRFFI { throw implementedAsNode(); } + @Override + public Object SETCADDR(Object x, Object y) { + throw implementedAsNode(); + } + + @Override + public Object SETCADDDR(Object x, Object y) { + throw implementedAsNode(); + } + + @Override + public Object SETCAD4R(Object x, Object y) { + throw implementedAsNode(); + } + @Override @TruffleBoundary public Object SYMVALUE(Object x) { diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/ListAccessNodes.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/ListAccessNodes.java index 379adb5684..41cc4ea43f 100644 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/ListAccessNodes.java +++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/ListAccessNodes.java @@ -172,6 +172,52 @@ public final class ListAccessNodes { } } + @TypeSystemReference(RTypes.class) + public static final class SETCADDRNode extends FFIUpCallNode.Arg2 { + @Child CDDRNode cddr = CDDRNode.create(); + @Child SETCARNode setcarNode = SETCARNode.create(); + + @Override + public Object executeObject(Object x, Object val) { + return setcarNode.executeObject(cddr.executeObject(x), val); + } + + public static SETCADDRNode create() { + return new SETCADDRNode(); + } + } + + @TypeSystemReference(RTypes.class) + public static final class SETCADDDRNode extends FFIUpCallNode.Arg2 { + @Child CDDDRNode cdddr = CDDDRNode.create(); + @Child SETCARNode setcarNode = SETCARNode.create(); + + @Override + public Object executeObject(Object x, Object val) { + return setcarNode.executeObject(cdddr.executeObject(x), val); + } + + public static SETCADDDRNode create() { + return new SETCADDDRNode(); + } + } + + @TypeSystemReference(RTypes.class) + public static final class SETCAD4RNode extends FFIUpCallNode.Arg2 { + @Child CDDDRNode cdddr = CDDDRNode.create(); + @Child CDRNode cdr = CDRNode.create(); + @Child SETCARNode setcarNode = SETCARNode.create(); + + @Override + public Object executeObject(Object x, Object val) { + return setcarNode.executeObject(cdddr.executeObject(cdr.executeObject(x)), val); + } + + public static SETCAD4RNode create() { + return new SETCAD4RNode(); + } + } + @TypeSystemReference(RTypes.class) public abstract static class SETCARNode extends FFIUpCallNode.Arg2 { public static SETCARNode create() { diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/upcalls/StdUpCallsRFFI.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/upcalls/StdUpCallsRFFI.java index b8a3e57d37..7151f48559 100644 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/upcalls/StdUpCallsRFFI.java +++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/upcalls/StdUpCallsRFFI.java @@ -45,6 +45,9 @@ import com.oracle.truffle.r.ffi.impl.nodes.ListAccessNodes.CDARNode; import com.oracle.truffle.r.ffi.impl.nodes.ListAccessNodes.CDDDRNode; import com.oracle.truffle.r.ffi.impl.nodes.ListAccessNodes.CDDRNode; import com.oracle.truffle.r.ffi.impl.nodes.ListAccessNodes.CDRNode; +import com.oracle.truffle.r.ffi.impl.nodes.ListAccessNodes.SETCAD4RNode; +import com.oracle.truffle.r.ffi.impl.nodes.ListAccessNodes.SETCADDDRNode; +import com.oracle.truffle.r.ffi.impl.nodes.ListAccessNodes.SETCADDRNode; import com.oracle.truffle.r.ffi.impl.nodes.ListAccessNodes.SETCADRNode; import com.oracle.truffle.r.ffi.impl.nodes.ListAccessNodes.SETCARNode; import com.oracle.truffle.r.ffi.impl.nodes.MatchNodes; @@ -263,6 +266,15 @@ public interface StdUpCallsRFFI { @RFFIUpCallNode(SETCADRNode.class) Object SETCADR(Object x, Object y); + @RFFIUpCallNode(SETCADDRNode.class) + Object SETCADDR(Object x, Object y); + + @RFFIUpCallNode(SETCADDDRNode.class) + Object SETCADDDR(Object x, Object y); + + @RFFIUpCallNode(SETCAD4RNode.class) + Object SETCAD4R(Object x, Object y); + Object SYMVALUE(Object x); void SET_SYMVALUE(Object x, Object v); 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 fa00c66c35..8c6c129944 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 @@ -157,42 +157,45 @@ #define Rf_warning_x 152 #define Rf_warningcall_x 153 #define Rprintf_x 154 -#define SETCADR_x 155 -#define SETCAR_x 156 -#define SETCDR_x 157 -#define SET_BODY_x 158 -#define SET_CLOENV_x 159 -#define SET_FORMALS_x 160 -#define SET_NAMED_FASTR_x 161 -#define SET_RDEBUG_x 162 -#define SET_RSTEP_x 163 -#define SET_S4_OBJECT_x 164 -#define SET_STRING_ELT_x 165 -#define SET_SYMVALUE_x 166 -#define SET_TAG_x 167 -#define SET_TYPEOF_FASTR_x 168 -#define SET_VECTOR_ELT_x 169 -#define STRING_ELT_x 170 -#define SYMVALUE_x 171 -#define TAG_x 172 -#define TYPEOF_x 173 -#define UNSET_S4_OBJECT_x 174 -#define VECTOR_ELT_x 175 -#define forceSymbols_x 176 -#define getCCallable_x 177 -#define getConnectionClassString_x 178 -#define getEmbeddingDLLInfo_x 179 -#define getOpenModeString_x 180 -#define getSummaryDescription_x 181 -#define isSeekable_x 182 -#define octsize_x 183 -#define registerCCallable_x 184 -#define registerRoutines_x 185 -#define restoreHandlerStacks_x 186 -#define setDotSymbolValues_x 187 -#define unif_rand_x 188 -#define useDynamicSymbols_x 189 +#define SETCAD4R_x 155 +#define SETCADDDR_x 156 +#define SETCADDR_x 157 +#define SETCADR_x 158 +#define SETCAR_x 159 +#define SETCDR_x 160 +#define SET_BODY_x 161 +#define SET_CLOENV_x 162 +#define SET_FORMALS_x 163 +#define SET_NAMED_FASTR_x 164 +#define SET_RDEBUG_x 165 +#define SET_RSTEP_x 166 +#define SET_S4_OBJECT_x 167 +#define SET_STRING_ELT_x 168 +#define SET_SYMVALUE_x 169 +#define SET_TAG_x 170 +#define SET_TYPEOF_FASTR_x 171 +#define SET_VECTOR_ELT_x 172 +#define STRING_ELT_x 173 +#define SYMVALUE_x 174 +#define TAG_x 175 +#define TYPEOF_x 176 +#define UNSET_S4_OBJECT_x 177 +#define VECTOR_ELT_x 178 +#define forceSymbols_x 179 +#define getCCallable_x 180 +#define getConnectionClassString_x 181 +#define getEmbeddingDLLInfo_x 182 +#define getOpenModeString_x 183 +#define getSummaryDescription_x 184 +#define isSeekable_x 185 +#define octsize_x 186 +#define registerCCallable_x 187 +#define registerRoutines_x 188 +#define restoreHandlerStacks_x 189 +#define setDotSymbolValues_x 190 +#define unif_rand_x 191 +#define useDynamicSymbols_x 192 -#define UPCALLS_TABLE_SIZE 190 +#define UPCALLS_TABLE_SIZE 193 #endif // RFFI_UPCALLSINDEX_H diff --git a/com.oracle.truffle.r.native/fficall/src/truffle_common/Rinternals_truffle_common.h b/com.oracle.truffle.r.native/fficall/src/truffle_common/Rinternals_truffle_common.h index d512182aaf..82bf7b8f64 100644 --- a/com.oracle.truffle.r.native/fficall/src/truffle_common/Rinternals_truffle_common.h +++ b/com.oracle.truffle.r.native/fficall/src/truffle_common/Rinternals_truffle_common.h @@ -771,19 +771,20 @@ SEXP SETCADR(SEXP x, SEXP y) { SEXP SETCADDR(SEXP x, SEXP y) { TRACE0(); - unimplemented("SETCADDR"); + // note: signature is same, we reuse call_SETCADR + SEXP result = ((call_SETCADR) callbacks[SETCADDR_x])(x, y); return NULL; } SEXP SETCADDDR(SEXP x, SEXP y) { TRACE0(); - unimplemented("SETCADDDR"); + SEXP result = ((call_SETCADR) callbacks[SETCADDDR_x])(x, y); return NULL; } -SEXP SETCAD4R(SEXP e, SEXP y) { +SEXP SETCAD4R(SEXP x, SEXP y) { TRACE0(); - unimplemented("SETCAD4R"); + SEXP result = ((call_SETCADR) callbacks[SETCAD4R_x])(x, y); return NULL; } diff --git a/com.oracle.truffle.r.native/version.source b/com.oracle.truffle.r.native/version.source index 0691f67b20..59343b09ec 100644 --- a/com.oracle.truffle.r.native/version.source +++ b/com.oracle.truffle.r.native/version.source @@ -1 +1 @@ -52 +53 -- GitLab