Skip to content

Commit 02e852a

Browse files
committedJul 9, 2018
Try always setting current block type to current block's type.
1 parent 63f1c34 commit 02e852a

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed
 

Diff for: ‎core/src/main/java/org/jruby/runtime/CompiledIRBlockBody.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public MethodHandle getHandle() {
146146

147147
@Override
148148
protected IRubyObject callDirect(ThreadContext context, Block block, IRubyObject[] args, Block blockArg) {
149-
context.setCurrentBlockType(Block.Type.PROC);
149+
context.setCurrentBlockType(block.type);
150150
try {
151151
return (IRubyObject)handle.invokeExact(context, block, getStaticScope(), (IRubyObject)null, args, blockArg, block.getBinding().getMethod(), block.type);
152152
} catch (Throwable t) {
@@ -157,7 +157,8 @@ protected IRubyObject callDirect(ThreadContext context, Block block, IRubyObject
157157

158158
@Override
159159
protected IRubyObject yieldDirect(ThreadContext context, Block block, IRubyObject[] args, IRubyObject self) {
160-
context.setCurrentBlockType(Block.Type.NORMAL);
160+
context.setCurrentBlockType(block.type);
161+
// if (block.type != Block.Type.NORMAL) System.out.println("MISMATCH: " + getScope());
161162
try {
162163
return (IRubyObject)handle.invokeExact(context, block, getStaticScope(), self, args, Block.NULL_BLOCK, block.getBinding().getMethod(), block.type);
163164
} catch (Throwable t) {

Diff for: ‎core/src/main/java/org/jruby/runtime/InterpretedIRBlockBody.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ public boolean canCallDirect() {
9595

9696
@Override
9797
protected IRubyObject callDirect(ThreadContext context, Block block, IRubyObject[] args, Block blockArg) {
98-
context.setCurrentBlockType(Block.Type.PROC);
98+
context.setCurrentBlockType(block.type);
9999
InterpreterContext ic = ensureInstrsReady(); // so we get debugging output
100100
return Interpreter.INTERPRET_BLOCK(context, block, null, ic, args, block.getBinding().getMethod(), blockArg);
101101
}
102102

103103
@Override
104104
protected IRubyObject yieldDirect(ThreadContext context, Block block, IRubyObject[] args, IRubyObject self) {
105-
context.setCurrentBlockType(Block.Type.NORMAL);
105+
context.setCurrentBlockType(block.type);
106106
InterpreterContext ic = ensureInstrsReady(); // so we get debugging output
107107
return Interpreter.INTERPRET_BLOCK(context, block, self, ic, args, block.getBinding().getMethod(), Block.NULL_BLOCK);
108108
}

Diff for: ‎core/src/main/java/org/jruby/runtime/MixedModeIRBlockBody.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ protected IRubyObject callDirect(ThreadContext context, Block block, IRubyObject
113113
// We should never get here if jittedBody is null
114114
assert jittedBody != null : "direct call in MixedModeIRBlockBody without jitted body";
115115

116-
context.setCurrentBlockType(Block.Type.PROC);
116+
context.setCurrentBlockType(block.type);
117117
return jittedBody.callDirect(context, block, args, blockArg);
118118
}
119119

@@ -122,7 +122,7 @@ protected IRubyObject yieldDirect(ThreadContext context, Block block, IRubyObjec
122122
// We should never get here if jittedBody is null
123123
assert jittedBody != null : "direct yield in MixedModeIRBlockBody without jitted body";
124124

125-
context.setCurrentBlockType(Block.Type.NORMAL);
125+
context.setCurrentBlockType(block.type);
126126
return jittedBody.yieldDirect(context, block, args, self);
127127
}
128128

0 commit comments

Comments
 (0)