Skip to content

Commit f2d999d

Browse files
committed
[GR-33795] [GR-33589] FIx C_Approx{Test}, .Rprofile loading, update CHANGELOG, set impl. name.
PullRequest: fastr/2655
2 parents 8ba07c8 + fd3d3ce commit f2d999d

File tree

7 files changed

+47
-13
lines changed

7 files changed

+47
-13
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# 21.3.0
2+
* Upgrade of PCRE to PCRE2 version 10.37.
3+
* Some Unicode patterns and texts are still not supported.
4+
5+
Bug fixes:
6+
7+
* Fixed implicit make rule parameters used when building R extensions
8+
* Fixes, e.g., installation of maps package version 3.3.0.
9+
* Fixed unexpected garbage collection of CHARSXP objects in R extensions
10+
* Option --no-init-file is not ignored anymore
11+
* Fixed functions `approx` and `approxfun` from the `stats` package
12+
* Previously they were always failing with error message "Incorrect number of arguments"
13+
114
# 21.2.0
215
* Support for packages in 2021-02-01 CRAN snapshot:
316
* testthat 3.0.1 is partially supported.

com.oracle.truffle.r.launcher/src/com/oracle/truffle/r/launcher/RStartParams.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public RStartParams(RCmdOptions options, boolean embedded) {
8282
this.verbose = options.getBoolean(VERBOSE);
8383
this.quiet = options.getBoolean(QUIET) || options.getBoolean(SILENT) || options.getBoolean(NO_ECHO);
8484
this.loadSiteFile = options.getBoolean(NO_SITE_FILE);
85-
this.loadInitFile = !embedded && options.getBoolean(NO_INIT_FILE) && !options.getBoolean(VANILLA);
85+
this.loadInitFile = !embedded && !options.getBoolean(NO_INIT_FILE) && !options.getBoolean(VANILLA);
8686
this.noRenviron = embedded || options.getBoolean(NO_ENVIRON) || options.getBoolean(VANILLA);
8787
this.restoreAction = options.getBoolean(RESTORE) && !(options.getBoolean(NO_RESTORE) || options.getBoolean(NO_RESTORE_DATA) || options.getBoolean(VANILLA));
8888
this.noReadline = options.getBoolean(NO_READLINE);

com.oracle.truffle.r.launcher/src/com/oracle/truffle/r/launcher/RVersionNumber.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,9 @@ public class RVersionNumber {
5050

5151
public static final String VERSION_STRING = "FastR version " + FULL + RELEASE_DATE;
5252

53-
public static final String COPYRIGHT = "Copyright (c) 2013-19, Oracle and/or its affiliates\n" +
54-
"Copyright (c) 1995-2018, The R Core Team\n" +
55-
"Copyright (c) 2018 The R Foundation for Statistical Computing\n" +
53+
public static final String COPYRIGHT = "Copyright (c) 2013-21, Oracle and/or its affiliates\n" +
54+
"Copyright (C) 2020 The R Foundation for Statistical Computing\n" +
5655
"Copyright (c) 2012-4 Purdue University\n" +
57-
"Copyright (c) 1997-2002, Makoto Matsumoto and Takuji Nishimura\n" +
5856
"All rights reserved.\n";
5957

6058
/**

com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Approx.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.emptyDoubleVector;
2525
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.missingValue;
2626
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.nullValue;
27+
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.toBoolean;
2728

2829
import com.oracle.truffle.api.dsl.Specialization;
2930
import com.oracle.truffle.api.library.CachedLibrary;
@@ -36,7 +37,10 @@
3637
import com.oracle.truffle.r.runtime.data.VectorDataLibrary.SeqIterator;
3738
import com.oracle.truffle.r.runtime.ops.na.NACheck;
3839

39-
public abstract class Approx extends RExternalBuiltinNode.Arg7 {
40+
/**
41+
* Transcribed from {@code src/library/stats/src/approx.c:R_approxfun}.
42+
*/
43+
public abstract class Approx extends RExternalBuiltinNode.Arg8 {
4044
private static final NACheck naCheck = NACheck.create();
4145

4246
public static Approx create() {
@@ -52,10 +56,11 @@ public static Approx create() {
5256
casts.arg(4).asDoubleVector().findFirst();
5357
casts.arg(5).asDoubleVector().findFirst();
5458
casts.arg(6).asDoubleVector().findFirst();
59+
casts.arg(7).asLogicalVector().findFirst().map(toBoolean());
5560
}
5661

5762
@Specialization(limit = "getVectorAccessCacheSize()")
58-
protected RDoubleVector approx(RDoubleVector x, RDoubleVector y, RDoubleVector v, int method, double yl, double yr, double f,
63+
protected RDoubleVector approx(RDoubleVector x, RDoubleVector y, RDoubleVector v, int method, double yl, double yr, double f, boolean naRm,
5964
@CachedLibrary("x.getData()") VectorDataLibrary xLib,
6065
@CachedLibrary("y.getData()") VectorDataLibrary yLib,
6166
@CachedLibrary("v.getData()") VectorDataLibrary vLib) {
@@ -69,6 +74,7 @@ protected RDoubleVector approx(RDoubleVector x, RDoubleVector y, RDoubleVector v
6974
apprMeth.kind = method;
7075
apprMeth.ylow = yl;
7176
apprMeth.yhigh = yr;
77+
apprMeth.naRm = naRm;
7278
naCheck.enable(true);
7379

7480
Object xData = x.getData();
@@ -94,6 +100,8 @@ private static class ApprMeth {
94100
double f1;
95101
double f2;
96102
int kind;
103+
// In GNU-R, naRm field is unused.
104+
@SuppressWarnings("unused") boolean naRm;
97105
}
98106

99107
private static double approx1(double v, VectorDataLibrary xLib, Object xData, RandomAccessIterator xIter,

com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/ApproxTest.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 1995, 1996, 1997 Robert Gentleman and Ross Ihaka
33
* Copyright (c) 1998-2013, The R Core Team
44
* Copyright (c) 2003-2015, The R Foundation
5-
* Copyright (c) 2016, 2020, Oracle and/or its affiliates
5+
* Copyright (c) 2016, 2021, Oracle and/or its affiliates
66
*
77
* This program is free software; you can redistribute it and/or modify
88
* it under the terms of the GNU General Public License as published by
@@ -27,7 +27,12 @@
2727
import com.oracle.truffle.r.runtime.data.RDoubleVector;
2828
import com.oracle.truffle.r.runtime.data.RNull;
2929

30-
public abstract class ApproxTest extends RExternalBuiltinNode.Arg4 {
30+
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.toBoolean;
31+
32+
/**
33+
* Transcribed from {@code src/library/stats/src/approx.c:R_approxtest}.
34+
*/
35+
public abstract class ApproxTest extends RExternalBuiltinNode.Arg5 {
3136
public static ApproxTest create() {
3237
return ApproxTestNodeGen.create();
3338
}
@@ -36,10 +41,11 @@ public static ApproxTest create() {
3641
Casts casts = new Casts(ApproxTest.class);
3742
casts.arg(2).asIntegerVector().findFirst();
3843
casts.arg(3).asDoubleVector().findFirst();
44+
casts.arg(4).asLogicalVector().findFirst().map(toBoolean());
3945
}
4046

4147
@Specialization
42-
protected RNull approxtest(RDoubleVector x, RDoubleVector y, int method, double f) {
48+
protected RNull approxtest(RDoubleVector x, RDoubleVector y, int method, double f, boolean naRm) {
4349
int nx = x.getLength();
4450
switch (method) {
4551
case 1:
@@ -54,8 +60,16 @@ protected RNull approxtest(RDoubleVector x, RDoubleVector y, int method, double
5460
}
5561

5662
for (int i = 0; i < nx; i++) {
57-
if (RRuntime.isNAorNaN(x.getDataAt(i)) || RRuntime.isNAorNaN(y.getDataAt(i))) {
58-
throw error(RError.Message.GENERIC, ("approx(): attempted to interpolate NA values"));
63+
if (naRm) {
64+
// (x,y) should not have any NA's anymore
65+
if (RRuntime.isNAorNaN(x.getDataAt(i)) || RRuntime.isNAorNaN(y.getDataAt(i))) {
66+
throw error(RError.Message.GENERIC, ("approx(): attempted to interpolate NA values"));
67+
}
68+
} else {
69+
// na.rm = FALSE ==> at least y may contain NA's
70+
if (RRuntime.isNAorNaN(x.getDataAt(i))) {
71+
throw error(RError.Message.GENERIC, ("approx(x,y, .., na.rm=FALSE): NA values in x are not allowed"));
72+
}
5973
}
6074
}
6175

com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Prahlad Joshi
1616
Tomas Kalibera
1717
Roman Katerinenko
1818
Petr Maj
19+
Pavel Marek
1920
Miloslav Metelka
2021
Stepan Sindelar
2122
Zbynek Slajchrt

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/TruffleRLanguage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
import com.oracle.truffle.r.runtime.interop.ConvertForeignObjectNode;
6060
import com.oracle.truffle.r.runtime.interop.Foreign2R;
6161

62-
@TruffleLanguage.Registration(name = "R", id = "R", version = "4.0.3", characterMimeTypes = {RRuntime.R_APP_MIME,
62+
@TruffleLanguage.Registration(name = "R", id = "R", version = "4.0.3", implementationName = "FastR", characterMimeTypes = {RRuntime.R_APP_MIME,
6363
RRuntime.R_TEXT_MIME}, defaultMimeType = RRuntime.R_APP_MIME, interactive = true, fileTypeDetectors = RFileTypeDetector.class, dependentLanguages = "llvm")
6464
@ProvidedTags({StandardTags.CallTag.class, StandardTags.StatementTag.class, StandardTags.RootBodyTag.class, StandardTags.RootTag.class, RSyntaxTags.LoopTag.class, FunctionBodyBlockTag.class})
6565
public final class TruffleRLanguage extends TruffleLanguage<RContext> {

0 commit comments

Comments
 (0)