Skip to content

Commit 16f54f6

Browse files
author
Pavel Marek
committed
[GR-27932] Gnur 4.0.3 migration.
PullRequest: fastr/2569
2 parents 4606579 + 298f656 commit 16f54f6

File tree

419 files changed

+50952
-3806
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

419 files changed

+50952
-3806
lines changed

ci.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ overlay : '6a659ccc145041d13a26df8506464e6a7c737821' }
1+
{ overlay : '1e20e758987afb3ed80cc0b2d9e575851899f497' }

com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/JavaUpCallsRFFIImpl.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import com.oracle.truffle.r.runtime.RErrorHandling;
5656
import com.oracle.truffle.r.runtime.RInternalError;
5757
import com.oracle.truffle.r.runtime.RRuntime;
58+
import com.oracle.truffle.r.runtime.RSerialize;
5859
import com.oracle.truffle.r.runtime.RSource;
5960
import com.oracle.truffle.r.runtime.RSrcref;
6061
import com.oracle.truffle.r.runtime.RType;
@@ -1710,6 +1711,11 @@ public Object R_new_altrep(Object classDescriptor, Object data1, Object data2) {
17101711
throw implementedAsNode();
17111712
}
17121713

1714+
@Override
1715+
public long EXTPTR_PTR(Object x) {
1716+
return R_ExternalPtrAddr(x);
1717+
}
1718+
17131719
@Override
17141720
public long R_ExternalPtrAddr(Object x) {
17151721
RExternalPtr p = guaranteeInstanceOf(x, RExternalPtr.class);
@@ -1965,6 +1971,16 @@ public int FASTR_getConnectionChar(Object obj) {
19651971
}
19661972
}
19671973

