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

Commits on Oct 17, 2014

  1. [Truffle] Introduce LexicalScope to resolve constants.

    * Built during parsing, and completed with live modules when opening those.
    * No need for callingSelf except in the rare case of protected.
    * A few improvements on visbility checking.
    eregon committed Oct 17, 2014
    Copy the full SHA
    f25baf2 View commit details
  2. Copy the full SHA
    3b681af View commit details
  3. Copy the full SHA
    10be6ba View commit details
  4. Copy the full SHA
    5b6c7cf View commit details

Commits on Oct 20, 2014

  1. Copy the full SHA
    380de3b View commit details
  2. Copy the full SHA
    9640076 View commit details
  3. Copy the full SHA
    21d30da View commit details
  4. Copy the full SHA
    caf16a0 View commit details

Commits on Oct 21, 2014

  1. [Truffle] Fix Module#name.

    eregon committed Oct 21, 2014
    Copy the full SHA
    aa13f0c View commit details
  2. [Truffle] Fix most of constant lookup!

    * Use lexical scoping instead of pseudo-dynamic scoping.
    * Stop defining constants on singleton class, we define on the receiver only.
    * Temporarily disable the constant cache, we want better semantics first.
    eregon committed Oct 21, 2014
    Copy the full SHA
    286bee2 View commit details
  3. Copy the full SHA
    54be7dd View commit details
  4. Copy the full SHA
    002a256 View commit details
  5. Copy the full SHA
    f9292f3 View commit details
  6. Copy the full SHA
    5ccb89a View commit details
  7. Copy the full SHA
    4087b83 View commit details
  8. [Truffle] A few more specs in language/ are passing.

    * Also includes some fixes by the method lookup changes.
    eregon committed Oct 21, 2014
    Copy the full SHA
    9788867 View commit details
  9. [Truffle] Merge branch 'lexical_scope'

    * Constant cache is disabled for now.
    
    Conflicts:
    	core/src/main/java/org/jruby/truffle/nodes/core/CoreMethodNodeManager.java
    	core/src/main/java/org/jruby/truffle/runtime/RubyContext.java
    eregon committed Oct 21, 2014
    Copy the full SHA
    d673d88 View commit details
  10. Copy the full SHA
    c34c031 View commit details
  11. Copy the full SHA
    41aa299 View commit details
  12. Refactor and generify invokable wrappers for IR.

    * Factor out common code in several class/method instrs.
    * Reused factored code for both JIT and interp.
    * Align Compiled* method wrappers with interpreted versions.
    headius committed Oct 21, 2014
    Copy the full SHA
    df42503 View commit details
  13. Copy the full SHA
    79eb010 View commit details
  14. Copy the full SHA
    2cd322f View commit details
  15. Copy the full SHA
    f586a37 View commit details
