Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c1f8abef8cf2
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b19ae9822e48
Choose a head ref
  • 5 commits
  • 13 files changed
  • 1 contributor

Commits on Nov 24, 2016

  1. Copy the full SHA
    0a22d9c View commit details
  2. [Truffle] Redesign the classic/truffle interface so that you don't ne…

    …ed to share an interface.
    chrisseaton committed Nov 24, 2016
    Copy the full SHA
    c8fa8cf View commit details
  3. Copy the full SHA
    110c31d View commit details
  4. Copy the full SHA
    859df66 View commit details
  5. [Truffle] Fix typo.

    chrisseaton committed Nov 24, 2016
    Copy the full SHA
    b19ae98 View commit details
29 changes: 20 additions & 9 deletions core/src/main/java/org/jruby/Main.java
Original file line number Diff line number Diff line change
@@ -61,6 +61,9 @@
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -315,7 +318,7 @@ public void run() {
} else if (config.getShouldCheckSyntax()) {
// check syntax only and exit
if (isTruffle()) {
final JRubyTruffleInterface truffle = loadTruffle();
final TruffleRubyEngineInterface truffle = loadTruffle();

try {
final int exitCode = truffle.doCheckSyntax(in, filename);
@@ -329,7 +332,7 @@ public void run() {
} else {
// proceed to run the script
if (isTruffle()) {
final JRubyTruffleInterface truffle = loadTruffle();
final TruffleRubyEngineInterface truffle = loadTruffle();

printTruffleTimeMetric("before-run");

@@ -613,7 +616,7 @@ private boolean isTruffle() {
return config.getCompileMode().isTruffle();
}

private JRubyTruffleInterface loadTruffle() {
private TruffleRubyEngineInterface loadTruffle() {
Main.printTruffleTimeMetric("before-load-context");

String javaVersion = System.getProperty("java.version");
@@ -624,26 +627,34 @@ private JRubyTruffleInterface loadTruffle() {
System.exit(1);
}

final Class<?> clazz;
final Class<?> truffleRubyEngineClass;

try {
clazz = Class.forName("org.jruby.truffle.JRubyTruffleImpl");
truffleRubyEngineClass = Class.forName("org.jruby.truffle.RubyEngine");
} catch (Exception e) {
throw new RuntimeException("JRuby's Truffle backend not available - either it was not compiled because JRuby was built with Java 7, or it has been removed", e);
}

final JRubyTruffleInterface truffleContext;
final TruffleRubyEngineInterface truffleEngine;

try {
Constructor<?> con = clazz.getConstructor(RubyInstanceConfig.class);
truffleContext = (JRubyTruffleInterface) con.newInstance(config);
final Object truffleEngineInstance = truffleRubyEngineClass.getConstructor(RubyInstanceConfig.class).newInstance(config);

truffleEngine = (TruffleRubyEngineInterface) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{TruffleRubyEngineInterface.class}, new InvocationHandler() {

@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return truffleRubyEngineClass.getMethod(method.getName(), method.getParameterTypes()).invoke(truffleEngineInstance, args);
}

});
} catch (Exception e) {
throw new RuntimeException("Error while calling the constructor of Truffle's RubyContext", e);
}

Main.printTruffleTimeMetric("after-load-context");

return truffleContext;
return truffleEngine;
}

public static void printTruffleTimeMetric(String id) {
Original file line number Diff line number Diff line change
@@ -11,9 +11,7 @@

import java.io.InputStream;

public interface JRubyTruffleInterface {

String RUNTIME_SYMBOL = "org.jruby.truffle.runtime";
public interface TruffleRubyEngineInterface {

int execute(String path);

42 changes: 0 additions & 42 deletions truffle/src/main/java/org/jruby/truffle/JRubyTruffleImpl.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.language;
package org.jruby.truffle;

import static org.jruby.util.cli.Options.TRUFFLE_ALLOCATE_CLASS_CACHE;
import static org.jruby.util.cli.Options.TRUFFLE_ARRAY_SMALL;
@@ -150,7 +150,7 @@ public class Options {
public final boolean METHODMISSING_ALWAYS_CLONE = TRUFFLE_METHODMISSING_ALWAYS_CLONE.load();
public final boolean METHODMISSING_ALWAYS_INLINE = TRUFFLE_METHODMISSING_ALWAYS_INLINE.load();

// Other tuning parameteres
// Other tuning parameters

public final int PACK_UNROLL_LIMIT = TRUFFLE_PACK_UNROLL_LIMIT.load();
public final int PACK_RECOVER_LOOP_MIN = TRUFFLE_PACK_RECOVER_LOOP_MIN.load();
1 change: 0 additions & 1 deletion truffle/src/main/java/org/jruby/truffle/RubyContext.java
Original file line number Diff line number Diff line change
@@ -36,7 +36,6 @@
import org.jruby.truffle.interop.InteropManager;
import org.jruby.truffle.language.CallStackManager;
import org.jruby.truffle.language.LexicalScope;
import org.jruby.truffle.language.Options;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.SafepointManager;
import org.jruby.truffle.language.arguments.RubyArguments;
6 changes: 3 additions & 3 deletions truffle/src/main/java/org/jruby/truffle/RubyEngine.java
Original file line number Diff line number Diff line change
@@ -12,9 +12,7 @@
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.vm.PolyglotEngine;
import org.jruby.JRubyTruffleInterface;
import org.jruby.RubyInstanceConfig;
import org.jruby.truffle.interop.InstanceConfigWrapper;
import org.jruby.truffle.platform.graal.Graal;
import org.jruby.util.cli.Options;

@@ -28,13 +26,15 @@ public class RubyEngine {
private final PolyglotEngine engine;
private final RubyContext context;

public static final String INSTANCE_CONFIG_KEY = "instance-config";

public RubyEngine(RubyInstanceConfig instanceConfig) {
if (!instanceConfig.getCompileMode().isTruffle()) {
throw new UnsupportedOperationException();
}

engine = PolyglotEngine.newBuilder()
.globalSymbol(JRubyTruffleInterface.RUNTIME_SYMBOL, new InstanceConfigWrapper(instanceConfig))
.config(RubyLanguage.MIME_TYPE, INSTANCE_CONFIG_KEY, instanceConfig)
.build();
Main.printTruffleTimeMetric("before-load-context");
context = engine.eval(loadSource("Truffle::Boot.context", "context")).as(RubyContext.class);
9 changes: 2 additions & 7 deletions truffle/src/main/java/org/jruby/truffle/RubyLanguage.java
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@
import org.jruby.RubyInstanceConfig;
import org.jruby.runtime.Constants;
import org.jruby.truffle.core.kernel.TraceManager;
import org.jruby.truffle.interop.InstanceConfigWrapper;
import org.jruby.truffle.language.LazyRubyRootNode;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.stdlib.CoverageManager;
@@ -55,16 +54,12 @@ private RubyLanguage() {

@Override
public RubyContext createContext(Env env) {
final InstanceConfigWrapper runtimeWrapper = (InstanceConfigWrapper) env.importSymbol(JRubyTruffleImpl.RUNTIME_SYMBOL);
RubyInstanceConfig instanceConfig = (RubyInstanceConfig) env.getConfig().get(RubyEngine.INSTANCE_CONFIG_KEY);

final RubyInstanceConfig instanceConfig;

if (runtimeWrapper == null) {
if (instanceConfig == null) {
instanceConfig = new RubyInstanceConfig();
instanceConfig.processArgumentsWithRubyopts();
instanceConfig.setCompileMode(RubyInstanceConfig.CompileMode.TRUFFLE);
} else {
instanceConfig = runtimeWrapper.getInstanceConfig();
}

return new RubyContext(instanceConfig, env);
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
import org.jruby.truffle.core.numeric.FixnumLowerNodeGen;
import org.jruby.truffle.language.LexicalScope;
import org.jruby.truffle.language.NotProvided;
import org.jruby.truffle.language.Options;
import org.jruby.truffle.Options;
import org.jruby.truffle.language.RubyConstant;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
import com.oracle.truffle.api.object.DynamicObject;
import org.jruby.truffle.Layouts;
import org.jruby.truffle.core.numeric.FixnumNodesFactory;
import org.jruby.truffle.language.Options;
import org.jruby.truffle.Options;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.dispatch.RubyCallNode;
import org.jruby.truffle.language.dispatch.RubyCallNodeParameters;
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
import org.jruby.truffle.core.fiber.FiberManager;
import org.jruby.truffle.core.fiber.FiberNodes;
import org.jruby.truffle.core.proc.ProcOperations;
import org.jruby.truffle.language.Options;
import org.jruby.truffle.Options;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.SafepointAction;
import org.jruby.truffle.language.SafepointManager;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@
import com.oracle.truffle.api.source.SourceSection;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.runtime.Visibility;
import org.jruby.truffle.Options;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.RubyLanguage;
import org.jruby.truffle.language.arguments.RubyArguments;
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.Options;
import org.jruby.truffle.Options;
import org.jruby.truffle.language.objects.ObjectGraph;
import org.jruby.truffle.util.SourceSectionUtils;