Skip to content

Commit 095af90

Browse files
committed
[GR-14264] Use Truffle Options stability.
PullRequest: fastr/1938
2 parents 95455fb + 6c0f8f7 commit 095af90

File tree

11 files changed

+32
-17
lines changed

11 files changed

+32
-17
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# 1.0 RC 14
22

3+
* all FastR specific options (NOT those GNU-R compatible like `--save`) are experimental except for `--R.PrintErrorStacktracesToFile`,
4+
which is an option that enables logging of FastR internal errors for bug reporting purposes. Experimental options can be unlocked
5+
using `--experimental-options` or with `ContextBuilder#allowExperimentalOptions`.
6+
37
Bug fixes:
48

59
* `C_numeric_deriv` gives wrong results of gradient #54

ci_common/common.hocon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ common : ${java8Downloads} {
104104
PKG_TEST_ENV_miniUI : "LC_ALL=C"
105105
PKG_TEST_ENV_compare : "LC_ALL=C"
106106
FASTR_OPTION_PrintErrorStacktracesToFile: "true"
107+
GRAALVM_CHECK_EXPERIMENTAL_OPTIONS : "true"
107108
}
108109
}
109110

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,26 +171,26 @@ protected void validateArguments(Map<String, String> polyglotOptions) {
171171
}
172172

