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: 75b7542a934d
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a1a4fc3daf29
Choose a head ref

Commits on Sep 23, 2015

  1. Copy the full SHA
    3b1a4da View commit details
  2. Copy the full SHA
    8be8c21 View commit details
  3. Copy the full SHA
    aa67abe View commit details
  4. Copy the full SHA
    a01b18c View commit details
  5. Copy the full SHA
    36ec4eb View commit details
  6. [Truffle] Junk.

    chrisseaton committed Sep 23, 2015
    Copy the full SHA
    83eafc7 View commit details
  7. [Truffle] Repeated code.

    chrisseaton committed Sep 23, 2015
    Copy the full SHA
    43d89b4 View commit details
  8. Copy the full SHA
    ba40fa2 View commit details

Commits on Sep 24, 2015

  1. Copy the full SHA
    54933e0 View commit details
  2. Copy the full SHA
    ab8672c View commit details
  3. Copy the full SHA
    8f6737b View commit details
  4. Copy the full SHA
    067d7e3 View commit details
  5. Copy the full SHA
    6c25cea View commit details
  6. Copy the full SHA
    5cb0974 View commit details

Commits on Sep 25, 2015

  1. Copy the full SHA
    758404f View commit details
  2. Merge branch 'master' into truffle-yaml

    Conflicts:
    	truffle/src/main/java/org/jruby/truffle/nodes/RubyNode.java
    chrisseaton committed Sep 25, 2015
    Copy the full SHA
    7633e99 View commit details
  3. Copy the full SHA
    3ae7901 View commit details

Commits on Sep 28, 2015

  1. [Truffle] Add todos.

    chrisseaton committed Sep 28, 2015
    Copy the full SHA
    e4ef532 View commit details
  2. Merge branch 'master' into truffle-yaml

    Conflicts:
    	truffle/src/main/java/org/jruby/truffle/runtime/core/CoreLibrary.java
    	truffle/src/main/java/org/jruby/truffle/runtime/layouts/Layouts.java
    chrisseaton committed Sep 28, 2015
    Copy the full SHA
    d273188 View commit details

