Skip to content

Commit de00a17

Browse files
committed
[GR-10710] A bit more limit configs.
PullRequest: fastr/1751
2 parents c75cfad + 4fdc78f commit de00a17

File tree

6 files changed

+14
-16
lines changed

6 files changed

+14
-16
lines changed

com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Colon.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ public static RNode special(ArgumentsSignature signature, RNode[] arguments, boo
8585
@Child private ColonCastNode rightCast = ColonCastNodeGen.create();
8686
@Child private ColonInternal internal = ColonInternalNodeGen.create();
8787

88-
private static final double FLT_EPSILON = 1.19209290e-7;
89-
9088
static {
9189
Casts.noCasts(Colon.class);
9290
}
@@ -163,7 +161,7 @@ protected RSequence colonAscending(int left, double right,
163161
if (isDouble.profile(right > Integer.MAX_VALUE)) {
164162
return RDataFactory.createAscendingRange(left, right);
165163
} else {
166-
return RDataFactory.createIntSequence(left, 1, effectiveLength(left, right));
164+
return RDataFactory.createIntSequence(left, 1, RDataFactory.effectiveLength(left, right));
167165
}
168166
}
169167

@@ -176,7 +174,7 @@ protected RSequence colonDescending(int left, double right,
176174
if (isDouble.profile(right <= Integer.MIN_VALUE)) {
177175
return RDataFactory.createDescendingRange(left, right);
178176
} else {
179-
return RDataFactory.createIntSequence(left, -1, effectiveLength(left, right));
177+
return RDataFactory.createIntSequence(left, -1, RDataFactory.effectiveLength(left, right));
180178
}
181179
}
182180

@@ -216,11 +214,6 @@ private void checkVecLength(double from, double to) {
216214
throw error(RError.Message.TOO_LONG_VECTOR);
217215
}
218216
}
219-
220-
private static int effectiveLength(double start, double end) {
221-
double r = Math.abs(end - start);
222-
return (int) (r + 1 + FLT_EPSILON);
223-
}
224217
}
225218

226219
@NodeInfo(cost = NodeCost.NONE)

com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsListFactor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,20 @@
2525
import com.oracle.truffle.api.CompilerDirectives;
2626
import com.oracle.truffle.api.dsl.Cached;
2727
import com.oracle.truffle.api.dsl.Fallback;
28+
import com.oracle.truffle.api.dsl.ImportStatic;
2829
import com.oracle.truffle.api.dsl.Specialization;
2930
import com.oracle.truffle.api.nodes.Node;
3031
import com.oracle.truffle.r.nodes.builtin.RBuiltinNode;
3132
import com.oracle.truffle.r.nodes.builtin.base.IsListFactorNodeGen.IsListFactorInternalNodeGen;
3233
import com.oracle.truffle.r.nodes.unary.IsFactorNode;
34+
import com.oracle.truffle.r.runtime.DSLConfig;
3335
import com.oracle.truffle.r.runtime.RRuntime;
3436
import com.oracle.truffle.r.runtime.builtins.RBuiltin;
3537
import com.oracle.truffle.r.runtime.data.model.RAbstractListVector;
3638

3739
// from apply.c
3840