Showing with 875 additions and 925 deletions.
  1. +2 −7 core/src/main/java/org/jruby/compiler/JITCompiler.java
  2. +65 −0 core/src/main/java/org/jruby/internal/runtime/methods/CompiledIRMetaClassBody.java
  3. +45 −156 core/src/main/java/org/jruby/internal/runtime/methods/CompiledIRMethod.java
  4. +4 −0 core/src/main/java/org/jruby/internal/runtime/methods/IRMethodArgs.java
  5. +10 −9 core/src/main/java/org/jruby/ir/IRBuilder.java
  6. +2 −2 core/src/main/java/org/jruby/ir/IRClosure.java
  7. +3 −2 core/src/main/java/org/jruby/ir/IRMethod.java
  8. +8 −0 core/src/main/java/org/jruby/ir/JIT.java
  9. +4 −30 core/src/main/java/org/jruby/ir/instructions/DefineClassInstr.java
  10. +2 −17 core/src/main/java/org/jruby/ir/instructions/DefineClassMethodInstr.java
  11. +1 −17 core/src/main/java/org/jruby/ir/instructions/DefineInstanceMethodInstr.java
  12. +3 −6 core/src/main/java/org/jruby/ir/instructions/DefineMetaClassInstr.java
  13. +2 −10 core/src/main/java/org/jruby/ir/instructions/DefineModuleInstr.java
  14. +10 −0 core/src/main/java/org/jruby/ir/runtime/IRBreakJump.java
  15. +10 −0 core/src/main/java/org/jruby/ir/runtime/IRReturnJump.java
  16. +167 −15 core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
  17. +31 −229 core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
  18. +6 −9 core/src/main/java/org/jruby/runtime/CompiledIRBlockBody.java
  19. +14 −8 core/src/main/java/org/jruby/runtime/Helpers.java
  20. +1 −1 core/src/main/java/org/jruby/runtime/InterpretedIRBlockBody.java
  21. +20 −11 core/src/main/java/org/jruby/truffle/nodes/ReadConstantNode.java
  22. +2 −1 core/src/main/java/org/jruby/truffle/nodes/RubyCallNode.java
  23. +5 −0 core/src/main/java/org/jruby/truffle/nodes/RubyNode.java
  24. +2 −0 core/src/main/java/org/jruby/truffle/nodes/RubyTypes.java
  25. +12 −5 core/src/main/java/org/jruby/truffle/nodes/WriteConstantNode.java
  26. +2 −2 core/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
  27. +2 −2 core/src/main/java/org/jruby/truffle/nodes/core/CoreMethodNodeManager.java
  28. +1 −1 core/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
  29. +19 −9 core/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java
  30. +1 −1 core/src/main/java/org/jruby/truffle/nodes/core/SystemNode.java
  31. +6 −5 core/src/main/java/org/jruby/truffle/nodes/dispatch/CachedBooleanDispatchNode.java
  32. +6 −5 core/src/main/java/org/jruby/truffle/nodes/dispatch/CachedBoxedDispatchNode.java
  33. +6 −5 core/src/main/java/org/jruby/truffle/nodes/dispatch/CachedBoxedMethodMissingDispatchNode.java
  34. +6 −5 core/src/main/java/org/jruby/truffle/nodes/dispatch/CachedBoxedReturnMissingDispatchNode.java
  35. +5 −4 core/src/main/java/org/jruby/truffle/nodes/dispatch/CachedBoxedSymbolDispatchNode.java
  36. +2 −1 core/src/main/java/org/jruby/truffle/nodes/dispatch/CachedDispatchNode.java
  37. +7 −6 core/src/main/java/org/jruby/truffle/nodes/dispatch/CachedUnboxedDispatchNode.java
  38. +6 −6 core/src/main/java/org/jruby/truffle/nodes/dispatch/DispatchHeadNode.java
  39. +10 −23 core/src/main/java/org/jruby/truffle/nodes/dispatch/DispatchNode.java
  40. +19 −12 core/src/main/java/org/jruby/truffle/nodes/dispatch/GenericDispatchNode.java
  41. +52 −48 core/src/main/java/org/jruby/truffle/nodes/dispatch/UnresolvedDispatchNode.java
  42. +3 −0 core/src/main/java/org/jruby/truffle/nodes/methods/MethodDefinitionNode.java
  43. +8 −9 core/src/main/java/org/jruby/truffle/nodes/objects/DefineOrGetClassNode.java
  44. +8 −9 core/src/main/java/org/jruby/truffle/nodes/objects/DefineOrGetModuleNode.java
  45. +41 −0 core/src/main/java/org/jruby/truffle/nodes/objects/LexicalScopeNode.java
  46. +3 −0 core/src/main/java/org/jruby/truffle/nodes/objects/OpenModuleNode.java
  47. +2 −1 core/src/main/java/org/jruby/truffle/nodes/supercall/AbstractGeneralSuperCallNode.java
  48. +43 −0 core/src/main/java/org/jruby/truffle/runtime/LexicalScope.java
  49. +21 −14 core/src/main/java/org/jruby/truffle/runtime/ModuleOperations.java
  50. +22 −0 core/src/main/java/org/jruby/truffle/runtime/RubyContext.java
  51. +4 −0 core/src/main/java/org/jruby/truffle/runtime/core/CoreLibrary.java
  52. +1 −1 core/src/main/java/org/jruby/truffle/runtime/core/RubyBasicObject.java
  53. +1 −1 core/src/main/java/org/jruby/truffle/runtime/core/RubyClass.java
  54. +9 −54 core/src/main/java/org/jruby/truffle/runtime/core/RubyModule.java
  55. +1 −1 core/src/main/java/org/jruby/truffle/runtime/core/RubySymbol.java
  56. +4 −21 core/src/main/java/org/jruby/truffle/runtime/methods/RubyMethod.java
  57. +16 −1 core/src/main/java/org/jruby/truffle/runtime/methods/SharedMethodInfo.java
  58. +1 −1 core/src/main/java/org/jruby/truffle/runtime/subsystems/FeatureManager.java
  59. +97 −58 core/src/main/java/org/jruby/truffle/translator/BodyTranslator.java
  60. +1 −24 core/src/main/java/org/jruby/truffle/translator/ModuleTranslator.java
  61. +3 −4 core/src/main/java/org/jruby/truffle/translator/TranslatorDriver.java
  62. +2 −22 spec/compiler/general_spec.rb
  63. +0 −1 spec/truffle/tags/language/class_tags.txt
  64. +0 −20 spec/truffle/tags/language/constants_tags.txt
  65. +0 −4 spec/truffle/tags/language/defined_tags.txt
  66. +1 −5 spec/truffle/tags/language/metaclass_tags.txt
  67. +1 −0 spec/truffle/tags/language/module_tags.txt
  68. +0 −1 spec/truffle/tags/language/send_tags.txt
  69. +1 −3 spec/truffle/tags/language/singleton_class_tags.txt
