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 b1bd221a649b614f071bc770a5829fc546d236fd..cc47a945fc04cd80e080fc4f10f46835663a3b38 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 @@ -110,7 +110,6 @@ import com.oracle.truffle.r.runtime.ffi.CharSXPWrapper; import com.oracle.truffle.r.runtime.ffi.DLL.SymbolHandle; import com.oracle.truffle.r.runtime.gnur.SA_TYPE; import com.oracle.truffle.r.runtime.gnur.SEXPTYPE; -import com.oracle.truffle.r.runtime.nmath.RandomFunctions.RandomNumberProvider; import com.oracle.truffle.r.runtime.nmath.distr.Unif; import com.oracle.truffle.r.runtime.nodes.DuplicationHelper; import com.oracle.truffle.r.runtime.nodes.RNode; @@ -1604,4 +1603,9 @@ public abstract class JavaUpCallsRFFIImpl implements UpCallsRFFI { return (double) FFIUpCallRootNode.getCallTarget(RFFIUpCallTable.Rf_runif).call(a, b); } + @Override + public Object Rf_namesgets(Object x, Object y) { + return FFIUpCallRootNode.getCallTarget(RFFIUpCallTable.Rf_namesgets).call(x, y); + } + } 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 index 4add422498be6360d4a9c71c67c701640fdc94b1..8b5fc1e7b73848a4d471312f981c1bc9350174b9 100644 --- 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 @@ -872,4 +872,10 @@ final class TracingUpCallsRFFIImpl implements UpCallsRFFI { return delegate.Rf_runif(a, b); } + @Override + public Object Rf_namesgets(Object vec, Object val) { + RFFIUtils.traceUpCall("Rf_namesgets", vec, val); + return delegate.Rf_namesgets(vec, val); + } + } 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 index ae1086a488b99ba126b44bc1a4d22c6632dcb730..4470a37a76c32fce8da819194007efa910eedea4 100644 --- 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 @@ -113,5 +113,6 @@ public final class FFIUpCallRootNode extends RootNode { FFIUpCallRootNode.add(RFFIUpCallTable.Rf_dunif, () -> RandFunction3_1NodeGen.create(new Unif.DUnif())); FFIUpCallRootNode.add(RFFIUpCallTable.Rf_qunif, () -> RandFunction3_2NodeGen.create(new Unif.QUnif())); FFIUpCallRootNode.add(RFFIUpCallTable.Rf_punif, () -> RandFunction3_2NodeGen.create(new Unif.PUnif())); + FFIUpCallRootNode.add(RFFIUpCallTable.Rf_namesgets, MiscNodesFactory.NamesGetsNodeGen::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 8a438e02e744d08033cd05bc86cb964260d5b152..918352aba3a2b7ee6660ef9c5ad7fd41e976f82a 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 @@ -30,6 +30,8 @@ import com.oracle.truffle.r.nodes.access.AccessSlotNode; import com.oracle.truffle.r.nodes.access.AccessSlotNodeGen; import com.oracle.truffle.r.nodes.access.UpdateSlotNode; import com.oracle.truffle.r.nodes.access.UpdateSlotNodeGen; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.SetNamesAttributeNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctionsFactory.SetNamesAttributeNodeGen; import com.oracle.truffle.r.nodes.objects.NewObject; import com.oracle.truffle.r.nodes.objects.NewObjectNodeGen; import com.oracle.truffle.r.runtime.RError; @@ -157,4 +159,20 @@ public final class MiscNodes { } } + @TypeSystemReference(RTypes.class) + abstract static class NamesGetsNode extends FFIUpCallNode.Arg2 { + + @Child private SetNamesAttributeNode setNamesNode; + + NamesGetsNode() { + setNamesNode = SetNamesAttributeNodeGen.create(); + } + + @Specialization + Object doNewObject(Object vec, Object val) { + setNamesNode.execute(vec, val); + return vec; + } + } + } diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/RandFunctionsNodes.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/RandFunctionsNodes.java index 807ff5d5c02f0a023355413ed340371041235a92..f168c1caeda218a4a7589d1e2a6edc979faa8fb8 100644 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/RandFunctionsNodes.java +++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/RandFunctionsNodes.java @@ -1,3 +1,25 @@ +/* + * 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. + */ package com.oracle.truffle.r.ffi.impl.nodes; import com.oracle.truffle.api.dsl.Specialization; @@ -9,7 +31,7 @@ import com.oracle.truffle.r.runtime.nmath.RandomFunctions.RandomNumberProvider; public final class RandFunctionsNodes { public abstract static class RandFunction3_2Node extends FFIUpCallNode.Arg5 { - @Child private MathFunctions.Function3_2 inner; + private final MathFunctions.Function3_2 inner; protected RandFunction3_2Node(MathFunctions.Function3_2 inner) { this.inner = inner; @@ -22,7 +44,7 @@ public final class RandFunctionsNodes { } public abstract static class RandFunction3_1Node extends FFIUpCallNode.Arg4 { - @Child private MathFunctions.Function3_1 inner; + private final MathFunctions.Function3_1 inner; protected RandFunction3_1Node(MathFunctions.Function3_1 inner) { this.inner = inner; 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 fe1398c447c571d73cd806fb54b37c0d5d4fd0ed..76c10d6ac9e1285218e7e2774872b3375cc1ac2a 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 @@ -303,4 +303,6 @@ public interface StdUpCallsRFFI { double Rf_runif(double a, double b); + Object Rf_namesgets(Object vec, Object val); + } diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c b/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c index 0414f5f032cd4daf66d45d49b72ada1b39c15dc0..6b96159ed943fdcb8f106d9675fda498bfa74102 100644 --- a/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c +++ b/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c @@ -146,6 +146,7 @@ static jmethodID Rf_copyListMatrixMethodID; static jmethodID Rf_copyMatrixMethodID; static jmethodID Rf_nrowsMethodID; static jmethodID Rf_ncolsMethodID; +static jmethodID Rf_namesgetsMethodID; static jclass CharSXPWrapperClass; jclass JNIUpCallsRFFIImplClass; @@ -263,6 +264,7 @@ void init_internals(JNIEnv *env) { 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); // static JNI-specific methods JNIUpCallsRFFIImplClass = checkFindClass(env, "com/oracle/truffle/r/ffi/impl/jni/JNIUpCallsRFFIImpl"); @@ -740,7 +742,9 @@ SEXP R_lsInternal3(SEXP env, Rboolean all, Rboolean sorted) { } SEXP Rf_namesgets(SEXP x, SEXP y) { - return unimplemented("Rf_namesgets"); + JNIEnv *thisenv = getEnv(); + SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_namesgetsMethodID, x, y); + return checkRef(thisenv, result); } SEXP GetOption1(SEXP tag) 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 5e7b770f354ebcd5c52f4b837359c5c82fbfeed9..916a6d0a4be19b603150d698a09baca6a51243b6 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 @@ -449,7 +449,7 @@ SEXP R_lsInternal3(SEXP env, Rboolean all, Rboolean sorted) { } SEXP Rf_namesgets(SEXP x, SEXP y) { - return unimplemented("Rf_namesgets"); + return checkRef(((call_Rf_namesgets) callbacks[Rf_namesgets_x])(x, y)); } SEXP TAG(SEXP e) {