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

Commits on Mar 3, 2015

  1. Copy the full SHA
    54bcd35 View commit details
  2. Things we are minimally building and interpreting will now be more ob…

    …vious BEGIN/END/eval
    enebo committed Mar 3, 2015
    Copy the full SHA
    6a494f9 View commit details
  3. Copy the full SHA
    d823301 View commit details
  4. Copy the full SHA
    d6ebbb3 View commit details
  5. Copy the full SHA
    cba0983 View commit details
  6. Copy the full SHA
    8bf22fa View commit details
  7. Copy the full SHA
    b1f9c42 View commit details
  8. Copy the full SHA
    f9b3bfe View commit details
  9. Copy the full SHA
    8c6a32c View commit details
  10. Copy the full SHA
    ac3bc8a View commit details
  11. CFG can use Instr[] to build

    enebo committed Mar 3, 2015
    Copy the full SHA
    5ad4c5c View commit details
  12. 2
    Copy the full SHA
    dee6c77 View commit details
  13. Copy the full SHA
    675a0eb View commit details
  14. Copy the full SHA
    3c73e40 View commit details
  15. Copy the full SHA
    4462b99 View commit details
  16. Copy the full SHA
    9854e78 View commit details
  17. Copy the full SHA
    c1990ca View commit details
  18. Copy the full SHA
    766a91e View commit details
  19. lots of rearrangement and state added to fullinterpretercontext and s…

    …ome basic outline of flow in prepareFullBuild
    enebo committed Mar 3, 2015
    Copy the full SHA
    e2964e5 View commit details
  20. Copy the full SHA
    16def94 View commit details
  21. Copy the full SHA
    8355e22 View commit details
  22. Copy the full SHA
    5168e0e View commit details
  23. Copy the full SHA
    70539bb View commit details
  24. Copy the full SHA
    a6f82b8 View commit details
  25. Copy the full SHA
    e1d1877 View commit details
  26. Whoops added errant println

    enebo committed Mar 3, 2015
    Copy the full SHA
    d8f0060 View commit details
  27. Copy the full SHA
    112b450 View commit details
  28. Last sloppy commit. CFGBuilder removed from compilerpasses. JIT/Full …

    …build race problem finally solved
    enebo committed Mar 3, 2015
    Copy the full SHA
    63c8149 View commit details
  29. Unbreak the JI code so specs run again and comment out flip specs sin…

    …ce they test flip migrating through eval (which is currently broken and is amazing it ever worked
    enebo committed Mar 3, 2015
    Copy the full SHA
    8c13270 View commit details
Showing with 1,486 additions and 1,206 deletions.
  1. +1 −1 core/src/main/java/org/jruby/Ruby.java
  2. +60 −17 core/src/main/java/org/jruby/compiler/JITCompiler.java
  3. +4 −4 core/src/main/java/org/jruby/internal/runtime/methods/InterpretedIRBodyMethod.java
  4. +0 −13 core/src/main/java/org/jruby/internal/runtime/methods/InterpretedIRMetaClassBody.java
  5. +54 −141 core/src/main/java/org/jruby/internal/runtime/methods/InterpretedIRMethod.java
  6. +369 −0 core/src/main/java/org/jruby/internal/runtime/methods/MixedModeIRMethod.java
  7. +139 −39 core/src/main/java/org/jruby/ir/IRBuilder.java
  8. +23 −48 core/src/main/java/org/jruby/ir/IRClosure.java
  9. +4 −2 core/src/main/java/org/jruby/ir/IREvalScript.java
  10. +4 −4 core/src/main/java/org/jruby/ir/IRFor.java
  11. +43 −2 core/src/main/java/org/jruby/ir/IRManager.java
  12. +13 −18 core/src/main/java/org/jruby/ir/IRMethod.java
  13. +178 −478 core/src/main/java/org/jruby/ir/IRScope.java
  14. +5 −3 core/src/main/java/org/jruby/ir/IRScriptBody.java
  15. +4 −1 core/src/main/java/org/jruby/ir/IRTranslator.java
  16. +9 −25 core/src/main/java/org/jruby/ir/dataflow/DataFlowProblem.java
  17. +1 −1 core/src/main/java/org/jruby/ir/dataflow/FlowGraphNode.java
  18. +3 −4 core/src/main/java/org/jruby/ir/dataflow/analyses/LiveVariableNode.java
  19. +1 −1 core/src/main/java/org/jruby/ir/dataflow/analyses/LiveVariablesProblem.java
  20. +2 −2 core/src/main/java/org/jruby/ir/dataflow/analyses/StoreLocalVarPlacementNode.java
  21. +1 −1 core/src/main/java/org/jruby/ir/dataflow/analyses/StoreLocalVarPlacementProblem.java
  22. +4 −4 core/src/main/java/org/jruby/ir/dataflow/analyses/UnboxableOpsAnalysisNode.java
  23. +0 −1 core/src/main/java/org/jruby/ir/instructions/ProcessModuleBodyInstr.java
  24. +2 −4 core/src/main/java/org/jruby/ir/interpreter/BeginEndInterpreterContext.java
  25. +3 −2 core/src/main/java/org/jruby/ir/interpreter/ClosureInterpreterContext.java
  26. +152 −0 core/src/main/java/org/jruby/ir/interpreter/FullInterpreterContext.java
  27. +3 −9 core/src/main/java/org/jruby/ir/interpreter/Interpreter.java
  28. +88 −83 core/src/main/java/org/jruby/ir/interpreter/InterpreterContext.java
  29. +17 −40 core/src/main/java/org/jruby/ir/interpreter/InterpreterEngine.java
  30. +4 −4 core/src/main/java/org/jruby/ir/interpreter/Profiler.java
  31. +177 −0 core/src/main/java/org/jruby/ir/interpreter/StartupInterpreterEngine.java
  32. +0 −2 core/src/main/java/org/jruby/ir/operands/WrappedIRClosure.java
  33. +2 −9 core/src/main/java/org/jruby/ir/passes/AddCallProtocolInstructions.java
  34. +4 −7 core/src/main/java/org/jruby/ir/passes/AddLocalVarLoadStoreInstructions.java
  35. +0 −35 core/src/main/java/org/jruby/ir/passes/CFGBuilder.java
  36. +1 −7 core/src/main/java/org/jruby/ir/passes/DominatorTreeBuilder.java
  37. +0 −7 core/src/main/java/org/jruby/ir/passes/EnsureTempsAssigned.java
  38. +0 −34 core/src/main/java/org/jruby/ir/passes/LinearizeCFG.java
  39. +4 −11 core/src/main/java/org/jruby/ir/passes/LiveVariableAnalysis.java
  40. +0 −7 core/src/main/java/org/jruby/ir/passes/LocalOptimizationPass.java
  41. +7 −18 core/src/main/java/org/jruby/ir/passes/OptimizeDelegationPass.java
  42. +0 −4 core/src/main/java/org/jruby/ir/passes/OptimizeDynScopesPass.java
  43. +12 −8 core/src/main/java/org/jruby/ir/passes/OptimizeTempVarsPass.java
  44. +2 −2 core/src/main/java/org/jruby/ir/passes/UnboxingPass.java
  45. +2 −2 core/src/main/java/org/jruby/ir/persistence/IRReader.java
  46. +1 −4 core/src/main/java/org/jruby/ir/persistence/IRWriter.java
  47. +1 −1 core/src/main/java/org/jruby/ir/persistence/IRWriterFile.java
  48. +1 −1 core/src/main/java/org/jruby/ir/representations/BasicBlock.java
  49. +11 −30 core/src/main/java/org/jruby/ir/representations/CFG.java
  50. +1 −1 core/src/main/java/org/jruby/ir/representations/CFGLinearizer.java
  51. +17 −9 core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
  52. +2 −4 core/src/main/java/org/jruby/ir/targets/Bootstrap.java
  53. +8 −7 core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
  54. +0 −2 core/src/main/java/org/jruby/ir/transformations/inlining/CFGInliner.java
  55. +1 −11 core/src/main/java/org/jruby/runtime/InterpretedIRBlockBody.java
  56. +2 −0 core/src/main/java/org/jruby/runtime/backtrace/FrameType.java
  57. +38 −31 spec/compiler/general_spec.rb
  58. +1 −0 test/mri/excludes/TestFlip.rb
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -1254,7 +1254,7 @@ private void init() {
initThreadStatuses();

// Create an IR manager and a top-level IR scope and bind it to the top-level static-scope object
irManager = new IRManager();
irManager = new IRManager(getInstanceConfig());
// FIXME: This registers itself into static scope as a side-effect. Let's make this
// relationship handled either more directly or through a descriptice method
// FIXME: We need a failing test case for this since removing it did not regress tests
77 changes: 60 additions & 17 deletions core/src/main/java/org/jruby/compiler/JITCompiler.java
Original file line number Diff line number Diff line change
@@ -37,11 +37,9 @@
import org.jruby.ast.util.SexpMaker;
import org.jruby.internal.runtime.methods.CompiledIRMethod;
import org.jruby.internal.runtime.methods.InterpretedIRMethod;
import org.jruby.internal.runtime.methods.MixedModeIRMethod;
import org.jruby.ir.IRMethod;
import org.jruby.ir.targets.JVMVisitor;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.Block;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.threading.DaemonThreadFactory;
@@ -52,10 +50,8 @@
import org.jruby.util.log.LoggerFactory;
import org.objectweb.asm.Opcodes;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.Method;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Locale;
@@ -150,8 +146,29 @@ public void tearDown() {
}
}
}

public void fullBuildThresholdReached(final InterpretedIRMethod method, final RubyInstanceConfig config) {
// Disable any other jit tasks from entering queue
method.setCallCount(-1);

Runnable jitTask = new FullBuildTask(method);

// if background JIT is enabled and threshold is > 0 and we have an executor...
if (config.getJitBackground() && config.getJitThreshold() > 0 && executor != null) {
// JIT in background
try {
executor.submit(jitTask);
} catch (RejectedExecutionException ree) {
// failed to submit, just run it directly
jitTask.run();
}
} else {
// just run directly
jitTask.run();
}
}

public void jitThresholdReached(final InterpretedIRMethod method, final RubyInstanceConfig config, ThreadContext context, final String className, final String methodName) {
public void jitThresholdReached(final MixedModeIRMethod method, final RubyInstanceConfig config, ThreadContext context, final String className, final String methodName) {
// Disable any other jit tasks from entering queue
method.setCallCount(-1);

@@ -176,12 +193,38 @@ public void jitThresholdReached(final InterpretedIRMethod method, final RubyInst

private static final MethodHandles.Lookup PUBLIC_LOOKUP = MethodHandles.publicLookup().in(Ruby.class);

private class FullBuildTask implements Runnable {
private final InterpretedIRMethod method;

public FullBuildTask(InterpretedIRMethod method) {
this.method = method;
}

public void run() {
try {
method.switchToFullBuild(method.getIRMethod().prepareFullBuild());

if (config.isJitLogging()) {
log(method.getImplementationClass(), method.getFile(), method.getLine(), method.getName(), "done building");
}
} catch (Throwable t) {
if (config.isJitLogging()) {
log(method.getImplementationClass(), method.getFile(), method.getLine(), method.getName(),
"Could not build; passes run: " + method.getIRMethod().getExecutedPasses(), t.getMessage());
if (config.isJitLoggingVerbose()) {
t.printStackTrace();
}
}
}
}
}

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

public JITTask(String className, InterpretedIRMethod method, String methodName) {
public JITTask(String className, MixedModeIRMethod method, String methodName) {
this.className = className;
this.method = method;
this.methodName = methodName;
@@ -203,7 +246,7 @@ public void run() {
|| config.getExcludedMethods().contains(excludeModuleName + "#" + methodName)
|| config.getExcludedMethods().contains(methodName))) {
method.setCallCount(-1);
log(method, methodName, "skipping method: " + excludeModuleName + "#" + methodName);
log(method.getImplementationClass(), method.getFile(), method.getLine(), methodName, "skipping method: " + excludeModuleName + "#" + methodName);
return;
}
}
@@ -235,12 +278,12 @@ public void run() {
// logEvery n methods based on configuration
if (config.getJitLogEvery() > 0) {
if (methodCount % config.getJitLogEvery() == 0) {
log(method, methodName, "live compiled methods: " + methodCount);
log(method.getImplementationClass(), method.getFile(), method.getLine(), methodName, "live compiled methods: " + methodCount);
}
}

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

Map<Integer, MethodType> signatures = ((IRMethod)method.getIRMethod()).getNativeSignatures();
@@ -273,7 +316,7 @@ public void run() {
return;
} catch (Throwable t) {
if (config.isJitLogging()) {
log(method, className + "." + methodName, "Could not compile; passes run: " + method.getIRMethod().getExecutedPasses(), t.getMessage());
log(method.getImplementationClass(), method.getFile(), method.getLine(), className + "." + methodName, "Could not compile; passes run: " + method.getIRMethod().getExecutedPasses(), t.getMessage());
if (config.isJitLoggingVerbose()) {
t.printStackTrace();
}
@@ -305,7 +348,7 @@ public static String getHashForBytes(byte[] bytes) {
}

public static class JITClassGenerator {
public JITClassGenerator(String className, String methodName, String key, Ruby ruby, InterpretedIRMethod method, JVMVisitor visitor) {
public JITClassGenerator(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
@@ -378,20 +421,20 @@ public String toString() {
private final String className;
private final String methodName;
private final String digestString;
private final InterpretedIRMethod method;
private final MixedModeIRMethod method;
private final JVMVisitor visitor;

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

static void log(InterpretedIRMethod method, String name, String message, String... reason) {
String className = method.getImplementationClass().getBaseName();
static void log(RubyModule implementationClass, String file, int line, String name, String message, String... reason) {
String className = implementationClass.getBaseName();

if (className == null) className = "<anon class>";

StringBuilder builder = new StringBuilder(message + ":" + className + "." + name + " at " + method.getIRMethod().getFileName() + ":" + method.getIRMethod().getLineNumber());
StringBuilder builder = new StringBuilder(message + ":" + className + "." + name + " at " + file + ":" + line);

if (reason.length > 0) {
builder.append(" because of: \"");
Original file line number Diff line number Diff line change
@@ -18,12 +18,12 @@ public class InterpretedIRBodyMethod extends InterpretedIRMethod {
public InterpretedIRBodyMethod(IRScope method, RubyModule implementationClass) {
super(method, Visibility.PUBLIC, implementationClass);

this.box.callCount = -1;
callCount = -1;
}

@Override
public List<String[]> getParameterList() {
return new ArrayList<String[]>();
return new ArrayList<>();
}

@Override
@@ -40,10 +40,10 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
return ic.engine.interpret(context, self, ic, getImplementationClass().getMethodLocation(), name, block, null);
} else {
try {
this.pre(ic, context, self, name, block, getImplementationClass());
pre(ic, context, self, name, block, getImplementationClass());
return ic.engine.interpret(context, self, ic, getImplementationClass().getMethodLocation(), name, block, null);
} finally {
this.post(ic, context);
post(ic, context);
}
}
}
Original file line number Diff line number Diff line change
@@ -36,11 +36,6 @@ protected void pre(InterpreterContext ic, ThreadContext context, IRubyObject sel

@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, Block block) {
DynamicMethodBox box = this.box;
if (box.callCount >= 0) tryJit(context, box);
DynamicMethod actualMethod = box.actualMethod;
if (actualMethod != null) return actualMethod.call(context, self, clazz, name, block);

InterpreterContext ic = ensureInstrsReady();

if (IRRuntimeHelpers.isDebug()) doDebug();
@@ -57,12 +52,4 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
}
}
}

@Override
public DynamicMethod dup() {
InterpretedIRMetaClassBody x = new InterpretedIRMetaClassBody(method, implementationClass);
x.dupBox(this);

return x;
}
}
Loading