@Override public Instr cloneForInlining(InlinerInfo ii) { return new ThrowExceptionInstr(exceptionArg.cloneForInlining(ii)); }
@Override public Instr clone(CloneInfo ii) { return new ThrowExceptionInstr(getException().cloneForInlining(ii)); }
public Operand getException() { return getOperand1(); }
@Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { if (getException() instanceof IRException) { throw ((IRException) getException()).getException(context.runtime); } Object excObj = getException().retrieve(context, self, currScope, currDynScope, temp); if (excObj instanceof IRubyObject) { RubyKernel.raise(context, context.runtime.getKernel(), new IRubyObject[] {(IRubyObject)excObj}, Block.NULL_BLOCK); } else if (excObj instanceof Throwable) { // java exception -- avoid having to add 'throws' clause everywhere! Helpers.throwException((Throwable)excObj); } // should never get here throw new RuntimeException("Control shouldn't have reached here in ThrowExceptionInstr. excObj is: " + excObj); }
case TRACE: return TraceInstr.decode(this); case THREAD_POLL: return ThreadPollInstr.decode(this); case THROW: return ThrowExceptionInstr.decode(this); case TO_ARY: return ToAryInstr.decode(this); case TOGGLE_BACKTRACE: return ToggleBacktraceInstr.decode(this);
@Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { if (getException() instanceof IRException) { throw ((IRException) getException()).getException(context.runtime); } Object excObj = getException().retrieve(context, self, currScope, currDynScope, temp); if (excObj instanceof IRubyObject) { RubyKernel.raise(context, context.runtime.getKernel(), new IRubyObject[] {(IRubyObject)excObj}, Block.NULL_BLOCK); } else if (excObj instanceof Throwable) { // java exception -- avoid having to add 'throws' clause everywhere! Helpers.throwException((Throwable)excObj); } // should never get here throw new RuntimeException("Control shouldn't have reached here in ThrowExceptionInstr. excObj is: " + excObj); }
case TRACE: return TraceInstr.decode(this); case THREAD_POLL: return ThreadPollInstr.decode(this); case THROW: return ThrowExceptionInstr.decode(this); case TO_ARY: return ToAryInstr.decode(this); case TOGGLE_BACKTRACE: return ToggleBacktraceInstr.decode(this);
@Override public Instr cloneForInlining(InlinerInfo ii) { return new ThrowExceptionInstr(exceptionArg.cloneForInlining(ii)); }
@Override public Instr clone(CloneInfo ii) { return new ThrowExceptionInstr(getException().cloneForInlining(ii)); }
@Override public void encode(IRWriterEncoder e) { super.encode(e); e.encode(getException()); }
public Operand getException() { return getOperand1(); }
public static ThrowExceptionInstr decode(IRReaderDecoder d) { return new ThrowExceptionInstr(d.decodeOperand()); }
@Override public void encode(IRWriterEncoder e) { super.encode(e); e.encode(getException()); }
public static ThrowExceptionInstr decode(IRReaderDecoder d) { return new ThrowExceptionInstr(d.decodeOperand()); }
@Override public void ThrowExceptionInstr(ThrowExceptionInstr throwexceptioninstr) { visit(throwexceptioninstr.getException()); jvmAdapter().athrow(); }
public Operand buildRetry(Node node, IRScope s) { // JRuby only supports retry when present in rescue blocks! // 1.9 doesn't support retry anywhere else. // Jump back to the innermost rescue block // We either find it, or we add code to throw a runtime exception if (_rescueBlockStack.empty()) { s.addInstr(new ThrowExceptionInstr(IRException.RETRY_LocalJumpError)); } else { s.addInstr(new ThreadPollInstr(true)); // Restore $! and jump back to the entry of the rescue block RescueBlockInfo rbi = _rescueBlockStack.peek(); s.addInstr(new PutGlobalVarInstr("$!", rbi.savedExceptionVariable)); s.addInstr(new JumpInstr(rbi.entryLabel)); // Retries effectively create a loop s.setHasLoopsFlag(true); } return manager.getNil(); }
@Override public void ThrowExceptionInstr(ThrowExceptionInstr throwexceptioninstr) { visit(throwexceptioninstr.getException()); jvmAdapter().athrow(); }
public Operand buildRetry(Node node, IRScope s) { // JRuby only supports retry when present in rescue blocks! // 1.9 doesn't support retry anywhere else. // Jump back to the innermost rescue block // We either find it, or we add code to throw a runtime exception if (_rescueBlockStack.empty()) { s.addInstr(new ThrowExceptionInstr(IRException.RETRY_LocalJumpError)); } else { s.addInstr(new ThreadPollInstr(true)); // Restore $! and jump back to the entry of the rescue block RescueBlockInfo rbi = _rescueBlockStack.peek(); s.addInstr(new PutGlobalVarInstr("$!", rbi.savedExceptionVariable)); s.addInstr(new JumpInstr(rbi.entryLabel)); // Retries effectively create a loop s.setHasLoopsFlag(true); } return manager.getNil(); }
public Operand buildRetry() { // JRuby only supports retry when present in rescue blocks! // 1.9 doesn't support retry anywhere else. // SSS FIXME: We should be able to use activeEnsureBlockStack for this // But, see the code in buildRescueInternal that pushes/pops these and // the documentation for retries. There is a small ordering issue // which is preventing me from getting rid of activeRescueBlockStack // altogether! // // Jump back to the innermost rescue block // We either find it, or we add code to throw a runtime exception if (activeRescueBlockStack.empty()) { addInstr(new ThrowExceptionInstr(IRException.RETRY_LocalJumpError)); } else { addInstr(new ThreadPollInstr(true)); // Restore $! and jump back to the entry of the rescue block RescueBlockInfo rbi = activeRescueBlockStack.peek(); addInstr(new PutGlobalVarInstr(symbol("$!"), rbi.savedExceptionVariable)); addInstr(new JumpInstr(rbi.entryLabel)); // Retries effectively create a loop scope.setHasLoopsFlag(); } return manager.getNil(); }
public Operand buildNext(final NextNode nextNode, IRScope s) { IRLoop currLoop = getCurrentLoop(); Operand rv = (nextNode.getValueNode() == null) ? manager.getNil() : build(nextNode.getValueNode(), s); // If we have ensure blocks, have to run those first! if (!_ensureBlockStack.empty()) EnsureBlockInfo.emitJumpChain(s, _ensureBlockStack, currLoop); else if (!_rescueBlockStack.empty()) _rescueBlockStack.peek().restoreException(s, currLoop); if (currLoop != null) { // If a regular loop, the next is simply a jump to the end of the iteration s.addInstr(new JumpInstr(currLoop.iterEndLabel)); } else { s.addInstr(new ThreadPollInstr(true)); // If a closure, the next is simply a return from the closure! if (s instanceof IRClosure) s.addInstr(new ReturnInstr(rv)); else s.addInstr(new ThrowExceptionInstr(IRException.NEXT_LocalJumpError)); } // Once the "next instruction" (closure-return) executes, control exits this scope return UnexecutableNil.U_NIL; }