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: 289b48d83cd2
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6e934143e571
Choose a head ref
  • 3 commits
  • 9 files changed
  • 1 contributor

Commits on May 9, 2015

  1. Copy the full SHA
    ec31a17 View commit details
  2. Copy the full SHA
    49aafeb View commit details
  3. Copy the full SHA
    6e93414 View commit details
3 changes: 1 addition & 2 deletions core/src/main/java/org/jruby/Main.java
Original file line number Diff line number Diff line change
@@ -45,7 +45,6 @@
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.SafePropertyAccessor;
import org.jruby.util.cli.Options;
import org.jruby.util.cli.OutputStrings;
import org.jruby.util.log.Logger;
import org.jruby.util.log.LoggerFactory;
@@ -401,7 +400,7 @@ private Status doRunFromMain(Ruby runtime, InputStream in, String filename) {

runtime.runFromMain(in, filename);

runtime.shutdownTruffleBridge();
runtime.shutdownTruffleContext();

} catch (RaiseException rj) {
return new Status(handleRaiseException(rj));
38 changes: 19 additions & 19 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -849,7 +849,8 @@ public IRubyObject runScriptBody(Script script) {
public IRubyObject runInterpreter(ThreadContext context, ParseResult parseResult, IRubyObject self) {
if (getInstanceConfig().getCompileMode() == CompileMode.TRUFFLE) {
assert parseResult instanceof RootNode;
getTruffleBridge().execute(getTruffleBridge().toTruffle(self), (RootNode) parseResult);
assert self == getTopSelf();
getTruffleContext().execute((RootNode) parseResult);
return getNil();
} else {
try {
@@ -865,7 +866,8 @@ public IRubyObject runInterpreter(ThreadContext context, Node rootNode, IRubyObj

if (getInstanceConfig().getCompileMode() == CompileMode.TRUFFLE) {
assert rootNode instanceof RootNode;
getTruffleBridge().execute(getTruffleBridge().toTruffle(self), (RootNode) rootNode);
assert self == getTopSelf();
getTruffleContext().execute((RootNode) rootNode);
return getNil();
} else {
try {
@@ -909,42 +911,40 @@ public JITCompiler getJITCompiler() {
return jitCompiler;
}

public TruffleBridge getTruffleBridge() {
synchronized (truffleBridgeMutex) {
if (truffleBridge == null) {
truffleBridge = loadTruffleBridge();
public TruffleContextInterface getTruffleContext() {
synchronized (truffleContextMonitor) {
if (truffleContext == null) {
truffleContext = loadTruffleContext();
}
return truffleBridge;
return truffleContext;
}
}

private TruffleBridge loadTruffleBridge() {
private TruffleContextInterface loadTruffleContext() {
final Class<?> clazz;

try {
clazz = getJRubyClassLoader().loadClass("org.jruby.truffle.TruffleBridgeImpl");
clazz = getJRubyClassLoader().loadClass("org.jruby.truffle.runtime.RubyContext");
} catch (Exception e) {
throw new UnsupportedOperationException("Truffle classes not available", e);
}

final TruffleBridge truffleBridge;
final TruffleContextInterface truffleBridge;

try {
Constructor<?> con = clazz.getConstructor(Ruby.class);
truffleBridge = (TruffleBridge) con.newInstance(this);
truffleBridge = (TruffleContextInterface) con.newInstance(this);
} catch (Exception e) {
throw new UnsupportedOperationException("Error while calling the constructor of TruffleBridgeImpl", e);
}

truffleBridge.init();

return truffleBridge;
}

public void shutdownTruffleBridge() {
synchronized (truffleBridgeMutex) {
if (truffleBridge != null) {
truffleBridge.shutdown();
public void shutdownTruffleContext() {
synchronized (truffleContextMonitor) {
if (truffleContext != null) {
truffleContext.shutdown();
}
}
}
@@ -4926,8 +4926,8 @@ public FilenoUtil getFilenoUtil() {
// Compilation
private final JITCompiler jitCompiler;

private TruffleBridge truffleBridge;
private final Object truffleBridgeMutex = new Object();
private TruffleContextInterface truffleContext;
private final Object truffleContextMonitor = new Object();

// Note: this field and the following static initializer
// must be located be in this order!
Original file line number Diff line number Diff line change
@@ -9,22 +9,15 @@
*/
package org.jruby;

import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;

public interface TruffleBridge {
public interface TruffleContextInterface {

enum BacktraceFormatter {
MRI,
DEBUG,
IMPL_DEBUG
}

void init();

Object execute(Object self, org.jruby.ast.RootNode rootNode);

Object toTruffle(IRubyObject object);
Object execute(org.jruby.ast.RootNode rootNode);

void shutdown();

10 changes: 5 additions & 5 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@
import java.util.HashSet;

import com.headius.options.Option;
import org.jruby.TruffleBridge;
import org.jruby.TruffleContextInterface;
import org.jruby.runtime.Constants;
import org.jruby.util.KCode;
import org.jruby.util.SafePropertyAccessor;
@@ -155,10 +155,10 @@ public class Options {
public static final Option<Boolean> TRUFFLE_RANDOMIZE_STORAGE_ARRAY = bool(TRUFFLE, "truffle.randomize_storage.array", false, "Randomize Array storage strategy.");
public static final Option<Integer> TRUFFLE_RANDOMIZE_SEED = integer(TRUFFLE, "truffle.randomize.seed", 0, "Seed for any randomization.");

public static final Option<TruffleBridge.BacktraceFormatter> TRUFFLE_BACKTRACE_DISPLAY_FORMAT = enumeration(TRUFFLE, "truffle.backtrace.display_format", TruffleBridge.BacktraceFormatter.class, TruffleBridge.BacktraceFormatter.MRI, "How to format backtraces displayed to the user.");
public static final Option<TruffleBridge.BacktraceFormatter> TRUFFLE_BACKTRACE_DEBUG_FORMAT = enumeration(TRUFFLE, "truffle.backtrace.debug_format", TruffleBridge.BacktraceFormatter.class, TruffleBridge.BacktraceFormatter.DEBUG, "How to format backtraces displayed using TruffleDebug.dump_call_stack.");
public static final Option<TruffleBridge.BacktraceFormatter> TRUFFLE_BACKTRACE_EXCEPTION_FORMAT = enumeration(TRUFFLE, "truffle.backtrace.exception_format", TruffleBridge.BacktraceFormatter.class, TruffleBridge.BacktraceFormatter.MRI, "How to format backtraces in Exception objects.");
public static final Option<TruffleBridge.BacktraceFormatter> TRUFFLE_BACKTRACE_PANIC_FORMAT = enumeration(TRUFFLE, "truffle.backtrace.panic_format", TruffleBridge.BacktraceFormatter.class, TruffleBridge.BacktraceFormatter.IMPL_DEBUG, "How to format backtraces in panics.");
public static final Option<TruffleContextInterface.BacktraceFormatter> TRUFFLE_BACKTRACE_DISPLAY_FORMAT = enumeration(TRUFFLE, "truffle.backtrace.display_format", TruffleContextInterface.BacktraceFormatter.class, TruffleContextInterface.BacktraceFormatter.MRI, "How to format backtraces displayed to the user.");
public static final Option<TruffleContextInterface.BacktraceFormatter> TRUFFLE_BACKTRACE_DEBUG_FORMAT = enumeration(TRUFFLE, "truffle.backtrace.debug_format", TruffleContextInterface.BacktraceFormatter.class, TruffleContextInterface.BacktraceFormatter.DEBUG, "How to format backtraces displayed using TruffleDebug.dump_call_stack.");
public static final Option<TruffleContextInterface.BacktraceFormatter> TRUFFLE_BACKTRACE_EXCEPTION_FORMAT = enumeration(TRUFFLE, "truffle.backtrace.exception_format", TruffleContextInterface.BacktraceFormatter.class, TruffleContextInterface.BacktraceFormatter.MRI, "How to format backtraces in Exception objects.");
public static final Option<TruffleContextInterface.BacktraceFormatter> TRUFFLE_BACKTRACE_PANIC_FORMAT = enumeration(TRUFFLE, "truffle.backtrace.panic_format", TruffleContextInterface.BacktraceFormatter.class, TruffleContextInterface.BacktraceFormatter.IMPL_DEBUG, "How to format backtraces in panics.");
public static final Option<Integer> TRUFFLE_BACKTRACE_MAX_VALUE_LENGTH = integer(TRUFFLE, "truffle.backtrace.max_value_length", 20, "Max length for values when displayed in a backtrace.");
public static final Option<Boolean> TRUFFLE_BACKTRACE_GENERATE = bool(TRUFFLE, "truffle.backtrace.generate", true, "Generate backtraces on exceptions.");

218 changes: 0 additions & 218 deletions truffle/src/main/java/org/jruby/truffle/TruffleBridgeImpl.java

This file was deleted.

Loading