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

Commits on Dec 20, 2017

  1. Copy the full SHA
    578918b View commit details
  2. Move protocol check, prep for compilation inside call count guard.

    Having this outside the call count guard caused all blocks to
    prepare for compilation (whether they'd ever need to JIT or not)
    as well as producing false errors in JIT logs for blocks that
    couldn't jit but never need to.
    headius committed Dec 20, 2017
    Copy the full SHA
    acc44a6 View commit details
  3. Copy the full SHA
    1fd8a50 View commit details
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9.1.15.0
9.1.16.0-SNAPSHOT
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ DO NOT MODIFIY - GENERATED CODE
<parent>
<groupId>org.jruby</groupId>
<artifactId>jruby-parent</artifactId>
<version>9.1.15.0</version>
<version>9.1.16.0-SNAPSHOT</version>
</parent>
<artifactId>jruby-core</artifactId>
<name>JRuby Core</name>
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/ir/IRVisitor.java
Original file line number Diff line number Diff line change
@@ -132,6 +132,7 @@ private void error(Object object) {
public void ThrowExceptionInstr(ThrowExceptionInstr throwexceptioninstr) { error(throwexceptioninstr); }
public void ToggleBacktraceInstr(ToggleBacktraceInstr instr) { error(instr); }
public void ToAryInstr(ToAryInstr toaryinstr) { error(toaryinstr); }
public void TraceInstr(TraceInstr toaryinstr) { error(toaryinstr); }
public void UndefMethodInstr(UndefMethodInstr undefmethodinstr) { error(undefmethodinstr); }
public void UnresolvedSuperInstr(UnresolvedSuperInstr unresolvedsuperinstr) { error(unresolvedsuperinstr); }
public void UpdateBlockExecutionStateInstr (UpdateBlockExecutionStateInstr instr) { error(instr); }
29 changes: 23 additions & 6 deletions core/src/main/java/org/jruby/ir/instructions/TraceInstr.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package org.jruby.ir.instructions;

import org.jruby.ir.IRFlags;
import org.jruby.ir.IRScope;
import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.persistence.IRReaderDecoder;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.RubyEvent;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;

import java.util.EnumSet;

// FIXME: When presistence is revisited this should strip these out of code streams on save and add them in if
// tracing is on for load.
/**
@@ -71,13 +77,24 @@ public static TraceInstr decode(IRReaderDecoder d) {

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
if (context.runtime.hasEventHooks()) {
// FIXME: Try and statically generate END linenumber instead of hacking it.
int linenumber = getLinenumber() == -1 ? context.getLine()+1 : getLinenumber();

context.trace(getEvent(), getName(), context.getFrameKlazz(), getFilename(), linenumber);
}
IRRuntimeHelpers.callTrace(context, getEvent(), getName(), getFilename(), getLinenumber());

return null;
}

@Override
public void visit(IRVisitor visitor) {
visitor.TraceInstr(this);
}

@Override
public boolean computeScopeFlags(IRScope scope) {
EnumSet<IRFlags> flags = scope.getFlags();

if (flags.contains(IRFlags.REQUIRES_FRAME)) return false;

flags.add(IRFlags.REQUIRES_FRAME);

return true;
}
}
10 changes: 10 additions & 0 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Original file line number Diff line number Diff line change
@@ -1966,6 +1966,16 @@ public static RubyArray newArray(ThreadContext context, IRubyObject obj0, IRubyO
return RubyArray.newArray(context.runtime, obj0, obj1);
}

@JIT
public static void callTrace(ThreadContext context, RubyEvent event, String name, String filename, int line) {
if (context.runtime.hasEventHooks()) {
// FIXME: Try and statically generate END linenumber instead of hacking it.
int linenumber = line == -1 ? context.getLine()+1 : line;

context.trace(event, name, context.getFrameKlazz(), filename, linenumber);
}
}

private static IRRuntimeHelpersSites sites(ThreadContext context) {
return context.sites.IRRuntimeHelpers;
}
15 changes: 15 additions & 0 deletions core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Original file line number Diff line number Diff line change
@@ -2168,6 +2168,21 @@ public void ToAryInstr(ToAryInstr toaryinstr) {
jvmStoreLocal(toaryinstr.getResult());
}

@Override
public void TraceInstr(TraceInstr traceInstr) {
jvmMethod().loadContext();
jvmAdapter().getstatic(p(RubyEvent.class), traceInstr.getEvent().name(), ci(RubyEvent.class));
String name = traceInstr.getName();
if (name == null) {
jvmAdapter().aconst_null();
} else {
jvmAdapter().ldc(name);
}
jvmAdapter().ldc(traceInstr.getFilename());
jvmAdapter().ldc(traceInstr.getLinenumber());
jvmMethod().invokeIRHelper("callTrace", sig(void.class, ThreadContext.class, RubyEvent.class, String.class, String.class, int.class));
}

@Override
public void UndefMethodInstr(UndefMethodInstr undefmethodinstr) {
jvmMethod().loadContext();
27 changes: 14 additions & 13 deletions core/src/main/java/org/jruby/runtime/MixedModeIRBlockBody.java
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import org.jruby.EvalType;
import org.jruby.RubyModule;
import org.jruby.compiler.Compilable;
import org.jruby.compiler.NotCompilableException;
import org.jruby.ir.IRClosure;
import org.jruby.ir.IRScope;
import org.jruby.ir.interpreter.Interpreter;
@@ -164,25 +165,25 @@ protected void promoteToFullBuild(ThreadContext context) {
if (context.runtime.isBooting() && !Options.JIT_KERNEL.load()) return; // don't JIT during runtime boot

if (callCount >= 0) {
// ensure we've got code ready for JIT
ensureInstrsReady();
closure.getNearestTopLocalVariableScope().prepareForCompilation();

// if we don't have an explicit protocol, disable JIT
if (!closure.hasExplicitCallProtocol()) {
if (Options.JIT_LOGGING.load()) {
LOG.info("JIT failed; no protocol found in block: " + closure);
}
callCount = -1;
return;
}

synchronized (this) {
// check call count again
if (callCount < 0) return;

if (callCount++ >= Options.JIT_THRESHOLD.load()) {
callCount = -1;

// ensure we've got code ready for JIT
ensureInstrsReady();
closure.getNearestTopLocalVariableScope().prepareForCompilation();

// if we don't have an explicit protocol, disable JIT
if (!closure.hasExplicitCallProtocol()) {
if (Options.JIT_LOGGING.load()) {
LOG.info("JIT failed; no protocol found in block: " + closure);
}
return;
}

context.runtime.getJITCompiler().buildThresholdReached(context, this);
}
}
4 changes: 2 additions & 2 deletions lib/pom.xml
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ DO NOT MODIFIY - GENERATED CODE
<parent>
<groupId>org.jruby</groupId>
<artifactId>jruby-parent</artifactId>
<version>9.1.15.0</version>
<version>9.1.16.0-SNAPSHOT</version>
</parent>
<artifactId>jruby-stdlib</artifactId>
<name>JRuby Lib Setup</name>
@@ -28,7 +28,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-core</artifactId>
<version>9.1.15.0</version>
<version>9.1.16.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
5 changes: 1 addition & 4 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ DO NOT MODIFIY - GENERATED CODE
</parent>
<groupId>org.jruby</groupId>
<artifactId>jruby-parent</artifactId>
<version>9.1.15.0</version>
<version>9.1.16.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>JRuby</name>
<description>JRuby is the effort to recreate the Ruby (http://www.ruby-lang.org) interpreter in Java.</description>
@@ -271,9 +271,6 @@ DO NOT MODIFIY - GENERATED CODE
<requireMavenVersion>
<version>[3.3.0,)</version>
</requireMavenVersion>
<requireReleaseDeps>
<message>No Snapshots Allowed!</message>
</requireReleaseDeps>
</rules>
</configuration>
</execution>