Skip to content

Commit 3544d33

Browse files
committed
Avoid creating an Engine during RubyLauncher.preprocessArguments()
PullRequest: truffleruby/522
2 parents 62bb601 + 88e3f79 commit 3544d33

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

spec/tags/truffle/launcher_tags.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,4 @@ slow:The launcher does not create context on --version and -v
6262
aot(no sulong):The launcher 'gem' in `RbConfig::CONFIG['bindir']` directory runs when symlinked
6363
aot(no sulong):The launcher 'gem' in `RbConfig::CONFIG['extra_bindirs'][0]` directory runs when symlinked
6464
aot(no sulong):The launcher 'gem' in `RbConfig::CONFIG['extra_bindirs'][1]` directory runs when symlinked
65+
slow:The launcher applies Truffle options

spec/truffle/launcher_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,4 +280,15 @@ def should_print_full_java_command(options, env: {})
280280
out.should include(':b')
281281
end
282282

283+
guard -> { TruffleRuby.graal? } do
284+
it "applies Truffle options" do
285+
prefix = TruffleRuby.native? ? '--native.' : '--jvm.'
286+
options = [
287+
"#{prefix}Dgraal.TraceTruffleCompilation=true",
288+
"#{prefix}Dgraal.TruffleBackgroundCompilation=false",
289+
].join(" ")
290+
out = ruby_exe("2000.times {}", options: options, args: "2>&1")
291+
out.should include("[truffle] opt done")
292+
end
293+
end
283294
end

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.graalvm.nativeimage.ProcessProperties;
1414
import org.graalvm.options.OptionCategory;
1515
import org.graalvm.polyglot.Context;
16-
import org.graalvm.polyglot.Engine;
1716
import org.graalvm.polyglot.PolyglotException;
1817
import org.graalvm.polyglot.Source;
1918
import org.truffleruby.launcher.options.CommandLineException;
@@ -44,12 +43,6 @@ public static void main(String[] args) {
4443
new RubyLauncher().launch(args);
4544
}
4645

47-
static boolean isSulongAvailable() {
48-
try (Engine engine = Engine.create()) {
49-
return engine.getLanguages().containsKey(TruffleRuby.LLVM_ID);
50-
}
51-
}
52-
5346
@Override
5447
protected String getLanguageId() {
5548
return TruffleRuby.LANGUAGE_ID;
@@ -121,7 +114,7 @@ protected List<String> preprocessArguments(List<String> args, Map<String, String
121114
}
122115

123116
// In a native standalone distribution outside of GraalVM, we need to give the path to libsulong
124-
if (!isGraalVMAvailable() && isSulongAvailable()) {
117+
if (!isGraalVMAvailable()) { // TODO (eregon, 9 Jan 2019): This should check if Sulong is available.
125118
final String rubyHome = new File(launcher).getParentFile().getParent();
126119
final String libSulongPath = rubyHome + "/lib/cext/sulong-libs";
127120

0 commit comments

Comments
 (0)