diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RListMR.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RListMR.java index e1b29ff4d097c17b20b90f33cd768a97bfffcf2c..82cbe7aeda7fd52b3a790908ceb3c04cc0ae5308 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RListMR.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RListMR.java @@ -32,6 +32,7 @@ import com.oracle.truffle.r.engine.TruffleRLanguage; import com.oracle.truffle.r.nodes.access.vector.ElementAccessMode; import com.oracle.truffle.r.nodes.access.vector.ExtractVectorNode; import com.oracle.truffle.r.nodes.access.vector.ReplaceVectorNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.context.RContext; import com.oracle.truffle.r.runtime.context.RContext.RCloseable; @@ -106,12 +107,12 @@ public class RListMR { @Resolve(message = "KEYS") public abstract static class RListKeysNode extends Node { @Child private Node findContext = TruffleRLanguage.INSTANCE.actuallyCreateFindContextNode(); - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); + @Child private GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); @SuppressWarnings("try") protected Object access(RList receiver) { try (RCloseable c = RContext.withinContext(TruffleRLanguage.INSTANCE.actuallyFindContext0(findContext))) { - return receiver.getNames(attrProfiles); + return getNamesNode.getNames(receiver); } } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsCall.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsCall.java index 446875d8fee0449ccf2df866acde5d3cd2edcc2c..dca675c14235e8e0f136bfd61592a82f3b3cd8f3 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsCall.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsCall.java @@ -25,11 +25,13 @@ package com.oracle.truffle.r.nodes.builtin.base; import static com.oracle.truffle.r.runtime.builtins.RBehavior.PURE; import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.PRIMITIVE; +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.profiles.ConditionProfile; import com.oracle.truffle.r.nodes.RASTUtils; import com.oracle.truffle.r.nodes.access.variables.ReadVariableNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.runtime.ArgumentsSignature; import com.oracle.truffle.r.runtime.RError; @@ -50,7 +52,7 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; public abstract class AsCall extends RBuiltinNode { private final ConditionProfile nullNamesProfile = ConditionProfile.createBinaryProfile(); - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); + @Child private GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); @Specialization protected RLanguage asCallFunction(RList x) { @@ -89,12 +91,12 @@ public abstract class AsCall extends RBuiltinNode { values[i] = x.getDataAtAsObject(i + 1); } ArgumentsSignature signature; - if (nullNamesProfile.profile(x.getNames(attrProfiles) == null)) { + if (nullNamesProfile.profile(getNamesNode.getNames(x) == null)) { signature = ArgumentsSignature.empty(values.length); } else { String[] names = new String[length]; // extract names, converting "" to null - RStringVector ns = x.getNames(attrProfiles); + RStringVector ns = getNamesNode.getNames(x); for (int i = 0; i < length; i++) { String name = ns.getDataAt(i + 1); if (name != null && !name.isEmpty()) { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Bind.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Bind.java index 8ae71563084a6c71e6e6816ee8a0e49b4dfc7417..0a95c508e5ae397f7717df4e96528108cb1d0c27 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Bind.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Bind.java @@ -38,6 +38,7 @@ import com.oracle.truffle.api.profiles.ValueProfile; import com.oracle.truffle.r.nodes.RASTUtils; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimNamesAttributeNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.SetDimAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.SetDimNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; @@ -65,7 +66,6 @@ import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.Utils; import com.oracle.truffle.r.runtime.builtins.RBuiltin; import com.oracle.truffle.r.runtime.data.RArgsValuesAndNames; -import com.oracle.truffle.r.runtime.data.RAttributeProfiles; import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RList; import com.oracle.truffle.r.runtime.data.RNull; @@ -108,7 +108,6 @@ public abstract class Bind extends RBaseNode { private final ConditionProfile allEmptyVectorProfile = ConditionProfile.createBinaryProfile(); private final BranchProfile nonNullNames = BranchProfile.create(); private final NACheck naCheck = NACheck.create(); - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); protected final ValueProfile resultProfile = ValueProfile.createClassProfile(); protected final ValueProfile vectorProfile = ValueProfile.createClassProfile(); @@ -175,7 +174,7 @@ public abstract class Bind extends RBaseNode { } private Object bindInternal(int deparseLevel, Object[] args, RArgsValuesAndNames promiseArgs, CastNode castNode, boolean needsVectorCast, SetDimAttributeNode setDimNode, - SetDimNamesAttributeNode setDimNamesNode, GetDimNamesAttributeNode getDimNamesNode) { + SetDimNamesAttributeNode setDimNamesNode, GetDimNamesAttributeNode getDimNamesNode, GetNamesAttributeNode getNamesNode) { ArgumentsSignature signature = promiseArgs.getSignature(); String[] vecNames = nullNamesProfile.profile(signature.getNonNullCount() == 0) ? null : new String[signature.getLength()]; RAbstractVector[] vectors = new RAbstractVector[args.length]; @@ -231,9 +230,9 @@ public abstract class Bind extends RBaseNode { } } if (type == BindType.cbind) { - return genericCBind(promiseArgs, vectors, complete, vecNames, naCheck.neverSeenNA(), deparseLevel, setDimNode, setDimNamesNode, getDimNamesNode); + return genericCBind(promiseArgs, vectors, complete, vecNames, naCheck.neverSeenNA(), deparseLevel, setDimNode, setDimNamesNode, getDimNamesNode, getNamesNode); } else { - return genericRBind(promiseArgs, vectors, complete, vecNames, naCheck.neverSeenNA(), deparseLevel, setDimNode, setDimNamesNode, getDimNamesNode); + return genericRBind(promiseArgs, vectors, complete, vecNames, naCheck.neverSeenNA(), deparseLevel, setDimNode, setDimNamesNode, getDimNamesNode, getNamesNode); } } @@ -242,8 +241,9 @@ public abstract class Bind extends RBaseNode { @Cached("create()") CastLogicalNode cast, @Cached("create()") SetDimAttributeNode setDimNode, @Cached("create()") SetDimNamesAttributeNode setDimNamesNode, - @Cached("create()") GetDimNamesAttributeNode getDimNamesNode) { - return bindInternal(deparseLevel, args, promiseArgs, cast, true, setDimNode, setDimNamesNode, getDimNamesNode); + @Cached("create()") GetDimNamesAttributeNode getDimNamesNode, + @Cached("create()") GetNamesAttributeNode getNamesNode) { + return bindInternal(deparseLevel, args, promiseArgs, cast, true, setDimNode, setDimNamesNode, getDimNamesNode, getNamesNode); } @Specialization(guards = {"precedence == INT_PRECEDENCE", "args.length > 1", "!isDataFrame(args)"}) @@ -251,8 +251,9 @@ public abstract class Bind extends RBaseNode { @Cached("create()") CastIntegerNode cast, @Cached("create()") SetDimAttributeNode setDimNode, @Cached("create()") SetDimNamesAttributeNode setDimNamesNode, - @Cached("create()") GetDimNamesAttributeNode getDimNamesNode) { - return bindInternal(deparseLevel, args, promiseArgs, cast, true, setDimNode, setDimNamesNode, getDimNamesNode); + @Cached("create()") GetDimNamesAttributeNode getDimNamesNode, + @Cached("create()") GetNamesAttributeNode getNamesNode) { + return bindInternal(deparseLevel, args, promiseArgs, cast, true, setDimNode, setDimNamesNode, getDimNamesNode, getNamesNode); } @Specialization(guards = {"precedence == DOUBLE_PRECEDENCE", "args.length > 1", "!isDataFrame(args)"}) @@ -260,8 +261,9 @@ public abstract class Bind extends RBaseNode { @Cached("create()") CastDoubleNode cast, @Cached("create()") SetDimAttributeNode setDimNode, @Cached("create()") SetDimNamesAttributeNode setDimNamesNode, - @Cached("create()") GetDimNamesAttributeNode getDimNamesNode) { - return bindInternal(deparseLevel, args, promiseArgs, cast, true, setDimNode, setDimNamesNode, getDimNamesNode); + @Cached("create()") GetDimNamesAttributeNode getDimNamesNode, + @Cached("create()") GetNamesAttributeNode getNamesNode) { + return bindInternal(deparseLevel, args, promiseArgs, cast, true, setDimNode, setDimNamesNode, getDimNamesNode, getNamesNode); } @Specialization(guards = {"precedence == STRING_PRECEDENCE", "args.length> 1", "!isDataFrame(args)"}) @@ -269,8 +271,9 @@ public abstract class Bind extends RBaseNode { @Cached("create()") CastStringNode cast, @Cached("create()") SetDimAttributeNode setDimNode, @Cached("create()") SetDimNamesAttributeNode setDimNamesNode, - @Cached("create()") GetDimNamesAttributeNode getDimNamesNode) { - return bindInternal(deparseLevel, args, promiseArgs, cast, true, setDimNode, setDimNamesNode, getDimNamesNode); + @Cached("create()") GetDimNamesAttributeNode getDimNamesNode, + @Cached("create()") GetNamesAttributeNode getNamesNode) { + return bindInternal(deparseLevel, args, promiseArgs, cast, true, setDimNode, setDimNamesNode, getDimNamesNode, getNamesNode); } @Specialization(guards = {"precedence == COMPLEX_PRECEDENCE", "args.length > 1", "!isDataFrame(args)"}) @@ -278,8 +281,9 @@ public abstract class Bind extends RBaseNode { @Cached("create()") CastComplexNode cast, @Cached("create()") SetDimAttributeNode setDimNode, @Cached("create()") SetDimNamesAttributeNode setDimNamesNode, - @Cached("create()") GetDimNamesAttributeNode getDimNamesNode) { - return bindInternal(deparseLevel, args, promiseArgs, cast, true, setDimNode, setDimNamesNode, getDimNamesNode); + @Cached("create()") GetDimNamesAttributeNode getDimNamesNode, + @Cached("create()") GetNamesAttributeNode getNamesNode) { + return bindInternal(deparseLevel, args, promiseArgs, cast, true, setDimNode, setDimNamesNode, getDimNamesNode, getNamesNode); } @Specialization(guards = {"precedence == LIST_PRECEDENCE", "args.length > 1", "!isDataFrame(args)"}) @@ -287,8 +291,9 @@ public abstract class Bind extends RBaseNode { @Cached("create()") CastListNode cast, @Cached("create()") SetDimAttributeNode setDimNode, @Cached("create()") SetDimNamesAttributeNode setDimNamesNode, - @Cached("create()") GetDimNamesAttributeNode getDimNamesNode) { - return bindInternal(deparseLevel, args, promiseArgs, cast, false, setDimNode, setDimNamesNode, getDimNamesNode); + @Cached("create()") GetDimNamesAttributeNode getDimNamesNode, + @Cached("create()") GetNamesAttributeNode getNamesNode) { + return bindInternal(deparseLevel, args, promiseArgs, cast, false, setDimNode, setDimNamesNode, getDimNamesNode, getNamesNode); } /** @@ -299,7 +304,7 @@ public abstract class Bind extends RBaseNode { * @param dimLength * @return dimnames */ - protected Object getDimResultNamesFromElements(RAbstractVector vec, int dimLength, int dimInd, GetDimNamesAttributeNode getDimNamesNode) { + protected Object getDimResultNamesFromElements(RAbstractVector vec, int dimLength, int dimInd, GetDimNamesAttributeNode getDimNamesNode, GetNamesAttributeNode getNamesNode) { Object firstDimResultNames = RNull.instance; Object firstDimNames = RNull.instance; if (vec.isMatrix()) { @@ -308,7 +313,7 @@ public abstract class Bind extends RBaseNode { firstDimNames = vecDimNames.getDataAt(dimInd); } } else if (!vec.isArray() || getVectorDimensions(vec).length == 1) { - RStringVector names = vec.getNames(attrProfiles); + RStringVector names = getNamesNode.getNames(vec); firstDimNames = names == null ? RNull.instance : names; } else { RInternalError.unimplemented("binding multi-dimensional arrays is not supported"); @@ -477,7 +482,8 @@ public abstract class Bind extends RBaseNode { @Specialization(guards = {"precedence != NO_PRECEDENCE", "args.length == 1"}) protected Object allOneElem(int deparseLevel, Object[] args, RArgsValuesAndNames promiseArgs, @SuppressWarnings("unused") int precedence, - @Cached("create()") SetDimNamesAttributeNode setDimNamesNode) { + @Cached("create()") SetDimNamesAttributeNode setDimNamesNode, + @Cached("create()") GetNamesAttributeNode getNamesNode) { RAbstractVector vec = castVector(args[0]); if (vec.isMatrix()) { return vec; @@ -485,7 +491,10 @@ public abstract class Bind extends RBaseNode { int[] dims = getDimensions(vec); // for cbind dimNamesA is names for the 1st dim and dimNamesB is names for 2nd dim; for // rbind the other way around - Object dimNamesA = vec.getNames(attrProfiles) == null ? RNull.instance : vec.getNames(attrProfiles); + Object dimNamesA = getNamesNode.getNames(vec); + if (dimNamesA == null) { + dimNamesA = RNull.instance; + } Object dimNamesB; ArgumentsSignature signature = promiseArgs.getSignature(); @@ -512,7 +521,7 @@ public abstract class Bind extends RBaseNode { } public RVector<?> genericCBind(RArgsValuesAndNames promiseArgs, RAbstractVector[] vectors, boolean complete, String[] vecNames, boolean vecNamesComplete, int deparseLevel, - SetDimAttributeNode setDimNode, SetDimNamesAttributeNode setDimNamesNode, GetDimNamesAttributeNode getDimNamesNode) { + SetDimAttributeNode setDimNode, SetDimNamesAttributeNode setDimNamesNode, GetDimNamesAttributeNode getDimNamesNode, GetNamesAttributeNode getNamesNode) { int[] resultDimensions = new int[2]; int[] secondDims = new int[vectors.length]; @@ -529,7 +538,7 @@ public abstract class Bind extends RBaseNode { RAbstractVector vec = vectorProfile.profile(vectors[i]); if (rowDimResultNames == RNull.instance) { // get the first valid names value - rowDimResultNames = getDimResultNamesFromElements(vec, resultDimensions[0], 0, getDimNamesNode); + rowDimResultNames = getDimResultNamesFromElements(vec, resultDimensions[0], 0, getDimNamesNode, getNamesNode); } // compute dimnames for the second dimension @@ -594,7 +603,7 @@ public abstract class Bind extends RBaseNode { } public RVector<?> genericRBind(RArgsValuesAndNames promiseArgs, RAbstractVector[] vectors, boolean complete, String[] vecNames, boolean vecNamesComplete, int deparseLevel, - SetDimAttributeNode setDimNode, SetDimNamesAttributeNode setDimNamesNode, GetDimNamesAttributeNode getDimNamesNode) { + SetDimAttributeNode setDimNode, SetDimNamesAttributeNode setDimNamesNode, GetDimNamesAttributeNode getDimNamesNode, GetNamesAttributeNode getNamesNode) { int[] resultDimensions = new int[2]; int[] firstDims = new int[vectors.length]; @@ -610,7 +619,7 @@ public abstract class Bind extends RBaseNode { RAbstractVector vec = vectorProfile.profile(vectors[i]); if (colDimResultNames == RNull.instance) { // get the first valid names value - colDimResultNames = getDimResultNamesFromElements(vec, resultDimensions[1], 1, getDimNamesNode); + colDimResultNames = getDimResultNamesFromElements(vec, resultDimensions[1], 1, getDimNamesNode, getNamesNode); } // compute dimnames for the second dimension diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Combine.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Combine.java index 7733fc871c01a48f94c82a6892a6f8a28ce42f28..99f09dcce3d563e95b0a3292e91bb7de0395d97e 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Combine.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Combine.java @@ -48,6 +48,7 @@ import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.api.profiles.ValueProfile; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimNamesAttributeNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.nodes.builtin.base.CombineNodeGen.CombineInputCastNodeGen; @@ -96,7 +97,6 @@ public abstract class Combine extends RBuiltinNode { @Child private CombineInputCast inputCast = CombineInputCastNodeGen.create(null); @Child private CastToVectorNode castVector; - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); private final BranchProfile naBranch = BranchProfile.create(); private final NACheck naCheck = NACheck.create(); private final ConditionProfile fastNamesMerge = ConditionProfile.createBinaryProfile(); @@ -127,7 +127,8 @@ public abstract class Combine extends RBuiltinNode { @Cached("createCast(cachedPrecedence)") CastNode cast, // @Cached("create()") BranchProfile naNameBranch, // @Cached("create()") NACheck naNameCheck, // - @Cached("createBinaryProfile()") ConditionProfile hasNamesProfile) { + @Cached("createBinaryProfile()") ConditionProfile hasNamesProfile, + @Cached("create()") GetNamesAttributeNode getNamesNode) { CompilerAsserts.partialEvaluationConstant(cachedSignature); CompilerAsserts.partialEvaluationConstant(cachedPrecedence); @@ -142,7 +143,8 @@ public abstract class Combine extends RBuiltinNode { // prepare the names (if there are any) boolean signatureHasNames = signatureHasNames(cachedSignature); CompilerAsserts.partialEvaluationConstant(signatureHasNames); - RStringVector namesVector = hasNamesProfile.profile(signatureHasNames || hasNames(elements)) ? foldNames(naNameBranch, naNameCheck, elements, size, cachedSignature) : null; + RStringVector namesVector = hasNamesProfile.profile(signatureHasNames || hasNames(elements, getNamesNode)) ? foldNames(naNameBranch, naNameCheck, elements, size, cachedSignature, getNamesNode) + : null; // get the actual contents of the result RVector<?> result = foldContents(cachedPrecedence, elements, size, namesVector); @@ -159,8 +161,9 @@ public abstract class Combine extends RBuiltinNode { @Cached("createCast(cachedPrecedence)") CastNode cast, // @Cached("create()") BranchProfile naNameBranch, // @Cached("create()") NACheck naNameCheck, // - @Cached("createBinaryProfile()") ConditionProfile hasNamesProfile) { - return combineCached(args, false, args.getSignature(), cachedPrecedence, cast, naNameBranch, naNameCheck, hasNamesProfile); + @Cached("createBinaryProfile()") ConditionProfile hasNamesProfile, + @Cached("create()") GetNamesAttributeNode getNamesNode) { + return combineCached(args, false, args.getSignature(), cachedPrecedence, cast, naNameBranch, naNameCheck, hasNamesProfile, getNamesNode); } @Specialization(guards = "recursive") @@ -226,7 +229,7 @@ public abstract class Combine extends RBuiltinNode { } @ExplodeLoop - private boolean hasNames(Object[] elements) { + private boolean hasNames(Object[] elements, GetNamesAttributeNode getNamesNode) { for (int i = 0; i < elements.length; i++) { Object element = elements[i]; if (i < argProfiles.length) { @@ -234,7 +237,7 @@ public abstract class Combine extends RBuiltinNode { } if (element instanceof RAbstractVector) { RAbstractVector vector = (RAbstractVector) element; - if (vector.getNames(attrProfiles) != null) { + if (getNamesNode.getNames(vector) != null) { return true; } } @@ -243,7 +246,7 @@ public abstract class Combine extends RBuiltinNode { } @ExplodeLoop - private RStringVector foldNames(BranchProfile naNameBranch, NACheck naNameCheck, Object[] elements, int size, ArgumentsSignature signature) { + private RStringVector foldNames(BranchProfile naNameBranch, NACheck naNameCheck, Object[] elements, int size, ArgumentsSignature signature, GetNamesAttributeNode getNamesNode) { RStringVector result = RDataFactory.createStringVector(new String[size], true); result.incRefCount(); int pos = 0; @@ -252,18 +255,19 @@ public abstract class Combine extends RBuiltinNode { if (i < argProfiles.length) { element = argProfiles[i].profile(element); } - pos += processNamesElement(naNameBranch, naNameCheck, result, pos, element, i, signature); + pos += processNamesElement(naNameBranch, naNameCheck, result, pos, element, i, signature, getNamesNode); } return result; } - private int processNamesElement(BranchProfile naNameBranch, NACheck naNameCheck, RStringVector result, int pos, Object element, int index, ArgumentsSignature signature) { + private int processNamesElement(BranchProfile naNameBranch, NACheck naNameCheck, RStringVector result, int pos, Object element, int index, ArgumentsSignature signature, + GetNamesAttributeNode getNamesNode) { String signatureName = signature.getName(index); if (element instanceof RAbstractVector) { RAbstractVector v = (RAbstractVector) element; int length = v.getLength(); - RStringVector newNames = v.getNames(attrProfiles); + RStringVector newNames = getNamesNode.getNames(v); if (signatureName != null && length > 0) { if (fastNamesMerge.profile(length == 1 && newNames == null)) { newNames = RDataFactory.createStringVector(new String[]{signatureName}, true); @@ -456,6 +460,7 @@ public abstract class Combine extends RBuiltinNode { private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); @Child private GetDimNamesAttributeNode getDimNamesNode = GetDimNamesAttributeNode.create(); + @Child private GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); public abstract Object execute(Object operand); @@ -475,11 +480,11 @@ public abstract class Combine extends RBuiltinNode { RVector<?> materialized = vector.materialize(); RVector<?> result = materialized.copyDropAttributes(); - RStringVector vecNames = materialized.getNamesFromAttrs(); + RStringVector vecNames = getNamesNode.getNames(materialized); if (hasNamesProfile.profile(vecNames != null)) { result.initAttributes(RAttributesLayout.createNames(vecNames)); } else { - RList dimNames = materialized.getDimNames(); + RList dimNames = getDimNamesNode.getDimNames(materialized); if (hasDimNamesProfile.profile(dimNames != null)) { result.initAttributes(RAttributesLayout.createDimNames(dimNames)); } @@ -493,7 +498,7 @@ public abstract class Combine extends RBuiltinNode { } protected boolean needsCopy(RAbstractVector vector) { - return vector.getAttributes() != null || vector.getNames(attrProfiles) != null || getDimNamesNode.getDimNames(vector) != null; + return vector.getAttributes() != null || getNamesNode.getNames(vector) != null || getDimNamesNode.getDimNames(vector) != null; } } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumMax.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumMax.java index edf8441b58c47ee9bad392bd698d4bc1c72247d7..b172409a9eeb9aaebc2e36bcf2d0673981e28a4f 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumMax.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumMax.java @@ -24,6 +24,7 @@ import java.util.Arrays; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.runtime.RError; @@ -43,7 +44,7 @@ import com.oracle.truffle.r.runtime.ops.na.NACheck; public abstract class CumMax extends RBuiltinNode { private final NACheck na = NACheck.create(); - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); + @Child private GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); @Override protected void createCasts(CastBuilder casts) { @@ -96,7 +97,7 @@ public abstract class CumMax extends RBuiltinNode { if (!na.neverSeenNA()) { Arrays.fill(cmaxV, i, cmaxV.length, RRuntime.DOUBLE_NA); } - return RDataFactory.createDoubleVector(cmaxV, na.neverSeenNA(), v.getNames(attrProfiles)); + return RDataFactory.createDoubleVector(cmaxV, na.neverSeenNA(), getNamesNode.getNames(v)); } @Specialization(contains = "cummaxIntSequence") @@ -118,7 +119,7 @@ public abstract class CumMax extends RBuiltinNode { if (!na.neverSeenNA()) { Arrays.fill(cmaxV, i, cmaxV.length, RRuntime.INT_NA); } - return RDataFactory.createIntVector(cmaxV, na.neverSeenNA(), v.getNames(attrProfiles)); + return RDataFactory.createIntVector(cmaxV, na.neverSeenNA(), getNamesNode.getNames(v)); } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumMin.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumMin.java index a1da7b792e40c8abb45fa505b7b76c03946a281f..d10cad5de95daa876bcd7a427f079cc8f285d3db 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumMin.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumMin.java @@ -23,7 +23,9 @@ import java.util.Arrays; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.nodes.Node.Child; import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.runtime.RError; @@ -43,7 +45,7 @@ import com.oracle.truffle.r.runtime.ops.na.NACheck; public abstract class CumMin extends RBuiltinNode { private final NACheck na = NACheck.create(); - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); + @Child private GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); @Override protected void createCasts(CastBuilder casts) { @@ -96,7 +98,7 @@ public abstract class CumMin extends RBuiltinNode { if (!na.neverSeenNA()) { Arrays.fill(cminV, i, cminV.length, RRuntime.DOUBLE_NA); } - return RDataFactory.createDoubleVector(cminV, na.neverSeenNA(), v.getNames(attrProfiles)); + return RDataFactory.createDoubleVector(cminV, na.neverSeenNA(), getNamesNode.getNames(v)); } @Specialization(contains = "cumminIntSequence") @@ -118,7 +120,7 @@ public abstract class CumMin extends RBuiltinNode { if (!na.neverSeenNA()) { Arrays.fill(cminV, i, cminV.length, RRuntime.INT_NA); } - return RDataFactory.createIntVector(cminV, na.neverSeenNA(), v.getNames(attrProfiles)); + return RDataFactory.createIntVector(cminV, na.neverSeenNA(), getNamesNode.getNames(v)); } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumProd.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumProd.java index 56cda98a07fd8f9e13be1f2833356ff00be34526..0f0a547ccc2baf87ce5f2d6c1fa5efdd33185ef4 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumProd.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumProd.java @@ -24,6 +24,8 @@ import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.PRIMITIVE; import java.util.Arrays; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.nodes.Node.Child; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.runtime.RRuntime; @@ -45,7 +47,7 @@ import com.oracle.truffle.r.runtime.ops.na.NACheck; public abstract class CumProd extends RBuiltinNode { private final NACheck na = NACheck.create(); - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); + @Child private GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); @Child private BinaryArithmetic mul = BinaryArithmetic.MULTIPLY.createOperation(); @@ -88,7 +90,7 @@ public abstract class CumProd extends RBuiltinNode { if (!na.neverSeenNA()) { Arrays.fill(array, i, array.length, RRuntime.INT_NA); } - return RDataFactory.createIntVector(array, !na.neverSeenNA(), arg.getNames(attrProfiles)); + return RDataFactory.createIntVector(array, !na.neverSeenNA(), getNamesNode.getNames(arg)); } @Specialization @@ -110,7 +112,7 @@ public abstract class CumProd extends RBuiltinNode { if (!na.neverSeenNA()) { Arrays.fill(array, i, array.length, RRuntime.DOUBLE_NA); } - return RDataFactory.createDoubleVector(array, !na.neverSeenNA(), arg.getNames(attrProfiles)); + return RDataFactory.createDoubleVector(array, !na.neverSeenNA(), getNamesNode.getNames(arg)); } @Specialization @@ -133,6 +135,6 @@ public abstract class CumProd extends RBuiltinNode { if (!na.neverSeenNA()) { Arrays.fill(array, 2 * i, array.length, RRuntime.DOUBLE_NA); } - return RDataFactory.createComplexVector(array, !na.neverSeenNA(), arg.getNames(attrProfiles)); + return RDataFactory.createComplexVector(array, !na.neverSeenNA(), getNamesNode.getNames(arg)); } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumSum.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumSum.java index 06c1be88b75946797245a613f51c0f5a2578668a..3b6074626f3ab1dc0fc1aedf94739337cd75964d 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumSum.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumSum.java @@ -36,11 +36,11 @@ import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.PRIMITIVE; import java.util.Arrays; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.builtins.RBuiltin; -import com.oracle.truffle.r.runtime.data.RAttributeProfiles; import com.oracle.truffle.r.runtime.data.RComplex; import com.oracle.truffle.r.runtime.data.RComplexVector; import com.oracle.truffle.r.runtime.data.RDataFactory; @@ -58,7 +58,7 @@ import com.oracle.truffle.r.runtime.ops.na.NACheck; public abstract class CumSum extends RBuiltinNode { private final NACheck na = NACheck.create(); - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); + @Child private GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); @Child private BinaryArithmetic add = BinaryArithmetic.ADD.createOperation(); @@ -100,7 +100,7 @@ public abstract class CumSum extends RBuiltinNode { if (!na.neverSeenNA()) { Arrays.fill(res, i, res.length, RRuntime.INT_NA); } - return RDataFactory.createIntVector(res, na.neverSeenNA(), arg.getNames(attrProfiles)); + return RDataFactory.createIntVector(res, na.neverSeenNA(), getNamesNode.getNames(arg)); } @Specialization @@ -119,7 +119,7 @@ public abstract class CumSum extends RBuiltinNode { if (!na.neverSeenNA()) { Arrays.fill(res, i, res.length, RRuntime.DOUBLE_NA); } - return RDataFactory.createDoubleVector(res, na.neverSeenNA(), arg.getNames(attrProfiles)); + return RDataFactory.createDoubleVector(res, na.neverSeenNA(), getNamesNode.getNames(arg)); } @Specialization @@ -141,7 +141,7 @@ public abstract class CumSum extends RBuiltinNode { if (!na.neverSeenNA()) { Arrays.fill(res, i, res.length, RRuntime.INT_NA); } - return RDataFactory.createIntVector(res, na.neverSeenNA(), arg.getNames(attrProfiles)); + return RDataFactory.createIntVector(res, na.neverSeenNA(), getNamesNode.getNames(arg)); } @Specialization @@ -161,6 +161,6 @@ public abstract class CumSum extends RBuiltinNode { if (!na.neverSeenNA()) { Arrays.fill(res, 2 * i, res.length, RRuntime.DOUBLE_NA); } - return RDataFactory.createComplexVector(res, na.neverSeenNA(), arg.getNames(attrProfiles)); + return RDataFactory.createComplexVector(res, na.neverSeenNA(), getNamesNode.getNames(arg)); } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DatePOSIXFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DatePOSIXFunctions.java index 16c0b8f946f59b79edba83cd41086a2275e68f8e..c45cb05324403c8247e900ca5c64b8162defb836 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DatePOSIXFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DatePOSIXFunctions.java @@ -38,6 +38,7 @@ import java.util.TimeZone; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.SetClassAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; @@ -139,6 +140,7 @@ public class DatePOSIXFunctions { public abstract static class Date2POSIXlt extends RBuiltinNode { private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); + @Child private GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); @Override protected void createCasts(CastBuilder casts) { @@ -163,7 +165,7 @@ public class DatePOSIXFunctions { } } RList result = builder.finish(); - RStringVector xNames = x.getNames(attrProfiles); + RStringVector xNames = getNamesNode.getNames(x); if (xNames != null) { ((RIntVector) result.getDataAt(5)).copyNamesFrom(attrProfiles, x); } @@ -175,6 +177,7 @@ public class DatePOSIXFunctions { public abstract static class AsPOSIXlt extends RBuiltinNode { private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); + @Child private GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); @Override protected void createCasts(CastBuilder casts) { @@ -205,7 +208,7 @@ public class DatePOSIXFunctions { } } RList result = builder.finish(); - RStringVector xNames = x.getNames(attrProfiles); + RStringVector xNames = getNamesNode.getNames(x); if (xNames != null) { ((RIntVector) result.getDataAt(5)).copyNamesFrom(attrProfiles, x); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DoCall.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DoCall.java index 7cb11a03f335315d7421134e3bb055a720266eed..dbcf174805a15697847c63c09643e27572a98e02 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DoCall.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DoCall.java @@ -37,6 +37,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.r.nodes.RASTUtils; import com.oracle.truffle.r.nodes.access.FrameSlotNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.nodes.builtin.base.GetFunctionsFactory.GetNodeGen; @@ -50,7 +51,6 @@ import com.oracle.truffle.r.runtime.RType; import com.oracle.truffle.r.runtime.builtins.RBuiltin; import com.oracle.truffle.r.runtime.context.RContext; import com.oracle.truffle.r.runtime.data.RArgsValuesAndNames; -import com.oracle.truffle.r.runtime.data.RAttributeProfiles; import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.REmpty; import com.oracle.truffle.r.runtime.data.RFunction; @@ -72,8 +72,8 @@ public abstract class DoCall extends RBuiltinNode implements InternalRSyntaxNode @Child private GetFunctions.Get getNode; @Child private GetCallerFrameNode getCallerFrame; + @Child private GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); private final BranchProfile containsRLanguageProfile = BranchProfile.create(); private final BranchProfile containsRSymbolProfile = BranchProfile.create(); @@ -113,7 +113,7 @@ public abstract class DoCall extends RBuiltinNode implements InternalRSyntaxNode * To re-create the illusion of a normal call, turn the values in argsAsList into promises. */ Object[] argValues = argsAsList.getDataCopy(); - RStringVector n = argsAsList.getNames(attrProfiles); + RStringVector n = getNamesNode.getNames(argsAsList); ArgumentsSignature signature; if (n == null) { signature = ArgumentsSignature.empty(argValues.length); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsNA.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsNA.java index 8730d78a9e45251ddf395d7c811916f4b193f7fa..961a01f2b605bc17949e75eeac8b7d0f5f234238 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsNA.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsNA.java @@ -31,9 +31,11 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; 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.Child; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimNamesAttributeNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.SetDimNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.runtime.RError; @@ -58,6 +60,7 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractVector; public abstract class IsNA extends RBuiltinNode { @Child private IsNA recursiveIsNA; + @Child private GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); private final ConditionProfile nullDimNamesProfile = ConditionProfile.createBinaryProfile(); @@ -217,7 +220,7 @@ public abstract class IsNA extends RBuiltinNode { private RLogicalVector createResult(byte[] data, RAbstractVector originalVector, GetDimAttributeNode getDimsNode, SetDimNamesAttributeNode setDimNamesNode, GetDimNamesAttributeNode getDimNamesNode) { - RLogicalVector result = RDataFactory.createLogicalVector(data, RDataFactory.COMPLETE_VECTOR, getDimsNode.getDimensions(originalVector), originalVector.getNames(attrProfiles)); + RLogicalVector result = RDataFactory.createLogicalVector(data, RDataFactory.COMPLETE_VECTOR, getDimsNode.getDimensions(originalVector), getNamesNode.getNames(originalVector)); RList dimNames = getDimNamesNode.getDimNames(originalVector); if (nullDimNamesProfile.profile(dimNames != null)) { setDimNamesNode.setDimNames(result, dimNames); 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 da2e58590d3677dddd566d2df622a52d776b94c0..376b2e141e3dfdb85c6ffab612ae4d6ac3870eca 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 @@ -487,7 +487,8 @@ public class LaFunctions { @Specialization protected RDoubleVector doDetGeReal(RDoubleVector aIn, boolean piv, double tol, @Cached("create()") GetDimAttributeNode getDimsNode, - @Cached("create()") SetDimNamesAttributeNode setDimNamesNode) { + @Cached("create()") SetDimNamesAttributeNode setDimNamesNode, + @Cached("create()") GetDimNamesAttributeNode getDimNamesNode) { RDoubleVector a = (RDoubleVector) aIn.copy(); int[] aDims = getDimsNode.getDimensions(aIn); int n = aDims[0]; @@ -519,7 +520,7 @@ public class LaFunctions { } setPivotAttrNode.execute(a, RRuntime.asLogical(piv)); setRankAttrNode.execute(a, rank[0]); - RList dn = a.getDimNames(); + RList dn = getDimNamesNode.getDimNames(a); if (dn != null && dn.getDataAt(0) != null) { Object[] dn2 = new Object[m]; // need to pivot the colnames @@ -563,7 +564,8 @@ public class LaFunctions { @Cached("create()") GetDimAttributeNode getBinDimsNode, @Cached("create()") SetDimAttributeNode setBDimsNode, @Cached("create()") SetDimNamesAttributeNode setBDimNamesNode, - @Cached("create()") GetDimNamesAttributeNode getDimNamesNode) { + @Cached("create()") GetDimNamesAttributeNode getADimNamesNode, + @Cached("create()") GetDimNamesAttributeNode getBinDimNamesNode) { int[] aDims = getADimsNode.getDimensions(a); int n = aDims[0]; if (n == 0) { @@ -573,7 +575,7 @@ public class LaFunctions { if (n2 != n) { throw RError.error(this, RError.Message.MUST_BE_SQUARE, "a", n, n2); } - RList aDn = getDimNamesNode.getDimNames(a); + RList aDn = getADimNamesNode.getDimNames(a); int p; double[] bData; RDoubleVector b; @@ -590,7 +592,7 @@ public class LaFunctions { bData = new double[n * p]; b = RDataFactory.createDoubleVector(bData, RDataFactory.COMPLETE_VECTOR); setBDimsNode.setDimensions(b, new int[]{n, p}); - RList binDn = bin.getDimNames(); + RList binDn = getBinDimNamesNode.getDimNames(bin); // This is somewhat odd, but Matrix relies on dropping NULL dimnames if (aDn != null || binDn != null) { // rownames(ans) = colnames(A), colnames(ans) = colnames(Bin) diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Lapply.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Lapply.java index a75fdbb515e1a6c46e2d4a92aedaf3d6a5d9a70a..1a03846697f2c018f2d1239cf1f9e30066784e13 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Lapply.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Lapply.java @@ -26,6 +26,7 @@ import com.oracle.truffle.api.frame.FrameSlotKind; import com.oracle.truffle.api.frame.FrameSlotTypeException; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.LoopNode; +import com.oracle.truffle.api.nodes.Node.Child; import com.oracle.truffle.api.profiles.LoopConditionProfile; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; @@ -33,6 +34,7 @@ import com.oracle.truffle.r.nodes.access.variables.ReadVariableNode; import com.oracle.truffle.r.nodes.access.vector.ElementAccessMode; import com.oracle.truffle.r.nodes.access.vector.ExtractVectorNode; import com.oracle.truffle.r.nodes.access.vector.ExtractVectorNodeGen; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.nodes.builtin.base.LapplyNodeGen.LapplyInternalNodeGen; @@ -69,8 +71,6 @@ public abstract class Lapply extends RBuiltinNode { private static final Source CALL_SOURCE = RSource.fromTextInternal("FUN(X[[i]], ...)", RSource.Internal.LAPPLY); - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); - @Child private LapplyInternalNode lapply = LapplyInternalNodeGen.create(); @Override @@ -83,10 +83,10 @@ public abstract class Lapply extends RBuiltinNode { } @Specialization - protected Object lapply(VirtualFrame frame, RAbstractVector vec, RFunction fun) { + protected Object lapply(VirtualFrame frame, RAbstractVector vec, RFunction fun, @Cached("create()") GetNamesAttributeNode getNamesNode) { Object[] result = lapply.execute(frame, vec, fun); // set here else it gets overridden by the iterator evaluation - return RDataFactory.createList(result, vec.getNames(attrProfiles)); + return RDataFactory.createList(result, getNamesNode.getNames(vec)); } private static final class ExtractElementInternal extends RSourceSectionNode implements RSyntaxCall { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/LogFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/LogFunctions.java index d408b9a4d0e03fbc59dabe28e63bc21d273ff854..457eca9da958eace8975e6ec36c6fb2cd25d90ca 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/LogFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/LogFunctions.java @@ -33,6 +33,7 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.r.nodes.attributes.CopyOfRegAttributesNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimAttributeNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.nodes.unary.UnaryArithmeticBuiltinNode; @@ -40,7 +41,6 @@ import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.RType; import com.oracle.truffle.r.runtime.builtins.RBuiltin; -import com.oracle.truffle.r.runtime.data.RAttributeProfiles; import com.oracle.truffle.r.runtime.data.RComplex; import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RDoubleVector; @@ -81,7 +81,7 @@ public class LogFunctions { @Specialization protected RDoubleVector log(RAbstractIntVector vector, double base, @Cached("create()") CopyOfRegAttributesNode copyAttrsNode, - @Cached("create()") RAttributeProfiles attrProfiles, + @Cached("create()") GetNamesAttributeNode getNamesNode, @Cached("create()") GetDimAttributeNode getDimsNode) { double[] resultVector = new double[vector.getLength()]; for (int i = 0; i < vector.getLength(); i++) { @@ -92,13 +92,13 @@ public class LogFunctions { } resultVector[i] = result; } - return createResult(vector, resultVector, base, copyAttrsNode, attrProfiles, getDimsNode); + return createResult(vector, resultVector, base, copyAttrsNode, getNamesNode, getDimsNode); } @Specialization protected RDoubleVector log(RAbstractDoubleVector vector, double base, @Cached("create()") CopyOfRegAttributesNode copyAttrsNode, - @Cached("create()") RAttributeProfiles attrProfiles, + @Cached("create()") GetNamesAttributeNode getNamesNode, @Cached("create()") GetDimAttributeNode getDimsNode) { double[] doubleVector = new double[vector.getLength()]; for (int i = 0; i < vector.getLength(); i++) { @@ -108,7 +108,7 @@ public class LogFunctions { } doubleVector[i] = value; } - return createResult(vector, doubleVector, base, copyAttrsNode, attrProfiles, getDimsNode); + return createResult(vector, doubleVector, base, copyAttrsNode, getNamesNode, getDimsNode); } private double logb(double x, double base) { @@ -124,9 +124,9 @@ public class LogFunctions { return Math.log(x) / Math.log(base); } - private static RDoubleVector createResult(RAbstractVector source, double[] resultData, double base, CopyOfRegAttributesNode copyAttrsNode, RAttributeProfiles attrProfiles, + private static RDoubleVector createResult(RAbstractVector source, double[] resultData, double base, CopyOfRegAttributesNode copyAttrsNode, GetNamesAttributeNode getNamesNode, GetDimAttributeNode getDimsNode) { - RDoubleVector result = RDataFactory.createDoubleVector(resultData, source.isComplete() && !RRuntime.isNA(base), getDimsNode.getDimensions(source), source.getNames(attrProfiles)); + RDoubleVector result = RDataFactory.createDoubleVector(resultData, source.isComplete() && !RRuntime.isNA(base), getDimsNode.getDimensions(source), getNamesNode.getNames(source)); copyAttrsNode.execute(source, result); return result; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Mapply.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Mapply.java index f363a88b079d661e0154ec885754984e446561d8..372547fa0f8364b32aa5a51ea702a98dcaeaae62 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Mapply.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Mapply.java @@ -37,6 +37,7 @@ import com.oracle.truffle.r.nodes.access.FrameSlotNode; import com.oracle.truffle.r.nodes.access.WriteVariableNode; import com.oracle.truffle.r.nodes.access.WriteVariableNode.Mode; import com.oracle.truffle.r.nodes.access.variables.ReadVariableNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.nodes.builtin.base.MapplyNodeGen.MapplyInternalNodeGen; @@ -49,7 +50,6 @@ import com.oracle.truffle.r.runtime.ArgumentsSignature; import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.builtins.RBuiltin; import com.oracle.truffle.r.runtime.data.RArgsValuesAndNames; -import com.oracle.truffle.r.runtime.data.RAttributeProfiles; import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RFunction; import com.oracle.truffle.r.runtime.data.RLogicalVector; @@ -124,7 +124,7 @@ public abstract class Mapply extends RBuiltinNode { } } - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); + @Child private GetNamesAttributeNode getNames = GetNamesAttributeNode.create(); public abstract Object[] execute(VirtualFrame frame, RAbstractListVector dots, RFunction function, RAbstractListVector additionalArguments); @@ -215,13 +215,13 @@ public abstract class Mapply extends RBuiltinNode { } Object[] values = new Object[dotsLength + moreArgsLength]; String[] names = new String[dotsLength + moreArgsLength]; - RStringVector dotsNames = dots.getNames(attrProfiles); + RStringVector dotsNames = getNames.getNames(dots); if (dotsNames != null) { for (int listIndex = 0; listIndex < dotsLength; listIndex++) { names[listIndex] = dotsNames.getDataAt(listIndex).isEmpty() ? null : dotsNames.getDataAt(listIndex); } } - RStringVector moreArgsNames = moreArgs.getNames(attrProfiles); + RStringVector moreArgsNames = getNames.getNames(moreArgs); for (int listIndex = dotsLength; listIndex < dotsLength + moreArgsLength; listIndex++) { values[listIndex] = moreArgs.getDataAt(listIndex - dotsLength); names[listIndex] = moreArgsNames == null ? null : (moreArgsNames.getDataAt(listIndex - dotsLength).isEmpty() ? null : moreArgsNames.getDataAt(listIndex - dotsLength)); @@ -260,11 +260,11 @@ public abstract class Mapply extends RBuiltinNode { protected ElementNode[] createElementNodeArray(RAbstractListVector dots, RAbstractListVector moreArgs) { int length = dots.getLength() + moreArgs.getLength(); ElementNode[] elementNodes = new ElementNode[length]; - RStringVector dotsNames = dots.getNames(attrProfiles); + RStringVector dotsNames = getNames.getNames(dots); for (int i = 0; i < dots.getLength(); i++) { elementNodes[i] = insert(new ElementNode(VECTOR_ELEMENT_PREFIX + (i + 1), dotsNames == null ? null : (dotsNames.getDataAt(i).isEmpty() ? null : dotsNames.getDataAt(i)))); } - RStringVector moreArgsNames = moreArgs.getNames(attrProfiles); + RStringVector moreArgsNames = getNames.getNames(moreArgs); for (int i = dots.getLength(); i < dots.getLength() + moreArgs.getLength(); i++) { elementNodes[i] = insert(new ElementNode(VECTOR_ELEMENT_PREFIX + (i + 1), moreArgsNames == null ? null : moreArgsNames.getDataAt(i - dots.getLength()).isEmpty() ? null : moreArgsNames.getDataAt(i - dots.getLength()))); @@ -289,14 +289,17 @@ public abstract class Mapply extends RBuiltinNode { } protected boolean sameNames(RAbstractListVector list, RAbstractListVector cachedList) { - if (list.getNames(attrProfiles) == null && cachedList.getNames(attrProfiles) == null) { + RStringVector listNames = getNames.getNames(list); + RStringVector cachedListNames = getNames.getNames(cachedList); + if (listNames == null && cachedListNames == null) { return true; - } else if (list.getNames(attrProfiles) == null || cachedList.getNames(attrProfiles) == null) { + } else if (listNames == null || cachedListNames == null) { return false; } else { + for (int i = 0; i < list.getLength(); i++) { - String name = list.getNames(attrProfiles).getDataAt(i); - String cachedName = cachedList.getNames(attrProfiles).getDataAt(i); + String name = listNames.getDataAt(i); + String cachedName = cachedListNames.getDataAt(i); if (name == cachedName) { continue; diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NChar.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NChar.java index aad7cf177b7d81740c655ce56613f1e1c963262c..c2faec1d69a4fca54a7103a68e8e3552c7ac485b 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NChar.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NChar.java @@ -35,12 +35,12 @@ import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.api.profiles.LoopConditionProfile; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimNamesAttributeNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.SetDimNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.builtins.RBuiltin; -import com.oracle.truffle.r.runtime.data.RAttributeProfiles; import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RIntVector; import com.oracle.truffle.r.runtime.data.RList; @@ -70,11 +70,11 @@ public abstract class NChar extends RBuiltinNode { @Specialization protected RIntVector ncharInt(RAbstractIntVector vector, String type, boolean allowNA, boolean keepNA, @Cached("createCountingProfile()") LoopConditionProfile loopProfile, - @Cached("create()") RAttributeProfiles attrProfiles, @Cached("createBinaryProfile()") ConditionProfile nullDimNamesProfile, @Cached("create()") GetDimAttributeNode getDimNode, @Cached("create()") SetDimNamesAttributeNode setDimNamesNode, - @Cached("create()") GetDimNamesAttributeNode getDimNamesNode) { + @Cached("create()") GetDimNamesAttributeNode getDimNamesNode, + @Cached("create()") GetNamesAttributeNode getNamesNode) { int len = vector.getLength(); int[] result = new int[len]; loopProfile.profileCounted(len); @@ -86,7 +86,7 @@ public abstract class NChar extends RBuiltinNode { result[i] = (int) (Math.log10(x) + 1); // not the fastest one } } - RIntVector resultVector = RDataFactory.createIntVector(result, true, getDimNode.getDimensions(vector), vector.getNames(attrProfiles)); + RIntVector resultVector = RDataFactory.createIntVector(result, true, getDimNode.getDimensions(vector), getNamesNode.getNames(vector)); RList dimNames = getDimNamesNode.getDimNames(vector); if (nullDimNamesProfile.profile(dimNames != null)) { setDimNamesNode.setDimNames(resultVector, dimNames); @@ -98,18 +98,18 @@ public abstract class NChar extends RBuiltinNode { @Specialization protected RIntVector nchar(RAbstractStringVector vector, String type, boolean allowNA, boolean keepNA, @Cached("createCountingProfile()") LoopConditionProfile loopProfile, - @Cached("create()") RAttributeProfiles attrProfiles, @Cached("createBinaryProfile()") ConditionProfile nullDimNamesProfile, @Cached("create()") GetDimAttributeNode getDimNode, @Cached("create()") SetDimNamesAttributeNode setDimNamesNode, - @Cached("create()") GetDimNamesAttributeNode getDimNamesNode) { + @Cached("create()") GetDimNamesAttributeNode getDimNamesNode, + @Cached("create()") GetNamesAttributeNode getNamesNode) { int len = vector.getLength(); int[] result = new int[len]; loopProfile.profileCounted(len); for (int i = 0; loopProfile.inject(i < len); i++) { result[i] = vector.getDataAt(i).length(); } - RIntVector resultVector = RDataFactory.createIntVector(result, true, getDimNode.getDimensions(vector), vector.getNames(attrProfiles)); + RIntVector resultVector = RDataFactory.createIntVector(result, true, getDimNode.getDimensions(vector), getNamesNode.getNames(vector)); RList dimNames = getDimNamesNode.getDimNames(vector); if (nullDimNamesProfile.profile(dimNames != null)) { setDimNamesNode.setDimNames(resultVector, dimNames); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Names.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Names.java index 91e6f763bcd36279b045cded3fa328d0a1cdf242..55c50f76361cc2080b1c84120370207135a03ece 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Names.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Names.java @@ -30,10 +30,11 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.runtime.builtins.RBuiltin; -import com.oracle.truffle.r.runtime.data.RAttributeProfiles; import com.oracle.truffle.r.runtime.data.RNull; +import com.oracle.truffle.r.runtime.data.RStringVector; import com.oracle.truffle.r.runtime.data.model.RAbstractContainer; import com.oracle.truffle.r.runtime.env.REnvironment; @@ -41,12 +42,13 @@ import com.oracle.truffle.r.runtime.env.REnvironment; public abstract class Names extends RBuiltinNode { private final ConditionProfile hasNames = ConditionProfile.createBinaryProfile(); - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); + @Child private GetNamesAttributeNode getNames = GetNamesAttributeNode.create(); @Specialization protected Object getNames(RAbstractContainer container) { - if (hasNames.profile(container.getNames(attrProfiles) != null)) { - return container.getNames(attrProfiles); + RStringVector names = getNames.getNames(container); + if (hasNames.profile(names != null)) { + return names; } else { return RNull.instance; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/OptionsFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/OptionsFunctions.java index f5487620db0fb63a21abd652f71710e0cf582d99..9486a8a9d9f6bde07fe95e17735384e70462fcb8 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/OptionsFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/OptionsFunctions.java @@ -22,7 +22,7 @@ */ package com.oracle.truffle.r.nodes.builtin.base; -import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.*; +import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.stringValue; import static com.oracle.truffle.r.runtime.RVisibility.CUSTOM; import static com.oracle.truffle.r.runtime.builtins.RBehavior.MODIFIES_STATE; import static com.oracle.truffle.r.runtime.builtins.RBehavior.READS_STATE; diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Repeat.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Repeat.java index 7c727694708c8bb6f3ab5268ee8dd8b2e590c3f9..e89c2645f46e5482347b24152fbff85318ef7c3a 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Repeat.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Repeat.java @@ -37,14 +37,14 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.profiles.ConditionProfile; -import com.oracle.truffle.r.nodes.attributes.SetFixedAttributeNode; import com.oracle.truffle.r.nodes.attributes.InitAttributesNode; +import com.oracle.truffle.r.nodes.attributes.SetFixedAttributeNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.builtins.RBuiltin; -import com.oracle.truffle.r.runtime.data.RAttributeProfiles; import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RMissing; import com.oracle.truffle.r.runtime.data.RStringVector; @@ -83,7 +83,7 @@ public abstract class Repeat extends RBuiltinNode { private final BranchProfile errorBranch = BranchProfile.create(); private final ConditionProfile oneTimeGiven = ConditionProfile.createBinaryProfile(); private final ConditionProfile replicateOnce = ConditionProfile.createBinaryProfile(); - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); + @Child private GetNamesAttributeNode getNames = GetNamesAttributeNode.create(); @Override public Object[] getDefaultParameterValues() { @@ -106,7 +106,7 @@ public abstract class Repeat extends RBuiltinNode { } protected boolean hasNames(RAbstractVector x) { - return x.getNames(attrProfiles) != null; + return getNames.getNames(x) != null; } private RError invalidTimes() { @@ -158,7 +158,7 @@ public abstract class Repeat extends RBuiltinNode { throw invalidTimes(); } RAbstractVector input = handleEach(x, each); - RStringVector names = (RStringVector) handleEach(x.getNames(attrProfiles), each); + RStringVector names = (RStringVector) handleEach(getNames.getNames(x), each); RVector<?> r; if (lengthOutOrTimes.profile(!RRuntime.isNA(lengthOut))) { names = (RStringVector) handleLengthOut(names, lengthOut, false); @@ -178,10 +178,10 @@ public abstract class Repeat extends RBuiltinNode { RStringVector names; RVector<?> r; if (lengthOutOrTimes.profile(!RRuntime.isNA(lengthOut))) { - names = (RStringVector) handleLengthOut(x.getNames(attrProfiles), lengthOut, true); + names = (RStringVector) handleLengthOut(getNames.getNames(x), lengthOut, true); r = handleLengthOut(x, lengthOut, true); } else { - names = (RStringVector) handleTimes(x.getNames(attrProfiles), times, true); + names = (RStringVector) handleTimes(getNames.getNames(x), times, true); r = handleTimes(x, times, true); } putNames.execute(initAttributes.execute(r), names); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Scan.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Scan.java index 6a4d2b0e3a599bbb0089d72d2dd6ae6b81277597..d9396a717a28d8f3084ab5a169a2ab44bc4fa0ac 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Scan.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Scan.java @@ -31,18 +31,18 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.nodes.unary.CastToVectorNode; import com.oracle.truffle.r.nodes.unary.CastToVectorNodeGen; import com.oracle.truffle.r.runtime.RError; +import com.oracle.truffle.r.runtime.RError.Message; import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.RRuntime; -import com.oracle.truffle.r.runtime.RError.Message; import com.oracle.truffle.r.runtime.builtins.RBuiltin; import com.oracle.truffle.r.runtime.conn.RConnection; import com.oracle.truffle.r.runtime.conn.StdConnections; -import com.oracle.truffle.r.runtime.data.RAttributeProfiles; import com.oracle.truffle.r.runtime.data.RComplex; import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RDouble; @@ -67,7 +67,7 @@ public abstract class Scan extends RBuiltinNode { private final NACheck naCheck = NACheck.create(); private final BranchProfile errorProfile = BranchProfile.create(); - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); + @Child private GetNamesAttributeNode getNames = GetNamesAttributeNode.create(); @Child private CastToVectorNode castVector; @@ -338,7 +338,7 @@ public abstract class Scan extends RBuiltinNode { list.updateDataAt(i, vec.createEmptySameType(blockSize, RDataFactory.COMPLETE_VECTOR), null); } } - list.setNames(what.getNames(attrProfiles)); + list.setNames(getNames.getNames(what)); naCheck.enable(true); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ToLowerOrUpper.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ToLowerOrUpper.java index 443a5505f5bc37089c8b11fb7562b3be52736cf9..31023607abacfbcd6dffea008880f47efebf75ec 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ToLowerOrUpper.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ToLowerOrUpper.java @@ -30,17 +30,16 @@ import java.util.function.BiFunction; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node.Child; import com.oracle.truffle.api.profiles.LoopConditionProfile; import com.oracle.truffle.r.nodes.attributes.CopyOfRegAttributesNode; import com.oracle.truffle.r.nodes.attributes.CopyOfRegAttributesNodeGen; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimAttributeNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.nodes.profile.VectorLengthProfile; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.builtins.RBuiltin; -import com.oracle.truffle.r.runtime.data.RAttributeProfiles; import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RStringVector; import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; @@ -54,7 +53,7 @@ public abstract class ToLowerOrUpper { private final VectorLengthProfile lengthProfile = VectorLengthProfile.create(); private final LoopConditionProfile loopProfile = LoopConditionProfile.createCountingProfile(); private final NACheck na = NACheck.create(); - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); + @Child private GetNamesAttributeNode getNames = GetNamesAttributeNode.create(); @Child private CopyOfRegAttributesNode copyAttributes = CopyOfRegAttributesNodeGen.create(); @Child private GetDimAttributeNode getDimNode = GetDimAttributeNode.create(); @@ -85,7 +84,7 @@ public abstract class ToLowerOrUpper { String value = vector.getDataAt(i); stringVector[i] = elementFunction(value, i, function); } - RStringVector result = RDataFactory.createStringVector(stringVector, vector.isComplete(), getDimNode.getDimensions(vector), vector.getNames(attrProfiles)); + RStringVector result = RDataFactory.createStringVector(stringVector, vector.isComplete(), getDimNode.getDimensions(vector), getNames.getNames(vector)); copyAttributes.execute(vector, result); return result; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Unlist.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Unlist.java index 03cf59487b7a937e378b58662b29d18458f38740..8558fef08d71acb5d113e9d833217db0c34a7f97 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Unlist.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Unlist.java @@ -22,6 +22,7 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.nodes.builtin.base.UnlistNodeGen.RecursiveLengthNodeGen; @@ -31,7 +32,6 @@ import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.builtins.RBuiltin; import com.oracle.truffle.r.runtime.context.RContext; -import com.oracle.truffle.r.runtime.data.RAttributeProfiles; import com.oracle.truffle.r.runtime.data.RComplex; import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RFunction; @@ -57,8 +57,7 @@ public abstract class Unlist extends RBuiltinNode { @Child private PrecedenceNode precedenceNode = PrecedenceNodeGen.create(); @Child private Length lengthNode; @Child private RecursiveLength recursiveLengthNode; - - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); + @Child private GetNamesAttributeNode getNames = GetNamesAttributeNode.create(); @TypeSystemReference(RTypes.class) protected abstract static class RecursiveLength extends Node { @@ -189,7 +188,8 @@ public abstract class Unlist extends RBuiltinNode { case PrecedenceNode.RAW_PRECEDENCE: { byte[] result = new byte[totalSize]; if (!recursive) { - RStringVector listNames = useNames && list.getNames(attrProfiles) != null ? list.getNames(attrProfiles) : null; + RStringVector ln = getNames.getNames(list); + RStringVector listNames = useNames && ln != null ? ln : null; int position = 0; for (int i = 0; i < list.getLength(); i++) { if (list.getDataAt(i) != RNull.instance) { @@ -204,7 +204,8 @@ public abstract class Unlist extends RBuiltinNode { case PrecedenceNode.LOGICAL_PRECEDENCE: { byte[] result = new byte[totalSize]; if (!recursive) { - RStringVector listNames = useNames && list.getNames(attrProfiles) != null ? list.getNames(attrProfiles) : null; + RStringVector ln = getNames.getNames(list); + RStringVector listNames = useNames && ln != null ? ln : null; int position = 0; for (int i = 0; i < list.getLength(); i++) { if (list.getDataAt(i) != RNull.instance) { @@ -220,7 +221,8 @@ public abstract class Unlist extends RBuiltinNode { case PrecedenceNode.INT_PRECEDENCE: { int[] result = new int[totalSize]; if (!recursive) { - RStringVector listNames = useNames && list.getNames(attrProfiles) != null ? list.getNames(attrProfiles) : null; + RStringVector ln = getNames.getNames(list); + RStringVector listNames = useNames && ln != null ? ln : null; int position = 0; for (int i = 0; i < list.getLength(); i++) { if (list.getDataAt(i) != RNull.instance) { @@ -236,7 +238,8 @@ public abstract class Unlist extends RBuiltinNode { case PrecedenceNode.DOUBLE_PRECEDENCE: { double[] result = new double[totalSize]; if (!recursive) { - RStringVector listNames = useNames && list.getNames(attrProfiles) != null ? list.getNames(attrProfiles) : null; + RStringVector ln = getNames.getNames(list); + RStringVector listNames = useNames && ln != null ? ln : null; int position = 0; for (int i = 0; i < list.getLength(); i++) { if (list.getDataAt(i) != RNull.instance) { @@ -252,7 +255,8 @@ public abstract class Unlist extends RBuiltinNode { case PrecedenceNode.COMPLEX_PRECEDENCE: { double[] result = new double[totalSize << 1]; if (!recursive) { - RStringVector listNames = useNames && list.getNames(attrProfiles) != null ? list.getNames(attrProfiles) : null; + RStringVector ln = getNames.getNames(list); + RStringVector listNames = useNames && ln != null ? ln : null; int position = 0; for (int i = 0; i < list.getLength(); i++) { if (list.getDataAt(i) != RNull.instance) { @@ -268,7 +272,8 @@ public abstract class Unlist extends RBuiltinNode { case PrecedenceNode.STRING_PRECEDENCE: { String[] result = new String[totalSize]; if (!recursive) { - RStringVector listNames = useNames && list.getNames(attrProfiles) != null ? list.getNames(attrProfiles) : null; + RStringVector ln = getNames.getNames(list); + RStringVector listNames = useNames && ln != null ? ln : null; int position = 0; for (int i = 0; i < list.getLength(); i++) { if (list.getDataAt(i) != RNull.instance) { @@ -285,7 +290,8 @@ public abstract class Unlist extends RBuiltinNode { case PrecedenceNode.EXPRESSION_PRECEDENCE: { Object[] result = new Object[totalSize]; if (!recursive) { - RStringVector listNames = useNames && list.getNames(attrProfiles) != null ? list.getNames(attrProfiles) : null; + RStringVector ln = getNames.getNames(list); + RStringVector listNames = useNames && ln != null ? ln : null; int position = 0; for (int i = 0; i < list.getLength(); i++) { if (list.getDataAt(i) != RNull.instance) { @@ -337,7 +343,8 @@ public abstract class Unlist extends RBuiltinNode { if (o instanceof RAbstractVector) { RAbstractVector v = (RAbstractVector) o; - RStringVector listNames = useNames && v.getNames(attrProfiles) != null ? v.getNames(attrProfiles) : null; + RStringVector ln = getNames.getNames(v); + RStringVector listNames = useNames && ln != null ? ln : null; for (int i = 0; i < v.getLength(); i++) { String name = itemName(listNames, i); Object cur = v.getDataAtAsObject(i); @@ -373,7 +380,8 @@ public abstract class Unlist extends RBuiltinNode { if (o instanceof RAbstractVector) { RAbstractVector v = (RAbstractVector) o; - RStringVector listNames = useNames && v.getNames(attrProfiles) != null ? v.getNames(attrProfiles) : null; + RStringVector ln = getNames.getNames(v); + RStringVector listNames = useNames && ln != null ? ln : null; for (int i = 0; i < v.getLength(); i++) { String name = itemName(listNames, i); Object cur = v.getDataAtAsObject(i); @@ -409,7 +417,8 @@ public abstract class Unlist extends RBuiltinNode { if (o instanceof RAbstractVector) { RAbstractVector v = (RAbstractVector) o; - RStringVector listNames = useNames && v.getNames(attrProfiles) != null ? v.getNames(attrProfiles) : null; + RStringVector ln = getNames.getNames(v); + RStringVector listNames = useNames && ln != null ? ln : null; for (int i = 0; i < v.getLength(); i++) { String name = itemName(listNames, i); Object cur = v.getDataAtAsObject(i); @@ -445,7 +454,8 @@ public abstract class Unlist extends RBuiltinNode { if (o instanceof RAbstractVector) { RAbstractVector v = (RAbstractVector) o; - RStringVector listNames = useNames && v.getNames(attrProfiles) != null ? v.getNames(attrProfiles) : null; + RStringVector ln = getNames.getNames(v); + RStringVector listNames = useNames && ln != null ? ln : null; for (int i = 0; i < v.getLength(); i++) { String name = itemName(listNames, i); Object cur = v.getDataAtAsObject(i); @@ -481,7 +491,8 @@ public abstract class Unlist extends RBuiltinNode { if (o instanceof RAbstractVector) { RAbstractVector v = (RAbstractVector) o; - RStringVector listNames = useNames && v.getNames(attrProfiles) != null ? v.getNames(attrProfiles) : null; + RStringVector ln = getNames.getNames(v); + RStringVector listNames = useNames && ln != null ? ln : null; for (int i = 0; i < v.getLength(); i++) { String name = itemName(listNames, i); Object cur = v.getDataAtAsObject(i); @@ -522,7 +533,8 @@ public abstract class Unlist extends RBuiltinNode { if (o instanceof RAbstractVector) { RAbstractVector v = (RAbstractVector) o; - RStringVector listNames = useNames && v.getNames(attrProfiles) != null ? v.getNames(attrProfiles) : null; + RStringVector ln = getNames.getNames(v); + RStringVector listNames = useNames && ln != null ? ln : null; for (int i = 0; i < v.getLength(); i++) { String name = itemName(listNames, i); Object cur = v.getDataAtAsObject(i); @@ -558,7 +570,8 @@ public abstract class Unlist extends RBuiltinNode { if (o instanceof RAbstractVector) { RAbstractVector v = (RAbstractVector) o; - RStringVector listNames = useNames && v.getNames(attrProfiles) != null ? v.getNames(attrProfiles) : null; + RStringVector ln = getNames.getNames(v); + RStringVector listNames = useNames && ln != null ? ln : null; for (int i = 0; i < v.getLength(); i++) { String name = itemName(listNames, i); Object cur = v.getDataAtAsObject(i); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttributes.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttributes.java index fd24c7fe3a85441890ec618d965dc8f2e03c3c3c..c53588cc748f1268276a8378ebea90fb6b87afdc 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttributes.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttributes.java @@ -33,6 +33,7 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.r.nodes.attributes.InitAttributesNode; import com.oracle.truffle.r.nodes.attributes.SetAttributeNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.SetClassAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.SetDimAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; @@ -59,6 +60,7 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractVector; public abstract class UpdateAttributes extends RBuiltinNode { private final ConditionProfile numAttributesProfile = ConditionProfile.createBinaryProfile(); private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); + @Child private GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); @Child private UpdateNames updateNames; @Child private UpdateDimNames updateDimNames; @@ -119,7 +121,7 @@ public abstract class UpdateAttributes extends RBuiltinNode { @Specialization protected RAbstractContainer updateAttributes(RAbstractContainer container, RList list) { - Object listNamesObject = list.getNames(attrProfiles); + Object listNamesObject = getNamesNode.getNames(list); if (listNamesObject == null || listNamesObject == RNull.instance) { throw RError.error(this, RError.Message.ATTRIBUTES_NAMED); } @@ -160,7 +162,7 @@ public abstract class UpdateAttributes extends RBuiltinNode { } private void setDimAttribute(RAbstractContainer result, RList sourceList) { - RStringVector listNames = sourceList.getNames(attrProfiles); + RStringVector listNames = getNamesNode.getNames(sourceList); int length = sourceList.getLength(); assert length > 0 : "Length should be > 0 for ExplodeLoop"; for (int i = 0; i < sourceList.getLength(); i++) { @@ -187,7 +189,7 @@ public abstract class UpdateAttributes extends RBuiltinNode { } private RAbstractContainer setRemainingAttributes(RAbstractContainer result, RList sourceList) { - RStringVector listNames = sourceList.getNames(attrProfiles); + RStringVector listNames = getNamesNode.getNames(sourceList); int length = sourceList.getLength(); assert length > 0 : "Length should be > 0 for ExplodeLoop"; RAbstractContainer res = result; diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/VApply.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/VApply.java index 305c602cad205fd89e0b3520f7dad06a9aa0a6ce..2be9987afc3a938032c803813242677704ca2fe5 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/VApply.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/VApply.java @@ -29,10 +29,10 @@ import static com.oracle.truffle.r.runtime.builtins.RBehavior.COMPLEX; import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.INTERNAL; import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.SetDimAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; @@ -52,7 +52,6 @@ import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.builtins.RBuiltin; -import com.oracle.truffle.r.runtime.data.RAttributeProfiles; import com.oracle.truffle.r.runtime.data.RComplex; import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RFunction; @@ -82,7 +81,6 @@ public abstract class VApply extends RBuiltinNode { private final ConditionProfile useNamesProfile = ConditionProfile.createBinaryProfile(); private final ConditionProfile dimsProfile = ConditionProfile.createBinaryProfile(); - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); private final NACheck naCheck = NACheck.create(); @Child private LapplyInternalNode doApply = LapplyInternalNodeGen.create(); @@ -93,6 +91,7 @@ public abstract class VApply extends RBuiltinNode { @Child private CastLogicalNode castLogical; @Child private CastStringNode castString; @Child private SetDimAttributeNode setDimNode; + @Child private GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); @Override protected void createCasts(CastBuilder casts) { @@ -198,7 +197,7 @@ public abstract class VApply extends RBuiltinNode { // TODO: handle names in case of matrices if (useNamesProfile.profile(RRuntime.fromLogical(useNames))) { - RStringVector names = vecMat.getNames(attrProfiles); + RStringVector names = getNamesNode.getNames(vecMat); RStringVector newNames = null; if (names != null) { newNames = names; diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/WhichFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/WhichFunctions.java index ec76dd55c89e32226ef5eafac0317d653103d41b..fc877bfacf4ca2258be4cf1a83c998187ff4d553 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/WhichFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/WhichFunctions.java @@ -30,6 +30,7 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.api.profiles.LoopConditionProfile; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.nodes.builtin.base.WhichFunctionsFactory.WhichMaxNodeGen; @@ -64,7 +65,7 @@ public class WhichFunctions { @Cached("create()") VectorLengthProfile lengthProfile, @Cached("createCountingProfile()") LoopConditionProfile loopProfile, @Cached("createBinaryProfile()") ConditionProfile hasNamesProfile, - @Cached("create()") RAttributeProfiles attrProfiles, + @Cached("create()") GetNamesAttributeNode getNamesNode, @Cached("create()") NACheck naCheck) { int length = lengthProfile.profile(x.getLength()); loopProfile.profileCounted(length); @@ -83,7 +84,7 @@ public class WhichFunctions { result[pos++] = i + 1; } } - RStringVector names = x.getNames(attrProfiles); + RStringVector names = getNamesNode.getNames(x); if (hasNamesProfile.profile(names != null)) { // collect result names String[] resultNames = new String[resultLength]; @@ -122,7 +123,7 @@ public class WhichFunctions { @Cached("createCountingProfile()") LoopConditionProfile loopProfile, @Cached("createBinaryProfile()") ConditionProfile isNaNProfile, @Cached("createBinaryProfile()") ConditionProfile hasNamesProfile, - @Cached("create()") RAttributeProfiles attrProfiles) { + @Cached("create()") GetNamesAttributeNode getNamesNode) { int length = lengthProfile.profile(x.getLength()); loopProfile.profileCounted(length); double extreme = Double.NaN; @@ -138,7 +139,7 @@ public class WhichFunctions { if (isNaNProfile.profile(extremeIndex == -1)) { return RDataFactory.createEmptyIntVector(); } - RStringVector names = x.getNames(attrProfiles); + RStringVector names = getNamesNode.getNames(x); if (hasNamesProfile.profile(names != null)) { // collect result names RStringVector resultNames = RDataFactory.createStringVectorFromScalar(names.getDataAt(extremeIndex)); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/Subset.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/Subset.java index 4b3166024df80800419b87a3ec2843f9f62f46b7..9d693de22845ef0dba043d41824103eeda08015e 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/Subset.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/Subset.java @@ -34,12 +34,12 @@ import com.oracle.truffle.r.nodes.EmptyTypeSystemFlatLayout; import com.oracle.truffle.r.nodes.access.vector.ElementAccessMode; import com.oracle.truffle.r.nodes.access.vector.ExtractListElement; import com.oracle.truffle.r.nodes.access.vector.ExtractVectorNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.runtime.ArgumentsSignature; import com.oracle.truffle.r.runtime.builtins.RBuiltin; import com.oracle.truffle.r.runtime.data.RArgsValuesAndNames; -import com.oracle.truffle.r.runtime.data.RAttributeProfiles; import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RList; import com.oracle.truffle.r.runtime.data.RLogical; @@ -55,12 +55,12 @@ import com.oracle.truffle.r.runtime.nodes.RNode; @TypeSystemReference(EmptyTypeSystemFlatLayout.class) abstract class SubsetSpecial extends SubscriptSpecialBase { - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); + @Child private GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); @Override protected boolean simpleVector(RAbstractVector vector) { vector = vectorClassProfile.profile(vector); - return super.simpleVector(vector) && vector.getNames(attrProfiles) == null; + return super.simpleVector(vector) && getNamesNode.getNames(vector) == null; } @Override diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/CachedExtractVectorNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/CachedExtractVectorNode.java index be3be6d2ff762fb0c2dee5c05add263c6dbc1754..589acd316b992ddc87812d2e6fb7306c88c4562d 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/CachedExtractVectorNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/CachedExtractVectorNode.java @@ -34,6 +34,7 @@ import com.oracle.truffle.r.nodes.access.vector.CachedExtractVectorNodeFactory.S import com.oracle.truffle.r.nodes.access.vector.PositionsCheckNode.PositionProfile; import com.oracle.truffle.r.nodes.attributes.GetFixedAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimNamesAttributeNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.SetDimAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.SetDimNamesAttributeNode; import com.oracle.truffle.r.nodes.profile.AlwaysOnBranchProfile; @@ -71,11 +72,15 @@ final class CachedExtractVectorNode extends CachedVectorNode { private final boolean dropDimensions; private final VectorLengthProfile vectorLengthProfile = VectorLengthProfile.create(); - private final RAttributeProfiles vectorNamesProfile = RAttributeProfiles.create(); @Child private WriteIndexedVectorNode writeVectorNode; @Child private PositionsCheckNode positionsCheckNode; @Child private SetNamesNode setNamesNode; + @Child private SetDimAttributeNode setDimNode; + @Child private SetDimNamesAttributeNode setDimNamesNode; + @Child private GetDimNamesAttributeNode getDimNamesNode; + @Child private GetNamesAttributeNode getNamesNode; + @Child private GetNamesAttributeNode getNamesFromDimNamesNode; @Children private final CachedExtractVectorNode[] extractNames; @Children private final CachedExtractVectorNode[] extractNamesAlternative; @@ -187,7 +192,11 @@ final class CachedExtractVectorNode extends CachedVectorNode { } if (oneDimensionProfile.profile(numberOfDimensions == 1)) { // names only need to be considered for single dimensional accesses - RStringVector originalNames = vector.getNames(vectorNamesProfile); + if (getNamesNode == null) { + CompilerDirectives.transferToInterpreter(); + getNamesNode = insert(GetNamesAttributeNode.create()); + } + RStringVector originalNames = getNamesNode.getNames(vector); if (originalNames != null) { metadataApplied.enter(); setNames(extractedVector, extractNames(originalNames, positions, positionProfiles, 0, originalExact, originalDropDimensions)); @@ -276,16 +285,11 @@ final class CachedExtractVectorNode extends CachedVectorNode { } private final ConditionProfile dimNamesNull = ConditionProfile.createBinaryProfile(); - private final RAttributeProfiles dimnamesNamesProfile = RAttributeProfiles.create(); private final ValueProfile foundDimNamesProfile = ValueProfile.createClassProfile(); private final ConditionProfile selectPositionsProfile = ConditionProfile.createBinaryProfile(); private final ConditionProfile originalDimNamesPRofile = ConditionProfile.createBinaryProfile(); private final ConditionProfile foundNamesProfile = ConditionProfile.createBinaryProfile(); - @Child private SetDimAttributeNode setDimNode; - @Child private SetDimNamesAttributeNode setDimNamesNode; - @Child private GetDimNamesAttributeNode getDimNamesNode; - @ExplodeLoop private void applyDimensions(RAbstractContainer originalTarget, RVector<?> extractedTarget, int extractedTargetLength, PositionProfile[] positionProfile, Object[] positions) { // TODO speculate on the number of counted dimensions @@ -306,8 +310,12 @@ final class CachedExtractVectorNode extends CachedVectorNode { originalDimNamesNames = null; newDimNamesNames = null; } else { + if (getNamesFromDimNamesNode == null) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + getNamesFromDimNamesNode = insert(GetNamesAttributeNode.create()); + } newDimNames = new Object[dimCount]; - originalDimNamesNames = originalDimNames.getNames(dimnamesNamesProfile); + originalDimNamesNames = getNamesFromDimNamesNode.getNames(originalDimNames); newDimNamesNames = originalDimNamesNames == null ? null : new String[dimCount]; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/CachedReplaceVectorNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/CachedReplaceVectorNode.java index e951c3c9927316606423f3d313152a0bc252a6c4..640919a6809fb0f99ae2d91fa42abbcfe2fb847f 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/CachedReplaceVectorNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/CachedReplaceVectorNode.java @@ -40,6 +40,7 @@ import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.api.profiles.ValueProfile; import com.oracle.truffle.r.nodes.access.vector.CachedReplaceVectorNodeFactory.ValueProfileNodeGen; import com.oracle.truffle.r.nodes.access.vector.PositionsCheckNode.PositionProfile; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.binary.CastTypeNode; import com.oracle.truffle.r.nodes.profile.VectorLengthProfile; import com.oracle.truffle.r.nodes.unary.CastListNodeGen; @@ -438,6 +439,8 @@ final class CachedReplaceVectorNode extends CachedVectorNode { } private final ValueProfile positionCastProfile = ValueProfile.createClassProfile(); + @Child private GetNamesAttributeNode getNamesNode; + @Child private GetNamesAttributeNode getResultNamesNode; private void updateVectorWithPositionNames(RAbstractVector vector, Object[] positions) { Object position = positionCastProfile.profile(positions[0]); @@ -446,7 +449,11 @@ final class CachedReplaceVectorNode extends CachedVectorNode { if (position instanceof RMissing) { positionNames = null; } else { - positionNames = ((RAbstractVector) position).getNames(positionNamesProfile); + if (getNamesNode == null) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + getNamesNode = insert(GetNamesAttributeNode.create()); + } + positionNames = getNamesNode.getNames(position); } if (positionNames != null && positionNames.getLength() > 0) { updatePositionNames(vector, positionNames, positions); @@ -551,7 +558,11 @@ final class CachedReplaceVectorNode extends CachedVectorNode { private final ConditionProfile updateNamesProfile = ConditionProfile.createBinaryProfile(); private void updatePositionNames(RAbstractVector resultVector, RAbstractStringVector positionNames, Object[] positions) { - RTypedValue originalNames = resultVector.getNames(positionNamesProfile); + if (getResultNamesNode == null) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + getResultNamesNode = insert(GetNamesAttributeNode.create()); + } + RTypedValue originalNames = getResultNamesNode.getNames(resultVector); RTypedValue names = originalNames; if (names == null) { String[] emptyVector = new String[resultVector.getLength()]; @@ -580,7 +591,7 @@ final class CachedReplaceVectorNode extends CachedVectorNode { */ @CompilationFinal private int previousResultLength = PREVIOUS_RESULT_UNINITIALIZED; - private final RAttributeProfiles vectorNamesProfile = RAttributeProfiles.create(); + @Child private GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); public RAbstractVector deleteElements(RAbstractVector vector, int vectorLength) { // we can speculate here that we delete always the same number of elements @@ -596,7 +607,7 @@ final class CachedReplaceVectorNode extends CachedVectorNode { } Object[] data = new Object[resultLength]; - RStringVector names = vector.getNames(vectorNamesProfile); + RStringVector names = getNamesNode.getNames(vector); boolean hasNames = names != null; String[] newNames = null; if (hasNames) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCharacterLookupNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCharacterLookupNode.java index 4b93498c0ddaca50eeb839023bb012c2e1b4ae8e..70e086e85722e0917405de4db7f6f82244cd5526 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCharacterLookupNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCharacterLookupNode.java @@ -22,13 +22,12 @@ */ package com.oracle.truffle.r.nodes.access.vector; -import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimNamesAttributeNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RError.Message; -import com.oracle.truffle.r.runtime.data.RAttributeProfiles; import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RList; import com.oracle.truffle.r.runtime.data.RNull; @@ -40,13 +39,13 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; final class PositionCharacterLookupNode extends Node { private final ElementAccessMode mode; - private final RAttributeProfiles attributeProfiles = RAttributeProfiles.create(); private final int numDimensions; private final int dimensionIndex; private final BranchProfile emptyProfile = BranchProfile.create(); @Child private SearchFirstStringNode searchNode; @Child private GetDimNamesAttributeNode getDimNamesNode = GetDimNamesAttributeNode.create(); + @Child private GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); PositionCharacterLookupNode(ElementAccessMode mode, int numDimensions, int dimensionIndex, boolean useNAForNotFound, boolean exact) { this.numDimensions = numDimensions; @@ -59,7 +58,7 @@ final class PositionCharacterLookupNode extends Node { // lookup names for single dimension case RAbstractIntVector result; if (numDimensions <= 1) { - RStringVector names = target.getNames(attributeProfiles); + RStringVector names = getNamesNode.getNames(target); if (names == null) { emptyProfile.enter(); names = RDataFactory.createEmptyStringVector(); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCheckSubscriptNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCheckSubscriptNode.java index 43486bf76a3b037d6e5eaf5ab11043ceba180ece..6aa4578656348d2c47e4ea9f19d82418716a06af 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCheckSubscriptNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCheckSubscriptNode.java @@ -22,9 +22,11 @@ */ package com.oracle.truffle.r.nodes.access.vector; +import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.r.nodes.access.vector.PositionsCheckNode.PositionProfile; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RError.Message; import com.oracle.truffle.r.runtime.RRuntime; @@ -61,7 +63,8 @@ abstract class PositionCheckSubscriptNode extends PositionCheckNode { } @Specialization - protected RAbstractVector doLogical(PositionProfile statistics, int dimSize, RAbstractLogicalVector position, int positionLength) { + protected RAbstractVector doLogical(PositionProfile statistics, int dimSize, RAbstractLogicalVector position, int positionLength, + @Cached("create()") GetNamesAttributeNode getNamesNode) { positionNACheck.enable(position); byte value = position.getDataAt(0); if (positionLength != 1) { @@ -77,11 +80,12 @@ abstract class PositionCheckSubscriptNode extends PositionCheckNode { } } - return doIntegerImpl(statistics, dimSize, positionNACheck.convertLogicalToInt(value), position); + return doIntegerImpl(statistics, dimSize, positionNACheck.convertLogicalToInt(value), position, getNamesNode); } @Specialization - protected RAbstractVector doInteger(PositionProfile profile, int dimSize, RAbstractIntVector position, int positionLength) { + protected RAbstractVector doInteger(PositionProfile profile, int dimSize, RAbstractIntVector position, int positionLength, + @Cached("create()") GetNamesAttributeNode getNamesNode) { if (positionLength != 1) { error.enter(); Message message; @@ -99,12 +103,12 @@ abstract class PositionCheckSubscriptNode extends PositionCheckNode { } assert positionLength == 1; positionNACheck.enable(position); - RAbstractVector result = doIntegerImpl(profile, dimSize, position.getDataAt(0), position); + RAbstractVector result = doIntegerImpl(profile, dimSize, position.getDataAt(0), position, getNamesNode); return result; } - private RAbstractVector doIntegerImpl(PositionProfile profile, int dimSize, int value, RAbstractVector originalVector) { + private RAbstractVector doIntegerImpl(PositionProfile profile, int dimSize, int value, RAbstractVector originalVector, GetNamesAttributeNode getNamesNode) { int result; if (greaterZero.profile(value > 0)) { // fast path @@ -121,7 +125,7 @@ abstract class PositionCheckSubscriptNode extends PositionCheckNode { } profile.selectedPositionsCount = 1; - RStringVector names = originalVector.getNames(attributeProfile); + RStringVector names = getNamesNode.getNames(originalVector); if (names != null) { return RDataFactory.createIntVector(new int[]{result}, !profile.containsNA, names); } else { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCheckSubsetNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCheckSubsetNode.java index bc29b18d2a136d3ebb10508126a66727b3b771a0..5929a57a89e8229850b1f94f5308156a38b82792 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCheckSubsetNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCheckSubsetNode.java @@ -31,6 +31,7 @@ import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.api.profiles.LoopConditionProfile; import com.oracle.truffle.r.nodes.access.vector.PositionsCheckNode.PositionProfile; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.runtime.NullProfile; import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RRuntime; @@ -128,8 +129,6 @@ abstract class PositionCheckSubsetNode extends PositionCheckNode { return position; } - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); - @Specialization(/* contains = "doSequence" */) protected RAbstractVector doDouble(PositionProfile profile, int dimensionLength, RAbstractDoubleVector position, int positionLength, // @Cached("create()") BranchProfile seenZeroProfile, // @@ -137,11 +136,12 @@ abstract class PositionCheckSubsetNode extends PositionCheckNode { @Cached("create()") BranchProfile seenNegativeProfile, // @Cached("create()") BranchProfile seenOutOfBounds, // @Cached("create()") NullProfile hasNamesProfile, // - @Cached("createCountingProfile()") LoopConditionProfile lengthProfile) { + @Cached("createCountingProfile()") LoopConditionProfile lengthProfile, + @Cached("create()") GetNamesAttributeNode getNamesNode) { RAbstractIntVector intPosition = RDataFactory.createIntVector(positionLength); intPosition.setComplete(position.isComplete()); // requires names preservation - RStringVector names = hasNamesProfile.profile(position.getNames(attrProfiles)); + RStringVector names = hasNamesProfile.profile(getNamesNode.getNames(position)); if (names != null) { intPosition.setNames(names); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/CopyAttributesNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/CopyAttributesNode.java index 67d5b8f3236fd552195e440f32e05434bfd4f64b..0184d74159a9c9e6f4282b9e6e7dcf0328739b9c 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/CopyAttributesNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/CopyAttributesNode.java @@ -30,6 +30,7 @@ import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimNamesAttributeNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.SetDimNamesAttributeNode; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.data.RAttributeProfiles; @@ -50,11 +51,9 @@ public abstract class CopyAttributesNode extends RBaseNode { private final boolean copyAllAttributes; - protected final RAttributeProfiles attrLeftProfiles = RAttributeProfiles.create(); - protected final RAttributeProfiles attrRightProfiles = RAttributeProfiles.create(); - @Child protected HasFixedAttributeNode hasDimNode = HasFixedAttributeNode.createDim(); @Child protected GetDimNamesAttributeNode getDimNamesNode = GetDimNamesAttributeNode.create(); + @Child protected GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); protected CopyAttributesNode(boolean copyAllAttributes) { this.copyAllAttributes = copyAllAttributes; @@ -66,9 +65,9 @@ public abstract class CopyAttributesNode extends RBaseNode { public abstract RAbstractVector execute(RAbstractVector target, RAbstractVector left, int leftLength, RAbstractVector right, int rightLength); - protected boolean containsMetadata(RAbstractVector vector, RAttributeProfiles attrProfiles) { + protected boolean containsMetadata(RAbstractVector vector) { return vector instanceof RVector && hasDimNode.execute(vector) || (copyAllAttributes && vector.getAttributes() != null) || getDimNamesNode.getDimNames(vector) != null || - vector.getNames(attrProfiles) != null; + getNamesNode.getNames(vector) != null; } private static int countNo; @@ -104,7 +103,7 @@ public abstract class CopyAttributesNode extends RBaseNode { } @SuppressWarnings("unused") - @Specialization(guards = {"!containsMetadata(left, attrLeftProfiles)", "!containsMetadata(right, attrRightProfiles)"}) + @Specialization(guards = {"!containsMetadata(left)", "!containsMetadata(right)"}) protected RAbstractVector copyNoMetadata(RAbstractVector target, RAbstractVector left, int leftLength, RAbstractVector right, int rightLength) { if (LOG) { log("copyAttributes: no"); @@ -113,7 +112,7 @@ public abstract class CopyAttributesNode extends RBaseNode { return target; } - @Specialization(guards = {"leftLength == rightLength", "containsMetadata(left, attrLeftProfiles) || containsMetadata(right, attrRightProfiles)"}) + @Specialization(guards = {"leftLength == rightLength", "containsMetadata(left) || containsMetadata(right)"}) protected RAbstractVector copySameLength(RAbstractVector target, RAbstractVector left, @SuppressWarnings("unused") int leftLength, RAbstractVector right, @SuppressWarnings("unused") int rightLength, @Cached("create()") CopyOfRegAttributesNode copyOfRegLeft, @@ -159,7 +158,7 @@ public abstract class CopyAttributesNode extends RBaseNode { removeDimNames.execute(attributes); } - RStringVector vecNames = left.getNames(attrLeftProfiles); + RStringVector vecNames = getNamesNode.getNames(left); if (hasNamesLeft.profile(vecNames != null)) { if (result != left) { putNames.execute(initAttributes.execute(result), vecNames); @@ -167,7 +166,7 @@ public abstract class CopyAttributesNode extends RBaseNode { return result; } if (result != right) { - vecNames = right.getNames(attrRightProfiles); + vecNames = getNamesNode.getNames(right); if (hasNamesRight.profile(vecNames != null)) { putNames.execute(initAttributes.execute(result), vecNames); } @@ -200,7 +199,7 @@ public abstract class CopyAttributesNode extends RBaseNode { return result; } - @Specialization(guards = {"leftLength < rightLength", "containsMetadata(left, attrLeftProfiles) || containsMetadata(right, attrRightProfiles)"}) + @Specialization(guards = {"leftLength < rightLength", "containsMetadata(left) || containsMetadata(right)"}) protected RAbstractVector copyShorter(RAbstractVector target, RAbstractVector left, @SuppressWarnings("unused") int leftLength, RAbstractVector right, @SuppressWarnings("unused") int rightLength, // @Cached("create()") CopyOfRegAttributesNode copyOfReg, // @Cached("createBinaryProfile()") ConditionProfile rightNotResultProfile, // @@ -233,7 +232,7 @@ public abstract class CopyAttributesNode extends RBaseNode { // 1-element matrix should be treated as 1-element vector noDimensions.enter(); if (rightNotResult) { - RStringVector vecNames = right.getNames(attrRightProfiles); + RStringVector vecNames = getNamesNode.getNames(right); if (hasNames.profile(vecNames != null)) { putNames.execute(initAttributes.execute(result), vecNames); } @@ -257,7 +256,7 @@ public abstract class CopyAttributesNode extends RBaseNode { return result; } - @Specialization(guards = {"leftLength > rightLength", "containsMetadata(left, attrLeftProfiles) || containsMetadata(right, attrRightProfiles)"}) + @Specialization(guards = {"leftLength > rightLength", "containsMetadata(left) || containsMetadata(right)"}) protected RAbstractVector copyLonger(RAbstractVector target, RAbstractVector left, @SuppressWarnings("unused") int leftLength, RAbstractVector right, @SuppressWarnings("unused") int rightLength, // @Cached("create()") CopyOfRegAttributesNode copyOfReg, // @Cached("create()") BranchProfile leftHasDimensions, // @@ -285,7 +284,7 @@ public abstract class CopyAttributesNode extends RBaseNode { if (newDimensions == null) { noDimensions.enter(); if (left != result) { - RStringVector vecNames = left.getNames(attrLeftProfiles); + RStringVector vecNames = getNamesNode.getNames(left); if (hasNames.profile(vecNames != null)) { putNames.execute(initAttributes.execute(result), vecNames); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/GetFixedAttributeNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/GetFixedAttributeNode.java index cfea85e1806d90b5dc4bddd2edca27daf0d8b244..3cd9524ce9949607b19f7a3bfe54ff0407f85bf7 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/GetFixedAttributeNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/GetFixedAttributeNode.java @@ -35,7 +35,6 @@ import com.oracle.truffle.api.profiles.ValueProfile; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetClassAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; -import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.data.RAttributable; import com.oracle.truffle.r.runtime.data.RAttributeStorage; diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/SpecialAttributesFunctions.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/SpecialAttributesFunctions.java index 100380c9eead08c57ec12f878ac0b58671148245..c55c482899d8291b684b18de0d960b5918055681 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/SpecialAttributesFunctions.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/SpecialAttributesFunctions.java @@ -35,12 +35,17 @@ import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.data.RAttributable; +import com.oracle.truffle.r.runtime.data.RAttributeProfiles; import com.oracle.truffle.r.runtime.data.RAttributesLayout; import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RIntVector; import com.oracle.truffle.r.runtime.data.RInteger; +import com.oracle.truffle.r.runtime.data.RLanguage; import com.oracle.truffle.r.runtime.data.RList; import com.oracle.truffle.r.runtime.data.RNull; +import com.oracle.truffle.r.runtime.data.RPairList; +import com.oracle.truffle.r.runtime.data.RScalarVector; +import com.oracle.truffle.r.runtime.data.RSequence; import com.oracle.truffle.r.runtime.data.RStringVector; import com.oracle.truffle.r.runtime.data.RVector; import com.oracle.truffle.r.runtime.data.model.RAbstractContainer; @@ -368,12 +373,39 @@ public final class SpecialAttributesFunctions { return SpecialAttributesFunctionsFactory.GetNamesAttributeNodeGen.create(); } - @Override - @Specialization(contains = "getAttrCached") - protected Object getAttrFallback(DynamicObject attrs) { - return super.getAttrFallback(attrs); + public final RStringVector getNames(Object x) { + return (RStringVector) execute(x); } + @Specialization(insertBefore = "getAttrFromAttributable") + protected Object getVectorNames(RVector<?> x, + @Cached("create()") BranchProfile attrNullProfile, + @Cached("createBinaryProfile()") ConditionProfile attrStorageProfile, + @Cached("createClassProfile()") ValueProfile xTypeProfile, + @Cached("create()") BranchProfile namesNullProfile, + @Cached("create()") BranchProfile dimNamesAvlProfile, + @Cached("create()") GetDimNamesAttributeNode getDimNames) { + RStringVector names = (RStringVector) super.getAttrFromAttributable(x, attrNullProfile, attrStorageProfile, xTypeProfile); + if (names == null) { + namesNullProfile.enter(); + RList dimNames = getDimNames.getDimNames(x); + if (dimNames != null && dimNames.getLength() == 1) { + dimNamesAvlProfile.enter(); + return dimNames.getDataAt(0); + } + return null; + } + + return names; + + } + + @Specialization(insertBefore = "getAttrFromAttributable") + protected Object getVectorNames(RAbstractContainer x, + @Cached("createClassProfile()") ValueProfile xTypeProfile, + @Cached("create()") RAttributeProfiles attrProfiles) { + return xTypeProfile.profile(x).getNames(attrProfiles); + } } public abstract static class SetDimAttributeNode extends SetSpecialAttributeNode { @@ -494,6 +526,8 @@ public final class SpecialAttributesFunctions { public abstract static class GetDimAttributeNode extends GetFixedAttributeNode { + private final BranchProfile isLanguageProfile = BranchProfile.create(); + private final BranchProfile isPairListProfile = BranchProfile.create(); private final ConditionProfile nullDimsProfile = ConditionProfile.createBinaryProfile(); private final ConditionProfile nonEmptyDimsProfile = ConditionProfile.createBinaryProfile(); private final ConditionProfile twoDimsOrMoreProfile = ConditionProfile.createBinaryProfile(); @@ -508,10 +542,46 @@ public final class SpecialAttributesFunctions { } public final int[] getDimensions(Object x) { + // Let's handle the following two types directly so as to avoid wrapping and unwrapping + // RIntVector. The getContainerDims spec would be invoked otherwise. + if (x instanceof RLanguage) { + isLanguageProfile.enter(); + return ((RLanguage) x).getDimensions(); + } + if (x instanceof RPairList) { + isPairListProfile.enter(); + return ((RPairList) x).getDimensions(); + } RIntVector dims = (RIntVector) execute(x); return nullDimsProfile.profile(dims == null) ? null : dims.getInternalStore(); } + @Specialization(insertBefore = "getAttrFromAttributable") + protected Object getScalarVectorDims(@SuppressWarnings("unused") RScalarVector x) { + return null; + } + + @Specialization(insertBefore = "getAttrFromAttributable") + protected Object getScalarVectorDims(@SuppressWarnings("unused") RSequence x) { + return null; + } + + @Specialization(insertBefore = "getAttrFromAttributable") + protected Object getVectorDims(RAbstractVector x, + @Cached("create()") BranchProfile attrNullProfile, + @Cached("createBinaryProfile()") ConditionProfile attrStorageProfile, + @Cached("createClassProfile()") ValueProfile xTypeProfile) { + return super.getAttrFromAttributable(x, attrNullProfile, attrStorageProfile, xTypeProfile); + } + + @Specialization(insertBefore = "getAttrFromAttributable") + protected Object getContainerDims(RAbstractContainer x, + @Cached("createClassProfile()") ValueProfile xTypeProfile, + @Cached("createBinaryProfile()") ConditionProfile nullResultProfile) { + int[] res = xTypeProfile.profile(x).getDimensions(); + return nullResultProfile.profile(res == null) ? null : RDataFactory.createIntVector(res, true); + } + public int nrows(Object x) { if (isContainerProfile.profile(x instanceof RAbstractContainer)) { RAbstractContainer xa = (RAbstractContainer) x; @@ -677,10 +747,19 @@ public final class SpecialAttributesFunctions { return (RList) execute(x); } - @Override - @Specialization(contains = "getAttrCached") - protected Object getAttrFallback(DynamicObject attrs) { - return super.getAttrFallback(attrs); + @Specialization(insertBefore = "getAttrFromAttributable") + protected Object getVectorDimNames(RVector<?> x, + @Cached("create()") BranchProfile attrNullProfile, + @Cached("createBinaryProfile()") ConditionProfile attrStorageProfile, + @Cached("createClassProfile()") ValueProfile xTypeProfile) { + return super.getAttrFromAttributable(x, attrNullProfile, attrStorageProfile, xTypeProfile); + } + + @Specialization(insertBefore = "getAttrFromAttributable") + protected Object getVectorDimNames(RAbstractContainer x, + @Cached("createClassProfile()") ValueProfile xTypeProfile, + @Cached("create()") RAttributeProfiles attrProfiles) { + return xTypeProfile.profile(x).getDimNames(attrProfiles); } } @@ -730,10 +809,19 @@ public final class SpecialAttributesFunctions { return SpecialAttributesFunctionsFactory.GetRowNamesAttributeNodeGen.create(); } - @Override - @Specialization(contains = "getAttrCached") - protected Object getAttrFallback(DynamicObject attrs) { - return super.getAttrFallback(attrs); + @Specialization(insertBefore = "getAttrFromAttributable") + protected Object getVectorRowNames(RVector<?> x, + @Cached("create()") BranchProfile attrNullProfile, + @Cached("createBinaryProfile()") ConditionProfile attrStorageProfile, + @Cached("createClassProfile()") ValueProfile xTypeProfile) { + return super.getAttrFromAttributable(x, attrNullProfile, attrStorageProfile, xTypeProfile); + } + + @Specialization(insertBefore = "getAttrFromAttributable") + protected Object getVectorRowNames(RAbstractContainer x, + @Cached("createClassProfile()") ValueProfile xTypeProfile, + @Cached("create()") RAttributeProfiles attrProfiles) { + return xTypeProfile.profile(x).getRowNames(attrProfiles); } } @@ -850,10 +938,19 @@ public final class SpecialAttributesFunctions { return SpecialAttributesFunctionsFactory.GetClassAttributeNodeGen.create(); } - @Override - @Specialization(contains = "getAttrCached") - protected Object getAttrFallback(DynamicObject attrs) { - return super.getAttrFallback(attrs); + @Specialization(insertBefore = "getAttrFromAttributable") + protected Object getVectorClass(RVector<?> x, + @Cached("create()") BranchProfile attrNullProfile, + @Cached("createBinaryProfile()") ConditionProfile attrStorageProfile, + @Cached("createClassProfile()") ValueProfile xTypeProfile) { + return super.getAttrFromAttributable(x, attrNullProfile, attrStorageProfile, xTypeProfile); + } + + @Specialization(insertBefore = "getAttrFromAttributable") + protected Object getVectorClass(RAbstractContainer x, + @Cached("createClassProfile()") ValueProfile xTypeProfile, + @Cached("create()") RAttributeProfiles attrProfiles) { + return xTypeProfile.profile(x).getClassAttr(attrProfiles); } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/UnaryCopyAttributesNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/UnaryCopyAttributesNode.java index 97f977cbd6e31821d9b711483db5a459b603d3d1..bf86e3a314282b7f6136f23d7a4dd8160504fe29 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/UnaryCopyAttributesNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/UnaryCopyAttributesNode.java @@ -28,6 +28,7 @@ import com.oracle.truffle.api.object.DynamicObject; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimNamesAttributeNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.data.RAttributeProfiles; import com.oracle.truffle.r.runtime.data.RDataFactory; @@ -49,10 +50,9 @@ public abstract class UnaryCopyAttributesNode extends RBaseNode { protected final boolean copyAllAttributes; - protected final RAttributeProfiles attrSourceProfiles = RAttributeProfiles.create(); - @Child protected HasFixedAttributeNode hasDimNode = HasFixedAttributeNode.createDim(); @Child protected GetDimNamesAttributeNode getDimNamesNode = GetDimNamesAttributeNode.create(); + @Child protected GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); protected UnaryCopyAttributesNode(boolean copyAllAttributes) { this.copyAllAttributes = copyAllAttributes; @@ -64,13 +64,13 @@ public abstract class UnaryCopyAttributesNode extends RBaseNode { public abstract RAbstractVector execute(RAbstractVector target, RAbstractVector left); - protected boolean containsMetadata(RAbstractVector vector, RAttributeProfiles attrProfiles) { - return vector instanceof RVector && hasDimNode.execute(vector) || (copyAllAttributes && vector.getAttributes() != null) || vector.getNames(attrProfiles) != null || + protected boolean containsMetadata(RAbstractVector vector) { + return vector instanceof RVector && hasDimNode.execute(vector) || (copyAllAttributes && vector.getAttributes() != null) || getNamesNode.getNames(vector) != null || getDimNamesNode.getDimNames(vector) != null; } @SuppressWarnings("unused") - @Specialization(guards = "!containsMetadata(source, attrSourceProfiles)") + @Specialization(guards = "!containsMetadata(source)") protected RAbstractVector copyNoMetadata(RAbstractVector target, RAbstractVector source) { return target; } @@ -81,7 +81,7 @@ public abstract class UnaryCopyAttributesNode extends RBaseNode { return target; } - @Specialization(guards = {"!copyAllAttributes || target != source", "containsMetadata(source, attrSourceProfiles)"}) + @Specialization(guards = {"!copyAllAttributes || target != source", "containsMetadata(source)"}) protected RAbstractVector copySameLength(RAbstractVector target, RAbstractVector source, // @Cached("create()") CopyOfRegAttributesNode copyOfReg, // @Cached("createDim()") RemoveFixedAttributeNode removeDim, // @@ -108,7 +108,7 @@ public abstract class UnaryCopyAttributesNode extends RBaseNode { removeDimNames.execute(attributes); } - RStringVector vecNames = source.getNames(attrSourceProfiles); + RStringVector vecNames = getNamesNode.getNames(source); if (hasNamesSource.profile(vecNames != null)) { putNames.execute(initAttributes.execute(result), vecNames); return result; diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/primitive/UnaryMapNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/primitive/UnaryMapNode.java index 394e4bc550b6df237bd9ae67077f88267b49e160..c92b663f2002689d97a7e26a779d293a7d0ae5bd 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/primitive/UnaryMapNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/primitive/UnaryMapNode.java @@ -32,6 +32,7 @@ import com.oracle.truffle.api.profiles.LoopConditionProfile; import com.oracle.truffle.r.nodes.attributes.HasFixedAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimNamesAttributeNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.SetDimAttributeNode; import com.oracle.truffle.r.nodes.primitive.UnaryMapNodeFactory.MapUnaryVectorInternalNodeGen; import com.oracle.truffle.r.nodes.profile.VectorLengthProfile; @@ -57,6 +58,7 @@ public final class UnaryMapNode extends RBaseNode { @Child private MapUnaryVectorInternalNode vectorNode; @Child private GetDimAttributeNode getDimNode; @Child private SetDimAttributeNode setDimNode; + @Child private GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); // profiles private final Class<? extends RAbstractVector> operandClass; @@ -203,7 +205,7 @@ public final class UnaryMapNode extends RBaseNode { private boolean containsMetadata(RAbstractVector vector) { return vector instanceof RVector && - (hasDimensionsProfile.profile(hasDimNode.execute(vector)) || vector.getAttributes() != null || hasNamesProfile.profile(vector.getNames(attrProfiles) != null) || + (hasDimensionsProfile.profile(hasDimNode.execute(vector)) || vector.getAttributes() != null || hasNamesProfile.profile(getNamesNode.getNames(vector) != null) || getDimNamesNode.getDimNames(vector) != null); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastBaseNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastBaseNode.java index dc9c4d5ab6dda8de8a67359d734d4262bb19c724..c03dda5612698f4ac3bb2a825f42e60144a1621f 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastBaseNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastBaseNode.java @@ -30,6 +30,7 @@ import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimNamesAttributeNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.SetDimNamesAttributeNode; import com.oracle.truffle.r.runtime.NullProfile; import com.oracle.truffle.r.runtime.RError; @@ -50,7 +51,7 @@ public abstract class CastBaseNode extends CastNode { private final ConditionProfile hasDimNamesProfile = ConditionProfile.createBinaryProfile(); private final NullProfile hasDimensionsProfile = NullProfile.create(); private final NullProfile hasNamesProfile = NullProfile.create(); - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); + @Child private GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); @Child private GetDimAttributeNode getDimNode; @Child private SetDimNamesAttributeNode setDimNamesNode; @Child private GetDimNamesAttributeNode getDimNamesNode; @@ -101,7 +102,7 @@ public abstract class CastBaseNode extends CastNode { protected RStringVector getPreservedNames(RAbstractContainer operand) { if (preserveNames()) { - return hasNamesProfile.profile(operand.getNames(attrProfiles)); + return hasNamesProfile.profile(getNamesNode.getNames(operand)); } else { return null; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastExpressionNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastExpressionNode.java index 60f816057c901fbe6863f0c7cc5460d7c54c4cf1..fcb70e3c9b6268cd1fb92272507562614320c54d 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastExpressionNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastExpressionNode.java @@ -22,7 +22,9 @@ */ package com.oracle.truffle.r.nodes.unary; +import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RType; import com.oracle.truffle.r.runtime.data.RAttributeProfiles; @@ -36,8 +38,6 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractContainer; public abstract class CastExpressionNode extends CastBaseNode { - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); - public abstract Object executeExpression(Object o); protected CastExpressionNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { @@ -85,7 +85,8 @@ public abstract class CastExpressionNode extends CastBaseNode { } @Specialization - protected RExpression doAbstractContainer(RAbstractContainer obj) { + protected RExpression doAbstractContainer(RAbstractContainer obj, + @Cached("create()") GetNamesAttributeNode getNamesNode) { int len = obj.getLength(); Object[] data = new Object[len]; for (int i = 0; i < len; i++) { @@ -94,7 +95,7 @@ public abstract class CastExpressionNode extends CastBaseNode { if (obj instanceof RList) { RList list = (RList) obj; // TODO other attributes - return RDataFactory.createExpression(data, list.getNames(attrProfiles)); + return RDataFactory.createExpression(data, getNamesNode.getNames(list)); } else { return RDataFactory.createExpression(data); } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RVector.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RVector.java index feea7fec65ef5e2625574e2ae14eb323226565a2..4b1a2f8fb2c9fecacb9776255387c17af282f4ca 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RVector.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RVector.java @@ -105,7 +105,7 @@ public abstract class RVector<ArrayT> extends RSharingAttributeStorage implement } } - public final RStringVector getNamesFromAttrs() { + protected final RStringVector getNamesFromAttrs() { if (attributes == null) { return null; } else { diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test index 82a4c02981fb51b1b459c1a4dd58a8341dd6d387..d4ff74b7edd2ff56450aa5e776f77dbbc7b1f116 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test @@ -17948,6 +17948,10 @@ NULL [,1] [1,] NA +##com.oracle.truffle.r.test.builtins.TestBuiltin_dimassign.testdimassign12# +#b <- c(a=1+2i,b=3+4i);dim(b) <- c(2,1);attributes(x) +Error: object 'x' not found + ##com.oracle.truffle.r.test.builtins.TestBuiltin_dimassign.testdimassign2# #argv <- list(structure(logical(0), .Dim = c(0L, 0L)), value = c(0L, 0L));`dim<-`(argv[[1]],argv[[2]]); <0 x 0 matrix>