Skip to content

Commit 070d3bc

Browse files
eregonfniephaus
authored andcommitted
[GR-66817] Remove the need to use --polyglot to enable other languages in the jvm standalones
PullRequest: truffleruby/4587
2 parents 637216b + cfda106 commit 070d3bc

File tree

14 files changed

+9
-73
lines changed

14 files changed

+9
-73
lines changed

doc/contributor/workflow.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,10 @@ git clone https://github.com/graalvm/graalpython.git ../graalpython
250250
jt build --env jvm-py
251251
```
252252

253-
Then, run TruffleRuby with `--polyglot` support and evaluate some JavaScript:
253+
Then, run TruffleRuby and evaluate some JavaScript:
254254

255255
```bash
256-
$ jt --use jvm-js ruby --polyglot
256+
$ jt --use jvm-js ruby
257257
> Polyglot.eval('js', 'var a = 1; a + 1')
258258
=> 2
259259
```

doc/user/deploying.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ The advantages of the native configuration are that it [starts about as fast as
2020
The disadvantages are that you can't use Java tools like VisualVM, it is less convenient for Java interoperability (see the details [here](compatibility.md#java-interoperability-with-the-native-configuration)), and *peak performance may be lower than on the JVM*.
2121

2222
The native configuration is used by default, but you can also request it using `--native`.
23-
To use polyglot programming with the *native* configuration, you need to pass the `--polyglot` flag.
2423

2524
### JVM Configuration
2625

doc/user/options.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,8 @@ Warning categories:
5555
performance performance issues
5656
5757
Runtime options:
58-
--polyglot Run with all other guest languages accessible.
59-
--native Run using the native launcher with limited access to Java libraries
60-
(default).
61-
--jvm Run on the Java Virtual Machine with access to Java libraries.
58+
--native Ensure to run in Native mode.
59+
--jvm Ensure to run in JVM mode.
6260
--vm.[option] Pass options to the host VM. To see available options, use '--help:vm'.
6361
--log.file=<String> Redirect guest languages logging into a given file.
6462
--log.[logger].level=<String> Set language log level to OFF, SEVERE, WARNING, INFO, CONFIG, FINE,

doc/user/polyglot.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ TruffleRuby allows you to interface with any other Truffle language to create po
44

55
This guide describes how to load code written in foreign languages, how to export and import objects between languages, how to use Ruby objects from a foreign language, how to use foreign objects from Ruby, how to load Java types to interface with Java, and how to embed in Java.
66

7-
If you are using the native configuration, you will need to use the `--polyglot` flag to get access to other languages.
8-
The JVM configuration automatically has access to other languages.
9-
107
* [Running Ruby code from another language](#running-ruby-code-from-another-language)
118
* [Loading code written in foreign languages](#loading-code-written-in-foreign-languages)
129
* [Exporting Ruby objects to foreign languages](#exporting-ruby-objects-to-foreign-languages)
@@ -44,8 +41,6 @@ This is similar to most REPL semantics.
4441

4542
## Loading Code Written in Foreign Languages
4643

47-
Note the ruby command line needs to be passed `--polyglot` to enable access to foreign languages.
48-
4944
`Polyglot.eval(id, string)` executes code in a foreign language identified by its ID.
5045

5146
`Polyglot.eval_file(id, path)` executes code in a foreign language from a file, identified by its language ID.

mx.truffleruby/suite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
{
2323
"name": "regex",
2424
"subdir": True,
25-
"version": "462a5b312605cd780b9f26e43f8062e83a0dc3d0",
25+
"version": "bf93eb7ebf60a975203a55c243c00055ef572c06",
2626
"urls": [
2727
{"url": "https://github.com/oracle/graal.git", "kind": "git"},
2828
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},
@@ -31,7 +31,7 @@
3131
{
3232
"name": "sulong",
3333
"subdir": True,
34-
"version": "462a5b312605cd780b9f26e43f8062e83a0dc3d0",
34+
"version": "bf93eb7ebf60a975203a55c243c00055ef572c06",
3535
"urls": [
3636
{"url": "https://github.com/oracle/graal.git", "kind": "git"},
3737
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},

spec/tags/truffle/interop/languages_tags.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

spec/truffle/interop/languages_spec.rb

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,6 @@
1010

1111
describe "Truffle::Interop.languages" do
1212
it "returns the public languages" do
13-
Truffle::Interop.languages.should.include?('ruby')
14-
end
15-
16-
it "returns only ruby from the RubyLauncher" do
17-
# Use RbConfig.ruby to remove a potential --polyglot option
18-
`#{RbConfig.ruby} -e 'p Truffle::Interop.languages'`.should == "[\"ruby\"]\n"
19-
end
20-
end
21-
22-
describe "Truffle::Interop.other_languages?" do
23-
guard_not -> { TruffleRuby.native? } do
24-
it "returns true with --polyglot" do
25-
ruby_exe('p Truffle::Interop.other_languages?', options: '--polyglot').should == "true\n"
26-
end
27-
end
28-
29-
it "returns false without --polyglot" do
30-
# Use RbConfig.ruby to remove a potential --polyglot option
31-
`#{RbConfig.ruby} -e 'p Truffle::Interop.other_languages?'`.should == "false\n"
13+
Truffle::Interop.languages.sort.should == %w[llvm ruby]
3214
end
3315
end

spec/truffle/launcher_spec.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,6 @@ def should_print_full_java_command(options, env: {})
340340
else
341341
out.should include("--jvm")
342342
end
343-
344-
unless TruffleRuby.native?
345-
# This is only shown in JVM standalones
346-
out.should include("--polyglot")
347-
end
348343
end
349344

350345
it "prints help:ruby containing ruby language options" do

src/main/java/org/truffleruby/RubyContext.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ public final class RubyContext {
101101
@CompilationFinal private TruffleLanguage.Env env;
102102
@CompilationFinal private PrintStream outStream;
103103
@CompilationFinal private PrintStream errStream;
104-
@CompilationFinal private boolean hasOtherPublicLanguages;
105104

106105
@CompilationFinal public TruffleLogger logger;
107106
@CompilationFinal private Options options;
@@ -399,7 +398,6 @@ private void setEnv(Env env) {
399398
this.outStream = printStreamFor(env.out());
400399
this.errStream = printStreamFor(env.err());
401400
this.logger = env.getLogger("");
402-
this.hasOtherPublicLanguages = computeHasOtherPublicLanguages(env);
403401
this.preInitializing = env.isPreInitialization();
404402
}
405403

@@ -411,19 +409,6 @@ private static PrintStream printStreamFor(OutputStream outputStream) {
411409
}
412410
}
413411

414-
private static boolean computeHasOtherPublicLanguages(Env env) {
415-
for (String language : env.getPublicLanguages().keySet()) {
416-
if (!language.equals(TruffleRuby.LANGUAGE_ID)) {
417-
return true;
418-
}
419-
}
420-
return false;
421-
}
422-
423-
public boolean hasOtherPublicLanguages() {
424-
return hasOtherPublicLanguages;
425-
}
426-
427412
private long generateHashingSeed() {
428413
if (options.HASHING_DETERMINISTIC) {
429414
RubyLanguage.LOGGER.severe(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void processReferenceQueue(ReferenceProcessingService<?, ?> service) {
9797
}
9898

9999
public boolean processOnMainThread() {
100-
return context.getOptions().SINGLE_THREADED || context.hasOtherPublicLanguages();
100+
return context.getOptions().SINGLE_THREADED;
101101
}
102102

103103
private static final String THREAD_NAME = "Ruby-reference-processor";

0 commit comments

Comments
 (0)