Skip to content

Commit 2291566

Browse files
committed
Cleanup TruffleRuby.graalvm_home it is always nil now
* Specifically it is nil in JVM & Native standalones. * Legacy GraalVMs with languages inside are no longer supported. * The method is kept since this is public API.
1 parent 1ffd279 commit 2291566

File tree

3 files changed

+4
-69
lines changed

3 files changed

+4
-69
lines changed

doc/user/truffleruby-additions.md

-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ TruffleRuby provides these non-standard methods and classes that provide additio
3838

3939
* `TruffleRuby.full_memory_barrier` ensures lack of reordering of loads or stores before the barrier with loads or stores after the barrier.
4040

41-
* `TruffleRuby.graalvm_home` returns the GraalVM home or `nil` if running outside of GraalVM (e.g., Native standalone).
42-
4341
* `TruffleRuby.synchronized(object) { }` will run the block while holding an implicit lock per object instance.
4442

4543
### Atomic References

spec/truffle/launcher_spec.rb

+2-51
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ def should_print_full_java_command(options, env: {})
341341
out.should include("--jvm")
342342
end
343343

344-
if TruffleRuby.graalvm_home or !TruffleRuby.native?
345-
# These options are only shown in GraalVM, they are not available in a native standalone
344+
unless TruffleRuby.native?
345+
# This is only shown in JVM standalones
346346
out.should include("--polyglot")
347347
end
348348
end
@@ -417,53 +417,4 @@ def should_print_full_java_command(options, env: {})
417417
out.should == 'bar'
418418
end
419419
end
420-
421-
guard -> {
422-
# GraalVM with both --jvm and --native
423-
defined?(::TruffleRuby) and TruffleRuby.graalvm_home and TruffleRuby.native?
424-
} do
425-
describe "runtime configuration flags" do
426-
before :each do
427-
@trufflerubyopt = ENV['TRUFFLERUBYOPT']
428-
# remove --native/--jvm from $TRUFFLERUBYOPT as they can conflict with command line arguments for these specs
429-
ENV['TRUFFLERUBYOPT'] = @trufflerubyopt.to_s.gsub(/--(native|jvm)\b/, '')
430-
end
431-
432-
after :each do
433-
ENV['TRUFFLERUBYOPT'] = @trufflerubyopt
434-
end
435-
436-
['RUBYOPT', 'TRUFFLERUBYOPT'].each do |var|
437-
it "should recognize ruby --vm options in #{var} when switching to JVM" do
438-
env = { var => "--jvm #{@ignore_jvm_thread_warnings} --vm.Dfoo=bar" } # ignoring the original value of RUBYOPT/TRUFFLERUBYOPT on purpose here
439-
out = ruby_exe('puts RUBY_DESCRIPTION; puts Truffle::System.get_java_property("foo")', env: env, args: @redirect)
440-
check_status_and_empty_stderr
441-
out = out.lines.map(&:chomp)
442-
out[0].should =~ /(GraalVM CE|Oracle GraalVM) JVM/
443-
out[1].should == 'bar'
444-
end
445-
end
446-
447-
it "uses --native by default" do
448-
out = ruby_exe(nil, options: "--version", args: @redirect)
449-
check_status_and_empty_stderr
450-
out.should =~ /(GraalVM CE|Oracle GraalVM) Native/
451-
end
452-
453-
it "switches to JVM with --jvm as a Ruby argument" do
454-
out = ruby_exe(nil, options: "--jvm #{@ignore_jvm_thread_warnings} --version", args: @redirect)
455-
check_status_and_empty_stderr
456-
out.should =~ /(GraalVM CE|Oracle GraalVM) JVM/
457-
end
458-
459-
it "keeps --jvm as an application argument if given as an application argument" do
460-
script = fixture(__FILE__, "argv.rb")
461-
out = ruby_exe(nil, options: "-v", args: "#{script} --jvm 1 2 #{@redirect}")
462-
check_status_and_empty_stderr
463-
out = out.lines.map(&:chomp)
464-
out[0].should =~ /(GraalVM CE|Oracle GraalVM) Native/
465-
out.should.include?('["--jvm", "1", "2"]')
466-
end
467-
end
468-
end
469420
end

src/main/java/org/truffleruby/extra/TruffleRubyNodes.java

+2-16
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import com.oracle.truffle.api.nodes.Node;
1818
import com.oracle.truffle.api.object.DynamicObjectLibrary;
1919
import com.oracle.truffle.api.profiles.InlinedBranchProfile;
20-
import com.oracle.truffle.api.strings.TruffleString;
2120
import org.truffleruby.Layouts;
2221
import org.truffleruby.RubyContext;
2322
import org.truffleruby.RubyLanguage;
@@ -26,7 +25,6 @@
2625
import org.truffleruby.builtins.CoreMethodArrayArgumentsNode;
2726
import org.truffleruby.builtins.CoreMethodNode;
2827
import org.truffleruby.annotations.CoreModule;
29-
import org.truffleruby.core.encoding.Encodings;
3028
import org.truffleruby.core.mutex.MutexOperations;
3129
import org.truffleruby.core.proc.RubyProc;
3230

@@ -48,21 +46,9 @@ public abstract class TruffleRubyNodes {
4846
public abstract static class GraalvmHomeNode extends CoreMethodArrayArgumentsNode {
4947

5048
@Specialization
51-
Object graalvmHome(
52-
@Cached TruffleString.FromJavaStringNode fromJavaStringNode) {
53-
String value = getProperty("org.graalvm.home");
54-
if (value == null) {
55-
return nil;
56-
} else {
57-
return createString(fromJavaStringNode, value, Encodings.UTF_8);
58-
}
59-
}
60-
61-
@TruffleBoundary
62-
private static String getProperty(String key) {
63-
return System.getProperty(key);
49+
Object graalvmHome() {
50+
return nil;
6451
}
65-
6652
}
6753

6854
@CoreMethod(names = "jit?", onSingleton = true)

0 commit comments

Comments
 (0)