Skip to content
Snippets Groups Projects
Commit e256ece0 authored by Lukas Stadler's avatar Lukas Stadler
Browse files

remove unnecessary usages of NodeFields and NodeChildren

parent cceb99dd
No related branches found
No related tags found
No related merge requests found
Showing
with 57 additions and 48 deletions
......@@ -28,9 +28,8 @@ import static com.oracle.truffle.r.runtime.nmath.RMath.fmax2;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.r.nodes.builtin.RBuiltinNode;
import com.oracle.truffle.r.nodes.builtin.base.BaseGammaFunctionsFactory.DpsiFnCalcNodeGen;
import com.oracle.truffle.r.runtime.RError;
......@@ -44,7 +43,6 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector;
import com.oracle.truffle.r.runtime.data.model.RAbstractLogicalVector;
import com.oracle.truffle.r.runtime.nmath.GammaFunctions;
import com.oracle.truffle.r.runtime.nmath.RMath;
import com.oracle.truffle.r.runtime.nodes.RNode;
import com.oracle.truffle.r.runtime.ops.na.NACheck;
public class BaseGammaFunctions {
......@@ -110,7 +108,7 @@ public class BaseGammaFunctions {
private double dpsiFnCalc(double x, int n, int kode, double ans) {
if (dpsiFnCalc == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
dpsiFnCalc = insert(DpsiFnCalcNodeGen.create(null, null, null, null));
dpsiFnCalc = insert(DpsiFnCalcNodeGen.create());
}
return dpsiFnCalc.executeDouble(x, n, kode, ans);
}
......@@ -156,8 +154,7 @@ public class BaseGammaFunctions {
}
}
@NodeChildren({@NodeChild(value = "x"), @NodeChild(value = "n"), @NodeChild(value = "kode"), @NodeChild(value = "ans")})
protected abstract static class DpsiFnCalc extends RNode {
protected abstract static class DpsiFnCalc extends Node {
// the following is transcribed from polygamma.c
......@@ -179,7 +176,7 @@ public class BaseGammaFunctions {
private double dpsiFnCalc(double x, int n, int kode, double ans) {
if (dpsiFnCalc == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
dpsiFnCalc = insert(DpsiFnCalcNodeGen.create(null, null, null, null));
dpsiFnCalc = insert(DpsiFnCalcNodeGen.create());
}
return dpsiFnCalc.executeDouble(x, n, kode, ans);
}
......
......@@ -25,7 +25,6 @@ package com.oracle.truffle.r.nodes.builtin.base.infix;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.dsl.TypeSystemReference;
import com.oracle.truffle.api.frame.VirtualFrame;
......@@ -172,7 +171,7 @@ class SpecialsUtils {
}
@NodeInfo(cost = NodeCost.NONE)
@NodeChildren({@NodeChild(value = "delegate", type = RNode.class)})
@NodeChild(value = "delegate", type = RNode.class)
@TypeSystemReference(EmptyTypeSystemFlatLayout.class)
public abstract static class ConvertIndex extends RNode {
......
......@@ -31,7 +31,6 @@ 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.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.dsl.TypeSystemReference;
import com.oracle.truffle.api.frame.VirtualFrame;
......@@ -66,7 +65,8 @@ import com.oracle.truffle.r.runtime.nodes.RNode;
/**
* Subscript code for vectors minus list is the same as subset code, this class allows sharing it.
*/
@NodeChildren({@NodeChild(value = "vector", type = ProfiledValue.class), @NodeChild(value = "index", type = ConvertIndex.class)})
@NodeChild(value = "vector", type = ProfiledValue.class)
@NodeChild(value = "index", type = ConvertIndex.class)
abstract class SubscriptSpecialBase extends SubscriptSpecialCommon {
protected SubscriptSpecialBase(boolean inReplacement) {
......@@ -104,7 +104,9 @@ abstract class SubscriptSpecialBase extends SubscriptSpecialCommon {
/**
* Subscript code for matrices minus list is the same as subset code, this class allows sharing it.
*/
@NodeChildren({@NodeChild(value = "vector", type = ProfiledValue.class), @NodeChild(value = "index1", type = ConvertIndex.class), @NodeChild(value = "index2", type = ConvertIndex.class)})
@NodeChild(value = "vector", type = ProfiledValue.class)
@NodeChild(value = "index1", type = ConvertIndex.class)
@NodeChild(value = "index2", type = ConvertIndex.class)
abstract class SubscriptSpecial2Base extends SubscriptSpecial2Common {
protected SubscriptSpecial2Base(boolean inReplacement) {
......
......@@ -32,7 +32,6 @@ import java.util.Arrays;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.dsl.TypeSystemReference;
import com.oracle.truffle.api.frame.VirtualFrame;
......@@ -60,7 +59,9 @@ import com.oracle.truffle.r.runtime.data.RStringVector;
import com.oracle.truffle.r.runtime.nodes.RNode;
import com.oracle.truffle.r.runtime.ops.na.NACheck;
@NodeChildren({@NodeChild(value = "vector", type = ProfiledValue.class), @NodeChild(value = "index", type = ConvertIndex.class), @NodeChild(value = "value", type = RNode.class)})
@NodeChild(value = "vector", type = ProfiledValue.class)
@NodeChild(value = "index", type = ConvertIndex.class)
@NodeChild(value = "value", type = RNode.class)
abstract class UpdateSubscriptSpecial extends SubscriptSpecialCommon {
protected UpdateSubscriptSpecial(boolean inReplacement) {
......@@ -108,8 +109,10 @@ abstract class UpdateSubscriptSpecial extends SubscriptSpecialCommon {
}
}
@NodeChildren({@NodeChild(value = "vector", type = ProfiledValue.class), @NodeChild(value = "index1", type = ConvertIndex.class), @NodeChild(value = "index2", type = ConvertIndex.class),
@NodeChild(value = "value", type = RNode.class)})
@NodeChild(value = "vector", type = ProfiledValue.class)
@NodeChild(value = "index1", type = ConvertIndex.class)
@NodeChild(value = "index2", type = ConvertIndex.class)
@NodeChild(value = "value", type = RNode.class)
abstract class UpdateSubscriptSpecial2 extends SubscriptSpecial2Common {
protected UpdateSubscriptSpecial2(boolean inReplacement) {
......
......@@ -23,10 +23,10 @@
package com.oracle.truffle.r.nodes.binary;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.r.runtime.nodes.RNode;
@NodeChildren({@NodeChild(value = "left", type = RNode.class), @NodeChild(value = "right", type = RNode.class)})
@NodeChild(value = "left", type = RNode.class)
@NodeChild(value = "right", type = RNode.class)
abstract class BinaryNode extends RNode {
protected abstract RNode getLeft();
......
......@@ -22,7 +22,6 @@
*/
package com.oracle.truffle.r.nodes.unary;
import com.oracle.truffle.api.dsl.NodeField;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.r.runtime.data.RDataFactory;
import com.oracle.truffle.r.runtime.data.RFunction;
......@@ -30,14 +29,21 @@ import com.oracle.truffle.r.runtime.data.RMissing;
import com.oracle.truffle.r.runtime.data.RNull;
import com.oracle.truffle.r.runtime.data.model.RAbstractVector;
@NodeField(name = "preserveNonVector", type = boolean.class)
public abstract class CastToVectorNode extends CastNode {
public abstract boolean isPreserveNonVector();
private final boolean preserveNonVector;
protected CastToVectorNode(boolean preserveNonVector) {
this.preserveNonVector = preserveNonVector;
}
public final boolean isPreserveNonVector() {
return preserveNonVector;
}
@Specialization
protected Object castNull(@SuppressWarnings("unused") RNull rnull) {
if (isPreserveNonVector()) {
if (preserveNonVector) {
return RNull.instance;
} else {
return RDataFactory.createList();
......@@ -46,7 +52,7 @@ public abstract class CastToVectorNode extends CastNode {
@Specialization
protected Object castMissing(@SuppressWarnings("unused") RMissing missing) {
if (isPreserveNonVector()) {
if (preserveNonVector) {
return RMissing.instance;
} else {
return RDataFactory.createList();
......@@ -55,7 +61,7 @@ public abstract class CastToVectorNode extends CastNode {
@Specialization
protected Object castFunction(RFunction f) {
if (isPreserveNonVector()) {
if (preserveNonVector) {
return f;
} else {
return RDataFactory.createList();
......
......@@ -23,7 +23,6 @@
package com.oracle.truffle.r.nodes.unary;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.BranchProfile;
......@@ -44,7 +43,7 @@ import com.oracle.truffle.r.runtime.nodes.RNode;
import com.oracle.truffle.r.runtime.nodes.RSyntaxNode;
import com.oracle.truffle.r.runtime.ops.na.NAProfile;
@NodeChildren({@NodeChild("operand")})
@NodeChild("operand")
public abstract class ConvertBooleanNode extends RNode {
private final NAProfile naProfile = NAProfile.create();
......
......@@ -22,25 +22,26 @@
*/
package com.oracle.truffle.r.nodes.unary;
import com.oracle.truffle.api.dsl.NodeField;
import com.oracle.truffle.api.dsl.NodeFields;
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.runtime.RError;
import com.oracle.truffle.r.runtime.RError.Message;
import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector;
@NodeFields({@NodeField(name = "emptyError", type = RError.Message.class), @NodeField(name = "sizeWarning", type = RError.Message.class), @NodeField(name = "argumentName", type = String.class),
@NodeField(name = "defaultValue", type = int.class)})
public abstract class FirstIntNode extends CastNode {
protected abstract RError.Message getEmptyError();
private final RError.Message emptyError;
private final RError.Message sizeWarning;
private final String argumentName;
private final int defaultValue;
protected abstract RError.Message getSizeWarning();
protected abstract String getArgumentName();
protected abstract int getDefaultValue();
protected FirstIntNode(Message emptyError, Message sizeWarning, String argumentName, int defaultValue) {
this.emptyError = emptyError;
this.sizeWarning = sizeWarning;
this.argumentName = argumentName;
this.defaultValue = defaultValue;
}
public abstract int executeInt(Object value);
......@@ -55,14 +56,14 @@ public abstract class FirstIntNode extends CastNode {
@Specialization(replaces = "firstScalar")
protected int firstVector(RAbstractIntVector argument) {
if (!lengthOneProfile.profile(argument.getLength() == 1)) {
if (getSizeWarning() != null) {
RError.warning(this, getSizeWarning(), getArgumentName());
if (sizeWarning != null) {
RError.warning(this, sizeWarning, argumentName);
if (argument.getLength() == 0) {
return getDefaultValue();
return defaultValue;
}
} else if (getEmptyError() != null && argument.getLength() == 0) {
} else if (emptyError != null && argument.getLength() == 0) {
errorProfile.enter();
throw RError.error(this, getEmptyError(), getArgumentName());
throw RError.error(this, emptyError, argumentName);
}
}
return argument.getDataAt(0);
......
......@@ -23,20 +23,22 @@
package com.oracle.truffle.r.nodes.unary;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.NodeField;
import com.oracle.truffle.api.dsl.NodeFields;
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.runtime.RError;
import com.oracle.truffle.r.runtime.RError.Message;
import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector;
@NodeFields({@NodeField(name = "emptyError", type = RError.Message.class), @NodeField(name = "argumentName", type = String.class)})
public abstract class FirstStringNode extends CastNode {
protected abstract RError.Message getEmptyError();
private final RError.Message emptyError;
private final String argumentName;
protected abstract String getArgumentName();
protected FirstStringNode(Message emptyError, String argumentName) {
this.emptyError = emptyError;
this.argumentName = argumentName;
}
private final ConditionProfile lengthOneProfile = ConditionProfile.createBinaryProfile();
private final BranchProfile errorProfile = BranchProfile.create();
......@@ -54,14 +56,14 @@ public abstract class FirstStringNode extends CastNode {
protected String firstVector(RAbstractStringVector argument) {
if (!lengthOneProfile.profile(argument.getLength() == 1)) {
errorProfile.enter();
throw RError.error(RError.SHOW_CALLER, getEmptyError(), getArgumentName());
throw RError.error(RError.SHOW_CALLER, emptyError, argumentName);
}
return argument.getDataAt(0);
}
@Fallback
protected String firstVectorFallback(@SuppressWarnings("unused") Object argument) {
throw RError.error(RError.SHOW_CALLER, getEmptyError(), getArgumentName());
throw RError.error(RError.SHOW_CALLER, emptyError, argumentName);
}
public static FirstStringNode createWithError(RError.Message emptyError, String argumentName) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment