private Operand receiveBreakException(Operand block, CodeBlock codeBlock) { // Check if we have to handle a break if (block == null || !(block instanceof WrappedIRClosure) || !(((WrappedIRClosure)block).getClosure()).flags.contains(IRFlags.HAS_BREAK_INSTRS)) { // No protection needed -- add the call and return return codeBlock.run(); } Label rBeginLabel = getNewLabel(); Label rEndLabel = getNewLabel(); Label rescueLabel = getNewLabel(); // Protected region addInstr(new LabelInstr(rBeginLabel)); addInstr(new ExceptionRegionStartMarkerInstr(rescueLabel)); Variable callResult = (Variable)codeBlock.run(); addInstr(new JumpInstr(rEndLabel)); addInstr(new ExceptionRegionEndMarkerInstr()); // Receive exceptions (could be anything, but the handler only processes IRBreakJumps) addInstr(new LabelInstr(rescueLabel)); Variable exc = createTemporaryVariable(); addInstr(new ReceiveJRubyExceptionInstr(exc)); // Handle break using runtime helper // --> IRRuntimeHelpers.handlePropagatedBreak(context, scope, bj, blockType) addInstr(new RuntimeHelperCall(callResult, HANDLE_PROPAGATED_BREAK, new Operand[]{exc} )); // End addInstr(new LabelInstr(rEndLabel)); return callResult; }
Object v1 = protectedCode.run(protectedCodeArgs); // YIELD: Run the protected code block m.addInstr(new CopyInstr(rv, (Operand)v1)); m.addInstr(new JumpInstr(rEndLabel)); Object v2 = rescueBlock.run(rescueBlockArgs); // YIELD: Run the protected code block if (v2 != null) m.addInstr(new CopyInstr(rv, manager.getNil()));
Object v1 = protectedCode.run(protectedCodeArgs); // YIELD: Run the protected code block m.addInstr(new CopyInstr(rv, (Operand)v1)); m.addInstr(new JumpInstr(rEndLabel)); Object v2 = rescueBlock.run(rescueBlockArgs); // YIELD: Run the protected code block if (v2 != null) m.addInstr(new CopyInstr(rv, manager.getNil()));
private Operand receiveBreakException(Operand block, CodeBlock codeBlock) { // Check if we have to handle a break if (block == null || !(block instanceof WrappedIRClosure) || !(((WrappedIRClosure)block).getClosure()).flags.contains(IRFlags.HAS_BREAK_INSTRS)) { // No protection needed -- add the call and return return codeBlock.run(); } Label rBeginLabel = getNewLabel(); Label rEndLabel = getNewLabel(); Label rescueLabel = getNewLabel(); // Protected region addInstr(new LabelInstr(rBeginLabel)); addInstr(new ExceptionRegionStartMarkerInstr(rescueLabel)); Variable callResult = (Variable)codeBlock.run(); addInstr(new JumpInstr(rEndLabel)); addInstr(new ExceptionRegionEndMarkerInstr()); // Receive exceptions (could be anything, but the handler only processes IRBreakJumps) addInstr(new LabelInstr(rescueLabel)); Variable exc = createTemporaryVariable(); addInstr(new ReceiveJRubyExceptionInstr(exc)); // Handle break using runtime helper // --> IRRuntimeHelpers.handlePropagatedBreak(context, scope, bj, blockType) addInstr(new RuntimeHelperCall(callResult, HANDLE_PROPAGATED_BREAK, new Operand[]{exc} )); // End addInstr(new LabelInstr(rEndLabel)); return callResult; }