Skip to content

Commit c476ed3

Browse files
committed
[GR-13740] Define the OptionStability for all options and use --experimental-options
PullRequest: truffleruby/670
2 parents 9adecc6 + 61f773c commit c476ed3

File tree

16 files changed

+407
-262
lines changed

16 files changed

+407
-262
lines changed

ci.jsonnet

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ local part_definitions = {
3535
java_opts+:: ["-Xmx2G"],
3636
TRUFFLERUBY_CI: "true",
3737
RUBY_BENCHMARKS: "true",
38+
GRAALVM_CHECK_EXPERIMENTAL_OPTIONS: "true",
3839
JAVA_OPTS: std.join(" ", self.java_opts),
3940
PATH: std.join(":", self.path + ["$PATH"]),
4041
},

mx.truffleruby/mx_truffleruby.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def miniruby_for_building_cexts(args):
7474
jvm_args = mx.get_runtime_jvm_args(['TRUFFLERUBY', 'TRUFFLERUBY-LAUNCHER'])
7575
mx_binary = join(mx._mx_home, 'mx')
7676
options = [
77+
'--experimental-options',
7778
'--home=' + root,
7879
'--launcher=' + mx_binary + ' -p ' + root + ' miniruby_for_building_cexts',
7980
'--disable-gems'

src/launcher/java/org/truffleruby/launcher/RubyLauncher.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.graalvm.nativeimage.ProcessProperties;
1414
import org.graalvm.options.OptionCategory;
1515
import org.graalvm.polyglot.Context;
16+
import org.graalvm.polyglot.Engine;
1617
import org.graalvm.polyglot.PolyglotException;
1718
import org.graalvm.polyglot.Source;
1819
import org.truffleruby.shared.options.CommandLineOptions;
@@ -57,7 +58,7 @@ protected void validateArguments(Map<String, String> polyglotOptions) {
5758

5859
@Override
5960
protected void printVersion() {
60-
System.out.println(TruffleRuby.getVersionString(isAOT()));
61+
System.out.println(TruffleRuby.getVersionString(getImplementationNameFromEngine(), isAOT()));
6162
System.out.println();
6263
printPolyglotVersions();
6364
}
@@ -271,7 +272,7 @@ private String setRubyLauncher() {
271272

272273
private static void printPreRunInformation(CommandLineOptions config) {
273274
if ((boolean) config.getOption(OptionsCatalog.SHOW_VERSION)) {
274-
System.out.println(TruffleRuby.getVersionString(isAOT()));
275+
System.out.println(TruffleRuby.getVersionString(getImplementationNameFromEngine(), isAOT()));
275276
}
276277

277278
if ((boolean) config.getOption(OptionsCatalog.SHOW_COPYRIGHT)) {
@@ -290,6 +291,12 @@ private static void printPreRunInformation(CommandLineOptions config) {
290291
}
291292
}
292293

294+
private static String getImplementationNameFromEngine() {
295+
try (Engine engine = Engine.create()) {
296+
return engine.getImplementationName();
297+
}
298+
}
299+
293300
// To update this, use:
294301
// ruby --help | ruby -e 'puts STDIN.readlines.map{|line|"out.println(#{line.chomp.inspect});"}'
295302
// replace ruby by truffleruby for the first line, and remove unsupported flags.

src/main/java/org/truffleruby/core/CoreLibrary.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.concurrent.ConcurrentMap;
2525

2626
import com.oracle.truffle.api.CompilerDirectives;
27+
import com.oracle.truffle.api.Truffle;
2728
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
2829
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
2930
import com.oracle.truffle.api.TruffleOptions;
@@ -711,7 +712,7 @@ private void initializeConstants() {
711712
setConstant(objectClass, "RUBY_ENGINE_VERSION", frozenUSASCIIString(TruffleRuby.getEngineVersion()));
712713
setConstant(objectClass, "RUBY_PLATFORM", frozenUSASCIIString(RubyLanguage.PLATFORM));
713714
setConstant(objectClass, "RUBY_RELEASE_DATE", frozenUSASCIIString(BuildInformationImpl.INSTANCE.getCompileDate()));
714-
setConstant(objectClass, "RUBY_DESCRIPTION", frozenUSASCIIString(TruffleRuby.getVersionString(TruffleOptions.AOT)));
715+
setConstant(objectClass, "RUBY_DESCRIPTION", frozenUSASCIIString(TruffleRuby.getVersionString(Truffle.getRuntime().getName(), TruffleOptions.AOT)));
715716
setConstant(objectClass, "RUBY_COPYRIGHT", frozenUSASCIIString(TruffleRuby.RUBY_COPYRIGHT));
716717

717718
// BasicObject knows itself

src/main/java/org/truffleruby/language/backtrace/Backtrace.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public Activation[] getActivations(TruffleException truffleException) {
8989

9090
// The stacktrace is computed here if it was not already computed and stored in the
9191
// TruffleException with TruffleStackTraceElement.fillIn().
92-
final List<TruffleStackTraceElement> stackTrace = TruffleStackTrace.getStacktrace((Throwable) truffleException);
92+
final List<TruffleStackTraceElement> stackTrace = TruffleStackTrace.getStackTrace((Throwable) truffleException);
9393

9494
final List<Activation> activations = new ArrayList<>();
9595
final RubyContext context = RubyLanguage.getCurrentContext();

src/options.yml

Lines changed: 174 additions & 171 deletions
Large diffs are not rendered by default.

src/services/java/org/truffleruby/services/scriptengine/TruffleRubyScriptEngineFactory.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,7 @@ public ScriptEngine getScriptEngine() {
107107
}
108108

109109
private String query(String expression) {
110-
try (Context context = Context.newBuilder("ruby")
111-
.option("ruby.platform.native", "false")
112-
.option("ruby.rubygems", "false")
113-
.build()) {
110+
try (Context context = Context.create("ruby")) {
114111
return context.eval("ruby", expression).asString();
115112
}
116113
}

src/shared/java/org/truffleruby/shared/TruffleRuby.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
*/
1010
package org.truffleruby.shared;
1111

12-
import org.graalvm.polyglot.Engine;
13-
1412
public class TruffleRuby {
1513

1614
public static final String FORMAL_NAME = "TruffleRuby";
@@ -27,12 +25,7 @@ public class TruffleRuby {
2725
public static final String RUBY_COPYRIGHT = "truffleruby - Copyright (c) 2013-2019 Oracle and/or its affiliates";
2826
public static final boolean PRE_INITIALIZE_CONTEXTS = System.getProperty("polyglot.engine.PreinitializeContexts") != null;
2927

30-
public static String getVersionString(boolean isAOT) {
31-
final String implementationName;
32-
try (Engine engine = Engine.create()) {
33-
implementationName = engine.getImplementationName();
34-
}
35-
28+
public static String getVersionString(String implementationName, boolean isAOT) {
3629
final String vm;
3730
if (isAOT) {
3831
vm = implementationName + " Native";

0 commit comments

Comments
 (0)