41+
@ImportStatic({DSLConfig.class})
3942
@RBuiltin(name = "islistfactor", kind = INTERNAL, parameterNames = {"x", "recursive"}, behavior = PURE)
4043
public abstract class IsListFactor extends RBuiltinNode.Arg2 {
4144

@@ -87,7 +90,7 @@ protected static IsListFactorInternal createNode(boolean recursive) {
8790
}
8891

8992
// Note: the limit should never be reached
90-
@Specialization(guards = "recursive == node.recursive", limit = "2")
93+
@Specialization(guards = "recursive == node.recursive", limit = "99")
9194
protected byte isListFactor(Object value, @SuppressWarnings("unused") boolean recursive,
9295
@Cached("createNode(recursive)") IsListFactorInternal node) {
9396
return RRuntime.asLogical(node.execute(value));

com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/ProfiledSpecialsUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class ProfiledSpecialsUtils {
4040
@NodeChild(value = "index", type = ConvertIndex.class)
4141
protected abstract static class ProfiledSubscriptSpecialBase extends RNode {
4242

43-
protected static final int CACHE_LIMIT = 3;
43+
protected static final int CACHE_LIMIT = DSLConfig.getCacheSize(3);
4444
protected final boolean inReplacement;
4545

4646
@Child protected SubscriptSpecialBase defaultAccessNode;
@@ -158,7 +158,7 @@ protected SubscriptSpecial2Base createAccessNode() {
158158
@NodeChild(value = "value", type = ConvertValue.class)
159159
public abstract static class ProfiledUpdateSubscriptSpecialBase extends RNode {
160160

161-
protected static final int CACHE_LIMIT = 3;
161+
protected static final int CACHE_LIMIT = DSLConfig.getCacheSize(3);
162162
protected final boolean inReplacement;
163163

164164
public abstract Object execute(VirtualFrame frame, Object vector, Object index, Object value);
@@ -196,7 +196,7 @@ public Object accessGeneric(VirtualFrame frame, Object vector, Object index, Obj
196196
@NodeChild(value = "value", type = ConvertValue.class)
197197
public abstract static class ProfiledUpdateSubscriptSpecial2 extends RNode {
198198

199-
protected static final int CACHE_LIMIT = 3;
199+
protected static final int CACHE_LIMIT = DSLConfig.getCacheSize(3);
200200
protected final boolean inReplacement;
201201

202202
public abstract Object execute(VirtualFrame frame, Object vector, Object index1, Object index2, Object value);

com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ReplaceVectorNode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef;
3838
import com.oracle.truffle.r.nodes.objects.GetS4DataSlot;
3939
import com.oracle.truffle.r.nodes.profile.TruffleBoundaryNode;
40+
import com.oracle.truffle.r.runtime.DSLConfig;
4041
import com.oracle.truffle.r.runtime.RError;
4142
import com.oracle.truffle.r.runtime.RInternalError;
4243
import com.oracle.truffle.r.runtime.RRuntime;
@@ -61,7 +62,7 @@
6162
@ImportStatic({RRuntime.class, com.oracle.truffle.api.interop.Message.class})
6263
public abstract class ReplaceVectorNode extends RBaseNode {
6364

64-
protected static final int CACHE_LIMIT = 5;
65+
protected static final int CACHE_LIMIT = DSLConfig.getCacheSize(5);
6566

6667
protected final ElementAccessMode mode;
6768
private final boolean recursive;

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RDataFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ public static RIntSequence createIntSequence(int start, int stride, int length)
10061006

10071007
private static final double FLT_EPSILON = 1.19209290e-7;
10081008

1009-
private static int effectiveLength(double start, double end) {
1009+
public static int effectiveLength(double start, double end) {
10101010
double r = Math.abs(end - start);
10111011
return (int) (r + 1 + FLT_EPSILON);
10121012
}

com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/S4/TestS4.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ public void testMethods() {
124124

125125
assertEval("{ setGeneric(\"gen\", function(o) standardGeneric(\"gen\")); res<-print(setGeneric(\"gen\", function(o) standardGeneric(\"gen\"))); removeGeneric(\"gen\"); res }");
126126

127-
assertEval("{ setClass(\"foo\"); setMethod(\"diag<-\", \"foo\", function(x, value) 42); removeMethod(\"diag<-\", \"foo\"); removeGeneric(\"diag<-\"); removeClass(\"foo\") }");
127+
assertEval(Output.IgnoreWarningMessage,
128+
"{ setClass(\"foo\"); setMethod(\"diag<-\", \"foo\", function(x, value) 42); removeMethod(\"diag<-\", \"foo\"); removeGeneric(\"diag<-\"); removeClass(\"foo\") }");
128129

129130
assertEval("{ setClass('A'); setClass('A1', contains = 'A'); setClass('A2', contains = 'A1'); setGeneric('foo', function(a, b) standardGeneric('foo')); setMethod('foo', signature('A1', 'A2'), function(a, b) '1-2'); setMethod('foo', signature('A2', 'A1'), function(a, b) '2-1'); foo(new('A2'), new('A2')) }");
130131

0 commit comments

Comments
 (0)