Skip to content

Commit

Permalink
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions core/src/main/java/org/jruby/runtime/CompiledIRBlockBody.java
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ public ArgumentDescriptor[] getArgumentDescriptors() {

@Override
public boolean canCallDirect() {
return true;
return closure.hasExplicitCallProtocol();
}

@Override
@@ -58,44 +58,44 @@ protected IRubyObject yieldDirect(ThreadContext context, Block block, IRubyObjec
}
}

// @Override
// protected IRubyObject commonYieldPath(ThreadContext context, Block block, Block.Type type, IRubyObject[] args, IRubyObject self, Block blockArg) {
// Binding binding = block.getBinding();
// Visibility oldVis = binding.getFrame().getVisibility();
// Frame prevFrame = context.preYieldNoScope(binding);
//
// // SSS FIXME: Maybe, we should allocate a NoVarsScope/DummyScope for for-loop bodies because the static-scope here
// // probably points to the parent scope? To be verified and fixed if necessary. There is no harm as it is now. It
// // is just wasteful allocation since the scope is not used at all.
// DynamicScope prevScope = binding.getDynamicScope();
// if (this.pushScope) {
// // SSS FIXME: for lambdas, this behavior is different
// // compared to what InterpretedIRBlockBody and MixedModeIRBlockBody do
// context.pushScope(DynamicScope.newDynamicScope(getStaticScope(), prevScope, this.evalType.get()));
// } else if (this.reuseParentScope) {
// // Reuse! We can avoid the push only if surrounding vars aren't referenced!
// context.pushScope(prevScope);
// }
//
// self = IRRuntimeHelpers.updateBlockState(block, self);
//
// if (usesKwargs) IRRuntimeHelpers.frobnicateKwargsArgument(context, getSignature().required(), args);
//
// try {
// return (IRubyObject) handle.invokeExact(context, block, getStaticScope(), self, args, blockArg, binding.getMethod(), block.type);
// } catch (Throwable t) {
// Helpers.throwException(t);
// return null; // not reached
// } finally {
// // IMPORTANT: Do not clear eval-type in case this is reused in bindings!
// // Ex: eval("...", foo.instance_eval { binding })
// // The dyn-scope used for binding needs to have its eval-type set to INSTANCE_EVAL
// binding.getFrame().setVisibility(oldVis);
// if (this.pushScope || this.reuseParentScope) {
// context.postYield(binding, prevFrame);
// } else {
// context.postYieldNoScope(prevFrame);
// }
// }
// }
@Override
protected IRubyObject commonYieldPath(ThreadContext context, Block block, Block.Type type, IRubyObject[] args, IRubyObject self, Block blockArg) {
Binding binding = block.getBinding();
Visibility oldVis = binding.getFrame().getVisibility();
Frame prevFrame = context.preYieldNoScope(binding);

// SSS FIXME: Maybe, we should allocate a NoVarsScope/DummyScope for for-loop bodies because the static-scope here
// probably points to the parent scope? To be verified and fixed if necessary. There is no harm as it is now. It
// is just wasteful allocation since the scope is not used at all.
DynamicScope prevScope = binding.getDynamicScope();
if (this.pushScope) {
// SSS FIXME: for lambdas, this behavior is different
// compared to what InterpretedIRBlockBody and MixedModeIRBlockBody do
context.pushScope(DynamicScope.newDynamicScope(getStaticScope(), prevScope, this.evalType.get()));
} else if (this.reuseParentScope) {
// Reuse! We can avoid the push only if surrounding vars aren't referenced!
context.pushScope(prevScope);
}

self = IRRuntimeHelpers.updateBlockState(block, self);

if (usesKwargs) IRRuntimeHelpers.frobnicateKwargsArgument(context, getSignature().required(), args);

try {
return (IRubyObject) handle.invokeExact(context, block, getStaticScope(), self, args, blockArg, binding.getMethod(), block.type);
} catch (Throwable t) {
Helpers.throwException(t);
return null; // not reached
} finally {
// IMPORTANT: Do not clear eval-type in case this is reused in bindings!
// Ex: eval("...", foo.instance_eval { binding })
// The dyn-scope used for binding needs to have its eval-type set to INSTANCE_EVAL
binding.getFrame().setVisibility(oldVis);
if (this.pushScope || this.reuseParentScope) {
context.postYield(binding, prevFrame);
} else {
context.postYieldNoScope(prevFrame);
}
}
}
}

0 comments on commit 04a3410

Please sign in to comment.