1974+
@Override
1975+
public int FASTR_getSerializeVersion() {
1976+
return RSerialize.DEFAULT_VERSION;
1977+
}
1978+
1979+
@Override
1980+
public void FASTR_serialize(Object object, int type, int version, Object stream, Object outBytesFunc) {
1981+
throw implementedAsNode();
1982+
}
1983+
19681984
@Override
19691985
@TruffleBoundary
19701986
public int Rf_str2type(String name) {
@@ -3033,6 +3049,21 @@ public Object gdMetricInfo(int gdId, int ch, RContext ctx) {
30333049
return getJavaGDContext(ctx).getGD(gdId).gdMetricInfo(ch);
30343050
}
30353051

3052+
@Override
3053+
@TruffleBoundary
3054+
public void R_removeVarFromFrame(Object sym, Object env) {
3055+
if (!(env instanceof REnvironment && sym instanceof RSymbol)) {
3056+
throw RInternalError.shouldNotReachHere();
3057+
}
3058+
RSymbol symbol = (RSymbol) sym;
3059+
REnvironment envir = (REnvironment) env;
3060+
try {
3061+
envir.rm(symbol.getName());
3062+
} catch (PutException e) {
3063+
throw RInternalError.shouldNotReachHere(e);
3064+
}
3065+
}
3066+
30363067
@Override
30373068
public Object DispatchPRIMFUN(Object call, Object op, Object args, Object rho) {
30383069
throw implementedAsNode();

com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/CoerceNodes.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ protected Object convert(RNull x) {
119119

120120
@Specialization
121121
protected Object convert(RPairList list) {
122-
if (list.isLanguage() || type == SEXPTYPE.LISTSXP) {
122+
if (type == SEXPTYPE.LISTSXP && !list.isLanguage()) {
123+
return list;
124+
} else if (type == SEXPTYPE.LANGSXP && list.isLanguage()) {
123125
return list;
124126
} else {
125127
return doFallback(list);
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 3 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 3 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 3 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
package com.oracle.truffle.r.ffi.impl.nodes;
25+
26+
import com.oracle.truffle.api.TruffleLanguage;
27+
import com.oracle.truffle.api.dsl.CachedContext;
28+
import com.oracle.truffle.api.dsl.GenerateUncached;
29+
import com.oracle.truffle.api.dsl.Specialization;
30+
import com.oracle.truffle.api.interop.ArityException;
31+
import com.oracle.truffle.api.interop.InteropLibrary;
32+
import com.oracle.truffle.api.interop.TruffleObject;
33+
import com.oracle.truffle.api.interop.UnknownIdentifierException;
34+
import com.oracle.truffle.api.interop.UnsupportedMessageException;
35+
import com.oracle.truffle.api.interop.UnsupportedTypeException;
36+
import com.oracle.truffle.api.library.CachedLibrary;
37+
import com.oracle.truffle.r.runtime.RInternalError;
38+
import com.oracle.truffle.r.runtime.RSerialize;
39+
import com.oracle.truffle.r.runtime.context.RContext;
40+
import com.oracle.truffle.r.runtime.context.TruffleRLanguage;
41+
import com.oracle.truffle.r.runtime.data.RNull;
42+
import com.oracle.truffle.r.runtime.ffi.interop.NativeCharArray;
43+
44+
@GenerateUncached
45+
public abstract class FASTR_serializeNode extends FFIUpCallNode.Arg5 {
46+
// void OutBytes(R_outpstream_t stream, void *buffer, int n)
47+
private static final String outBytesFuncSignature = "(pointer, pointer, sint32): void";
48+
49+
public static FASTR_serializeNode create() {
50+
return FASTR_serializeNodeGen.create();
51+
}
52+
53+
/**
54+
* Serializes object into buffer of bytes and passes this buffer into outBytesFunc native
55+
* callback.
56+
*
57+
* FIXME: We serialize to XDR format no matter what the caller specified, therefore type
58+
* parameter is intentionally ignored.
59+
*
60+
* @param object Object to be serialized.
61+
* @param type Type of serialization, e.g., XDR or BINARY. Currently, only XDR is supported.
62+
* @param version Version of serialization. Can be either 2 or 3.
63+
* @param stream A native object of type R_outpstream_t. Defined in Rinternals.h. Contains
64+
* pointers to various callback functions into which we pass serialized byte array.
65+
* @param outBytesFunc Pointer to native function callback. This is a member of R_outpstream_t
66+
* struct.
67+
* @return RNull, bytes are passed into outBytesFunc native function.
68+
*/
69+
@Specialization
70+
protected Object doIt(Object object, @SuppressWarnings("unused") int type, int version, Object stream, Object outBytesFunc,
71+
@CachedContext(TruffleRLanguage.class) TruffleLanguage.ContextReference<RContext> ctxRef,
72+
@CachedLibrary(limit = "getInteropLibraryCacheSize()") InteropLibrary interopLibrary) {
73+
74+
TruffleObject outBytesFuncExecutable = null;
75+
if (interopLibrary.isMemberInvocable(outBytesFunc, "bind")) {
76+
try {
77+
outBytesFuncExecutable = (TruffleObject) interopLibrary.invokeMember(outBytesFunc, "bind", outBytesFuncSignature);
78+
} catch (UnsupportedMessageException | ArityException | UnknownIdentifierException | UnsupportedTypeException e) {
79+
throw RInternalError.shouldNotReachHere(e);
80+
}
81+
} else {
82+
outBytesFuncExecutable = (TruffleObject) outBytesFunc;
83+
}
84+
assert outBytesFuncExecutable != null;
85+
assert interopLibrary.isExecutable(outBytesFuncExecutable);
86+
87+
// TODO: Pass type instead of RSerialize.XDR
88+
byte[] serializedBuff = RSerialize.serialize(ctxRef.get(), object, RSerialize.XDR, version, null);
89+
NativeCharArray nativeBuff = new NativeCharArray(serializedBuff);
90+
91+
try {
92+
interopLibrary.execute(outBytesFuncExecutable, stream, nativeBuff, serializedBuff.length);
93+
} catch (Exception e) {
94+
throw RInternalError.shouldNotReachHere(e);
95+
}
96+
return RNull.instance;
97+
}
98+
}

com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/upcalls/FastRUpCalls.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
2323
package com.oracle.truffle.r.ffi.impl.upcalls;
2424

2525
import com.oracle.truffle.r.ffi.impl.nodes.FASTR_DATAPTRNode;
26+
import com.oracle.truffle.r.ffi.impl.nodes.FASTR_serializeNode;
2627
import com.oracle.truffle.r.ffi.processor.RFFICpointer;
2728
import com.oracle.truffle.r.ffi.processor.RFFIUpCallNode;
2829

@@ -36,6 +37,11 @@ public interface FastRUpCalls {
3637

3738
int FASTR_getConnectionChar(Object obj);
3839

40+
int FASTR_getSerializeVersion();
41+
42+
@RFFIUpCallNode(FASTR_serializeNode.class)
43+
void FASTR_serialize(Object object, int type, int version, @RFFICpointer Object stream, @RFFICpointer Object outBytesFunc);
44+
3945
Object getSummaryDescription(Object x);
4046

4147
Object getConnectionClassString(Object x);

com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/upcalls/StdUpCallsRFFI.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,8 @@ public interface StdUpCallsRFFI {
588588
@RFFIUpCallNode(RMakeExternalPtrNode.class)
589589
Object R_MakeExternalPtr(@RFFICpointer Object addr, Object tag, Object prot);
590590

591+
long EXTPTR_PTR(Object x);
592+
591593
long R_ExternalPtrAddr(Object x);
592594

593595
Object R_ExternalPtrTag(Object x);
@@ -1067,6 +1069,8 @@ public interface StdUpCallsRFFI {
10671069
@RFFIUpCallNode(MakeActiveBindingNode.class)
10681070
void R_MakeActiveBinding(Object sym, Object fun, Object env);
10691071

1072+
void R_removeVarFromFrame(Object sym, Object env);
1073+
10701074
/**
10711075
* <code>PRIMFUN(op)</code> returns a function pointer for the given function object (SEXP)
10721076
* argument identifying a primitive builtin. Its main purpose is to be stored in a display list.

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -22,13 +22,13 @@
2222
*/
2323
package com.oracle.truffle.r.launcher;
2424

25-
import com.oracle.truffle.r.launcher.RMain.PrintHelp;
26-
import com.oracle.truffle.r.launcher.RMain.PrintVersion;
27-
2825
import java.util.ArrayList;
2926
import java.util.EnumMap;
3027
import java.util.List;
3128

29+
import com.oracle.truffle.r.launcher.RMain.PrintHelp;
30+
import com.oracle.truffle.r.launcher.RMain.PrintVersion;
31+
3232
/**
3333
* (Abstract) definition of the standard R command line options. The setting of the values from the
3434
* environment is handled in some other class.
@@ -139,7 +139,7 @@ public enum RCmdOption {
139139
MAX_PPSIZE(RCmdOptionType.STRING, false, "max-ppsize", null, "Set max size of protect stack to N"),
140140
QUIET(RCmdOptionType.BOOLEAN, true, "q", "quiet", false, "Don't print startup message"),
141141
SILENT(RCmdOptionType.BOOLEAN, true, "silent", false, "Same as --quiet"),
142-
SLAVE(RCmdOptionType.BOOLEAN, true, "slave", false, "Make R run as quietly as possible"),
142+
NO_ECHO(RCmdOptionType.BOOLEAN, true, "s", "no-echo", false, "Make R run as quietly as possible"),
143143
INTERACTIVE(RCmdOptionType.BOOLEAN, true, "interactive", false, "Force an interactive session"),
144144
VERBOSE(RCmdOptionType.BOOLEAN, true, "verbose", false, "Print more information about progress"),
145145
ARGS(RCmdOptionType.BOOLEAN, true, "args", false, "Skip the rest of the command line"),
@@ -312,6 +312,12 @@ private static final class MatchResult {
312312
}
313313

314314
private static MatchResult matchOption(String arg) {
315+
// --slave option is currently an undocumented alias for --no-echo option (GNU-R silently
316+
// treats --slave as --no-echo, and provides no help for it)
317+
if (arg.equals("--slave")) {
318+
return new MatchResult(RCmdOption.NO_ECHO, false);
319+
}
320+
315321
for (RCmdOption option : RCmdOption.values()) {
316322
switch (option.type) {
317323
case BOOLEAN:
@@ -493,11 +499,11 @@ private static String[] preprocessRScriptOptions(RCmdOptions options) {
493499
String[] arguments = options.getArguments();
494500
int resultArgsLength = arguments.length;
495501
int firstNonOptionArgIndex = options.getFirstNonOptionArgIndex();
496-
// Now reformat the args, setting --slave and --no-restore as per the spec
502+
// Now reformat the args, setting --no-echo and --no-restore as per the spec
497503
ArrayList<String> adjArgs = new ArrayList<>(resultArgsLength + 1);
498504
adjArgs.add(arguments[0]);
499-
adjArgs.add("--slave");
500-
options.setValue(RCmdOption.SLAVE, true);
505+
adjArgs.add("--no-echo");
506+
options.setValue(RCmdOption.NO_ECHO, true);
501507
adjArgs.add("--no-restore");
502508
options.setValue(RCmdOption.NO_RESTORE, true);
503509
// Either -e options are set or first non-option arg is a file

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
2525
import static com.oracle.truffle.r.launcher.RCmdOptions.RCmdOption.EXPR;
2626
import static com.oracle.truffle.r.launcher.RCmdOptions.RCmdOption.FILE;
2727
import static com.oracle.truffle.r.launcher.RCmdOptions.RCmdOption.INTERACTIVE;
28+
import static com.oracle.truffle.r.launcher.RCmdOptions.RCmdOption.NO_ECHO;
2829
import static com.oracle.truffle.r.launcher.RCmdOptions.RCmdOption.NO_ENVIRON;
2930
import static com.oracle.truffle.r.launcher.RCmdOptions.RCmdOption.NO_INIT_FILE;
3031
import static com.oracle.truffle.r.launcher.RCmdOptions.RCmdOption.NO_READLINE;
@@ -36,7 +37,6 @@
3637
import static com.oracle.truffle.r.launcher.RCmdOptions.RCmdOption.RESTORE;
3738
import static com.oracle.truffle.r.launcher.RCmdOptions.RCmdOption.SAVE;
3839
import static com.oracle.truffle.r.launcher.RCmdOptions.RCmdOption.SILENT;
39-
import static com.oracle.truffle.r.launcher.RCmdOptions.RCmdOption.SLAVE;
4040
import static com.oracle.truffle.r.launcher.RCmdOptions.RCmdOption.VANILLA;
4141
import static com.oracle.truffle.r.launcher.RCmdOptions.RCmdOption.VERBOSE;
4242

@@ -80,13 +80,13 @@ public class RStartParams {
8080
public RStartParams(RCmdOptions options, boolean embedded) {
8181
this.embedded = embedded;
8282
this.verbose = options.getBoolean(VERBOSE);
83-
this.quiet = options.getBoolean(QUIET) || options.getBoolean(SILENT) || options.getBoolean(SLAVE);
83+
this.quiet = options.getBoolean(QUIET) || options.getBoolean(SILENT) || options.getBoolean(NO_ECHO);
8484
this.loadSiteFile = options.getBoolean(NO_SITE_FILE);
8585
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);
89-
this.slave = options.getBoolean(SLAVE);
89+
this.slave = options.getBoolean(NO_ECHO);
9090

9191
/*
9292
* GnuR behavior differs from the manual entry for {@code interactive} in that {@code

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -31,20 +31,20 @@
3131
* for consistency, we set the date to that of the corresponding GnuR release.
3232
*/
3333
public class RVersionNumber {
34-
public static final String MAJOR = "3";
35-
public static final String MINOR = "6";
36-
public static final String PATCH = "1";
34+
public static final String MAJOR = "4";
35+
public static final String MINOR = "0";
36+
public static final String PATCH = "3";
3737

38-
public static final int R_VERSION = (3 << 16) + (6 << 8) + 1;
38+
public static final int R_VERSION = (4 << 16) + (0 << 8) + 3;
3939

4040
public static final String MAJOR_MINOR = MAJOR + "." + MINOR;
4141
public static final String MINOR_PATCH = MINOR + "." + PATCH;
4242
public static final String FULL = MAJOR + "." + MINOR + "." + PATCH;
4343
public static final String R_HYPHEN_FULL = "R-" + FULL;
4444

45-
public static final String RELEASE_YEAR = "2019";
46-
public static final String RELEASE_MONTH = "07";
47-
public static final String RELEASE_DAY = "05";
45+
public static final String RELEASE_YEAR = "2020";
46+
public static final String RELEASE_MONTH = "10";
47+
public static final String RELEASE_DAY = "10";
4848

4949
public static final String RELEASE_DATE = " (" + RELEASE_YEAR + "-" + RELEASE_MONTH + "-" + RELEASE_DAY + ")";
5050

0 commit comments

Comments
 (0)