diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Identical.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Identical.java index 9c86d76106b540ff298ff0570f5df7846c137e6b..5d38e92408ae8f6ed08e183e86067d3b025d5587 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Identical.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Identical.java @@ -73,11 +73,6 @@ public abstract class Identical extends RBuiltinNode { @Child private Identical identicalRecursive; @Child private Identical identicalRecursiveAttr; - private final boolean recursive; - - protected Identical(boolean recursive) { - this.recursive = recursive; - } @Override protected void createCasts(CastBuilder casts) { @@ -86,10 +81,13 @@ public abstract class Identical extends RBuiltinNode { private final ConditionProfile vecLengthProfile = ConditionProfile.createBinaryProfile(); + // Note: the execution of the recursive cases is not done directly and not through RCallNode or + // similar, this means that the visibility handling is left to us. + private byte identicalRecursive(Object x, Object y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { if (identicalRecursive == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); - identicalRecursive = insert(IdenticalNodeGen.create(true, null)); + identicalRecursive = insert(IdenticalNodeGen.create(null)); } return identicalRecursive.executeByte(x, y, numEq, singleNA, attribAsSet, ignoreBytecode, ignoreEnvironment); } @@ -97,7 +95,7 @@ public abstract class Identical extends RBuiltinNode { private byte identicalRecursiveAttr(Object x, Object y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { if (identicalRecursiveAttr == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); - identicalRecursiveAttr = insert(IdenticalNodeGen.create(true, null)); + identicalRecursiveAttr = insert(IdenticalNodeGen.create(null)); } return identicalRecursiveAttr.executeByte(x, y, numEq, singleNA, attribAsSet, ignoreBytecode, ignoreEnvironment); } @@ -105,35 +103,30 @@ public abstract class Identical extends RBuiltinNode { @SuppressWarnings("unused") @Specialization(guards = "isRNull(x) || isRNull(y)") protected byte doInternalIdenticalNull(Object x, Object y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); return x == y ? RRuntime.LOGICAL_TRUE : RRuntime.LOGICAL_FALSE; } @SuppressWarnings("unused") @Specialization(guards = "isRMissing(x) || isRMissing(y)") protected byte doInternalIdenticalMissing(Object x, Object y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); return x == y ? RRuntime.LOGICAL_TRUE : RRuntime.LOGICAL_FALSE; } @SuppressWarnings("unused") @Specialization protected byte doInternalIdentical(byte x, byte y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); return x == y ? RRuntime.LOGICAL_TRUE : RRuntime.LOGICAL_FALSE; } @SuppressWarnings("unused") @Specialization protected byte doInternalIdentical(String x, String y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); return x.equals(y) ? RRuntime.LOGICAL_TRUE : RRuntime.LOGICAL_FALSE; } @SuppressWarnings("unused") @Specialization protected byte doInternalIdentical(double x, double y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); boolean truth = numEq ? x == y : Double.doubleToRawLongBits(x) == Double.doubleToRawLongBits(y); return truth ? RRuntime.LOGICAL_TRUE : RRuntime.LOGICAL_FALSE; } @@ -167,21 +160,18 @@ public abstract class Identical extends RBuiltinNode { @SuppressWarnings("unused") @Specialization protected byte doInternalIdentical(RAbstractLogicalVector x, REnvironment y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); return RRuntime.LOGICAL_FALSE; } @SuppressWarnings("unused") @Specialization protected byte doInternalIdentical(REnvironment x, RAbstractLogicalVector y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); return RRuntime.LOGICAL_FALSE; } @SuppressWarnings("unused") @Specialization protected byte doInternalIdentical(REnvironment x, REnvironment y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); // reference equality for environments return x == y ? RRuntime.LOGICAL_TRUE : RRuntime.LOGICAL_FALSE; } @@ -189,7 +179,6 @@ public abstract class Identical extends RBuiltinNode { @SuppressWarnings("unused") @Specialization protected byte doInternalIdentical(RSymbol x, RSymbol y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); assert x.getName() == x.getName().intern() && y.getName() == y.getName().intern(); return x.getName() == y.getName() ? RRuntime.LOGICAL_TRUE : RRuntime.LOGICAL_FALSE; } @@ -197,7 +186,6 @@ public abstract class Identical extends RBuiltinNode { @Specialization @TruffleBoundary protected byte doInternalIdentical(RLanguage x, RLanguage y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); if (x == y) { return RRuntime.LOGICAL_TRUE; } @@ -212,13 +200,11 @@ public abstract class Identical extends RBuiltinNode { @SuppressWarnings("unused") @Specialization byte doInternalIdentical(RFunction x, RFunction y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); return RRuntime.asLogical(x == y); } @Specialization(guards = "!vectorsLists(x, y)") protected byte doInternalIdenticalGeneric(RAbstractVector x, RAbstractVector y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); if (vecLengthProfile.profile(x.getLength() != y.getLength())) { return RRuntime.LOGICAL_FALSE; } else { @@ -233,7 +219,6 @@ public abstract class Identical extends RBuiltinNode { @Specialization protected byte doInternalIdenticalGeneric(RList x, RList y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); if (x.getLength() != y.getLength()) { return RRuntime.LOGICAL_FALSE; } @@ -249,27 +234,23 @@ public abstract class Identical extends RBuiltinNode { @SuppressWarnings("unused") @Specialization protected byte doInternalIdenticalGeneric(RFunction x, RAbstractContainer y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); return RRuntime.LOGICAL_FALSE; } @SuppressWarnings("unused") @Specialization protected byte doInternalIdenticalGeneric(RLanguage x, RAbstractContainer y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); return RRuntime.LOGICAL_FALSE; } @SuppressWarnings("unused") @Specialization protected byte doInternalIdenticalGeneric(RAbstractContainer x, RFunction y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); return RRuntime.LOGICAL_FALSE; } @Specialization protected byte doInternalIdenticalGeneric(RS4Object x, RS4Object y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); if (x.isS4() != y.isS4()) { return RRuntime.LOGICAL_FALSE; } @@ -279,13 +260,11 @@ public abstract class Identical extends RBuiltinNode { @SuppressWarnings("unused") @Specialization protected byte doInternalIdenticalGeneric(RExternalPtr x, RExternalPtr y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); return RRuntime.asLogical(x.getAddr() == y.getAddr()); } @Specialization protected byte doInternalIdenticalGeneric(RPairList x, RPairList y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); if (identicalRecursive(x.car(), y.car(), numEq, singleNA, attribAsSet, ignoreBytecode, ignoreEnvironment) == RRuntime.LOGICAL_FALSE) { return RRuntime.LOGICAL_FALSE; } @@ -337,14 +316,12 @@ public abstract class Identical extends RBuiltinNode { @Specialization protected byte doInternalIdenticalGeneric(RExpression x, RExpression y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); return doInternalIdenticalGeneric(x.getList(), y.getList(), numEq, singleNA, attribAsSet, ignoreBytecode, ignoreEnvironment); } @SuppressWarnings("unused") @Fallback protected byte doInternalIdenticalWrongTypes(Object x, Object y, boolean numEq, boolean singleNA, boolean attribAsSet, boolean ignoreBytecode, boolean ignoreEnvironment) { - updateVisibility(); if (x.getClass() != y.getClass()) { return RRuntime.LOGICAL_FALSE; } else { @@ -352,15 +329,6 @@ public abstract class Identical extends RBuiltinNode { } } - /** - * Common visibility related code that should be invoked in each specialization. - */ - private void updateVisibility() { - // this is the original code, - // TODO: what difference did it make, why is GnuR 'identical' visibility set to 'force ON' - // if (!recursive) setVisibility() - } - protected boolean vectorsLists(RAbstractVector x, RAbstractVector y) { return x instanceof RList && y instanceof RList; } @@ -370,6 +338,6 @@ public abstract class Identical extends RBuiltinNode { } public static Identical create(RNode[] arguments) { - return IdenticalNodeGen.create(false, arguments); + return IdenticalNodeGen.create(arguments); } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Unique.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Unique.java index 1ea305971293b87305783ad01e109e4cfa856eba..b9e5d25da2b563303c223af4384306e08084c3e9 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Unique.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Unique.java @@ -280,7 +280,7 @@ public abstract class Unique extends RBuiltinNode { private boolean identical(Object x, Object y) { if (identical == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); - identical = insert(IdenticalNodeGen.create(true, null)); + identical = insert(IdenticalNodeGen.create(null)); } return RRuntime.fromLogical(identical.executeByte(x, y, true, true, true, true, false)); }