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: 07ff81994756
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 80c178618e2a
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Mar 22, 2017

  1. Copy the full SHA
    e9ffc2d View commit details
  2. Remove variable inDefineMethod for early return.

    Make two types of scope names more obviously different.
    enebo committed Mar 22, 2017
    Copy the full SHA
    80c1786 View commit details
Showing with 12 additions and 32 deletions.
  1. +12 −32 core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
44 changes: 12 additions & 32 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Original file line number Diff line number Diff line change
@@ -80,40 +80,20 @@ public static boolean inProc(Block.Type blockType) {
}

public static void checkForLJE(ThreadContext context, DynamicScope dynScope, boolean maybeLambda, Block.Type blockType) {
if (IRRuntimeHelpers.inLambda(blockType)) return;

StaticScope scope = dynScope.getStaticScope();
IRScopeType scopeType = scope.getScopeType();
boolean inDefineMethod = false;
while (dynScope != null) {
StaticScope ss = dynScope.getStaticScope();
// SSS FIXME: Why is scopeType empty? Looks like this static-scope
// was not associated with the AST scope that got converted to IR.
//
// Ruby code: lambda { Thread.new { return }.join }.call
//
// To be investigated.
IRScopeType ssType = ss.getScopeType();
if (ssType != null) {
if (ssType.isMethodType()) {
break;
} else if (ss.isArgumentScope() && ssType.isClosureType() && ssType != IRScopeType.EVAL_SCRIPT) {
inDefineMethod = true;
break;
}
}
dynScope = dynScope.getParentScope();
if (IRRuntimeHelpers.inLambda(blockType)) return; // break/return in lambda will return from lambda (no LJE possible).

StaticScope entryScope = dynScope.getStaticScope();
IRScopeType entryScopeType = entryScope.getScopeType();

for (; dynScope != null; dynScope = dynScope.getParentScope()) {
StaticScope currentScope = dynScope.getStaticScope();
IRScopeType currentScopeType = currentScope.getScopeType();

if (currentScopeType.isMethodType()) break;
if (currentScope.isArgumentScope() && currentScopeType.isClosureType() && currentScopeType != IRScopeType.EVAL_SCRIPT) return;
}

// SSS FIXME: Why is scopeType empty? Looks like this static-scope
// was not associated with the AST scope that got converted to IR.
//
// Ruby code: lambda { Thread.new { return }.join }.call
//
// To be investigated.
if ( (scopeType == null || (!inDefineMethod && scopeType.isClosureType() && scopeType != IRScopeType.EVAL_SCRIPT))
&& (maybeLambda || !context.scopeExistsOnCallStack(dynScope)))
{
if (entryScopeType.isClosureType() && entryScopeType != IRScopeType.EVAL_SCRIPT && (maybeLambda || !context.scopeExistsOnCallStack(dynScope))) {
// Cannot return from the call that we have long since exited.
throw IRException.RETURN_LocalJumpError.getException(context.runtime);
}