From a17d3966cba958fefbe7139739f68449ae146f59 Mon Sep 17 00:00:00 2001 From: Lukas Stadler <lukas.stadler@oracle.com> Date: Wed, 15 Nov 2017 17:12:29 +0100 Subject: [PATCH] remove initial vector access implementation --- .../r/ffi/impl/nodes/ListAccessNodes.java | 4 +- .../r/nodes/builtin/base/LaFunctions.java | 10 +- .../truffle/r/nodes/primitive/Utils.java | 71 ---- .../runtime/data/nodes/EnableNACheckNode.java | 48 --- .../r/runtime/data/nodes/GetDataAt.java | 369 ----------------- .../r/runtime/data/nodes/GetDataCopy.java | 96 ----- .../r/runtime/data/nodes/GetDataStore.java | 80 ---- .../r/runtime/data/nodes/ReadAccessor.java | 184 --------- .../r/runtime/data/nodes/SetDataAt.java | 224 ---------- .../data/nodes/VectorAccessAdapter.java | 37 -- .../r/runtime/data/nodes/VectorIterator.java | 385 ------------------ .../runtime/data/nodes/VectorReadAccess.java | 152 ------- .../runtime/data/nodes/VectorWriteAccess.java | 118 ------ 13 files changed, 5 insertions(+), 1773 deletions(-) delete mode 100644 com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/primitive/Utils.java delete mode 100644 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/EnableNACheckNode.java delete mode 100644 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/GetDataAt.java delete mode 100644 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/GetDataCopy.java delete mode 100644 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/GetDataStore.java delete mode 100644 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/ReadAccessor.java delete mode 100644 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/SetDataAt.java delete mode 100644 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/VectorAccessAdapter.java delete mode 100644 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/VectorIterator.java delete mode 100644 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/VectorReadAccess.java delete mode 100644 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/VectorWriteAccess.java 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 9e8c18a8c8..61fa874e2c 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 @@ -49,7 +49,6 @@ import com.oracle.truffle.r.runtime.data.RPairList; import com.oracle.truffle.r.runtime.data.RStringVector; import com.oracle.truffle.r.runtime.data.RSymbol; import com.oracle.truffle.r.runtime.data.RTypes; -import com.oracle.truffle.r.runtime.data.nodes.GetDataCopy; /** * Nodes that implement {@code CAR}, {@code CDR}, etc. N.B. GNU R does not error check the @@ -170,7 +169,6 @@ public final class ListAccessNodes { @Specialization protected Object cdr(RList list, - @Cached("create()") GetDataCopy.String getDataCopyNode, @Cached("create()") GetNamesAttributeNode getNamesNode, @Cached("create()") SetNamesAttributeNode setNamesNode) { if (list.getLength() == 1) { @@ -179,7 +177,7 @@ public final class ListAccessNodes { RStringVector names = getNamesNode.getNames(list); RList copy = RDataFactory.createList(list.getDataCopy()); if (names != null) { - String[] namesDataCopy = getDataCopyNode.execute(names); + String[] namesDataCopy = names.getDataCopy(); setNamesNode.setNames(copy, RDataFactory.createStringVector(namesDataCopy, true)); } return copy; diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/LaFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/LaFunctions.java index a0ccf139a8..b1681c9175 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/LaFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/LaFunctions.java @@ -65,7 +65,6 @@ import com.oracle.truffle.r.runtime.data.RStringVector; import com.oracle.truffle.r.runtime.data.RVector; import com.oracle.truffle.r.runtime.data.model.RAbstractDoubleVector; import com.oracle.truffle.r.runtime.data.model.RAbstractVector; -import com.oracle.truffle.r.runtime.data.nodes.GetDataCopy; import com.oracle.truffle.r.runtime.data.nodes.GetReadonlyData; import com.oracle.truffle.r.runtime.ffi.LapackRFFI; import com.oracle.truffle.r.runtime.ffi.RFFIFactory; @@ -751,7 +750,6 @@ public class LaFunctions { @Specialization protected Object doSvd(String ju, RAbstractDoubleVector x, RAbstractDoubleVector s, RAbstractDoubleVector u, RAbstractDoubleVector vt, - @Cached("create()") GetDataCopy.Double getDataCopyNode, @Cached("createCopyAllAttributes()") CopyAttributesNode copyAttrNode, @Cached("create()") GetDimAttributeNode getDimsNode) { @@ -767,10 +765,10 @@ public class LaFunctions { int[] iwork = new int[8 * Math.min(n, p)]; - double[] xvals = getDataCopyNode.execute(x); - double[] sdata = getDataCopyNode.execute(s); - double[] udata = getDataCopyNode.execute(u); - double[] vtdata = getDataCopyNode.execute(vt); + double[] xvals = x.materialize().getDataTemp(); + double[] sdata = s.materialize().getDataTemp(); + double[] udata = u.materialize().getDataTemp(); + double[] vtdata = vt.materialize().getDataTemp(); double[] tmp = new double[1]; int info = dgesddNode.execute(ju.charAt(0), n, p, xvals, n, sdata, udata, ldu, vtdata, ldvt, tmp, -1, iwork); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/primitive/Utils.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/primitive/Utils.java deleted file mode 100644 index 3ec6b0e3b7..0000000000 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/primitive/Utils.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2017, 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.nodes.primitive; - -import com.oracle.truffle.r.runtime.RInternalError; -import com.oracle.truffle.r.runtime.RType; -import com.oracle.truffle.r.runtime.data.model.RAbstractVector; -import com.oracle.truffle.r.runtime.data.nodes.SetDataAt; -import com.oracle.truffle.r.runtime.data.nodes.VectorIterator; - -abstract class Utils { - private Utils() { - } - - static SetDataAt createSetDataAtNode(RType type) { - switch (type) { - case Raw: - return SetDataAt.Raw.create(); - case Logical: - return SetDataAt.Logical.create(); - case Integer: - return SetDataAt.Int.create(); - case Double: - return SetDataAt.Double.create(); - case Complex: - return SetDataAt.Complex.create(); - case Character: - return SetDataAt.String.create(); - default: - throw RInternalError.shouldNotReachHere("BinaryMapNode unexpected result type " + type); - } - } - - static final class VecStore<T extends RAbstractVector> { - public final T vector; - public final Object store; - - VecStore(T vector, Object store) { - this.vector = vector; - this.store = store; - } - } - - public static VectorIterator.Generic createIterator() { - return VectorIterator.Generic.create(); - } - - public static VectorIterator.Generic createIteratorWrapAround() { - return VectorIterator.Generic.createWrapAround(); - } -} diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/EnableNACheckNode.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/EnableNACheckNode.java deleted file mode 100644 index d9884dc626..0000000000 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/EnableNACheckNode.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.runtime.data.nodes; - -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.r.runtime.data.model.RAbstractVector; -import com.oracle.truffle.r.runtime.ops.na.NACheck; - -public abstract class EnableNACheckNode extends Node { - public abstract void execute(NACheck check, RAbstractVector vector); - - public static EnableNACheckNode create() { - return EnableNACheckNodeGen.create(); - } - - @Specialization(guards = "vector.getClass() == clazz", limit = "10") - public void doEnable(NACheck check, RAbstractVector vector, - @Cached("vector.getClass()") Class<? extends RAbstractVector> clazz) { - check.enable(clazz.cast(vector)); - } - - @Specialization(replaces = "doEnable") - public void doEnableGeneric(NACheck check, RAbstractVector vector) { - check.enable(vector); - } -} diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/GetDataAt.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/GetDataAt.java deleted file mode 100644 index e85b37ebc4..0000000000 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/GetDataAt.java +++ /dev/null @@ -1,369 +0,0 @@ -/* - * 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.runtime.data.nodes; - -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.ImportStatic; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.r.runtime.RInternalError; -import com.oracle.truffle.r.runtime.data.NativeDataAccess; -import com.oracle.truffle.r.runtime.data.RComplex; -import com.oracle.truffle.r.runtime.data.RComplexVector; -import com.oracle.truffle.r.runtime.data.RDoubleSequence; -import com.oracle.truffle.r.runtime.data.RDoubleVector; -import com.oracle.truffle.r.runtime.data.RIntSequence; -import com.oracle.truffle.r.runtime.data.RIntVector; -import com.oracle.truffle.r.runtime.data.RLogicalVector; -import com.oracle.truffle.r.runtime.data.RRawVector; -import com.oracle.truffle.r.runtime.data.RStringVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractComplexVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractDoubleVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractLogicalVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractRawVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractVector; -import com.oracle.truffle.r.runtime.data.nodes.GetDataAtFactory.DoubleNodeGen; -import com.oracle.truffle.r.runtime.data.nodes.GetDataAtFactory.IntNodeGen; - -/** - * Contains nodes implementing fast-path versions of e.g. - * {@link RAbstractIntVector#getDataAt(Object, int)}. The first parameter 'store' should be - * retrieved for given vector using {@link GetDataStore} node. Store object must be used only for - * accessing the data of the vector for which it was created. The reason for having a store object - * is to avoid field load (field of the RVector object) on every data access. - */ -public abstract class GetDataAt extends Node { - - public abstract Object getAsObject(RAbstractVector vector, Object store, int index); - - @ImportStatic(NativeDataAccess.class) - @SuppressWarnings("unused") - public abstract static class Int extends GetDataAt { - - public static Int create() { - return IntNodeGen.create(); - } - - @Override - public Object getAsObject(RAbstractVector vector, Object store, int index) { - return get((RAbstractIntVector) vector, store, index); - } - - public final int get(RAbstractIntVector vector, Object store, int index) { - return execute(vector, store, index); - } - - public abstract int execute(RAbstractIntVector vector, Object store, int index); - - protected int doRVector(RIntVector vector, int[] store, int index) { - return store[index]; - } - - @Specialization(guards = "isNativeMirror(store)") - protected int doRVector(RIntVector vector, Object store, int index) { - return NativeDataAccess.getIntNativeMirrorData(store, index); - } - - @Specialization - protected int doSequence(RIntSequence sequence, Object store, int index) { - return sequence.getStart() + index * sequence.getStride(); - } - - // This accounts for other vector types, like closures - @Specialization(guards = {"isGenericVector(vector)", "cachedClass == vector.getClass()"}, limit = "3") - protected int doGenericCached(RAbstractIntVector vector, Object store, int index, - @Cached("vector.getClass()") Class<? extends RAbstractIntVector> cachedClass) { - return cachedClass.cast(vector).getDataAt(store, index); - } - - @Specialization(guards = {"isGenericVector(vector)"}, replaces = "doGenericCached") - protected int doGeneric(RAbstractIntVector vector, Object store, int index) { - return vector.getDataAt(store, index); - } - - @Fallback - protected int doFallback(RAbstractIntVector vector, Object store, int index) { - return vector.getDataAt(store, index); - } - - protected static boolean isGenericVector(RAbstractIntVector vector) { - return !(vector instanceof RIntVector) && !(vector instanceof RIntSequence); - } - } - - @ImportStatic(NativeDataAccess.class) - @SuppressWarnings("unused") - public abstract static class Double extends GetDataAt { - - public static Double create() { - return DoubleNodeGen.create(); - } - - @Override - public Object getAsObject(RAbstractVector vector, Object store, int index) { - return get((RAbstractDoubleVector) vector, store, index); - } - - public final double get(RAbstractDoubleVector vector, Object store, int index) { - return execute(vector, store, index); - } - - public abstract double execute(RAbstractDoubleVector vector, Object store, int index); - - @Specialization(guards = "isNativeMirror(store)") - protected double doRVector(RDoubleVector vector, Object store, int index) { - return NativeDataAccess.getDoubleNativeMirrorData(store, index); - } - - @Specialization - protected double doRVector(RDoubleVector vector, double[] store, int index) { - return store[index]; - } - - @Specialization - protected double doSequence(RDoubleSequence sequence, Object store, int index) { - return sequence.getStart() + index * sequence.getStride(); - } - - @Specialization(guards = {"isGenericVector(vector)", "cachedClass == vector.getClass()"}, limit = "3") - protected double doGenericCached(RAbstractDoubleVector vector, Object store, int index, - @Cached("vector.getClass()") Class<?> cachedClass) { - return ((RAbstractDoubleVector) cachedClass.cast(vector)).getDataAt(store, index); - } - - @Specialization(guards = "isGenericVector(vector)", replaces = "doGenericCached") - protected double doGeneric(RAbstractDoubleVector vector, Object store, int index) { - return vector.getDataAt(store, index); - } - - @Fallback - protected double doFallback(RAbstractDoubleVector vector, Object store, int index) { - return vector.getDataAt(store, index); - } - - protected static boolean isGenericVector(RAbstractDoubleVector vector) { - return !(vector instanceof RDoubleVector) && !(vector instanceof RDoubleSequence); - } - } - - @ImportStatic(NativeDataAccess.class) - @SuppressWarnings("unused") - public abstract static class Logical extends GetDataAt { - - public static Logical create() { - return GetDataAtFactory.LogicalNodeGen.create(); - } - - @Override - public Object getAsObject(RAbstractVector vector, Object store, int index) { - return get((RAbstractLogicalVector) vector, store, index); - } - - public final byte get(RAbstractLogicalVector vector, Object store, int index) { - return execute(vector, store, index); - } - - public abstract byte execute(RAbstractLogicalVector vector, Object store, int index); - - protected byte doRVector(RLogicalVector vector, byte[] store, int index) { - return store[index]; - } - - @Specialization(guards = "isNativeMirror(store)") - protected byte doRVector(RLogicalVector vector, Object store, int index) { - return NativeDataAccess.getLogicalNativeMirrorData(store, index); - } - - // This accounts for other vector types, like closures - @Specialization(guards = {"isGenericVector(vector)", "cachedClass == vector.getClass()"}, limit = "3") - protected byte doGenericCached(RAbstractLogicalVector vector, Object store, int index, - @Cached("vector.getClass()") Class<? extends RAbstractLogicalVector> cachedClass) { - return cachedClass.cast(vector).getDataAt(store, index); - } - - @Specialization(guards = {"isGenericVector(vector)"}, replaces = "doGenericCached") - protected byte doGeneric(RAbstractLogicalVector vector, Object store, int index) { - return vector.getDataAt(store, index); - } - - @Fallback - protected byte doFallback(RAbstractLogicalVector vector, Object store, int index) { - return vector.getDataAt(store, index); - } - - protected static boolean isGenericVector(RAbstractLogicalVector vector) { - return !(vector instanceof RLogicalVector); - } - } - - @ImportStatic(NativeDataAccess.class) - @SuppressWarnings("unused") - public abstract static class Raw extends GetDataAt { - - public static Raw create() { - return GetDataAtFactory.RawNodeGen.create(); - } - - @Override - public Object getAsObject(RAbstractVector vector, Object store, int index) { - return get((RAbstractRawVector) vector, store, index); - } - - public final byte get(RAbstractRawVector vector, Object store, int index) { - return execute(vector, store, index); - } - - public abstract byte execute(RAbstractRawVector vector, Object store, int index); - - protected byte doRVector(RRawVector vector, byte[] store, int index) { - return store[index]; - } - - @Specialization(guards = "isNativeMirror(store)") - protected byte doRVector(RRawVector vector, Object store, int index) { - return NativeDataAccess.getRawNativeMirrorData(store, index); - } - - // This accounts for other vector types, like closures - @Specialization(guards = {"isGenericVector(vector)", "cachedClass == vector.getClass()"}, limit = "3") - protected byte doGenericCached(RAbstractRawVector vector, Object store, int index, - @Cached("vector.getClass()") Class<? extends RAbstractRawVector> cachedClass) { - return cachedClass.cast(vector).getRawDataAt(store, index); - } - - @Specialization(guards = {"isGenericVector(vector)"}, replaces = "doGenericCached") - protected byte doGeneric(RAbstractRawVector vector, Object store, int index) { - return vector.getRawDataAt(store, index); - } - - @Fallback - protected byte doFallback(RAbstractRawVector vector, Object store, int index) { - return vector.getRawDataAt(store, index); - } - - protected static boolean isGenericVector(RAbstractRawVector vector) { - return !(vector instanceof RRawVector); - } - } - - @ImportStatic(NativeDataAccess.class) - public abstract static class Complex extends GetDataAt { - - public static Complex create() { - return GetDataAtFactory.ComplexNodeGen.create(); - } - - @Override - public Object getAsObject(RAbstractVector vector, Object store, int index) { - return get((RAbstractComplexVector) vector, store, index); - } - - public final RComplex get(RAbstractComplexVector vector, Object store, int index) { - return execute(vector, store, index); - } - - public abstract RComplex execute(RAbstractComplexVector vector, Object store, int index); - - protected RComplex doRVector(@SuppressWarnings("unused") RComplexVector vector, double[] store, int index) { - return RComplex.valueOf(store[index * 2], store[index * 2 + 1]); - } - - @SuppressWarnings("unused") - @Specialization(guards = "isNativeMirror(store)") - protected RComplex doRVector(RComplexVector vector, Object store, int index) { - throw RInternalError.unimplemented(); - } - - @Specialization(guards = {"isGenericVector(vector)", "cachedClass == vector.getClass()"}, limit = "3") - protected RComplex doGenericCached(RAbstractComplexVector vector, Object store, int index, - @Cached("vector.getClass()") Class<? extends RAbstractComplexVector> cachedClass) { - return cachedClass.cast(vector).getDataAt(store, index); - } - - @Specialization(guards = {"isGenericVector(vector)"}, replaces = "doGenericCached") - protected RComplex doGeneric(RAbstractComplexVector vector, Object store, int index) { - return vector.getDataAt(store, index); - } - - @Fallback - protected RComplex doFallback(RAbstractComplexVector vector, Object store, int index) { - return vector.getDataAt(store, index); - } - - protected static boolean isGenericVector(RAbstractComplexVector vector) { - return !(vector instanceof RComplexVector); - } - } - - @ImportStatic(NativeDataAccess.class) - public abstract static class String extends GetDataAt { - - public static String create() { - return GetDataAtFactory.StringNodeGen.create(); - } - - @Override - public Object getAsObject(RAbstractVector vector, Object store, int index) { - return get((RAbstractStringVector) vector, store, index); - } - - public final java.lang.String get(RAbstractStringVector vector, Object store, int index) { - return execute(vector, store, index); - } - - public abstract java.lang.String execute(RAbstractStringVector vector, Object store, int index); - - protected java.lang.String doRVector(@SuppressWarnings("unused") RStringVector vector, java.lang.String[] store, int index) { - return store[index]; - } - - @SuppressWarnings("unused") - @Specialization(guards = "isNativeMirror(store)") - protected java.lang.String doRVector(RStringVector vector, Object store, int index) { - throw RInternalError.unimplemented(); - } - - @Specialization(guards = {"isGenericVector(vector)", "cachedClass == vector.getClass()"}) - protected java.lang.String doGenericCached(RAbstractStringVector vector, Object store, int index, - @Cached("vector.getClass()") Class<? extends RAbstractStringVector> cachedClass) { - return cachedClass.cast(vector).getDataAt(store, index); - } - - @Specialization(guards = {"isGenericVector(vector)"}, replaces = "doGenericCached") - protected java.lang.String doGeneric(RAbstractStringVector vector, Object store, int index) { - return vector.getDataAt(store, index); - } - - @Fallback - protected java.lang.String doFallback(RAbstractStringVector vector, Object store, int index) { - return vector.getDataAt(store, index); - } - - protected static boolean isGenericVector(RAbstractStringVector vector) { - return !(vector instanceof RStringVector); - } - } -} diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/GetDataCopy.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/GetDataCopy.java deleted file mode 100644 index ebd66da59d..0000000000 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/GetDataCopy.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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.runtime.data.nodes; - -import java.util.Arrays; - -import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.r.runtime.RInternalError; -import com.oracle.truffle.r.runtime.data.NativeDataAccess; -import com.oracle.truffle.r.runtime.data.RDoubleVector; -import com.oracle.truffle.r.runtime.data.RStringVector; -import com.oracle.truffle.r.runtime.data.RVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractDoubleVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; -import com.oracle.truffle.r.runtime.data.nodes.GetDataCopyFactory.DoubleNodeGen; -import com.oracle.truffle.r.runtime.data.nodes.GetDataCopyFactory.StringNodeGen; - -/** - * Nodes contained in this class materialize given vector into an array of corresponding type. The - * array is always a copy of the original data and can be modified freely. - * - * @see RVector#getDataCopy() - */ -public abstract class GetDataCopy { - - public abstract static class Double extends Node { - public abstract double[] execute(RAbstractDoubleVector vector); - - public static Double create() { - return DoubleNodeGen.create(); - } - - @Specialization(guards = "!vec.hasNativeMemoryData()") - protected double[] doManagedRVector(RDoubleVector vec) { - double[] data = vec.getInternalManagedData(); - return Arrays.copyOf(data, data.length); - } - - @Specialization(guards = "vec.hasNativeMemoryData()") - protected double[] doNativeDataRVector(RDoubleVector vec) { - return NativeDataAccess.copyDoubleNativeData(vec.getNativeMirror()); - } - - @Fallback - protected double[] doOthers(RAbstractDoubleVector vec) { - int len = vec.getLength(); - double[] result = new double[len]; - Object store = vec.getInternalStore(); - for (int i = 0; i < len; i++) { - result[i] = vec.getDataAt(store, i); - } - return result; - } - } - - public abstract static class String extends Node { - public abstract java.lang.String[] execute(RAbstractStringVector vector); - - public static String create() { - return StringNodeGen.create(); - } - - @Specialization(guards = "vec.hasNativeMemoryData()") - protected java.lang.String[] doManagedRVector(@SuppressWarnings("unused") RStringVector vec) { - throw RInternalError.unimplemented("string vectors backed by native memory"); - } - - @Specialization(guards = "!vec.hasNativeMemoryData()") - protected java.lang.String[] doNativeDataRVector(RStringVector vec) { - java.lang.String[] data = vec.getInternalManagedData(); - return Arrays.copyOf(data, data.length); - } - } -} diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/GetDataStore.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/GetDataStore.java deleted file mode 100644 index a9baa4b417..0000000000 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/GetDataStore.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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.runtime.data.nodes; - -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.r.runtime.data.RVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractVector; - -public abstract class GetDataStore extends Node { - - protected static final int CACHE_LIMIT = 6; - - public static GetDataStore create() { - return GetDataStoreNodeGen.create(); - } - - public abstract Object execute(RAbstractVector vector); - - @Specialization(guards = "vector.hasNativeMemoryData()") - protected Object doNative(RVector<?> vector) { - return vector.getNativeMirror(); - } - - @Specialization(guards = {"noNativeMemoryData(vector)", "vector.getClass() == vectorClass"}, limit = "CACHE_LIMIT") - protected Object doCached(RAbstractVector vector, - @Cached("vector.getClass()") Class<? extends RAbstractVector> vectorClass, - @Cached("getStoreClass(vector)") Class<?> storeClass) { - Object store = vectorClass.cast(vector).getInternalStore(); - assert store.getClass() == storeClass : "every concrete implementation of RAbstractVector#getInternalStore() must always return a store object of the same type."; - return storeClass.cast(store); - } - - @Specialization(replaces = "doCached", guards = {"noNativeMemoryData(vector)"}) - protected Object doGeneric(RAbstractVector vector) { - Object store = vector.getInternalStore(); - return store; - } - - @Fallback - protected Object doFallback(RAbstractVector vector) { - if (noNativeMemoryData(vector)) { - RVector<?> vec = (RVector<?>) vector; - if (vec.hasNativeMemoryData()) { - return vec.getNativeMirror(); - } - } - return vector.getInternalStore(); - } - - protected static boolean noNativeMemoryData(RAbstractVector vector) { - return !(vector instanceof RVector<?>) || !((RVector<?>) vector).hasNativeMemoryData(); - } - - protected static Class<?> getStoreClass(RAbstractVector vector) { - return vector.getInternalStore().getClass(); - } -} diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/ReadAccessor.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/ReadAccessor.java deleted file mode 100644 index 997488a9de..0000000000 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/ReadAccessor.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * 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.runtime.data.nodes; - -import com.oracle.truffle.r.runtime.data.RComplex; -import com.oracle.truffle.r.runtime.data.model.RAbstractComplexVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractDoubleVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractLogicalVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractRawVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; - -/** - * Convenience classes that wraps {@link VectorReadAccess} node, the vector and its store so that - * those data can be passed around as a single paramter. - */ -public abstract class ReadAccessor { - private ReadAccessor() { - } - - public static final class Int extends ReadAccessor { - private final RAbstractIntVector vector; - private final VectorReadAccess.Int readAccess; - private final Object store; - - public Int(RAbstractIntVector vector, VectorReadAccess.Int readAccess) { - this.vector = vector; - this.readAccess = readAccess; - store = readAccess.getDataStore(vector); - } - - public int getDataAt(int index) { - return readAccess.getDataAt(vector, store, index); - } - - public Object getStore() { - return store; - } - - public RAbstractIntVector getVector() { - return vector; - } - } - - public static final class Double extends ReadAccessor { - private final RAbstractDoubleVector vector; - private final VectorReadAccess.Double readAccess; - private final Object store; - - public Double(RAbstractDoubleVector vector, VectorReadAccess.Double readAccess) { - this.vector = vector; - this.readAccess = readAccess; - store = readAccess.getDataStore(vector); - } - - public double getDataAt(int index) { - return readAccess.getDataAt(vector, store, index); - } - - public Object getStore() { - return store; - } - - public RAbstractDoubleVector getVector() { - return vector; - } - } - - public static final class Logical extends ReadAccessor { - private final RAbstractLogicalVector vector; - private final VectorReadAccess.Logical readAccess; - private final Object store; - - public Logical(RAbstractLogicalVector vector, VectorReadAccess.Logical readAccess) { - this.vector = vector; - this.readAccess = readAccess; - store = readAccess.getDataStore(vector); - } - - public byte getDataAt(int index) { - return readAccess.getDataAt(vector, store, index); - } - - public Object getStore() { - return store; - } - - public RAbstractLogicalVector getVector() { - return vector; - } - } - - public static final class Raw extends ReadAccessor { - private final RAbstractRawVector vector; - private final VectorReadAccess.Raw readAccess; - private final Object store; - - public Raw(RAbstractRawVector vector, VectorReadAccess.Raw readAccess) { - this.vector = vector; - this.readAccess = readAccess; - store = readAccess.getDataStore(vector); - } - - public byte getDataAt(int index) { - return readAccess.getDataAt(vector, store, index); - } - - public Object getStore() { - return store; - } - - public RAbstractRawVector getVector() { - return vector; - } - } - - public static final class Complex extends ReadAccessor { - private final RAbstractComplexVector vector; - private final VectorReadAccess.Complex readAccess; - private final Object store; - - public Complex(RAbstractComplexVector vector, VectorReadAccess.Complex readAccess) { - this.vector = vector; - this.readAccess = readAccess; - store = readAccess.getDataStore(vector); - } - - public RComplex getDataAt(int index) { - return readAccess.getDataAt(vector, store, index); - } - - public Object getStore() { - return store; - } - - public RAbstractComplexVector getVector() { - return vector; - } - } - - public static final class String extends ReadAccessor { - private final RAbstractStringVector vector; - private final VectorReadAccess.String readAccess; - private final Object store; - - public String(RAbstractStringVector vector, VectorReadAccess.String readAccess) { - this.vector = vector; - this.readAccess = readAccess; - store = readAccess.getDataStore(vector); - } - - public java.lang.String getDataAt(int index) { - return readAccess.getDataAt(vector, store, index); - } - - public Object getStore() { - return store; - } - - public RAbstractStringVector getVector() { - return vector; - } - } -} diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/SetDataAt.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/SetDataAt.java deleted file mode 100644 index 297b29b932..0000000000 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/SetDataAt.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * 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.runtime.data.nodes; - -import com.oracle.truffle.api.dsl.ImportStatic; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.r.runtime.RInternalError; -import com.oracle.truffle.r.runtime.data.NativeDataAccess; -import com.oracle.truffle.r.runtime.data.RComplex; -import com.oracle.truffle.r.runtime.data.RComplexVector; -import com.oracle.truffle.r.runtime.data.RDoubleVector; -import com.oracle.truffle.r.runtime.data.RIntVector; -import com.oracle.truffle.r.runtime.data.RLogicalVector; -import com.oracle.truffle.r.runtime.data.RRawVector; -import com.oracle.truffle.r.runtime.data.RStringVector; -import com.oracle.truffle.r.runtime.data.RVector; - -public abstract class SetDataAt extends Node { - - public abstract void setDataAtAsObject(RVector<?> vector, Object store, int index, Object value); - - @ImportStatic(NativeDataAccess.class) - @SuppressWarnings("unused") - public abstract static class Double extends SetDataAt { - - @Override - public final void setDataAtAsObject(RVector<?> vector, Object store, int index, Object value) { - setDataAt((RDoubleVector) vector, store, index, (double) value); - } - - public final void setDataAt(RDoubleVector vector, Object store, int index, double value) { - execute(vector, store, index, value); - } - - public abstract void execute(RDoubleVector vector, Object store, int index, double value); - - @Specialization(guards = "!isNativeMirror(store)") - protected void doManagedRVector(RDoubleVector vec, Object store, int index, double value) { - ((double[]) store)[index] = value; - } - - @Specialization(guards = "isNativeMirror(store)") - protected void doNativeDataRVector(RDoubleVector vec, Object store, int index, double value) { - NativeDataAccess.setNativeMirrorData(store, index, value); - } - - public static Double create() { - return SetDataAtFactory.DoubleNodeGen.create(); - } - } - - @ImportStatic(NativeDataAccess.class) - @SuppressWarnings("unused") - public abstract static class Int extends SetDataAt { - - @Override - public final void setDataAtAsObject(RVector<?> vector, Object store, int index, Object value) { - setDataAt((RIntVector) vector, store, index, (int) value); - } - - public final void setDataAt(RIntVector vector, Object store, int index, int value) { - execute(vector, store, index, value); - } - - public abstract void execute(RIntVector vector, Object store, int index, int value); - - @Specialization(guards = "!isNativeMirror(store)") - protected void doManagedRVector(RIntVector vec, Object store, int index, int value) { - ((int[]) store)[index] = value; - } - - @Specialization(guards = "isNativeMirror(store)") - protected void doNativeDataRVector(RIntVector vec, Object store, int index, int value) { - NativeDataAccess.setNativeMirrorData(store, index, value); - } - - public static Int create() { - return SetDataAtFactory.IntNodeGen.create(); - } - } - - @ImportStatic(NativeDataAccess.class) - @SuppressWarnings("unused") - public abstract static class Logical extends SetDataAt { - - @Override - public final void setDataAtAsObject(RVector<?> vector, Object store, int index, Object value) { - setDataAt((RLogicalVector) vector, store, index, (byte) value); - } - - public final void setDataAt(RLogicalVector vector, Object store, int index, byte value) { - execute(vector, store, index, value); - } - - public abstract void execute(RLogicalVector vector, Object store, int index, byte value); - - @Specialization(guards = "!isNativeMirror(store)") - protected void doManagedRVector(RLogicalVector vec, Object store, int index, byte value) { - ((byte[]) store)[index] = value; - } - - @Specialization(guards = "isNativeMirror(store)") - protected void doNativeDataRVector(RLogicalVector vec, Object store, int index, byte value) { - NativeDataAccess.setNativeMirrorData(store, index, value); - } - - public static Logical create() { - return SetDataAtFactory.LogicalNodeGen.create(); - } - } - - @ImportStatic(NativeDataAccess.class) - @SuppressWarnings("unused") - public abstract static class Raw extends SetDataAt { - - @Override - public final void setDataAtAsObject(RVector<?> vector, Object store, int index, Object value) { - setDataAt((RRawVector) vector, store, index, (byte) value); - } - - public final void setDataAt(RRawVector vector, Object store, int index, byte value) { - execute(vector, store, index, value); - } - - public abstract void execute(RRawVector vector, Object store, int index, byte value); - - @Specialization(guards = "!isNativeMirror(store)") - protected void doManagedRVector(RRawVector vec, Object store, int index, byte value) { - ((byte[]) store)[index] = value; - } - - @Specialization(guards = "isNativeMirror(store)") - protected void doNativeDataRVector(RRawVector vec, Object store, int index, byte value) { - NativeDataAccess.setNativeMirrorData(store, index, value); - } - - public static Raw create() { - return SetDataAtFactory.RawNodeGen.create(); - } - } - - @ImportStatic(NativeDataAccess.class) - @SuppressWarnings("unused") - public abstract static class Complex extends SetDataAt { - - @Override - public final void setDataAtAsObject(RVector<?> vector, Object store, int index, Object value) { - setDataAt((RComplexVector) vector, store, index, (RComplex) value); - } - - public final void setDataAt(RComplexVector vector, Object store, int index, RComplex value) { - execute(vector, store, index, value); - } - - public abstract void execute(RComplexVector vector, Object store, int index, RComplex value); - - @Specialization(guards = "!isNativeMirror(storeObj)") - protected void doManagedRVector(RComplexVector vec, Object storeObj, int index, RComplex value) { - double[] store = (double[]) storeObj; - store[index * 2] = value.getRealPart(); - store[index * 2 + 1] = value.getImaginaryPart(); - } - - @Specialization(guards = "isNativeMirror(store)") - protected void doNativeDataRVector(RComplexVector vec, Object store, int index, RComplex value) { - throw RInternalError.unimplemented(); - } - - public static Complex create() { - return SetDataAtFactory.ComplexNodeGen.create(); - } - } - - @ImportStatic(NativeDataAccess.class) - @SuppressWarnings("unused") - public abstract static class String extends SetDataAt { - - @Override - public final void setDataAtAsObject(RVector<?> vector, Object store, int index, Object value) { - setDataAt((RStringVector) vector, store, index, (java.lang.String) value); - } - - public final void setDataAt(RStringVector vector, Object store, int index, java.lang.String value) { - execute(vector, store, index, value); - } - - public abstract void execute(RStringVector vector, Object store, int index, java.lang.String value); - - @Specialization(guards = "!isNativeMirror(store)") - protected void doManagedRVector(RStringVector vec, Object store, int index, java.lang.String value) { - ((java.lang.String[]) store)[index] = value; - } - - @Specialization(guards = "isNativeMirror(store)") - protected void doNativeDataRVector(RStringVector vec, Object store, int index, java.lang.String value) { - throw RInternalError.unimplemented(); - } - - public static String create() { - return SetDataAtFactory.StringNodeGen.create(); - } - } -} diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/VectorAccessAdapter.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/VectorAccessAdapter.java deleted file mode 100644 index c42c45e40b..0000000000 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/VectorAccessAdapter.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.runtime.data.nodes; - -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.r.runtime.data.model.RAbstractVector; - -/** - * Factors out common code. - */ -abstract class VectorAccessAdapter extends Node { - @Child private GetDataStore getDataStoreNode = GetDataStoreNodeGen.create(); - - public Object getDataStore(RAbstractVector vector) { - return getDataStoreNode.execute(vector); - } -} diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/VectorIterator.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/VectorIterator.java deleted file mode 100644 index ebb528ff5b..0000000000 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/VectorIterator.java +++ /dev/null @@ -1,385 +0,0 @@ -/* - * 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.runtime.data.nodes; - -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.ValueType; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.r.runtime.RInternalError; -import com.oracle.truffle.r.runtime.Utils; -import com.oracle.truffle.r.runtime.data.NativeDataAccess; -import com.oracle.truffle.r.runtime.data.RComplex; -import com.oracle.truffle.r.runtime.data.RComplexVector; -import com.oracle.truffle.r.runtime.data.RDoubleVector; -import com.oracle.truffle.r.runtime.data.RIntVector; -import com.oracle.truffle.r.runtime.data.RLogicalVector; -import com.oracle.truffle.r.runtime.data.RRawVector; -import com.oracle.truffle.r.runtime.data.RStringVector; -import com.oracle.truffle.r.runtime.data.RVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractComplexVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractDoubleVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractLogicalVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractRawVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractVector; -import com.oracle.truffle.r.runtime.data.nodes.GetNextNodeGen.GetNextGenericNodeGen; -import com.oracle.truffle.r.runtime.data.nodes.VectorIterator.IteratorData; - -abstract class VectorIteratorNodeAdapter extends Node { - public static boolean hasNoNativeMemoryData(RAbstractVector vector, Class<? extends RAbstractVector> vecClass) { - return !(RVector.class.isAssignableFrom(vecClass)) || !((RVector<?>) vecClass.cast(vector)).hasNativeMemoryData(); - } - - public static boolean isRVector(Class<? extends RAbstractVector> vecClass) { - return RVector.class.isAssignableFrom(vecClass); - } -} - -abstract class GetIteratorNode extends VectorIteratorNodeAdapter { - public abstract IteratorData<?> execute(RAbstractVector vector); - - @Specialization(guards = "vector.hasNativeMemoryData()") - protected IteratorData<?> nativeMirrorIterator(RVector<?> vector) { - return new IteratorData<>(vector.getNativeMirror(), vector.getLength()); - } - - @Specialization(guards = {"vectorClass == vector.getClass()", "hasNoNativeMemoryData(vector, vectorClass)"}, limit = "10") - protected IteratorData<?> cached(RAbstractVector vector, - @Cached("vector.getClass()") Class<? extends RAbstractVector> vectorClass) { - RAbstractVector profiledVec = vectorClass.cast(vector); - return new IteratorData<>(profiledVec.getInternalStore(), profiledVec.getLength()); - } - - @Specialization(replaces = "cached", guards = {"hasNoNativeMemoryData(vector, vector.getClass())"}) - protected IteratorData<?> generic(RAbstractVector vector) { - RAbstractVector profiledVec = vector; - return new IteratorData<>(profiledVec.getInternalStore(), profiledVec.getLength()); - } - - @Fallback - protected IteratorData<?> fallback(RAbstractVector vector) { - return new IteratorData<>(vector.getInternalStore(), vector.getLength()); - } -} - -@SuppressWarnings("unused") -abstract class HasNextNode extends VectorIteratorNodeAdapter { - public abstract boolean execute(RAbstractVector vector, IteratorData<?> iterator); - - @Specialization(guards = "!iter.hasNativeMirror()") - protected boolean intVector(RIntVector vector, IteratorData<?> iter) { - return iter.index < ((int[]) iter.store).length; - } - - @Specialization(guards = "!iter.hasNativeMirror()") - protected boolean doubleVector(RDoubleVector vector, IteratorData<?> iter) { - return iter.index < ((double[]) iter.store).length; - } - - @Specialization(guards = "!iter.hasNativeMirror()") - protected boolean logicalVector(RLogicalVector vector, IteratorData<?> iter) { - return iter.index < ((byte[]) iter.store).length; - } - - @Specialization(guards = "!iter.hasNativeMirror()") - protected boolean rawVector(RRawVector vector, IteratorData<?> iter) { - return iter.index < ((byte[]) iter.store).length; - } - - @Specialization(guards = "!iter.hasNativeMirror()") - protected boolean stringVector(RStringVector vector, IteratorData<?> iter) { - return iter.index < ((String[]) iter.store).length; - } - - @Specialization(guards = {"vectorClass == vector.getClass()", "!isRVector(vectorClass)"}, limit = "10") - protected boolean generic(RAbstractVector vector, IteratorData<?> iter, - @Cached("vector.getClass()") Class<? extends RAbstractVector> vectorClass) { - RAbstractVector profiledVec = vectorClass.cast(vector); - return iter.index < profiledVec.getLength(); - } - - @Specialization - protected boolean generic(RAbstractVector vector, IteratorData<?> iter) { - return iter.index < vector.getLength(); - } -} - -@SuppressWarnings("unused") -abstract class GetNextNode extends VectorIteratorNodeAdapter { - public abstract Object execute(RAbstractVector vector, IteratorData<?> iterator); - - @Specialization(guards = "!iter.hasNativeMirror()") - protected int intVector(RIntVector vector, IteratorData<?> iter) { - return ((int[]) iter.store)[iter.index]; - } - - @Specialization(guards = "!iter.hasNativeMirror()") - protected double doubleVector(RDoubleVector vector, IteratorData<?> iter) { - return ((double[]) iter.store)[iter.index]; - } - - @Specialization(guards = "!iter.hasNativeMirror()") - protected byte logicalVector(RLogicalVector vector, IteratorData<?> iter) { - return ((byte[]) iter.store)[iter.index]; - } - - @Specialization(guards = "!iter.hasNativeMirror()") - protected RComplex doComplexVector(RComplexVector vector, IteratorData<?> iter) { - double[] arr = (double[]) iter.store; - return RComplex.valueOf(arr[iter.index * 2], arr[iter.index * 2 + 1]); - } - - @Specialization(guards = "!iter.hasNativeMirror()") - protected byte doRawVector(RRawVector vector, IteratorData<?> iter) { - return ((byte[]) iter.store)[iter.index]; - } - - @Specialization(guards = "!iter.hasNativeMirror()") - protected String doStringVector(RStringVector vector, IteratorData<?> iter) { - return ((String[]) iter.store)[iter.index]; - } - - @Specialization(guards = "iter.hasNativeMirror()") - protected int intVectorNative(RIntVector vector, IteratorData<?> iter) { - return NativeDataAccess.getIntNativeMirrorData(iter.store, iter.index); - } - - @Specialization(guards = "iter.hasNativeMirror()") - protected double doubleVectorNative(RDoubleVector vector, IteratorData<?> iter) { - return NativeDataAccess.getDoubleNativeMirrorData(iter.store, iter.index); - } - - @Specialization(guards = "iter.hasNativeMirror()") - protected byte logicalVectorNative(RLogicalVector vector, IteratorData<?> iter) { - return NativeDataAccess.getLogicalNativeMirrorData(iter.store, iter.index); - } - - @Specialization(guards = "iter.hasNativeMirror()") - protected byte doubleVectorNative(RRawVector vector, IteratorData<?> iter) { - return NativeDataAccess.getRawNativeMirrorData(iter.store, iter.index); - } - - @Specialization(guards = "iter.hasNativeMirror()") - protected RComplex complexVectorNative(RComplexVector vector, IteratorData<?> iter) { - return NativeDataAccess.getComplexNativeMirrorData(iter.store, iter.index); - } - - @Specialization(guards = "iter.hasNativeMirror()") - protected byte stringVectorNative(RStringVector vector, IteratorData<?> iter) { - throw RInternalError.unimplemented("string vectors backed by native memory"); - } - - @Child private GetNextGenericNode getNextGenericNode; - - @Fallback - protected Object doGeneric(RAbstractVector vector, IteratorData<?> iter) { - // we use fallback and extra node so that we do not have to explicitly check that the vector - // is not - // RVector, DSL generates fallback guard that compares the class with the all RVector - // subclasses - // used in the specializations above, "vector instanceof RVector" would not be a leaf-check. - if (getNextGenericNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - getNextGenericNode = insert(GetNextGenericNode.create()); - } - return getNextGenericNode.execute(vector, iter); - } - - abstract static class GetNextGenericNode extends Node { - public abstract Object execute(RAbstractVector vector, IteratorData<?> iter); - - public static GetNextGenericNode create() { - return GetNextGenericNodeGen.create(); - } - - @Specialization - protected int intVectorGeneric(RAbstractIntVector vector, IteratorData<?> iter, - @Cached("create()") GetDataAt.Int getDataAtNode) { - return getDataAtNode.get(vector, iter.store, iter.index); - } - - @Specialization - protected double doubleVectorGeneric(RAbstractDoubleVector vector, IteratorData<?> iter, - @Cached("create()") GetDataAt.Double getDataAtNode) { - return getDataAtNode.get(vector, iter.store, iter.index); - } - - @Specialization - protected String stringVectorGeneric(RAbstractStringVector vector, IteratorData<?> iter, - @Cached("create()") GetDataAt.String getDataAtNode) { - return getDataAtNode.get(vector, iter.store, iter.index); - } - - @Specialization - protected byte rawVectorGeneric(RAbstractRawVector vector, IteratorData<?> iter, - @Cached("create()") GetDataAt.Raw getDataAtNode) { - return getDataAtNode.get(vector, iter.store, iter.index); - } - - @Specialization - protected byte logicalVectorGeneric(RAbstractLogicalVector vector, IteratorData<?> iter, - @Cached("create()") GetDataAt.Logical getDataAtNode) { - return getDataAtNode.get(vector, iter.store, iter.index); - } - - @Specialization - protected RComplex complexVectorGeneric(RAbstractComplexVector vector, IteratorData<?> iter, - @Cached("create()") GetDataAt.Complex getDataAtNode) { - return getDataAtNode.get(vector, iter.store, iter.index); - } - } -} - -// Checkstyle: stop final class check -// Note: the VectorIterator cannot be final, it has inner subclasses, which probably confuses check -// style - -/** - * This node wraps 3 nodes needed to sequentially iterate a given vector and provides convenience - * methods to invoke those nodes: {@link #init(RAbstractVector)}, - * {@link #next(RAbstractVector, Object)} and {@link #hasNext(RAbstractVector, Object)}. - * - * To construct use factory methods from type specialized inner classes, e.g. {@link Int#create()}, - * or generic version if the iterated vector could be of any type {@link Generic#create()}. - * - * Iterator can wrap around, i.e. once the iteration ends, it starts again from the first element. - */ -public abstract class VectorIterator<T> extends Node { - - // Note: it could be worth adding a LoopConditionProfile, however, it must be shared between - // getIteratorNode and getNextNode - - @Child private GetIteratorNode getIteratorNode = GetIteratorNodeGen.create(); - @Child private HasNextNode hasNextNode; - @Child private GetNextNode getNextNode = GetNextNodeGen.create(); - private final boolean wrapAround; - - private VectorIterator(boolean wrapAround) { - this.wrapAround = wrapAround; - if (!wrapAround) { - hasNextNode = HasNextNodeGen.create(); - } - } - - public Object init(RAbstractVector vector) { - return getIteratorNode.execute(vector); - } - - public boolean hasNext(RAbstractVector vector, Object iterator) { - assert !wrapAround : "wrap-around iteration does not support hasNext"; - return hasNextNode.execute(vector, (IteratorData<?>) iterator); - } - - @SuppressWarnings("unchecked") - public T next(RAbstractVector vector, Object iterator) { - IteratorData<T> it = (IteratorData<T>) iterator; - assert it.index < it.length; - Object result = getNextNode.execute(vector, it); - if (wrapAround) { - it.index = Utils.incMod(it.index, it.length); - } else { - it.index++; - } - return (T) result; - } - - public static final class Generic extends VectorIterator<Object> { - - private Generic(boolean wrapAround) { - super(wrapAround); - } - - public static Generic create() { - return new Generic(false); - } - - public static Generic createWrapAround() { - return new Generic(true); - } - } - - public static final class Int extends VectorIterator<Integer> { - - public Int(boolean wrapAround) { - super(wrapAround); - } - - public static Int create() { - return new Int(false); - } - } - - public static final class Double extends VectorIterator<java.lang.Double> { - public Double(boolean wrapAround) { - super(wrapAround); - } - - public static Double create() { - return new Double(false); - } - - public static Double createWrapAround() { - return new Double(true); - } - } - - public static final class Logical extends VectorIterator<Byte> { - public Logical(boolean wrapAround) { - super(wrapAround); - } - - public static Logical create() { - return new Logical(false); - } - } - - public static final class Raw extends VectorIterator<Byte> { - public Raw(boolean wrapAround) { - super(wrapAround); - } - - public static Raw create() { - return new Raw(false); - } - } - - @ValueType - public static final class IteratorData<StoreT> { - public int index = 0; - public final StoreT store; - public final int length; - - public IteratorData(StoreT store, int length) { - this.store = store; - this.length = length; - } - - public boolean hasNativeMirror() { - return NativeDataAccess.isNativeMirror(store); - } - } -} diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/VectorReadAccess.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/VectorReadAccess.java deleted file mode 100644 index f4d70cdf22..0000000000 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/VectorReadAccess.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * 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.runtime.data.nodes; - -import com.oracle.truffle.api.nodes.NodeCost; -import com.oracle.truffle.api.nodes.NodeInfo; -import com.oracle.truffle.r.runtime.data.RComplex; -import com.oracle.truffle.r.runtime.data.model.RAbstractComplexVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractDoubleVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractLogicalVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractRawVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractVector; - -/** - * Contains nodes that encapsulate {@link GetDataStore} and one of the nodes from {@link GetDataAt} - * as these are often used together. These are convenience wrappers to be used e.g. for a @Cached - * parameter. - */ -public abstract class VectorReadAccess extends VectorAccessAdapter { - - public abstract Object getDataAtAsObject(RAbstractVector vector, Object store, int index); - - @NodeInfo(cost = NodeCost.NONE) - public static final class Double extends VectorReadAccess { - @Child private GetDataAt.Double getDataAtNode = GetDataAt.Double.create(); - - public double getDataAt(RAbstractDoubleVector vec, Object store, int index) { - return getDataAtNode.get(vec, store, index); - } - - @Override - public Object getDataAtAsObject(RAbstractVector vector, Object store, int index) { - return getDataAt((RAbstractDoubleVector) vector, store, index); - } - - public static Double create() { - return new Double(); - } - } - - @NodeInfo(cost = NodeCost.NONE) - public static final class Int extends VectorReadAccess { - @Child private GetDataAt.Int getDataAtNode = GetDataAt.Int.create(); - - public int getDataAt(RAbstractIntVector vec, Object store, int index) { - return getDataAtNode.get(vec, store, index); - } - - @Override - public Object getDataAtAsObject(RAbstractVector vector, Object store, int index) { - return getDataAt((RAbstractIntVector) vector, store, index); - } - - public static Int create() { - return new Int(); - } - } - - @NodeInfo(cost = NodeCost.NONE) - public static final class Logical extends VectorReadAccess { - @Child private GetDataAt.Logical getDataAtNode = GetDataAt.Logical.create(); - - public byte getDataAt(RAbstractLogicalVector vec, Object store, int index) { - return getDataAtNode.get(vec, store, index); - } - - @Override - public Object getDataAtAsObject(RAbstractVector vector, Object store, int index) { - return getDataAt((RAbstractLogicalVector) vector, store, index); - } - - public static Logical create() { - return new Logical(); - } - } - - @NodeInfo(cost = NodeCost.NONE) - public static final class Complex extends VectorReadAccess { - @Child private GetDataAt.Complex getDataAtNode = GetDataAt.Complex.create(); - - public RComplex getDataAt(RAbstractComplexVector vec, Object store, int index) { - return getDataAtNode.get(vec, store, index); - } - - @Override - public Object getDataAtAsObject(RAbstractVector vector, Object store, int index) { - return getDataAt((RAbstractComplexVector) vector, store, index); - } - - public static Complex create() { - return new Complex(); - } - } - - @NodeInfo(cost = NodeCost.NONE) - public static final class String extends VectorReadAccess { - @Child private GetDataAt.String getDataAtNode = GetDataAt.String.create(); - - public java.lang.String getDataAt(RAbstractStringVector vec, Object store, int index) { - return getDataAtNode.get(vec, store, index); - } - - @Override - public Object getDataAtAsObject(RAbstractVector vector, Object store, int index) { - return getDataAt((RAbstractStringVector) vector, store, index); - } - - public static String create() { - return new String(); - } - } - - @NodeInfo(cost = NodeCost.NONE) - public static final class Raw extends VectorReadAccess { - @Child private GetDataAt.Raw getDataAtNode = GetDataAt.Raw.create(); - - public byte getDataAt(RAbstractRawVector vec, Object store, int index) { - return getDataAtNode.get(vec, store, index); - } - - @Override - public Object getDataAtAsObject(RAbstractVector vector, Object store, int index) { - return getDataAt((RAbstractRawVector) vector, store, index); - } - - public static Raw create() { - return new Raw(); - } - } -} diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/VectorWriteAccess.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/VectorWriteAccess.java deleted file mode 100644 index 8c8af33639..0000000000 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/VectorWriteAccess.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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.runtime.data.nodes; - -import com.oracle.truffle.api.nodes.NodeCost; -import com.oracle.truffle.api.nodes.NodeInfo; -import com.oracle.truffle.r.runtime.data.RComplex; -import com.oracle.truffle.r.runtime.data.RComplexVector; -import com.oracle.truffle.r.runtime.data.RDoubleVector; -import com.oracle.truffle.r.runtime.data.RIntVector; -import com.oracle.truffle.r.runtime.data.RLogicalVector; -import com.oracle.truffle.r.runtime.data.RRawVector; -import com.oracle.truffle.r.runtime.data.RStringVector; - -/** - * Contains nodes that encapsulate {@link GetDataStore} and one of the nodes from {@link SetDataAt} - * as these are often used together. These are convenience wrappers to be used e.g. for a @Cached - * parameter. - */ -public abstract class VectorWriteAccess { - @NodeInfo(cost = NodeCost.NONE) - public static final class Double extends VectorAccessAdapter { - @Child private SetDataAt.Double setDataAtNode = SetDataAt.Double.create(); - - public void setDataAt(RDoubleVector vector, Object store, int index, double value) { - setDataAtNode.setDataAt(vector, store, index, value); - } - - public static Double create() { - return new Double(); - } - } - - @NodeInfo(cost = NodeCost.NONE) - public static final class Int extends VectorAccessAdapter { - @Child private SetDataAt.Int setDataAtNode = SetDataAt.Int.create(); - - public void setDataAt(RIntVector vector, Object store, int index, int value) { - setDataAtNode.setDataAt(vector, store, index, value); - } - - public static Int create() { - return new Int(); - } - } - - @NodeInfo(cost = NodeCost.NONE) - public static final class Logical extends VectorAccessAdapter { - @Child private SetDataAt.Logical setDataAtNode = SetDataAt.Logical.create(); - - public void setDataAt(RLogicalVector vector, Object store, int index, byte value) { - setDataAtNode.setDataAt(vector, store, index, value); - } - - public static Logical create() { - return new Logical(); - } - } - - @NodeInfo(cost = NodeCost.NONE) - public static final class Raw extends VectorAccessAdapter { - @Child private SetDataAt.Raw setDataAtNode = SetDataAt.Raw.create(); - - public void setDataAt(RRawVector vector, Object store, int index, byte value) { - setDataAtNode.setDataAt(vector, store, index, value); - } - - public static Raw create() { - return new Raw(); - } - } - - @NodeInfo(cost = NodeCost.NONE) - public static final class String extends VectorAccessAdapter { - @Child private SetDataAt.String setDataAtNode = SetDataAt.String.create(); - - public void setDataAt(RStringVector vector, Object store, int index, java.lang.String value) { - setDataAtNode.setDataAt(vector, store, index, value); - } - - public static String create() { - return new String(); - } - } - - @NodeInfo(cost = NodeCost.NONE) - public static final class Complex extends VectorAccessAdapter { - @Child private SetDataAt.Complex setDataAtNode = SetDataAt.Complex.create(); - - public void setDataAt(RComplexVector vector, Object store, int index, RComplex value) { - setDataAtNode.setDataAt(vector, store, index, value); - } - - public static Complex create() { - return new Complex(); - } - } -} -- GitLab