173173
@Override
174-
protected void launch(Builder contextBuilder) {
174+
protected void launch(Builder contextBuilderIn) {
175175
StartupTiming.timestamp("RMain.launch");
176176
assert client != null;
177177
if (rArguments == null) {
178178
// validateArguments did not set the value
179179
return;
180180
}
181181
this.consoleHandler = ConsoleHandler.createConsoleHandler(options, null, inStream, outStream);
182-
Builder contextBuilderAllowAll = contextBuilder.allowAllAccess(true);
183-
if (ignoreJvmArguments) {
184-
contextBuilderAllowAll = contextBuilderAllowAll.allowHostAccess(useJVM);
182+
Builder contextBuilder = contextBuilderIn;
183+
if (!ignoreJvmArguments) {
184+
contextBuilder = contextBuilder.allowHostAccess(useJVM);
185185
}
186186

187187
Context context;
188188
String tracedLibs = System.getenv("DEBUG_LLVM_LIBS");
189189
if (tracedLibs != null) {
190-
context = preparedContext = contextBuilderAllowAll.option("inspect", "true").option("llvm.enableLVI", "true").option("llvm.llDebug", "true").arguments("R", rArguments).in(
190+
context = preparedContext = contextBuilder.option("inspect", "true").option("llvm.enableLVI", "true").option("llvm.llDebug", "true").arguments("R", rArguments).in(
191191
consoleHandler.createInputStream()).out(outStream).err(errStream).build();
192192
} else {
193-
context = preparedContext = contextBuilderAllowAll.arguments("R", rArguments).in(consoleHandler.createInputStream()).out(outStream).err(errStream).build();
193+
context = preparedContext = contextBuilder.arguments("R", rArguments).in(consoleHandler.createInputStream()).out(outStream).err(errStream).build();
194194
}
195195

196196
this.consoleHandler.setContext(context);

com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/castsTests/CastBuilderTest.java

Lines changed: 2 additions & 2 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, 2019, 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
@@ -939,7 +939,7 @@ public void testCastForeignObjectDisabled() {
939939
}
940940

941941
private static void execInContext(Runnable r) {
942-
Context context = Context.newBuilder("R", "llvm").allowAllAccess(true).build();
942+
Context context = Context.newBuilder("R", "llvm").allowExperimentalOptions(true).allowAllAccess(true).build();
943943
context.eval("R", "1"); // initialize context
944944
context.enter();
945945
try {

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.graalvm.options.OptionDescriptor;
3939
import org.graalvm.options.OptionDescriptors;
4040
import org.graalvm.options.OptionKey;
41+
import org.graalvm.options.OptionStability;
4142
import org.graalvm.options.OptionValues;
4243

4344
/**
@@ -56,7 +57,7 @@ public class FastROptions {
5657

5758
@Option(category = OptionCategory.INTERNAL, help = "Prints Java and R stack traces for all errors") //
5859
public static final OptionKey<Boolean> PrintErrorStacktraces = new OptionKey<>(false);
59-
@Option(category = OptionCategory.USER, help = "Dumps Java and R stack traces to 'fastr_errors.log' for all errors") //
60+
@Option(category = OptionCategory.USER, stability = OptionStability.STABLE, help = "Dumps Java and R stack traces to 'fastr_errors-{context ID}_{PID}.log' for all internal errors") //
6061
public static final OptionKey<Boolean> PrintErrorStacktracesToFile = new OptionKey<>(false);
6162

6263
@Option(category = OptionCategory.INTERNAL, help = "Debug=name1,name2,...; Turn on debugging output for 'name1', 'name2', etc.")//
@@ -83,7 +84,7 @@ public class FastROptions {
8384
public static final OptionKey<Boolean> SearchPathForcePromises = new OptionKey<>(false);
8485
@Option(category = OptionCategory.EXPERT, help = "Load native code of packages, including builtin packages.") //
8586
public static final OptionKey<Boolean> LoadPackagesNativeCode = new OptionKey<>(!FastRConfig.ManagedMode);
86-
@Option(category = OptionCategory.EXPERT, help = "Allow only one thread to enter packages' native code") //
87+
@Option(category = OptionCategory.EXPERT, help = "Allow only one thread to enter native code of packages") //
8788
public static final OptionKey<Boolean> SynchronizeNativeCode = new OptionKey<>(true);
8889
// Promises optimizations
8990
@Option(category = OptionCategory.INTERNAL, help = "If enabled, overrides all other EagerEval switches (see EagerEvalHelper)") //
@@ -114,9 +115,9 @@ public class FastROptions {
114115
// Dicontinued since rc12
115116
// only a warning is printed to use the default logger mechaninsm
116117
// TODO remove at some later point
117-
@Option(category = OptionCategory.INTERNAL, help = "Print FastR performance warning") //
118+
@Option(category = OptionCategory.EXPERT, help = "Print FastR performance warning") //
118119
public static final OptionKey<Boolean> PerformanceWarnings = new OptionKey<>(false);
119-
@Option(category = OptionCategory.INTERNAL, help = "Print a message for each non-trivial variable lookup")//
120+
@Option(category = OptionCategory.EXPERT, help = "Print a message for each non-trivial variable lookup")//
120121
public static final OptionKey<Boolean> PrintComplexLookups = new OptionKey<>(false);
121122
@Option(category = OptionCategory.INTERNAL, help = "Trace all R function calls") //
122123
public static final OptionKey<Boolean> TraceCalls = new OptionKey<>(false);

com.oracle.truffle.r.test.packages/r/install.packages.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2015, 2019, 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
@@ -204,7 +204,7 @@ fastr.test.jvm.args <- function() {
204204
return (opts)
205205
}
206206
})
207-
return ("'--R.IgnoreGraphicsCalls=true'")
207+
return ("'--experimental-options --R.IgnoreGraphicsCalls=true'")
208208
}
209209

210210
# returns a vector of package names that are the direct dependents of pkg
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
--experimental-options
12
--R.IgnoreGraphicsCalls
23
--R.AdditionalOptions=vdiffr_skip:T;svUnit.recordAll:F;svUnit.minTiming:10000;crayon.enabled:F

com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/generate/FastRSession.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public Context createContext(ContextKind contextKind, boolean allowHostAccess) {
136136
}
137137

138138
public static Context.Builder getContextBuilder(String... languages) {
139-
Context.Builder builder = Context.newBuilder(languages);
139+
Context.Builder builder = Context.newBuilder(languages).allowExperimentalOptions(true);
140140
setCLIOptions(builder);
141141
builder.allowAllAccess(true);
142142
// no point in printing errors to file when running tests (that contain errors on purpose)

documentation/dev/managed_ffi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ Note that boolean FastR options are prefixed with the language id "R" and passed
2222
aforementioned options:
2323

2424
```
25-
mx --J @'-Dfastr.rffi.factory.type=managed' r --R.LoadPackagesNativeCode=true --R.LoadProfiles=true
25+
mx --J @'-Dfastr.rffi.factory.type=managed' r --experimental-options --R.LoadPackagesNativeCode=true --R.LoadProfiles=true
2626
```

mx.fastr/mx_fastr.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def do_run_r(args, command, extraVmArgs=None, jdk=None, **kwargs):
9595

9696
vmArgs += set_graal_options()
9797
vmArgs += _sulong_options()
98+
args = _sulong_args() + args
9899

99100
if extraVmArgs is None or not '-da' in extraVmArgs:
100101
# unless explicitly disabled we enable assertion checking
@@ -148,6 +149,13 @@ def set_graal_options():
148149
else:
149150
return []
150151

152+
def _sulong_args():
153+
mx_sulong = mx.suite("sulong", fatalIfMissing=False)
154+
if mx_sulong:
155+
return ['--experimental-options']
156+
else:
157+
return []
158+
151159
def _sulong_options():
152160
mx_sulong = mx.suite("sulong", fatalIfMissing=False)
153161
if mx_sulong:

0 commit comments

Comments
 (0)