9 changes: 2 additions & 7 deletions core/src/main/java/org/jruby/compiler/JITCompiler.java
Original file line number Diff line number Diff line change
@@ -252,14 +252,9 @@ public void run() {
method.switchToJitted(
new CompiledIRMethod(
handle,
method.getName(),
method.getFile(),
method.getLine(),
method.getStaticScope(),
method.getIRMethod(),
method.getVisibility(),
method.getImplementationClass(),
Helpers.encodeParameterList(method.getParameterList()),
method.getIRMethod().hasExplicitCallProtocol()));
method.getImplementationClass()));

return;
} catch (Throwable t) {
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package org.jruby.internal.runtime.methods;

import org.jruby.RubyModule;
import org.jruby.ir.IRFlags;
import org.jruby.ir.IRMetaClassBody;
import org.jruby.ir.IRScope;
import org.jruby.ir.interpreter.InterpreterContext;
import org.jruby.runtime.Block;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;

import java.lang.invoke.MethodHandle;
import java.util.ArrayList;
import java.util.List;

public class CompiledIRMetaClassBody extends CompiledIRMethod {
private final IRMetaClassBody irMetaClassBody;
private final boolean reuseParentDynScope;
private final boolean pushNewDynScope;
private final boolean popDynScope;

public CompiledIRMetaClassBody(MethodHandle handle, IRScope scope, RubyModule implementationClass) {
super(handle, scope, Visibility.PUBLIC, implementationClass);

irMetaClassBody = (IRMetaClassBody)scope;
this.reuseParentDynScope = scope.getFlags().contains(IRFlags.REUSE_PARENT_DYNSCOPE);
this.pushNewDynScope = !scope.getFlags().contains(IRFlags.DYNSCOPE_ELIMINATED) && !this.reuseParentDynScope;
this.popDynScope = this.pushNewDynScope || this.reuseParentDynScope;
}

public String[] getParameterList() {
return new String[0];
}

@Override
protected void post(ThreadContext context) {
// update call stacks (pop: ..)
context.popFrame();
if (popDynScope) {
context.popScope();
}
}

@Override
protected void pre(ThreadContext context, IRubyObject self, String name, Block block) {
// update call stacks (push: frame, class, scope, etc.)
context.preMethodFrameOnly(getImplementationClass(), name, self, block);
if (pushNewDynScope) {
// Add a parent-link to current dynscope to support non-local returns cheaply
// This doesn't affect variable scoping since local variables will all have
// the right scope depth.
context.pushScope(DynamicScope.newDynamicScope(method.getStaticScope(), context.getCurrentScope()));
}
context.setCurrentVisibility(getVisibility());
}

@Override
public DynamicMethod dup() {
CompiledIRMetaClassBody x = new CompiledIRMetaClassBody(handle, method, implementationClass);

return x;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.jruby.internal.runtime.methods;

import org.jruby.RubyModule;
import org.jruby.ir.IRMethod;
import org.jruby.ir.IRScope;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.Arity;
@@ -13,55 +15,46 @@
import org.jruby.util.log.LoggerFactory;

import java.lang.invoke.MethodHandle;
import java.util.ArrayList;
import java.util.List;

import org.jruby.runtime.Helpers;

public class CompiledIRMethod extends JavaMethod implements Cloneable, PositionAware, MethodArgs2 {
public class CompiledIRMethod extends JavaMethod implements MethodArgs2, PositionAware {
private static final Logger LOG = LoggerFactory.getLogger("CompiledIRMethod");

private final MethodHandle method;
private final String name;
private final String file;
private final int line;
private final StaticScope scope;
private Arity arity;
private final boolean hasExplicitCallProtocol;

public CompiledIRMethod(MethodHandle method, String name, String file, int line, StaticScope scope,
Visibility visibility, RubyModule implementationClass, String parameterDesc, boolean hasExplicitCallProtocol) {
super(implementationClass, visibility, CallConfiguration.FrameNoneScopeNone);
protected final MethodHandle handle;

protected final IRScope method;
private final Arity arity;
private String[] parameterList;

public CompiledIRMethod(MethodHandle handle, IRScope method, Visibility visibility, RubyModule implementationClass) {
super(implementationClass, visibility, CallConfiguration.FrameNoneScopeNone, method.getName());
this.handle = handle;
this.method = method;
this.name = name;
this.file = file;
this.line = line;
this.scope = scope;
this.scope.determineModule();
this.method.getStaticScope().determineModule();
this.arity = calculateArity();
this.hasExplicitCallProtocol = hasExplicitCallProtocol;

setParameterDesc(parameterDesc);
setHandle(handle);
}

setHandle(method);
public IRScope getIRMethod() {
return method;
}

public CompiledIRMethod(MethodHandle method, String name, String file, int line, StaticScope scope,
Visibility visibility, RubyModule implementationClass, String[] parameterList, boolean hasExplicitCallProtocol) {
super(implementationClass, visibility, CallConfiguration.FrameNoneScopeNone);
this.method = method;
this.name = name;
this.file = file;
this.line = line;
this.scope = scope;
this.scope.determineModule();
this.arity = calculateArity();
this.hasExplicitCallProtocol = hasExplicitCallProtocol;
public StaticScope getStaticScope() {
return method.getStaticScope();
}

setParameterList(parameterList);
public String[] getParameterList() {
if (parameterList != null) return parameterList;

setHandle(method);
return parameterList = Helpers.irMethodArgsToParameters(((IRMethod)method).getArgDesc());
}

private Arity calculateArity() {
StaticScope s = scope;
StaticScope s = getStaticScope();
if (s.getOptionalArgs() > 0 || s.getRestArg() >= 0) return Arity.required(s.getRequiredArgs());

return Arity.createArity(s.getRequiredArgs());
@@ -72,158 +65,54 @@ public Arity getArity() {
return this.arity;
}

@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
if (IRRuntimeHelpers.isDebug()) {
// FIXME: name should probably not be "" ever.
String realName = name == null || "".equals(name) ? this.name : name;
LOG.info("Executing '" + realName + "'");
}

if (!hasExplicitCallProtocol) {
// update call stacks (push: frame, class, scope, etc.)
RubyModule implementationClass = getImplementationClass();
context.preMethodFrameAndScope(implementationClass, name, self, block, scope);
// FIXME: does not seem right to use this method's visibility as current!!!
// See also PushFrame instruction in org.jruby.ir.targets.JVMVisitor
context.setCurrentVisibility(Visibility.PUBLIC);
}

try {
return (IRubyObject)this.method.invokeExact(context, scope, self, args, block, implementationClass);
} catch (Throwable t) {
Helpers.throwException(t);
// not reached
return null;
} finally {
if (!hasExplicitCallProtocol) {
// update call stacks (pop: ..)
context.popFrame();
context.postMethodScopeOnly();
}
}
}

public boolean hasExplicitCallProtocol() {
return hasExplicitCallProtocol;
}
// Because compiled IR methods have been simplified to just use IRubyObject[], we have no specific-arity paths.
// This will come later by specializing the IR.
/*
@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, Block block) {
if (IRRuntimeHelpers.isDebug()) {
// FIXME: name should probably not be "" ever.
String realName = name == null || "".equals(name) ? this.name : name;
LOG.info("Executing '" + realName + "'");
}
try {
// update call stacks (push: frame, class, scope, etc.)
RubyModule implementationClass = getImplementationClass();
context.preMethodFrameAndScope(implementationClass, name, self, block, scope);
context.setCurrentVisibility(getVisibility());
return (IRubyObject)this.method.invokeWithArguments(context, scope, self, block);
} catch (Throwable t) {
Helpers.throwException(t);
// not reached
return null;
} finally {
protected void post(ThreadContext context) {
if (!method.hasExplicitCallProtocol()) {
// update call stacks (pop: ..)
context.popFrame();
context.postMethodScopeOnly();
}
}

@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, Block block) {
if (IRRuntimeHelpers.isDebug()) {
// FIXME: name should probably not be "" ever.
String realName = name == null || "".equals(name) ? this.name : name;
LOG.info("Executing '" + realName + "'");
}
try {
protected void pre(ThreadContext context, IRubyObject self, String name, Block block) {
if (!method.hasExplicitCallProtocol()) {
// update call stacks (push: frame, class, scope, etc.)
RubyModule implementationClass = getImplementationClass();
context.preMethodFrameAndScope(implementationClass, name, self, block, scope);
context.setCurrentVisibility(getVisibility());
return (IRubyObject)this.method.invokeWithArguments(context, scope, self, arg0, block);
} catch (Throwable t) {
Helpers.throwException(t);
// not reached
return null;
} finally {
// update call stacks (pop: ..)
context.popFrame();
context.postMethodScopeOnly();
context.preMethodFrameAndScope(implementationClass, name, self, block, method.getStaticScope());
// FIXME: does not seem right to use this method's visibility as current!!!
// See also PushFrame instruction in org.jruby.ir.targets.JVMVisitor
context.setCurrentVisibility(Visibility.PUBLIC);
}
}

@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, Block block) {
if (IRRuntimeHelpers.isDebug()) {
// FIXME: name should probably not be "" ever.
String realName = name == null || "".equals(name) ? this.name : name;
LOG.info("Executing '" + realName + "'");
}
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
pre(context, self, name, block);

try {
// update call stacks (push: frame, class, scope, etc.)
RubyModule implementationClass = getImplementationClass();
context.preMethodFrameAndScope(implementationClass, name, self, block, scope);
context.setCurrentVisibility(getVisibility());
return (IRubyObject)this.method.invokeWithArguments(context, scope, self, arg0, arg1, block);
return (IRubyObject)this.handle.invokeExact(context, method.getStaticScope(), self, args, block, implementationClass);
} catch (Throwable t) {
Helpers.throwException(t);
// not reached
return null;
} finally {
// update call stacks (pop: ..)
context.popFrame();
context.postMethodScopeOnly();
post(context);
}
}

@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) {
if (IRRuntimeHelpers.isDebug()) {
// FIXME: name should probably not be "" ever.
String realName = name == null || "".equals(name) ? this.name : name;
LOG.info("Executing '" + realName + "'");
}
try {
// update call stacks (push: frame, class, scope, etc.)
RubyModule implementationClass = getImplementationClass();
context.preMethodFrameAndScope(implementationClass, name, self, block, scope);
context.setCurrentVisibility(getVisibility());
return (IRubyObject)this.method.invokeWithArguments(context, scope, self, arg0, arg1, arg2, block);
} catch (Throwable t) {
Helpers.throwException(t);
// not reached
return null;
} finally {
// update call stacks (pop: ..)
context.popFrame();
context.postMethodScopeOnly();
}
public boolean hasExplicitCallProtocol() {
return method.hasExplicitCallProtocol();
}
*/

@Override
public DynamicMethod dup() {
return new CompiledIRMethod(method, name, file, line, scope, visibility, implementationClass, getParameterList(), hasExplicitCallProtocol);
return new CompiledIRMethod(handle, method, visibility, implementationClass);
}

public String getFile() {
return file;
return method.getFileName();
}

public int getLine() {
return line;
}

public StaticScope getStaticScope() {
return scope;
return method.getLineNumber();
}
}
Original file line number Diff line number Diff line change
@@ -4,4 +4,8 @@

public interface IRMethodArgs {
public List<String[]> getParameterList();

public enum ArgType {
key, keyrest, block, opt, rest, req
}
}
Loading