Skip to content

Commit

Permalink
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -419,7 +419,6 @@ protected static void processBookKeepingOp(ThreadContext context, Block block, I
protected static IRubyObject processReturnOp(ThreadContext context, Block block, Instr instr, Operation operation,
DynamicScope currDynScope, Object[] temp, IRubyObject self,
StaticScope currScope) {
Block.Type blockType = block == null ? null : block.type;
switch(operation) {
// --------- Return flavored instructions --------
case RETURN: {
@@ -433,12 +432,12 @@ protected static IRubyObject processReturnOp(ThreadContext context, Block block,
// This assumes that scopes with break instr. have a frame / dynamic scope
// pushed so that we can get to its static scope. For-loops now always have
// a dyn-scope pushed onto stack which makes this work in all scenarios.
return IRRuntimeHelpers.initiateBreak(context, currDynScope, rv, block, blockType);
return IRRuntimeHelpers.initiateBreak(context, currDynScope, rv, block);
}
case NONLOCAL_RETURN: {
NonlocalReturnInstr ri = (NonlocalReturnInstr)instr;
IRubyObject rv = (IRubyObject)retrieveOp(ri.getReturnValue(), context, self, currDynScope, currScope, temp);
return IRRuntimeHelpers.initiateNonLocalReturn(context, currDynScope, blockType, rv);
return IRRuntimeHelpers.initiateNonLocalReturn(context, currDynScope, block, rv);
}
case RETURN_OR_RETHROW_SAVED_EXC: {
IRubyObject retVal = (IRubyObject) retrieveOp(((ReturnBase) instr).getReturnValue(), context, self, currDynScope, currScope, temp);
8 changes: 4 additions & 4 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Original file line number Diff line number Diff line change
@@ -95,8 +95,8 @@ public static void checkForLJE(ThreadContext context, DynamicScope dynScope, boo
}

// Create a jump for a non-local return which will return from nearest lambda (which may be itself) or method.
public static IRubyObject initiateNonLocalReturn(ThreadContext context, DynamicScope dynScope, Block.Type blockType, IRubyObject returnValue) {
if (IRRuntimeHelpers.inLambda(blockType)) throw new IRWrappedLambdaReturnValue(returnValue);
public static IRubyObject initiateNonLocalReturn(ThreadContext context, DynamicScope dynScope, Block block, IRubyObject returnValue) {
if (IRRuntimeHelpers.inLambda(block.type)) throw new IRWrappedLambdaReturnValue(returnValue);

throw IRReturnJump.create(getContainingMethodOrLambdasDynamicScope(dynScope), returnValue);
}
@@ -159,10 +159,10 @@ private static IRScopeType ensureScopeIsClosure(ThreadContext context, DynamicSc
}

// FIXME: When we recompile lambdas we can eliminate this binary code path and we can emit as a NONLOCALRETURN directly.
public static IRubyObject initiateBreak(ThreadContext context, DynamicScope dynScope, IRubyObject breakValue, Block block, Block.Type blockType) throws RuntimeException {
public static IRubyObject initiateBreak(ThreadContext context, DynamicScope dynScope, IRubyObject breakValue, Block block) throws RuntimeException {
// Wrap the return value in an exception object and push it through the break exception
// paths so that ensures are run, frames/scopes are popped from runtime stacks, etc.
if (inLambda(blockType)) throw new IRWrappedLambdaReturnValue(breakValue);
if (inLambda(block.type)) throw new IRWrappedLambdaReturnValue(breakValue);

IRScopeType scopeType = ensureScopeIsClosure(context, dynScope);

0 comments on commit fb15a7d

Please sign in to comment.