Commits on Sep 29, 2015

  1. Copy the full SHA
    e139d9c View commit details
  2. Squashed 'spec/mspec/' changes from 77b49c2..c60587f

    c60587f Remove some uninitialized ivar warnings
    3e76cd0 Add spec for SpecTag#unescape
    e13dde3 Simplify espacing in SpecTag
    57652ef Fix SpecTag#unescape
    1e1b4af Support escape: true only in ruby_exe, by executing from a temporary file
    cc5fd36 Merge pull request #10 from nobu/bug/9-portable-backtick
    d0406c9 Do not use $() for portability
    
    git-subtree-dir: spec/mspec
    git-subtree-split: c60587f02dc806de53521a38cb029959126c7dea
    eregon committed Sep 29, 2015
    Copy the full SHA
    2c48369 View commit details
  3. Copy the full SHA
    a6f282c View commit details
  4. Squashed 'spec/ruby/' changes from f06add1..fa9e1cd

    fa9e1cd Add some other cases for #super_method specs
    3481f99 Add Enumerable#{min,max,min_by,max_by} specs with nil
    00f2439 added spec for lambda with optional parameter
    a9de138 Add version guard
    f424cb0 Add block and lambda specs for MRI bug #9593
    9d36115 Add spec for MRI bug #9593
    14f3122 Update hash spec to include quoted symbol key syntax
    8cb48a7 Spec for Method and UnboundMethod #super_method (Ruby 2.2+)
    d6e3175 Fix Float#prev_float and Float#next_float specs
    be46b2c More edge case specs for Float#next_float and #prev_float near zero
    d7434d3 Specs for Float#next_float and #prev_float use eql? instead of ==
    8fa732b Specs for Float#next_float and #prev_float on NAN
    41a949b Specs for Float#next_float and #prev_float
    4296712 Kernel#throw now raises an UncaughtThrowError when there is no matching catch block.
    1b79214 Add version guard
    3529807 birthtime can also be implemented on Windows
    cd31973 Only darwin supports birthtime
    e6cbae8 adapt specs for specifics platform checks
    6cca077 Add File.birthtime and File#birthtime specs
    ca27d37 Add a single space between after and :each
    8944d0c Add version guard
    8e3cfa6 File#birthtime is not be implemented on some platforms
    af195cb Add File::Stat#birthtime specs
    654c1ee Add version guard
    933b95f Add specs for Enumerable#slice_when
    8011bb5 Argument error -> ArgumentError
    1a9abba Add version guard
    9d9aa3e Add specs for Enumerable#max_by optional arg
    fa4e34a Add version guard
    18d00f6 Add specs for Binding#receiver
    c1a1972 Add version guard
    5f44013 Add spec for Enumerable#max optional arg
    534d780 Fix typo in Enumerable#max's spec. s/minimum/maximum
    78345ae We are already in the Enumerable#max block, there's no need to repeat it.
    559210b Remove unused @A instance variable
    c9b9cd0 Use context for readability
    56639ab Add version guard
    53c2397 Add specs for Enumberable#min_by optional args
    553610a Fix typo in Enumerable#min_by's descriptions: Minimum, not maximum
    549d3b7 Specify some edge cases for Enumerable#min optional arg
    e8a21bb Remove unused instance variable @A
    1469d34 Add version guard
    f8a2be8 Add specs for Enumerable#min with optional arg.
    bf8cd32 Add version guard and fix style
    976c355 Add spec for Enumerable#slice_after
    b92dde0 Add an example to Binding#local_variables
    45f2788 Add version guard
    41b3c09 Add specs for Binding#local_variables
    9b8336e Fix Method#curry spec and add version guard
    60ba4e9 Add Method#curry specs
    9f0f050 Fix an example in ObjectSpace#each_object to run in 2.0.0
    b68632e Specify Binding#local_variable_get
    0291545 Enumerable#find_index should use #== semantics for testing equality
    6e9cc19 Simplify the #=== private spec
    78ed9fc Super uses given block even if arguments are passed explicitly
    3f8b74b Case can call private #=== method
    d0d4f14 Synchronize Fixnum#<< and #>>
    fb52f65 Add a few examples to Fixnum#<<
    9a888d0 Add more examples for Fixnum#>>
    a1aabf0 Fixes to ObjectSpaces specs.
    cf62939 Fix spec name.
    b09b120 More places objects could hide from ObjectSpace - thread and fiber locals and at_exit handlers.
    b91a806 ObjectSpace can reach both implicitly and explicitly captured locals
    9c7123a Add specs for where ObjectSpace.each_object can find objects.
    254ccdf Improve Thread#raise spec to be more precise about the backtrace
    9955865 Remove trailing spaces
    4ab3965 Merge pull request #136 from wied03/master
    477068f Account for cases where the LHS is a nil local variable - opal/opal#1090 (comment)
    5cab2a8 Improve specdocs of class specs
    c9eb2f1 Remove trailing spaces
    db3c823 Merge pull request #135 from wied03/master
    ff28bca Test creating classes within Class.new blocks
    cd78752 Merge pull request #133 from ngoto/use-CCDLFLAGS
    23c373d CCDLFLAGS should be used to build Position Independent Code
    b027be8 Use the output matcher in PP.pp to avoid touching $stdout directly
    a01fdc4 Fix formatting and trailing spaces
    9a73ed9 Merge pull request #130 from wied03/master
    f02ff7d Remove stringio dependency and use IOStub
    ae1aa04 Try to simplify the File#flock blocking spec
    159de46 Get started with PP stdlib specs, especially the PP::pp method
    0e097ec Merge pull request #131 from nobu/ftp#system-fix
    de0d559 newlines do not matter
    46c3fb2 Inline shared describe for Kernel#lambda with single usage.
    80729a3 Merge pull request #129 from iliabylich/stop-generating-dynamic-test-names
    8343600 Stop generating dynamic test names for lambda.
    0dbf847 Merge pull request #128 from ngoto/atan2-revert-ac7ca51
    4abb3c6 Merge pull request #126 from ngoto/File-stat-NFS
    0995c96 Remove needless "platform_is :solaris" guards.
    ec6ce28 Use 1 second ago from now to avoid failure due to NFS cache behavior.
    1f65cb6 Merge pull request #124 from ngoto/flock-Solaris
    5190db6 Merge pull request #123 from ngoto/DATA-flock-Solaris
    aeeb3dd DATA (read-only opened) can not be locked by File#flock on Solaris
    73857c7 Rewrite some File#flock specs using ruby_exe for supporting Solaris
    a0570cc Rewrite -s flag specs to explicitly pass inline code
    25cda76 Use a fixture for the autoload with frozen Object spec
    6e93ec5 Merge pull request #117 from rashmirathi1729/master
    2a4a08c Add Matrix#to_a specs
    96b4183 Merge pull request #119 from tobiashm/master
    0bc0537 String#start_with? and #end_with? for empty string
    f7cf2bd Module#singleton_class? is 2.1+ only
    7afc6fb toplevel visibility is already specified in language/
    08088b9 There is no Kernel#type.
    c695c91 Move method_missing fixture
    48eff07 Move method_missing specs to the right place
    4ddc433 Relax spec of send arity
    511568b Organize send specs
    821845d Unshare Continuation specs
    329d7cc Continuations are only available as a library in 2.0+
    5cebf8e Fix specdocs for Float constants
    20cad95 Move Module#singleton_class? to the right file
    
    git-subtree-dir: spec/ruby
    git-subtree-split: fa9e1cdc2815fa006b89cf83344ba6041d0d566c
    eregon committed Sep 29, 2015
    Copy the full SHA
    ca0e14f View commit details
  5. Merge RubySpec commit 'ca0e14f96fee9cf3438e6513893a0770142798e6'

    * Conflicts:
    *	spec/ruby/core/objectspace/each_object_spec.rb
    eregon committed Sep 29, 2015
    Copy the full SHA
    b0488b8 View commit details
  6. [Truffle] Add new specs tags.

    eregon committed Sep 29, 2015
    Copy the full SHA
    fbb55c5 View commit details
  7. Copy the full SHA
    33d0851 View commit details
  8. Add new specs tags

    eregon committed Sep 29, 2015
    Copy the full SHA
    b3a6d4f View commit details
  9. 4
    Copy the full SHA
    c06ac7c View commit details
  10. Copy the full SHA
    22ee01d View commit details
  11. Remove inappropriate spec

    eregon committed Sep 29, 2015
    Copy the full SHA
    87d7b75 View commit details
  12. Copy the full SHA
    595d87a View commit details
  13. Copy the full SHA
    f149501 View commit details
  14. [Truffle] New spec tag.

    eregon committed Sep 29, 2015
    Copy the full SHA
    0358bcc View commit details
  15. Copy the full SHA
    c6ce091 View commit details
  16. Copy the full SHA
    5e0eece View commit details
  17. [Truffle] Fix wrong lowering indices in StringPrimitiveNodes.

    * Other lowerFixnumParameters seem good for @RubiniusPrimitive.
    eregon committed Sep 29, 2015
    Copy the full SHA
    82dc923 View commit details
  18. Copy the full SHA
    5f1f2e2 View commit details
  19. Copy the full SHA
    5c1a9c0 View commit details
  20. [Truffle] Findbugs.

    chrisseaton committed Sep 29, 2015
    Copy the full SHA
    c5a4e7f View commit details
  21. Copy the full SHA
    2359c8c View commit details
  22. Copy the full SHA
    f5def9a View commit details
  23. Copy the full SHA
    c05ede4 View commit details
  24. 2
    Copy the full SHA
    439da5d View commit details
  25. Merge pull request #3349 from jruby/truffle-yaml

    [Truffle] YAML complete
    chrisseaton committed Sep 29, 2015
    Copy the full SHA
    09cfe9b View commit details
  26. startupInterp rescuePCs stack is built on demand per scope:

    - Uses less memory for scopes with no exception handling
    - Is a little faster because we are not constantly alloc'ing a stack.
    
    Secondly base interpreter engine does not pass this stack as an argument
    into processBookkeeping.  It has been moved entirely into startup
    interpreter engine.
    enebo committed Sep 29, 2015
    Copy the full SHA
    6bd67c2 View commit details
  27. Set up remaining converters as postfix rescue for now.

    @enebo improved our runtime to omit stack traces downstream from
    simple postfix rescues, but simple long-form rescues don't get
    that optimization yet. This is a temporary measure until they do.
    headius committed Sep 29, 2015
    Copy the full SHA
    16dcafe View commit details
  28. Copy the full SHA
    20acc1b View commit details
  29. Make this exception lightweight, since it is only to unroll stack.

    This exception is immediately caught everywhere ConvertDouble is
    used, triggering a proper Ruby exception. The creation of a stack
    trace here is therefore extraneous.
    headius committed Sep 29, 2015
    Copy the full SHA
    e4727c3 View commit details
  30. Copy the full SHA
    06f1c2b View commit details

