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

Commits on Apr 25, 2018

  1. Copy the full SHA
    18849e2 View commit details
  2. Copy the full SHA
    cf66ceb View commit details
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -1141,9 +1141,9 @@ private IRubyObject op_equalCommon(ThreadContext context, IRubyObject other) {
return sites(context).equals.call(context, this, other, this).isTrue() ? runtime.getTrue() : runtime.getFalse();
}

@JRubyMethod(name = "-@") // -'foo' returns frozen string
@JRubyMethod(name = "-@") // -'foo' returns deduplicated (interned) string
public final IRubyObject minus_at(ThreadContext context) {
return isFrozen() ? this : context.runtime.freezeAndDedupString(this);
return context.runtime.freezeAndDedupString(this);
}

@JRubyMethod(name = "+@") // +'foo' returns modifiable string
4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -3792,6 +3792,10 @@ private InterpreterContext buildRootInner(RootNode rootNode) {
// Build IR for the tree and return the result of the expression tree
addInstr(new ReturnInstr(build(rootNode.getBodyNode())));

scope.computeScopeFlagsEarly(instructions);
// Root scope can receive returns now, so we add non-local return logic if necessary (2.5+)
if (scope.canReceiveNonlocalReturns()) handleNonlocalReturnInMethod();

return scope.allocateInterpreterContext(instructions);
}

18 changes: 11 additions & 7 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Original file line number Diff line number Diff line change
@@ -116,12 +116,15 @@ public static void checkForLJE(ThreadContext context, DynamicScope dynScope, boo
if (inLambda(blockType)) return; // break/return in lambda unconditionally a return.

dynScope = getContainingMethodsDynamicScope(dynScope);
boolean inDefineMethod = dynScope != null && dynScope.getStaticScope().isArgumentScope() && dynScope.getStaticScope().getScopeType().isBlock();
StaticScope staticScope = dynScope.getStaticScope();
boolean inDefineMethod = dynScope != null && staticScope.isArgumentScope() && staticScope.getScopeType().isBlock();
boolean topLevel = staticScope.getScopeType() == IRScopeType.SCRIPT_BODY;

// Is our proc in something unreturnable (e.g. module/class) or has it migrated (lexical parent method not in stack any more)?
if (!definedWithinMethod && !inDefineMethod || !context.scopeExistsOnCallStack(dynScope)) {
throw IRException.RETURN_LocalJumpError.getException(context.runtime);
if ((definedWithinMethod || inDefineMethod || topLevel) && context.scopeExistsOnCallStack(dynScope)) {
return;
}

throw IRException.RETURN_LocalJumpError.getException(context.runtime);
}

// Create a jump for a non-local return which will return from nearest lambda (which may be itself) or method.
@@ -138,7 +141,7 @@ private static DynamicScope getContainingMethodsDynamicScope(DynamicScope dynSco
IRScopeType scopeType = scope.getScopeType();

// We hit a method boundary (actual method or a define_method closure).
if (scopeType.isMethodType() || scopeType.isBlock() && scope.isArgumentScope()) return dynScope;
if (scopeType.isMethodType() || scopeType.isBlock() && scope.isArgumentScope() || scopeType == IRScopeType.SCRIPT_BODY) return dynScope;
}

return null;
@@ -152,8 +155,9 @@ private static DynamicScope getContainingMethodOrLambdasDynamicScope(DynamicScop
IRScope scope = staticScope.getIRScope();

// 1) method 2) lambda 3) closure (define_method) for zsuper
if (scope instanceof IRMethod ||
(scope instanceof IRClosure && (dynScope.isLambda() || staticScope.isArgumentScope()))) return dynScope;
if (scope instanceof IRMethod
|| scope instanceof IRScriptBody
|| (scope instanceof IRClosure && (dynScope.isLambda() || staticScope.isArgumentScope()))) return dynScope;
}

return null;