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 b73fac10a48f45e65171eed16e7b4aba01f21c94..c5c1f77155583854dda5b608987981a3b333d0b2 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 @@ -1684,4 +1684,9 @@ public abstract class JavaUpCallsRFFIImpl implements UpCallsRFFI { throw implementedAsNode(); } + @Override + public Object Rf_NonNullStringMatch(Object s, Object t) { + throw implementedAsNode(); + } + } diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/MatchNodes.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/MatchNodes.java new file mode 100644 index 0000000000000000000000000000000000000000..f307b7ffdd6520effbf87dc8cd640bf49ef71c94 --- /dev/null +++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/MatchNodes.java @@ -0,0 +1,49 @@ +package com.oracle.truffle.r.ffi.impl.nodes; + +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.TypeSystemReference; +import com.oracle.truffle.r.runtime.RInternalError; +import com.oracle.truffle.r.runtime.RRuntime; +import com.oracle.truffle.r.runtime.data.RTypes; +import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; + +public final class MatchNodes { + + @TypeSystemReference(RTypes.class) + public abstract static class MatchNode extends FFIUpCallNode.Arg3 { + + @SuppressWarnings("unused") + @Specialization + Object match(Object itables, Object ix, int nmatch) { + throw RInternalError.unimplemented("Rf_match"); + } + + public static MatchNode create() { + return MatchNodesFactory.MatchNodeGen.create(); + } + } + + @TypeSystemReference(RTypes.class) + public abstract static class NonNullStringMatchNode extends FFIUpCallNode.Arg2 { + + @Specialization(guards = {"s.getLength() == 1", "t.getLength() == 1"}) + Object matchSingle(RAbstractStringVector s, RAbstractStringVector t) { + if (s.getDataAt(0) == RRuntime.STRING_NA || t.getDataAt(0) == RRuntime.STRING_NA) { + return RRuntime.LOGICAL_FALSE; + } + return RRuntime.asLogical(s.getDataAt(0).equals(t.getDataAt(0))); + } + + @Fallback + @SuppressWarnings("unused") + Object match(Object s, Object t) { + throw RInternalError.unimplemented("Rf_NonNullStringMatch"); + } + + public static NonNullStringMatchNode create() { + return MatchNodesFactory.NonNullStringMatchNodeGen.create(); + } + } + +} diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/MiscNodes.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/MiscNodes.java index c595d84a4763ae83b8b36df882fa6b212eb77864..9a448ed172eff64a57b9d7ea066742f5c6cf685e 100644 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/MiscNodes.java +++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/MiscNodes.java @@ -40,7 +40,6 @@ import com.oracle.truffle.r.nodes.objects.NewObject; import com.oracle.truffle.r.nodes.objects.NewObjectNodeGen; import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.data.CharSXPWrapper; -import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.data.RArgsValuesAndNames; import com.oracle.truffle.r.runtime.data.RNull; import com.oracle.truffle.r.runtime.data.RSymbol; @@ -201,18 +200,4 @@ public final class MiscNodes { } } - @TypeSystemReference(RTypes.class) - public abstract static class MatchNode extends FFIUpCallNode.Arg3 { - - @SuppressWarnings("unused") - @Specialization - Object match(Object itables, Object ix, int nmatch) { - throw RInternalError.unimplemented("Rf_match"); - } - - public static MatchNode create() { - return MiscNodesFactory.MatchNodeGen.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 eee88cd69e35ab15a7ebdb4e025b83ed1fd9e449..50a20bc8e1ef9fde6f4d7c98bf03de997ce114b2 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 @@ -36,7 +36,7 @@ import com.oracle.truffle.r.ffi.impl.nodes.ListAccessNodes.CADRNode; import com.oracle.truffle.r.ffi.impl.nodes.ListAccessNodes.CARNode; 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.MiscNodes; +import com.oracle.truffle.r.ffi.impl.nodes.MatchNodes; import com.oracle.truffle.r.ffi.impl.nodes.MiscNodes.LENGTHNode; import com.oracle.truffle.r.ffi.processor.RFFICstring; import com.oracle.truffle.r.ffi.processor.RFFIRunGC; @@ -345,6 +345,9 @@ public interface StdUpCallsRFFI { @RFFIUpCallNode(CADDRNode.class) Object Rf_asCharacterFactor(Object x); - @RFFIUpCallNode(MiscNodes.MatchNode.class) + @RFFIUpCallNode(MatchNodes.MatchNode.class) Object Rf_match(Object itables, Object ix, int nmatch); + + @RFFIUpCallNode(MatchNodes.NonNullStringMatchNode.class) + Object Rf_NonNullStringMatch(Object s, Object t); } 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 6a0da3c3b7b4f2ee895030306691c95b54d5ca1b..e48fc20e3ce43ba1249164d1c78ab328bd6df01d 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 @@ -276,6 +276,7 @@ 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_Rf_match)(SEXP itable, SEXP ix, int nmatch); +typedef Rboolean (*call_Rf_NonNullStringMatch)(SEXP s, SEXP t); 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 87bae66a40019345ab1a5841d071a089fe498628..968cebc4bdb44747eeff2579015e16c6aad7264b 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 @@ -80,91 +80,92 @@ #define R_new_custom_connection_x 75 #define R_tryEval_x 76 #define Rf_GetOption1_x 77 -#define Rf_PairToVectorList_x 78 -#define Rf_ScalarDouble_x 79 -#define Rf_ScalarInteger_x 80 -#define Rf_ScalarLogical_x 81 -#define Rf_ScalarString_x 82 -#define Rf_VectorToPairList_x 83 -#define Rf_allocArray_x 84 -#define Rf_allocMatrix_x 85 -#define Rf_allocVector_x 86 -#define Rf_any_duplicated_x 87 -#define Rf_asChar_x 88 -#define Rf_asCharacterFactor_x 89 -#define Rf_asInteger_x 90 -#define Rf_asLogical_x 91 -#define Rf_asReal_x 92 -#define Rf_classgets_x 93 -#define Rf_coerceVector_x 94 -#define Rf_cons_x 95 -#define Rf_copyListMatrix_x 96 -#define Rf_copyMatrix_x 97 -#define Rf_copyMostAttrib_x 98 -#define Rf_defineVar_x 99 -#define Rf_dunif_x 100 -#define Rf_duplicate_x 101 -#define Rf_error_x 102 -#define Rf_errorcall_x 103 -#define Rf_eval_x 104 -#define Rf_findFun_x 105 -#define Rf_findVar_x 106 -#define Rf_findVarInFrame_x 107 -#define Rf_findVarInFrame3_x 108 -#define Rf_getAttrib_x 109 -#define Rf_gsetVar_x 110 -#define Rf_inherits_x 111 -#define Rf_install_x 112 -#define Rf_installChar_x 113 -#define Rf_isNull_x 114 -#define Rf_isString_x 115 -#define Rf_lengthgets_x 116 -#define Rf_match_x 117 -#define Rf_mkCharLenCE_x 118 -#define Rf_namesgets_x 119 -#define Rf_ncols_x 120 -#define Rf_nrows_x 121 -#define Rf_protect_x 122 -#define Rf_punif_x 123 -#define Rf_qunif_x 124 -#define Rf_runif_x 125 -#define Rf_setAttrib_x 126 -#define Rf_str2type_x 127 -#define Rf_unprotect_x 128 -#define Rf_unprotect_ptr_x 129 -#define Rf_warning_x 130 -#define Rf_warningcall_x 131 -#define Rprintf_x 132 -#define SETCADR_x 133 -#define SETCAR_x 134 -#define SETCDR_x 135 -#define SET_NAMED_FASTR_x 136 -#define SET_RDEBUG_x 137 -#define SET_RSTEP_x 138 -#define SET_S4_OBJECT_x 139 -#define SET_STRING_ELT_x 140 -#define SET_SYMVALUE_x 141 -#define SET_TAG_x 142 -#define SET_TYPEOF_FASTR_x 143 -#define SET_VECTOR_ELT_x 144 -#define STRING_ELT_x 145 -#define SYMVALUE_x 146 -#define TAG_x 147 -#define TYPEOF_x 148 -#define UNSET_S4_OBJECT_x 149 -#define VECTOR_ELT_x 150 -#define forceSymbols_x 151 -#define getCCallable_x 152 -#define getConnectionClassString_x 153 -#define getOpenModeString_x 154 -#define getSummaryDescription_x 155 -#define isSeekable_x 156 -#define registerCCallable_x 157 -#define registerRoutines_x 158 -#define setDotSymbolValues_x 159 -#define unif_rand_x 160 -#define useDynamicSymbols_x 161 +#define Rf_NonNullStringMatch_x 78 +#define Rf_PairToVectorList_x 79 +#define Rf_ScalarDouble_x 80 +#define Rf_ScalarInteger_x 81 +#define Rf_ScalarLogical_x 82 +#define Rf_ScalarString_x 83 +#define Rf_VectorToPairList_x 84 +#define Rf_allocArray_x 85 +#define Rf_allocMatrix_x 86 +#define Rf_allocVector_x 87 +#define Rf_any_duplicated_x 88 +#define Rf_asChar_x 89 +#define Rf_asCharacterFactor_x 90 +#define Rf_asInteger_x 91 +#define Rf_asLogical_x 92 +#define Rf_asReal_x 93 +#define Rf_classgets_x 94 +#define Rf_coerceVector_x 95 +#define Rf_cons_x 96 +#define Rf_copyListMatrix_x 97 +#define Rf_copyMatrix_x 98 +#define Rf_copyMostAttrib_x 99 +#define Rf_defineVar_x 100 +#define Rf_dunif_x 101 +#define Rf_duplicate_x 102 +#define Rf_error_x 103 +#define Rf_errorcall_x 104 +#define Rf_eval_x 105 +#define Rf_findFun_x 106 +#define Rf_findVar_x 107 +#define Rf_findVarInFrame_x 108 +#define Rf_findVarInFrame3_x 109 +#define Rf_getAttrib_x 110 +#define Rf_gsetVar_x 111 +#define Rf_inherits_x 112 +#define Rf_install_x 113 +#define Rf_installChar_x 114 +#define Rf_isNull_x 115 +#define Rf_isString_x 116 +#define Rf_lengthgets_x 117 +#define Rf_match_x 118 +#define Rf_mkCharLenCE_x 119 +#define Rf_namesgets_x 120 +#define Rf_ncols_x 121 +#define Rf_nrows_x 122 +#define Rf_protect_x 123 +#define Rf_punif_x 124 +#define Rf_qunif_x 125 +#define Rf_runif_x 126 +#define Rf_setAttrib_x 127 +#define Rf_str2type_x 128 +#define Rf_unprotect_x 129 +#define Rf_unprotect_ptr_x 130 +#define Rf_warning_x 131 +#define Rf_warningcall_x 132 +#define Rprintf_x 133 +#define SETCADR_x 134 +#define SETCAR_x 135 +#define SETCDR_x 136 +#define SET_NAMED_FASTR_x 137 +#define SET_RDEBUG_x 138 +#define SET_RSTEP_x 139 +#define SET_S4_OBJECT_x 140 +#define SET_STRING_ELT_x 141 +#define SET_SYMVALUE_x 142 +#define SET_TAG_x 143 +#define SET_TYPEOF_FASTR_x 144 +#define SET_VECTOR_ELT_x 145 +#define STRING_ELT_x 146 +#define SYMVALUE_x 147 +#define TAG_x 148 +#define TYPEOF_x 149 +#define UNSET_S4_OBJECT_x 150 +#define VECTOR_ELT_x 151 +#define forceSymbols_x 152 +#define getCCallable_x 153 +#define getConnectionClassString_x 154 +#define getOpenModeString_x 155 +#define getSummaryDescription_x 156 +#define isSeekable_x 157 +#define registerCCallable_x 158 +#define registerRoutines_x 159 +#define setDotSymbolValues_x 160 +#define unif_rand_x 161 +#define useDynamicSymbols_x 162 -#define UPCALLS_TABLE_SIZE 162 +#define UPCALLS_TABLE_SIZE 163 #endif // RFFI_UPCALLSINDEX_H diff --git a/com.oracle.truffle.r.native/fficall/src/truffle_common/match.c b/com.oracle.truffle.r.native/fficall/src/truffle_common/match.c new file mode 100644 index 0000000000000000000000000000000000000000..9a5d46d50c869f5e9fe00e6f214e34dc3a9c2387 --- /dev/null +++ b/com.oracle.truffle.r.native/fficall/src/truffle_common/match.c @@ -0,0 +1,30 @@ +/* + * 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. + */ +#include "../truffle_nfi/rffiutils.h" +#include "rffi_upcalls.h" + +Rboolean Rf_NonNullStringMatch(SEXP s, SEXP t) +{ + return ((call_Rf_NonNullStringMatch) callbacks[Rf_NonNullStringMatch_x])(s, t); +} + diff --git a/com.oracle.truffle.r.native/version.source b/com.oracle.truffle.r.native/version.source index 81b5c5d06cc0b8290c264b408abb32cc0986e8f2..e522732c77ec94723e739d22f28df549b0231f5f 100644 --- a/com.oracle.truffle.r.native/version.source +++ b/com.oracle.truffle.r.native/version.source @@ -1 +1 @@ -37 +38