From 3853a07625d2012409a898d610822c82d5e58d2b Mon Sep 17 00:00:00 2001 From: Lukas Stadler <lukas.stadler@oracle.com> Date: Mon, 12 Jun 2017 11:27:16 +0200 Subject: [PATCH] use RBaseNode.error in more places --- .../truffle/r/nodes/access/AccessSlotNode.java | 10 +++++----- .../access/vector/CachedReplaceVectorNode.java | 4 ++-- .../r/nodes/access/vector/ExtractVectorNode.java | 11 ++++++----- .../r/nodes/access/vector/PositionCastNode.java | 12 ++++++------ .../vector/PositionCharacterLookupNode.java | 10 +++++----- .../r/nodes/access/vector/PositionCheckNode.java | 14 +++++++------- .../vector/PositionCheckSubscriptNode.java | 16 ++++++++-------- .../access/vector/PositionCheckSubsetNode.java | 6 +++--- .../nodes/access/vector/PositionsCheckNode.java | 15 ++++++--------- .../vector/RecursiveExtractSubscriptNode.java | 11 +++-------- .../access/vector/RecursiveSubscriptNode.java | 13 ++++--------- .../r/nodes/access/vector/ReplaceVectorNode.java | 9 +++++---- 12 files changed, 60 insertions(+), 71 deletions(-) diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessSlotNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessSlotNode.java index 61f7c1074d..c0f82b72ba 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessSlotNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessSlotNode.java @@ -85,9 +85,9 @@ public abstract class AccessSlotNode extends RBaseNode { CompilerDirectives.transferToInterpreter(); RStringVector classAttr = getClassNode.getClassAttr(object); if (classAttr == null) { - throw RError.error(this, RError.Message.SLOT_CANNOT_GET, name, TypeofNode.getTypeof(object).getName()); + throw error(RError.Message.SLOT_CANNOT_GET, name, TypeofNode.getTypeof(object).getName()); } else { - throw RError.error(this, RError.Message.SLOT_NONE, name, classAttr.getLength() == 0 ? RRuntime.STRING_NA : classAttr.getDataAt(0)); + throw error(RError.Message.SLOT_NONE, name, classAttr.getLength() == 0 ? RRuntime.STRING_NA : classAttr.getDataAt(0)); } } if (value instanceof RSymbol) { @@ -101,7 +101,7 @@ public abstract class AccessSlotNode extends RBaseNode { @Specialization protected Object getSlotS4(@SuppressWarnings("unused") RNull object, String name) { - throw RError.error(this, RError.Message.SLOT_BASIC_CLASS, name, "NULL"); + throw error(RError.Message.SLOT_BASIC_CLASS, name, "NULL"); } @Specialization(guards = {"slotAccessAllowed(object)"}) @@ -138,10 +138,10 @@ public abstract class AccessSlotNode extends RBaseNode { if (classAttr == null) { RStringVector implicitClassVec = ImplicitClassHierarchyNode.getImplicitClass(object, false); assert implicitClassVec.getLength() > 0; - throw RError.error(this, RError.Message.SLOT_BASIC_CLASS, name, implicitClassVec.getDataAt(0)); + throw error(RError.Message.SLOT_BASIC_CLASS, name, implicitClassVec.getDataAt(0)); } else { assert classAttr.getLength() > 0; - throw RError.error(this, RError.Message.SLOT_NON_S4, name, classAttr.getDataAt(0)); + throw error(RError.Message.SLOT_NON_S4, name, classAttr.getDataAt(0)); } } 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 d6c7237c94..61c1891486 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 @@ -330,7 +330,7 @@ final class CachedReplaceVectorNode extends CachedVectorNode { } } error = () -> { - throw RError.error(this, message, valueType.getName(), vectorType.getName(), false); + throw error(message, valueType.getName(), vectorType.getName(), false); }; } } @@ -471,7 +471,7 @@ final class CachedReplaceVectorNode extends CachedVectorNode { } env.put(positionString, value); } catch (PutException ex) { - throw RError.error(this, ex); + throw error(ex); } return env; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ExtractVectorNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ExtractVectorNode.java index f0cccef445..ed622c1d7e 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ExtractVectorNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ExtractVectorNode.java @@ -52,9 +52,10 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector; import com.oracle.truffle.r.runtime.data.model.RAbstractListVector; import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; import com.oracle.truffle.r.runtime.data.model.RAbstractVector; +import com.oracle.truffle.r.runtime.nodes.RBaseNode; @ImportStatic({RRuntime.class, com.oracle.truffle.api.interop.Message.class}) -public abstract class ExtractVectorNode extends Node { +public abstract class ExtractVectorNode extends RBaseNode { protected static final int CACHE_LIMIT = 5; @@ -114,7 +115,7 @@ public abstract class ExtractVectorNode extends Node { @Cached("IS_BOXED.createNode()") Node isBoxedNode, @Cached("UNBOX.createNode()") Node unboxNode) { if (positions.length == 0) { - throw RError.error(this, RError.Message.GENERIC, "No positions for foreign access."); + throw error(RError.Message.GENERIC, "No positions for foreign access."); } positions = positionProfile.profile(positions); try { @@ -148,7 +149,7 @@ public abstract class ExtractVectorNode extends Node { return RRuntime.java2R(obj); } - public static Object read(Node caller, Object position, Node foreignRead, Node keyInfoNode, TruffleObject object, FirstStringNode firstString, CastStringNode castNode) + public static Object read(RBaseNode caller, Object position, Node foreignRead, Node keyInfoNode, TruffleObject object, FirstStringNode firstString, CastStringNode castNode) throws RError, InteropException { if (position instanceof Integer) { position = ((int) position) - 1; @@ -161,7 +162,7 @@ public abstract class ExtractVectorNode extends Node { } else if (position instanceof RAbstractStringVector) { position = firstString.executeString(castNode.doCast(position)); } else if (!(position instanceof String)) { - throw RError.error(caller, RError.Message.GENERIC, "invalid index during foreign access"); + throw caller.error(RError.Message.GENERIC, "invalid index during foreign access"); } int info = ForeignAccess.sendKeyInfo(keyInfoNode, object, position); @@ -174,7 +175,7 @@ public abstract class ExtractVectorNode extends Node { return ForeignAccess.sendRead(foreignRead, clazz, position); } } - throw RError.error(caller, RError.Message.GENERIC, "invalid index/identifier during foreign access: " + position); + throw caller.error(RError.Message.GENERIC, "invalid index/identifier during foreign access: " + position); } @Specialization(guards = {"cached != null", "cached.isSupported(vector, positions)"}) diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCastNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCastNode.java index 80e0e05b7b..32f9f06404 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCastNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCastNode.java @@ -24,7 +24,6 @@ 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.nodes.Node; import com.oracle.truffle.r.nodes.binary.BoxPrimitiveNode; import com.oracle.truffle.r.nodes.unary.CastIntegerNode; import com.oracle.truffle.r.nodes.unary.CastIntegerNodeGen; @@ -50,9 +49,10 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractRawVector; import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; import com.oracle.truffle.r.runtime.data.model.RAbstractVector; import com.oracle.truffle.r.runtime.env.REnvironment; +import com.oracle.truffle.r.runtime.nodes.RBaseNode; import com.oracle.truffle.r.runtime.ops.na.NACheck; -abstract class PositionCastNode extends Node { +abstract class PositionCastNode extends RBaseNode { private final ElementAccessMode mode; private final boolean replace; @@ -137,7 +137,7 @@ abstract class PositionCastNode extends Node { if (position.getName().length() == 0) { return doMissing(RMissing.instance); } else { - throw RError.error(this, RError.Message.INVALID_SUBSCRIPT_TYPE, "symbol"); + throw error(RError.Message.INVALID_SUBSCRIPT_TYPE, "symbol"); } } @@ -145,9 +145,9 @@ abstract class PositionCastNode extends Node { protected RMissing doMissing(@SuppressWarnings("unused") RMissing position) { if (mode.isSubscript()) { if (replace) { - throw RError.error(this, RError.Message.MISSING_SUBSCRIPT); + throw error(RError.Message.MISSING_SUBSCRIPT); } else { - throw RError.error(this, RError.Message.INVALID_SUBSCRIPT_TYPE, "symbol"); + throw error(RError.Message.INVALID_SUBSCRIPT_TYPE, "symbol"); } } else { return RMissing.instance; @@ -167,7 +167,7 @@ abstract class PositionCastNode extends Node { @Specialization(guards = "getInvalidType(position) != null") protected RAbstractVector doInvalidType(Object position) { - throw RError.error(this, RError.Message.INVALID_SUBSCRIPT_TYPE, getInvalidType(position).getName()); + throw error(RError.Message.INVALID_SUBSCRIPT_TYPE, getInvalidType(position).getName()); } protected static RType getInvalidType(Object positionValue) { 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 d1566a34ef..44ec6ed951 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,7 +22,6 @@ */ package com.oracle.truffle.r.nodes.access.vector; -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; @@ -35,8 +34,9 @@ import com.oracle.truffle.r.runtime.data.RStringVector; import com.oracle.truffle.r.runtime.data.model.RAbstractContainer; import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector; import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; +import com.oracle.truffle.r.runtime.nodes.RBaseNode; -final class PositionCharacterLookupNode extends Node { +final class PositionCharacterLookupNode extends RBaseNode { private final ElementAccessMode mode; private final int numDimensions; @@ -73,7 +73,7 @@ final class PositionCharacterLookupNode extends Node { result = searchNode.apply(dimName, position, notFoundStartIndex, null); } else { emptyProfile.enter(); - throw RError.error(this, Message.SUBSCRIPT_BOUNDS); + throw error(Message.SUBSCRIPT_BOUNDS); } } else { emptyProfile.enter(); @@ -85,9 +85,9 @@ final class PositionCharacterLookupNode extends Node { private RError noDimNames() { if (mode.isSubset()) { - throw RError.error(this, Message.NO_ARRAY_DIMNAMES); + throw error(Message.NO_ARRAY_DIMNAMES); } else { - throw RError.error(this, Message.SUBSCRIPT_BOUNDS); + throw error(Message.SUBSCRIPT_BOUNDS); } } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCheckNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCheckNode.java index dfe5493cb8..bcd27aa7d7 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCheckNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCheckNode.java @@ -24,7 +24,6 @@ package com.oracle.truffle.r.nodes.access.vector; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.api.profiles.ValueProfile; @@ -45,8 +44,9 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractDoubleVector; import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector; import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; import com.oracle.truffle.r.runtime.data.model.RAbstractVector; +import com.oracle.truffle.r.runtime.nodes.RBaseNode; -abstract class PositionCheckNode extends Node { +abstract class PositionCheckNode extends RBaseNode { private final Class<?> positionClass; private final int dimensionIndex; @@ -199,7 +199,7 @@ abstract class PositionCheckNode extends Node { * * A zero/NA anywhere in a row will cause a zero/NA in the same position in the result. */ - public abstract static class Mat2indsubNode extends Node { + public abstract static class Mat2indsubNode extends RBaseNode { public abstract RAbstractVector execute(int[] vectorDimensions, RAbstractVector pos, int[] positionDimensions); @@ -228,12 +228,12 @@ abstract class PositionCheckNode extends Node { } if (k < 0) { error.enter(); - throw RError.error(this, RError.Message.GENERIC, "negative values are not allowed in a matrix subscript"); + throw error(RError.Message.GENERIC, "negative values are not allowed in a matrix subscript"); } int dim = vectorDimensions[j]; if (k > dim) { error.enter(); - throw RError.error(this, RError.Message.SUBSCRIPT_BOUNDS); + throw error(RError.Message.SUBSCRIPT_BOUNDS); } iv[i] += (k - 1) * tdim; tdim *= dim; @@ -263,12 +263,12 @@ abstract class PositionCheckNode extends Node { } if (k < 0) { error.enter(); - throw RError.error(this, RError.Message.GENERIC, "negative values are not allowed in a matrix subscript"); + throw error(RError.Message.GENERIC, "negative values are not allowed in a matrix subscript"); } int dim = vectorDimensions[j]; if (k > dim) { error.enter(); - throw RError.error(this, RError.Message.SUBSCRIPT_BOUNDS); + throw error(RError.Message.SUBSCRIPT_BOUNDS); } iv[i] += (k - 1) * tdim; tdim *= dim; 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 2514a0825a..d11144c8c2 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 @@ -66,12 +66,12 @@ abstract class PositionCheckSubscriptNode extends PositionCheckNode { if (positionLength != 1) { error.enter(); if (positionLength >= 3) { - throw RError.error(this, RError.Message.SELECT_MORE_1); + throw error(RError.Message.SELECT_MORE_1); } else { if (value == RRuntime.LOGICAL_TRUE) { - throw RError.error(this, RError.Message.SELECT_MORE_1); + throw error(RError.Message.SELECT_MORE_1); } else { - throw RError.error(this, RError.Message.SELECT_LESS_1); + throw error(RError.Message.SELECT_LESS_1); } } } @@ -95,7 +95,7 @@ abstract class PositionCheckSubscriptNode extends PositionCheckNode { } else { message = RError.Message.SELECT_LESS_1; } - throw RError.error(this, message); + throw error(message); } assert positionLength == 1; positionNACheck.enable(position); @@ -153,9 +153,9 @@ abstract class PositionCheckSubscriptNode extends PositionCheckNode { } } if (selected <= 1) { - throw RError.error(this, RError.Message.SELECT_LESS_1); + throw error(RError.Message.SELECT_LESS_1); } else { - throw RError.error(this, RError.Message.SELECT_MORE_1); + throw error(RError.Message.SELECT_MORE_1); } } } @@ -173,7 +173,7 @@ abstract class PositionCheckSubscriptNode extends PositionCheckNode { message = RError.Message.SELECT_MORE_1; } } - throw RError.error(this, message); + throw error(message); } else { if (numDimensions == 1 && isListLike(containerType) && !recursive) { // lists pass on the NA value @@ -188,7 +188,7 @@ abstract class PositionCheckSubscriptNode extends PositionCheckNode { if (recursive) { throw new RecursiveIndexNotFoundError(); } else { - throw RError.error(this, RError.Message.SUBSCRIPT_BOUNDS); + throw error(RError.Message.SUBSCRIPT_BOUNDS); } } } 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 f45d9018a6..2549c6cfcd 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 @@ -108,7 +108,7 @@ abstract class PositionCheckSubsetNode extends PositionCheckNode { outOfBoundsProfile.enter(); if (isMultiDimension()) { error.enter(); - throw RError.error(this, RError.Message.LOGICAL_SUBSCRIPT_LONG); + throw error(RError.Message.LOGICAL_SUBSCRIPT_LONG); } length = positionLength; } @@ -265,11 +265,11 @@ abstract class PositionCheckSubsetNode extends PositionCheckNode { if (hasSeenPositive || hasSeenNA) { if (numDimensions > 1 && outOfBoundsCount > 0) { error.enter(); - throw RError.error(this, RError.Message.SUBSCRIPT_BOUNDS); + throw error(RError.Message.SUBSCRIPT_BOUNDS); } if (hasSeenNegative) { error.enter(); - throw RError.error(this, RError.Message.ONLY_0_MIXED); + throw error(RError.Message.ONLY_0_MIXED); } profile.maxOutOfBoundsIndex = maxOutOfBoundsIndex; profile.selectedPositionsCount = positionLength - zeroCount; diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionsCheckNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionsCheckNode.java index 34d28947e3..6258cd007b 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionsCheckNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionsCheckNode.java @@ -25,7 +25,6 @@ package com.oracle.truffle.r.nodes.access.vector; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.nodes.ExplodeLoop; -import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.r.nodes.profile.VectorLengthProfile; @@ -35,13 +34,13 @@ import com.oracle.truffle.r.runtime.data.REmpty; import com.oracle.truffle.r.runtime.data.RMissing; import com.oracle.truffle.r.runtime.data.RSymbol; import com.oracle.truffle.r.runtime.data.model.RAbstractContainer; +import com.oracle.truffle.r.runtime.nodes.RBaseNode; -final class PositionsCheckNode extends Node { +final class PositionsCheckNode extends RBaseNode { @Children private final PositionCheckNode[] positionsCheck; private final ElementAccessMode mode; - private final BranchProfile errorBranch = BranchProfile.create(); private final VectorLengthProfile selectedPositionsCountProfile = VectorLengthProfile.create(); private final VectorLengthProfile maxOutOfBoundsProfile = VectorLengthProfile.create(); private final ConditionProfile containsNAProfile = ConditionProfile.createBinaryProfile(); @@ -113,12 +112,10 @@ final class PositionsCheckNode extends Node { private void verifyDimensions(int[] vectorDimensions) { if (vectorDimensions == null) { if (isMultiDimension()) { - errorBranch.enter(); throw dimensionsError(); } } else { if (getDimensions() > vectorDimensions.length || getDimensions() < vectorDimensions.length) { - errorBranch.enter(); throw dimensionsError(); } } @@ -129,15 +126,15 @@ final class PositionsCheckNode extends Node { if (replace) { if (mode.isSubset()) { if (getDimensions() == 2) { - throw RError.error(this, RError.Message.INCORRECT_SUBSCRIPTS_MATRIX); + throw error(RError.Message.INCORRECT_SUBSCRIPTS_MATRIX); } else { - throw RError.error(this, RError.Message.INCORRECT_SUBSCRIPTS); + throw error(RError.Message.INCORRECT_SUBSCRIPTS); } } else { - throw RError.error(this, RError.Message.IMPROPER_SUBSCRIPT); + throw error(RError.Message.IMPROPER_SUBSCRIPT); } } else { - throw RError.error(this, RError.Message.INCORRECT_DIMENSIONS); + throw error(RError.Message.INCORRECT_DIMENSIONS); } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveExtractSubscriptNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveExtractSubscriptNode.java index 621139cc8a..984805f079 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveExtractSubscriptNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveExtractSubscriptNode.java @@ -59,8 +59,7 @@ abstract class RecursiveExtractSubscriptNode extends RecursiveSubscriptNode { try { return subscriptExtract.apply(frame, vector, positions, exact, dropDimensions); } catch (RecursiveIndexNotFoundError e) { - errorBranch.enter(); - throw RError.error(this, RError.Message.SUBSCRIPT_BOUNDS); + throw error(RError.Message.SUBSCRIPT_BOUNDS); } } @@ -74,17 +73,14 @@ abstract class RecursiveExtractSubscriptNode extends RecursiveSubscriptNode { Object selection = getPositionExtract.apply(frame, firstPosition, new Object[]{RInteger.valueOf(i)}, RLogical.TRUE, RLogical.TRUE); try { if (!(currentVector instanceof RAbstractListVector)) { - errorBranch.enter(); throw indexingFailed(i); } currentVector = recursiveSubscriptExtract.apply(frame, currentVector, new Object[]{selection}, exact, dropDimensions); if (currentVector == RNull.instance) { - errorBranch.enter(); - throw RError.error(this, RError.Message.SUBSCRIPT_BOUNDS); + throw error(RError.Message.SUBSCRIPT_BOUNDS); } } catch (RecursiveIndexNotFoundError e) { - errorBranch.enter(); throw noSuchIndex(i); } } @@ -92,8 +88,7 @@ abstract class RecursiveExtractSubscriptNode extends RecursiveSubscriptNode { try { return subscriptExtract.apply(frame, currentVector, new Object[]{selection}, exact, dropDimensions); } catch (RecursiveIndexNotFoundError e) { - errorBranch.enter(); - throw RError.error(this, RError.Message.SUBSCRIPT_BOUNDS); + throw error(RError.Message.SUBSCRIPT_BOUNDS); } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveSubscriptNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveSubscriptNode.java index 0e4e9b5030..72a24f39e2 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveSubscriptNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/RecursiveSubscriptNode.java @@ -22,19 +22,16 @@ */ package com.oracle.truffle.r.nodes.access.vector; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.r.nodes.control.RLengthNode; import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.data.model.RAbstractListVector; +import com.oracle.truffle.r.runtime.nodes.RBaseNode; -abstract class RecursiveSubscriptNode extends Node { +abstract class RecursiveSubscriptNode extends RBaseNode { protected final Class<?> vectorClass; protected final Class<?> positionClass; - protected final BranchProfile errorBranch = BranchProfile.create(); - @Child protected RLengthNode positionLengthNode = RLengthNode.create(); RecursiveSubscriptNode(RAbstractListVector vector, Object position) { @@ -50,12 +47,10 @@ abstract class RecursiveSubscriptNode extends Node { } protected final RError indexingFailed(int i) { - errorBranch.enter(); - throw RError.error(this, RError.Message.RECURSIVE_INDEXING_FAILED, i); + throw error(RError.Message.RECURSIVE_INDEXING_FAILED, i); } protected final RError noSuchIndex(int i) { - errorBranch.enter(); - throw RError.error(this, RError.Message.NO_SUCH_INDEX, i); + throw error(RError.Message.NO_SUCH_INDEX, i); } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ReplaceVectorNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ReplaceVectorNode.java index 77ce1d830a..f7af44de9b 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ReplaceVectorNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ReplaceVectorNode.java @@ -46,12 +46,13 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractDoubleVector; import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector; import com.oracle.truffle.r.runtime.data.model.RAbstractListVector; import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; +import com.oracle.truffle.r.runtime.nodes.RBaseNode; /** * Syntax node for element writes. */ @ImportStatic({RRuntime.class, com.oracle.truffle.api.interop.Message.class}) -public abstract class ReplaceVectorNode extends Node { +public abstract class ReplaceVectorNode extends RBaseNode { protected static final int CACHE_LIMIT = 5; @@ -84,7 +85,7 @@ public abstract class ReplaceVectorNode extends Node { protected Node createForeignWrite(Object[] positions) { if (positions.length != 1) { - throw RError.error(this, RError.Message.GENERIC, "Invalid number positions for foreign access."); + throw error(RError.Message.GENERIC, "Invalid number positions for foreign access."); } return Message.WRITE.createNode(); } @@ -132,7 +133,7 @@ public abstract class ReplaceVectorNode extends Node { String string = firstString.executeString(castNode.doCast(position)); position = string; } else if (!(position instanceof String)) { - throw RError.error(this, RError.Message.GENERIC, "invalid index during foreign access"); + throw error(RError.Message.GENERIC, "invalid index during foreign access"); } int info = ForeignAccess.sendKeyInfo(keyInfoNode, object, position); @@ -147,7 +148,7 @@ public abstract class ReplaceVectorNode extends Node { return; } } - throw RError.error(this, RError.Message.GENERIC, "invalid index/identifier during foreign access: " + position); + throw error(RError.Message.GENERIC, "invalid index/identifier during foreign access: " + position); } @Specialization(limit = "CACHE_LIMIT", guards = {"cached != null", "cached.isSupported(vector, positions)"}) -- GitLab