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: 1359326e7eae
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 053e1d0d0f92
Choose a head ref
  • 7 commits
  • 33 files changed
  • 1 contributor

Commits on Nov 15, 2016

  1. Copy the full SHA
    d241260 View commit details
  2. Copy the full SHA
    46159ab View commit details
  3. Copy the full SHA
    3afa6d8 View commit details
  4. [Truffle] --stress compiler option (compile immediately, background c…

    …ompilation, exceptions are fatal).
    chrisseaton committed Nov 15, 2016
    2
    Copy the full SHA
    cdb958e View commit details
  5. Copy the full SHA
    6d30397 View commit details
  6. Copy the full SHA
    891e7b6 View commit details
  7. [Truffle] Use Java 8 date/time instead of Joda.

    Still one use of Joda, and a couple of spec regressions.
    chrisseaton committed Nov 15, 2016
    Copy the full SHA
    053e1d0 View commit details
Showing with 471 additions and 304 deletions.
  1. +1 −0 bin/jruby.bash
  2. +5 −1 core/src/main/java/org/jruby/JRubyTruffleInterface.java
  3. +80 −11 core/src/main/java/org/jruby/Main.java
  4. +19 −95 core/src/main/java/org/jruby/Ruby.java
  5. +0 −2 core/src/main/java/org/jruby/ir/interpreter/Interpreter.java
  6. +1 −1 lib/ruby/truffle/truffle/truffle/execjs.rb
  7. +9 −3 mx.jruby/mx_jruby.py
  8. +1 −1 samples/truffle/can-we-fold-yet.rb
  9. +2 −0 spec/truffle/tags/core/marshal/load_tags.txt
  10. +2 −0 spec/truffle/tags/core/time/getlocal_tags.txt
  11. +2 −0 spec/truffle/tags/core/time/localtime_tags.txt
  12. +2 −0 spec/truffle/tags/core/time/new_tags.txt
  13. +2 −0 spec/truffle/tags/core/time/strftime_tags.txt
  14. +1 −1 test/truffle/compiler/attachments-optimise.sh
  15. +1 −1 test/truffle/compiler/osr.sh
  16. +1 −1 test/truffle/compiler/pe.sh
  17. +1 −1 test/truffle/compiler/pe/pe.rb
  18. +1 −1 test/truffle/compiler/stf-optimises.sh_excluded
  19. +1 −1 test/truffle/compiler/tp-optimises.sh_excluded
  20. +8 −0 tool/jt.rb
  21. +7 −0 truffle/src/main/java/org/jruby/truffle/JRubyTruffleImpl.java
  22. +1 −31 truffle/src/main/java/org/jruby/truffle/Main.java
  23. +40 −7 truffle/src/main/java/org/jruby/truffle/RubyEngine.java
  24. +1 −0 truffle/src/main/java/org/jruby/truffle/core/TruffleSystemNodes.java
  25. +7 −6 truffle/src/main/java/org/jruby/truffle/core/time/GetTimeZoneNode.java
  26. +40 −34 truffle/src/main/java/org/jruby/truffle/core/time/RubyDateFormatter.java
  27. +5 −4 truffle/src/main/java/org/jruby/truffle/core/time/TimeLayout.java
  28. +163 −90 truffle/src/main/java/org/jruby/truffle/core/time/TimeNodes.java
  29. +43 −0 truffle/src/main/java/org/jruby/truffle/core/time/TimeZoneAndName.java
  30. +4 −1 truffle/src/main/java/org/jruby/truffle/language/LazyRubyRootNode.java
  31. +1 −0 truffle/src/main/java/org/jruby/truffle/language/RubyBaseNode.java
  32. +1 −4 truffle/src/main/java/org/jruby/truffle/language/objects/DefineClassNode.java
  33. +18 −7 truffle/src/main/java/org/jruby/truffle/language/objects/LookupForExistingModuleNode.java
1 change: 1 addition & 0 deletions bin/jruby.bash
Original file line number Diff line number Diff line change
@@ -231,6 +231,7 @@ do
-*)
opt="${opt:1}=false" ;;
esac
echo "$1 is deprecated - use -J-Dgraal.$opt instead" >&2
java_args=("${java_args[@]}" "-Dgraal.$opt")
else
if [ "${val:0:3}" = "-ea" ]; then
6 changes: 5 additions & 1 deletion core/src/main/java/org/jruby/JRubyTruffleInterface.java
Original file line number Diff line number Diff line change
@@ -9,12 +9,16 @@
*/
package org.jruby;

