Skip to content

Commit

Permalink
Showing 132 changed files with 1,595 additions and 809 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -224,7 +224,7 @@ public class Options {
public static final Option<Boolean> TRUFFLE_COVERAGE_GLOBAL = bool(TRUFFLE, "truffle.coverage.global", false, "Run coverage for all code and print results on exit.");

public static final Option<String> TRUFFLE_CORE_LOAD_PATH = string(TRUFFLE, "truffle.core.load_path", "truffle:/jruby-truffle", "Location to load the Truffle core library from.");
public static final Option<Boolean> TRUFFLE_POSIX_USE_JAVA = bool(TRUFFLE, "truffle.posix.use_java", false, "Use a Java emulation of POSIX.");
public static final Option<Boolean> TRUFFLE_PLATFORM_USE_JAVA = bool(TRUFFLE, "truffle.platform.use_java", false, "Use a pure-Java platform, so no native POSIX.");

public static final Option<Integer> TRUFFLE_ARRAY_UNINITIALIZED_SIZE = integer(TRUFFLE, "truffle.array.uninitialized_size", 32, "How large an Array to allocate when we have no other information to go on.");
public static final Option<Integer> TRUFFLE_ARRAY_SMALL = integer(TRUFFLE, "truffle.array.small", 3, "Maximum size of an Array to consider small for optimisations.");
3 changes: 3 additions & 0 deletions test/truffle/integration/java-platform.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

ruby -X+T -Xtruffle.platform.use_java=true -e 'puts 14'
18 changes: 15 additions & 3 deletions truffle/src/main/java/org/jruby/truffle/JRubyTruffleImpl.java
Original file line number Diff line number Diff line change
@@ -13,6 +13,9 @@
import com.oracle.truffle.api.vm.PolyglotEngine;
import org.jruby.JRubyTruffleInterface;
import org.jruby.Ruby;
import org.jruby.truffle.interop.JRubyContextWrapper;
import org.jruby.truffle.platform.Graal;
import org.jruby.util.cli.Options;

import java.io.IOException;

@@ -21,9 +24,10 @@ public class JRubyTruffleImpl implements JRubyTruffleInterface {
private final PolyglotEngine engine;
private final RubyContext context;

// Run by reflection from Ruby#loadTruffle
// Created by reflection from Ruby#loadTruffle

public JRubyTruffleImpl(Ruby runtime) {
engine = PolyglotEngine.newBuilder().globalSymbol(JRubyTruffleInterface.RUNTIME_SYMBOL, new RubyLanguage.JRubyContextWrapper(runtime)).build();
engine = PolyglotEngine.newBuilder().globalSymbol(JRubyTruffleInterface.RUNTIME_SYMBOL, new JRubyContextWrapper(runtime)).build();

try {
context = (RubyContext) engine.eval(Source.fromText("Truffle::Primitive.context", "context").withMimeType(RubyLanguage.MIME_TYPE)).get();
@@ -34,10 +38,17 @@ public JRubyTruffleImpl(Ruby runtime) {

@Override
public Object execute(org.jruby.ast.RootNode rootNode) {
if (!Graal.isGraal() && Options.TRUFFLE_GRAAL_WARNING_UNLESS.load()) {
System.err.println("WARNING: This JVM does not have the Graal compiler. " +
"JRuby+Truffle's performance without it will be limited. " +
"See https://github.com/jruby/jruby/wiki/Truffle-FAQ#how-do-i-get-jrubytruffle");
}

context.setInitialJRubyRootNode(rootNode);

try {
return engine.eval(Source.fromText("Truffle::Primitive.run_jruby_root", "run_jruby_root").withMimeType(RubyLanguage.MIME_TYPE)).get();
return engine.eval(Source.fromText("Truffle::Primitive.run_jruby_root", "run_jruby_root")
.withMimeType(RubyLanguage.MIME_TYPE)).get();
} catch (IOException e) {
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException) e.getCause();
@@ -51,4 +62,5 @@ public Object execute(org.jruby.ast.RootNode rootNode) {
public void dispose() {
engine.dispose();
}

}
Loading

0 comments on commit 56fa2e8

Please sign in to comment.