diff options
| -rw-r--r-- | src/codegen.c | 8 | ||||
| -rw-r--r-- | src/vm.c | 23 | ||||
| -rw-r--r-- | test/t/exception.rb | 23 |
3 files changed, 23 insertions, 31 deletions
diff --git a/src/codegen.c b/src/codegen.c index 83d0136ef..d9fc10657 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -317,6 +317,14 @@ genop_peep(codegen_scope *s, mrb_code i, int val) s->iseq[s->pc-1] = MKOP_A(c0, 0); genop(s, MKOP_AB(OP_RETURN, 0, OP_R_NORMAL)); return; +#if 0 + case OP_SEND: + if (GETARG_B(i) == OP_R_NORMAL && GETARG_A(i) == GETARG_A(i0)) { + s->iseq[s->pc-1] = MKOP_ABC(OP_TAILCALL, GETARG_A(i0), GETARG_B(i0), GETARG_C(i0)); + return; + } + break; +#endif default: break; } @@ -403,7 +403,7 @@ mrb_yield_internal(mrb_state *mrb, mrb_value b, int argc, mrb_value *argv, mrb_v ci->nregs = argc + 2; } else { - ci->nregs = p->body.irep->nregs + 2; + ci->nregs = p->body.irep->nregs + 1; } ci->acc = -1; mrb->stack = mrb->stack + n; @@ -568,7 +568,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self) } stack_extend(mrb, irep->nregs, irep->nregs); mrb->ci->proc = proc; - mrb->ci->nregs = irep->nregs + 2; + mrb->ci->nregs = irep->nregs + 1; regs = mrb->stack; regs[0] = self; @@ -873,7 +873,13 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self) else { ci->argc = n; } - ci->target_class = c; + if (c->tt == MRB_TT_ICLASS) { + ci->target_class = c->c; + } + else { + ci->target_class = c; + } + ci->pc = pc + 1; ci->acc = a; @@ -1189,9 +1195,11 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self) NEXT; } + L_RETURN: + i = MKOP_AB(OP_RETURN, GETARG_A(i), OP_R_NORMAL); + /* fall through */ CASE(OP_RETURN) { /* A return R(A) */ - L_RETURN: if (mrb->exc) { mrb_callinfo *ci; int eidx; @@ -1327,7 +1335,6 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self) } } - /* replace callinfo */ ci = mrb->ci; ci->mid = mid; @@ -1652,7 +1659,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self) } while (0) CASE(OP_EQ) { - /* A B C R(A) := R(A)<R(A+1) (Syms[B]=:<,C=1)*/ + /* A B C R(A) := R(A)<R(A+1) (Syms[B]=:==,C=1)*/ int a = GETARG_A(i); if (mrb_obj_eq(mrb, regs[a], regs[a+1])) { SET_TRUE_VALUE(regs[a]); @@ -1670,7 +1677,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self) } CASE(OP_LE) { - /* A B C R(A) := R(A)<R(A+1) (Syms[B]=:<,C=1)*/ + /* A B C R(A) := R(A)<=R(A+1) (Syms[B]=:<=,C=1)*/ OP_CMP(<=); NEXT; } @@ -1682,7 +1689,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self) } CASE(OP_GE) { - /* A B C R(A) := R(A)<R(A+1) (Syms[B]=:<,C=1)*/ + /* A B C R(A) := R(A)<=R(A+1) (Syms[B]=:<=,C=1)*/ OP_CMP(>=); NEXT; } diff --git a/test/t/exception.rb b/test/t/exception.rb index 7ecc51fa8..d43ce8833 100644 --- a/test/t/exception.rb +++ b/test/t/exception.rb @@ -318,26 +318,3 @@ end assert('Exception#inspect without message') do Exception.new.inspect end - -# very deeply recursive function that stil returns albeit very deeply so -$test_infinite_recursion = 0 -TEST_INFINITE_RECURSION_MAX = 1000000 -def test_infinite_recursion - $test_infinite_recursion += 1 - if $test_infinite_recursion > TEST_INFINITE_RECURSION_MAX - return $test_infinite_recursion - end - test_infinite_recursion -end - -assert('Infinite recursion should result in an exception being raised') do - a = begin - test_infinite_recursion - rescue - :ok - end - # OK if an exception was caught, otherwise a number will be stored in a - a == :ok -end - - |