import java.io.InputStream;

public interface JRubyTruffleInterface {

String RUNTIME_SYMBOL = "org.jruby.truffle.runtime";

int execute(String path);

void dispose();


int doCheckSyntax(InputStream in, String filename);

}
91 changes: 80 additions & 11 deletions core/src/main/java/org/jruby/Main.java
Original file line number Diff line number Diff line change
@@ -60,6 +60,7 @@
import java.io.PrintStream;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -219,7 +220,7 @@ public static void main(String[] args) {
catch (Throwable t) {
// If a Truffle exception gets this far it's a hard failure - don't try and dress it up as a Ruby exception

if (main.config.getCompileMode() == RubyInstanceConfig.CompileMode.TRUFFLE) {
if (main.isTruffle()) {
System.err.println("Truffle internal error: " + t);
t.printStackTrace(System.err);
} else {
@@ -273,18 +274,22 @@ private Status internalRun() {

Ruby _runtime;

if (DripMain.DRIP_RUNTIME != null) {
// use drip's runtime, reinitializing config
_runtime = DripMain.DRIP_RUNTIME;
_runtime.reinitialize(true);
if (isTruffle()) {
_runtime = null;
} else {
_runtime = Ruby.newInstance(config);
if (DripMain.DRIP_RUNTIME != null) {
// use drip's runtime, reinitializing config
_runtime = DripMain.DRIP_RUNTIME;
_runtime.reinitialize(true);
} else {
_runtime = Ruby.newInstance(config);
}
}

final Ruby runtime = _runtime;
final AtomicBoolean didTeardown = new AtomicBoolean();

if (config.isHardExit()) {
if (runtime != null && config.isHardExit()) {
// we're the command-line JRuby, and should set a shutdown hook for
// teardown.
Runtime.getRuntime().addShutdownHook(new Thread() {
@@ -297,7 +302,9 @@ public void run() {
}

try {
doSetContextClassLoader(runtime);
if (runtime != null) {
doSetContextClassLoader(runtime);
}

if (in == null) {
// no script to run, return success
@@ -307,13 +314,38 @@ public void run() {
throw new MainExitException(1, "jruby: no Ruby script found in input (LoadError)");
} else if (config.getShouldCheckSyntax()) {
// check syntax only and exit
return doCheckSyntax(runtime, in, filename);
if (isTruffle()) {
final JRubyTruffleInterface truffle = loadTruffle();

try {
final int exitCode = truffle.doCheckSyntax(in, filename);
return new Status(exitCode);
} finally {
truffle.dispose();
}
} else {
return doCheckSyntax(runtime, in, filename);
}
} else {
// proceed to run the script
return doRunFromMain(runtime, in, filename);
if (isTruffle()) {
final JRubyTruffleInterface truffle = loadTruffle();

printTruffleTimeMetric("before-run");

try {
final int exitCode = truffle.execute(filename);
return new Status(exitCode);
} finally {
printTruffleTimeMetric("after-run");
truffle.dispose();
}
} else {
return doRunFromMain(runtime, in, filename);
}
}
} finally {
if (didTeardown.compareAndSet(false, true)) {
if (runtime != null && didTeardown.compareAndSet(false, true)) {
runtime.tearDown();
}
}
@@ -576,6 +608,43 @@ else if ( ex instanceof JumpException.FlowControlException ) {
// TODO: should match MRI (>= 2.2.3) exit status - @see ruby/test_enum.rb#test_first
return 2;
}

private boolean isTruffle() {
return config.getCompileMode().isTruffle();
}

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

String javaVersion = System.getProperty("java.version");
String[] parts = javaVersion.split("\\D+");
int firstPart = Integer.valueOf(parts[0]);
if (!(firstPart >= 9 || Integer.valueOf(parts[1]) >= 8)) {
System.err.println("JRuby+Truffle needs Java 8 to run (found " + javaVersion + ").");
System.exit(1);
}

final Class<?> clazz;

try {
clazz = Class.forName("org.jruby.truffle.JRubyTruffleImpl");
} 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;

try {
Constructor<?> con = clazz.getConstructor(RubyInstanceConfig.class);
truffleContext = (JRubyTruffleInterface) con.newInstance(config);
} catch (Exception e) {
throw new RuntimeException("Error while calling the constructor of Truffle's RubyContext", e);
}

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

return truffleContext;
}

public static void printTruffleTimeMetric(String id) {
if (Options.TRUFFLE_METRICS_TIME.load()) {
114 changes: 19 additions & 95 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -238,6 +238,10 @@ public final class Ruby implements Constantizable {
* @see org.jruby.RubyInstanceConfig
*/
private Ruby(RubyInstanceConfig config) {
if (config.getCompileMode().isTruffle()) {
throw new UnsupportedOperationException("Truffle isn't supported using a classic context - use PolyglotEngine instead.");
}

this.config = config;
this.threadService = new ThreadService(this);

@@ -554,20 +558,6 @@ public void runFromMain(InputStream inputStream, String filename) {
return;
}

if (getInstanceConfig().getCompileMode() == CompileMode.TRUFFLE) {
final JRubyTruffleInterface truffleContext = getTruffleContext();
Main.printTruffleTimeMetric("before-run");
int exitCode;
try {
exitCode = truffleContext.execute(filename);
} finally {
Main.printTruffleTimeMetric("after-run");
shutdownTruffleContextIfRunning();
}

throw new MainExitException(exitCode);
}

ParseResult parseResult = parseFromMain(filename, inputStream);

// if no DATA, we're done with the stream, shut it down
@@ -839,10 +829,6 @@ public IRubyObject runScript(Script script) {
}

public IRubyObject runScript(Script script, boolean wrap) {
if (getInstanceConfig().getCompileMode() == CompileMode.TRUFFLE) {
throw new UnsupportedOperationException();
}

return script.load(getCurrentContext(), getTopSelf(), wrap);
}

@@ -855,10 +841,6 @@ public IRubyObject runScriptBody(Script script) {
}

public IRubyObject runInterpreter(ThreadContext context, ParseResult parseResult, IRubyObject self) {
if (getInstanceConfig().getCompileMode() == CompileMode.TRUFFLE) {
throw new UnsupportedOperationException();
}

return interpreter.execute(this, parseResult, self);
}

@@ -898,56 +880,6 @@ public JITCompiler getJITCompiler() {
return jitCompiler;
}

public JRubyTruffleInterface getTruffleContext() {
synchronized (truffleContextMonitor) {
if (truffleContext == null) {
truffleContext = loadTruffle();
}
return truffleContext;
}
}

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

String javaVersion = System.getProperty("java.version");
String[] parts = javaVersion.split("\\D+");
int firstPart = Integer.valueOf(parts[0]);
if (!(firstPart >= 9 || Integer.valueOf(parts[1]) >= 8)) {
System.err.println("JRuby+Truffle needs Java 8 to run (found " + javaVersion + ").");
System.exit(1);
}

final Class<?> clazz;

try {
clazz = getJRubyClassLoader().loadClass("org.jruby.truffle.JRubyTruffleImpl");
} 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;

try {
Constructor<?> con = clazz.getConstructor(RubyInstanceConfig.class);
truffleContext = (JRubyTruffleInterface) con.newInstance(config);
} catch (Exception e) {
throw new RuntimeException("Error while calling the constructor of Truffle's RubyContext", e);
}

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

return truffleContext;
}

public void shutdownTruffleContextIfRunning() {
synchronized (truffleContextMonitor) {
if (truffleContext != null) {
truffleContext.dispose();
}
}
}

/**
* @deprecated use #newInstance()
*/
@@ -1276,8 +1208,7 @@ private void init() {
// if we can't use reflection, 'jruby' and 'java' won't work; no load.
boolean reflectionWorks = doesReflectionWork();

if (!RubyInstanceConfig.DEBUG_PARSER && reflectionWorks
&& getInstanceConfig().getCompileMode() != CompileMode.TRUFFLE) {
if (!RubyInstanceConfig.DEBUG_PARSER && reflectionWorks) {
loadService.require("jruby");
}

@@ -1286,23 +1217,21 @@ && getInstanceConfig().getCompileMode() != CompileMode.TRUFFLE) {
// out of base boot mode
bootingCore = false;

if (getInstanceConfig().getCompileMode() != CompileMode.TRUFFLE) {
// init Ruby-based kernel
initRubyKernel();
// init Ruby-based kernel
initRubyKernel();

// Define blank modules for feature detection in preludes
if (!config.isDisableGems()) {
defineModule("Gem");
}
if (!config.isDisableDidYouMean()) {
defineModule("DidYouMean");
}
// Define blank modules for feature detection in preludes
if (!config.isDisableGems()) {
defineModule("Gem");
}
if (!config.isDisableDidYouMean()) {
defineModule("DidYouMean");
}

initRubyPreludes();
initRubyPreludes();

// everything booted, so SizedQueue should be available; set up root fiber
ThreadFiber.initRootFiber(context);
}
// everything booted, so SizedQueue should be available; set up root fiber
ThreadFiber.initRootFiber(context);

if(config.isProfiling()) {
// additional twiddling for profiled mode
@@ -1324,10 +1253,8 @@ && getInstanceConfig().getCompileMode() != CompileMode.TRUFFLE) {
bootingRuntime = false;

// Require in all libraries specified on command line
if (getInstanceConfig().getCompileMode() != CompileMode.TRUFFLE) {
for (String scriptName : config.getRequiredLibraries()) {
topSelf.callMethod(context, "require", RubyString.newString(this, scriptName));
}
for (String scriptName : config.getRequiredLibraries()) {
topSelf.callMethod(context, "require", RubyString.newString(this, scriptName));
}
}

@@ -5187,9 +5114,6 @@ public IRubyObject call(ThreadContext context, RecursiveFunction func, IRubyObje
// Compilation
private final JITCompiler jitCompiler;

private JRubyTruffleInterface truffleContext;
private final Object truffleContextMonitor = new Object();

// Note: this field and the following static initializer
// must be located be in this order!
private volatile static boolean securityRestricted = false;
2 changes: 0 additions & 2 deletions core/src/main/java/org/jruby/ir/interpreter/Interpreter.java
Original file line number Diff line number Diff line change
@@ -146,7 +146,6 @@ public static IRubyObject INTERPRET_BLOCK(ThreadContext context, Block block, IR
*/
public static IRubyObject evalSimple(ThreadContext context, RubyModule under, IRubyObject self, RubyString src, String file, int lineNumber, EvalType evalType) {
Ruby runtime = context.runtime;
if (runtime.getInstanceConfig().getCompileMode() == RubyInstanceConfig.CompileMode.TRUFFLE) throw new UnsupportedOperationException();

// no binding, just eval in "current" frame (caller's frame)
DynamicScope parentScope = context.getCurrentScope();
@@ -192,7 +191,6 @@ private static IRubyObject evalCommon(ThreadContext context, DynamicScope evalSc
*/
public static IRubyObject evalWithBinding(ThreadContext context, IRubyObject self, IRubyObject src, Binding binding) {
Ruby runtime = context.runtime;
if (runtime.getInstanceConfig().getCompileMode() == RubyInstanceConfig.CompileMode.TRUFFLE) throw new UnsupportedOperationException();

DynamicScope evalScope = binding.getEvalScope(runtime);
evalScope.getStaticScope().determineModule(); // FIXME: It would be nice to just set this or remove it from staticScope altogether
2 changes: 1 addition & 1 deletion lib/ruby/truffle/truffle/truffle/execjs.rb
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ def unbox(value)
if Truffle::Interop.boxed?(value)
value
else
JSON.parse(Truffle::Interop.unbox(STRINGIFY.call(STRINGIFY, value)))
JSON.parse(Truffle::Interop.from_java_string(STRINGIFY.call(STRINGIFY, value)))
end
end

12 changes: 9 additions & 3 deletions mx.jruby/mx_jruby.py
Original file line number Diff line number Diff line change
@@ -191,11 +191,17 @@ def extractArguments(cli_args):
elif arg == '-J-cmd':
print_command = True
elif arg.startswith('-J-G:+'):
vmArgs.append('-Dgraal.'+arg[6:]+'=true')
rewritten = '-Dgraal.'+arg[6:]+'=true'
mx.warn(arg + ' is deprecated - use -J' + rewritten + ' instead')
vmArgs.append(rewritten)
elif arg.startswith('-J-G:-'):
vmArgs.append('-Dgraal.'+arg[6:]+'=false')
rewritten = '-Dgraal.'+arg[6:]+'=false'
mx.warn(arg + ' is deprecated - use -J' + rewritten + ' instead')
vmArgs.append(rewritten)
elif arg.startswith('-J-G:'):
vmArgs.append('-Dgraal.'+arg[5:])
rewritten = '-Dgraal.'+arg[5:]
mx.warn(arg + ' is deprecated - use -J' + rewritten + ' instead')
vmArgs.append(rewritten)
elif arg == '-J-cp' or arg == '-J-classpath':
cp = args.pop(0)
if cp[:2] == '-J':
Loading