Commits on Sep 30, 2015

  1. Merge pull request #3363 from jruby/truffle-block-given

    [Truffle] Optimise block_given?
    chrisseaton committed Sep 30, 2015
    Copy the full SHA
    3de14df View commit details
Showing 311 changed files with 4,043 additions and 1,398 deletions.
Original file line number Diff line number Diff line change
@@ -9,18 +9,12 @@
*/
package org.jruby;

public interface TruffleContextInterface {
public interface JRubyTruffleInterface {

enum BacktraceFormatter {
MRI,
DEBUG,
IMPL_DEBUG
}

void initialize();
String RUNTIME_SYMBOL = "org.jruby.truffle.runtime";

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

void shutdown();
void dispose();

}
20 changes: 9 additions & 11 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -842,7 +842,7 @@ public IRubyObject runInterpreter(ThreadContext context, Node rootNode, IRubyObj
if (getInstanceConfig().getCompileMode() == CompileMode.TRUFFLE) {
assert rootNode instanceof RootNode;
assert self == getTopSelf();
final TruffleContextInterface truffleContext = getTruffleContext();
final JRubyTruffleInterface truffleContext = getTruffleContext();
Main.printTruffleTimeMetric("before-run");
truffleContext.execute((RootNode) rootNode);
Main.printTruffleTimeMetric("after-run");
@@ -883,37 +883,35 @@ public JITCompiler getJITCompiler() {
return jitCompiler;
}

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

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

final Class<?> clazz;

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

final TruffleContextInterface truffleContext;
final JRubyTruffleInterface truffleContext;

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

truffleContext.initialize();

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

return truffleContext;
@@ -922,7 +920,7 @@ private TruffleContextInterface loadTruffleContext() {
public void shutdownTruffleContextIfRunning() {
synchronized (truffleContextMonitor) {
if (truffleContext != null) {
truffleContext.shutdown();
truffleContext.dispose();
}
}
}
@@ -4940,7 +4938,7 @@ public FilenoUtil getFilenoUtil() {
// Compilation
private final JITCompiler jitCompiler;

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

// Note: this field and the following static initializer
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyContinuation.java
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@
*/
@JRubyClass(name="Continuation")
public class RubyContinuation extends RubyObject {
public static class Continuation extends Error implements Unrescuable {
public static class Continuation extends RuntimeException implements Unrescuable {
public Continuation() {tag = null;}
public Continuation(IRubyObject tag) {
this.tag = tag;
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ast/DVarNode.java
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
/**
* Access a dynamic variable (e.g. block scope local variable).
*/
public class DVarNode extends Node implements INameNode, IScopedNode {
public class DVarNode extends Node implements INameNode, IScopedNode, SideEffectFree {
// The name of the variable
private String name;

167 changes: 161 additions & 6 deletions core/src/main/java/org/jruby/compiler/JITCompiler.java
Original file line number Diff line number Diff line change
@@ -37,9 +37,12 @@
import org.jruby.ast.util.SexpMaker;
import org.jruby.internal.runtime.methods.CompiledIRMethod;
import org.jruby.internal.runtime.methods.MixedModeIRMethod;
import org.jruby.ir.IRClosure;
import org.jruby.ir.interpreter.InterpreterContext;
import org.jruby.ir.targets.JVMVisitor;
import org.jruby.ir.targets.JVMVisitorMethodContext;
import org.jruby.runtime.CompiledIRBlockBody;
import org.jruby.runtime.MixedModeIRBlockBody;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.threading.DaemonThreadFactory;
@@ -54,6 +57,7 @@
import java.lang.invoke.MethodType;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ExecutorService;
@@ -147,7 +151,9 @@ public void tearDown() {

public Runnable getTaskFor(ThreadContext context, Compilable method) {
if (method instanceof MixedModeIRMethod) {
return new JITTask((MixedModeIRMethod) method, method.getClassName(context));
return new MethodJITTask((MixedModeIRMethod) method, method.getClassName(context));
} else if (method instanceof MixedModeIRBlockBody) {
return new BlockJITTask((MixedModeIRBlockBody) method, method.getClassName(context));
}

return new FullBuildTask(method);
@@ -204,12 +210,12 @@ public void run() {
}
}

private class JITTask implements Runnable {
private class MethodJITTask implements Runnable {
private final String className;
private final MixedModeIRMethod method;
private final String methodName;

public JITTask(MixedModeIRMethod method, String className) {
public MethodJITTask(MixedModeIRMethod method, String className) {
this.method = method;
this.className = className;
this.methodName = method.getName();
@@ -241,7 +247,7 @@ public void run() {

String key = SexpMaker.sha1(method.getIRScope());
JVMVisitor visitor = new JVMVisitor();
JITClassGenerator generator = new JITClassGenerator(className, methodName, key, runtime, method, visitor);
MethodJITClassGenerator generator = new MethodJITClassGenerator(className, methodName, key, runtime, method, visitor);

JVMVisitorMethodContext context = new JVMVisitorMethodContext();
generator.compile(context);
@@ -317,6 +323,68 @@ public void run() {
}
}

private class BlockJITTask implements Runnable {
private final String className;
private final MixedModeIRBlockBody body;
private final String methodName;

public BlockJITTask(MixedModeIRBlockBody body, String className) {
this.body = body;
this.className = className;
this.methodName = body.getName();
}

public void run() {
try {
String key = SexpMaker.sha1(body.getIRScope());
JVMVisitor visitor = new JVMVisitor();
BlockJITClassGenerator generator = new BlockJITClassGenerator(className, methodName, key, runtime, body, visitor);

JVMVisitorMethodContext context = new JVMVisitorMethodContext();
generator.compile(context);

// FIXME: reinstate active bytecode size check
// At this point we still need to reinstate the bytecode size check, to ensure we're not loading code
// that's so big that JVMs won't even try to compile it. Removed the check because with the new IR JIT
// bytecode counts often include all nested scopes, even if they'd be different methods. We need a new
// mechanism of getting all body sizes.
Class sourceClass = visitor.defineFromBytecode(body.getIRScope(), generator.bytecode(), new OneShotClassLoader(runtime.getJRubyClassLoader()));

if (sourceClass == null) {
// class could not be found nor generated; give up on JIT and bail out
counts.failCount.incrementAndGet();
return;
} else {
generator.updateCounters(counts);
}

// successfully got back a jitted body

if (config.isJitLogging()) {
log(body.getImplementationClass(), body.getFile(), body.getLine(), className + "." + methodName, "done jitting");
}

String jittedName = context.getJittedName();

// blocks only have variable-arity
body.completeBuild(
new CompiledIRBlockBody(
PUBLIC_LOOKUP.findStatic(sourceClass, jittedName, JVMVisitor.CLOSURE_SIGNATURE.type()),
body.getIRScope(),
((IRClosure) body.getIRScope()).getSignature().encode()));
} catch (Throwable t) {
if (config.isJitLogging()) {
log(body.getImplementationClass(), body.getFile(), body.getLine(), className + "." + methodName, "Could not compile; passes run: " + body.getIRScope().getExecutedPasses(), t.getMessage());
if (config.isJitLoggingVerbose()) {
t.printStackTrace();
}
}

counts.failCount.incrementAndGet();
}
}
}

public static String getHashForString(String str) {
return getHashForBytes(RubyEncoding.encodeUTF8(str));
}
@@ -335,8 +403,8 @@ public static String getHashForBytes(byte[] bytes) {
}
}

public static class JITClassGenerator {
public JITClassGenerator(String className, String methodName, String key, Ruby ruby, MixedModeIRMethod method, JVMVisitor visitor) {
public static class MethodJITClassGenerator {
public MethodJITClassGenerator(String className, String methodName, String key, Ruby ruby, MixedModeIRMethod method, JVMVisitor visitor) {
this.packageName = JITCompiler.RUBY_JIT_PREFIX;
if (RubyInstanceConfig.JAVA_VERSION == Opcodes.V1_7 || Options.COMPILE_INVOKEDYNAMIC.load() == true) {
// Some versions of Java 7 seems to have a bug that leaks definitions across cousin classloaders
@@ -422,6 +490,93 @@ public String toString() {
private String name;
}

public static class BlockJITClassGenerator {
public BlockJITClassGenerator(String className, String methodName, String key, Ruby ruby, MixedModeIRBlockBody body, JVMVisitor visitor) {
this.packageName = JITCompiler.RUBY_JIT_PREFIX;
if (RubyInstanceConfig.JAVA_VERSION == Opcodes.V1_7 || Options.COMPILE_INVOKEDYNAMIC.load() == true) {
// Some versions of Java 7 seems to have a bug that leaks definitions across cousin classloaders
// so we force the class name to be unique to this runtime.

// Also, invokedynamic forces us to make jitted bytecode unique to each runtime, since the call sites cache
// at class level rather than at our runtime level. This makes it impossible to share jitted bytecode
// across runtimes.

digestString = key + Math.abs(ruby.hashCode());
} else {
digestString = key;
}
this.className = packageName + "/" + className.replace('.', '/') + CLASS_METHOD_DELIMITER + JavaNameMangler.mangleMethodName(methodName) + "_" + digestString;
this.name = this.className.replaceAll("/", ".");
this.methodName = methodName;
this.body = body;
this.visitor = visitor;
}

@SuppressWarnings("unchecked")
protected void compile(JVMVisitorMethodContext context) {
if (bytecode != null) return;

// Time the compilation
long start = System.nanoTime();

InterpreterContext ic = body.ensureInstrsReady();

int insnCount = ic.getInstructions().length;
if (insnCount > Options.JIT_MAXSIZE.load()) {
// methods with more than our limit of basic blocks are likely too large to JIT, so bail out
throw new NotCompilableException("Could not compile " + body + "; instruction count " + insnCount + " exceeds threshold of " + Options.JIT_MAXSIZE.load());
}

// This may not be ok since we'll end up running passes specific to JIT
// CON FIXME: Really should clone scope before passes in any case
bytecode = visitor.compileToBytecode(body.getIRScope(), context);

compileTime = System.nanoTime() - start;
}

void updateCounters(JITCounts counts) {
counts.compiledCount.incrementAndGet();
counts.compileTime.addAndGet(compileTime);
counts.codeSize.addAndGet(bytecode.length);
counts.averageCompileTime.set(counts.compileTime.get() / counts.compiledCount.get());
counts.averageCodeSize.set(counts.codeSize.get() / counts.compiledCount.get());
synchronized (counts) {
if (counts.largestCodeSize.get() < bytecode.length) {
counts.largestCodeSize.set(bytecode.length);
}
}
}

// FIXME: Does anything call this? If so we should document it.
public void generate() {
compile(new JVMVisitorMethodContext());
}

public byte[] bytecode() {
return bytecode;
}

public String name() {
return name;
}

@Override
public String toString() {
return "{} at " + body.getFile() + ":" + body.getLine();
}

private final String packageName;
private final String className;
private final String methodName;
private final String digestString;
private final MixedModeIRBlockBody body;
private final JVMVisitor visitor;

private byte[] bytecode;
private long compileTime;
private String name;
}

static void log(RubyModule implementationClass, String file, int line, String name, String message, String... reason) {
boolean isBlock = implementationClass == null;
String className = isBlock ? "<block>" : implementationClass.getBaseName();
13 changes: 10 additions & 3 deletions core/src/main/java/org/jruby/exceptions/RaiseException.java
Original file line number Diff line number Diff line change
@@ -203,11 +203,19 @@ private void preRaise(ThreadContext context, StackTraceElement[] javaTrace) {

if (RubyInstanceConfig.LOG_EXCEPTIONS) TraceType.dumpException(exception);

if (context.exceptionRequiresBacktrace) {
if (requiresBacktrace(context)) {
exception.prepareIntegratedBacktrace(context, javaTrace);
}
}

private boolean requiresBacktrace(ThreadContext context) {
IRubyObject debugMode = context.runtime.getGlobalVariables().get("$DEBUG");
// We can only omit backtraces of descendents of Standard error for 'foo rescue nil'
return context.exceptionRequiresBacktrace ||
(debugMode != null && debugMode.isTrue()) ||
!exception.kind_of_p(context, context.runtime.getStandardError()).isTrue();
}

private void preRaise(ThreadContext context, IRubyObject backtrace) {
context.runtime.incrementExceptionCount();
doSetLastError(context);
@@ -216,8 +224,7 @@ private void preRaise(ThreadContext context, IRubyObject backtrace) {
if (RubyInstanceConfig.LOG_EXCEPTIONS) TraceType.dumpException(exception);

// We can only omit backtraces of descendents of Standard error for 'foo rescue nil'
if (!exception.kind_of_p(context, context.runtime.getStandardError()).isTrue() ||
context.exceptionRequiresBacktrace) {
if (requiresBacktrace(context)) {
if (backtrace == null) {
exception.prepareBacktrace(context, nativeException);
} else {
5 changes: 5 additions & 0 deletions core/src/main/java/org/jruby/exceptions/ThreadKill.java
Original file line number Diff line number Diff line change
@@ -29,4 +29,9 @@

public class ThreadKill extends RuntimeException implements Unrescuable {
private static final long serialVersionUID = -6885888060743175327L;

@Override
public Throwable fillInStackTrace() {
return this;
}
}
Loading