diff options
Diffstat (limited to 'src/vm.c')
| -rw-r--r-- | src/vm.c | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -234,6 +234,8 @@ cipush(mrb_state *mrb) struct mrb_context *c = mrb->c; mrb_callinfo *ci = c->ci; + int ridx = ci->ridx; + if (ci + 1 == c->ciend) { ptrdiff_t size = ci - c->cibase; @@ -243,7 +245,7 @@ cipush(mrb_state *mrb) } ci = ++c->ci; ci->epos = mrb->c->eidx; - ci->rpos = mrb->c->ridx; + ci->ridx = ridx; ci->env = 0; ci->pc = 0; ci->err = 0; @@ -283,8 +285,8 @@ cipop(mrb_state *mrb) struct mrb_context *c = mrb->c; struct REnv *env = c->ci->env; - c->ridx = c->ci->rpos; c->ci--; + if (env) { mrb_env_unshare(mrb, env); } @@ -1123,12 +1125,12 @@ RETRY_TRY_BLOCK: CASE(OP_ONERR) { /* sBx pc+=sBx on exception */ - if (mrb->c->rsize <= mrb->c->ridx) { + if (mrb->c->rsize <= mrb->c->ci->ridx) { if (mrb->c->rsize == 0) mrb->c->rsize = RESCUE_STACK_INIT_SIZE; else mrb->c->rsize *= 2; mrb->c->rescue = (mrb_code **)mrb_realloc(mrb, mrb->c->rescue, sizeof(mrb_code*) * mrb->c->rsize); } - mrb->c->rescue[mrb->c->ridx++] = pc + GETARG_sBx(i); + mrb->c->rescue[mrb->c->ci->ridx++] = pc + GETARG_sBx(i); NEXT; } @@ -1178,7 +1180,7 @@ RETRY_TRY_BLOCK: int a = GETARG_A(i); while (a--) { - mrb->c->ridx--; + mrb->c->ci->ridx--; } NEXT; } @@ -1789,11 +1791,11 @@ RETRY_TRY_BLOCK: L_RAISE: ci0 = ci = mrb->c->ci; if (ci == mrb->c->cibase) { - if (mrb->c->ridx == 0) goto L_FTOP; + if (ci->ridx == 0) goto L_FTOP; goto L_RESCUE; } stk = mrb->c->stack; - while (mrb->c->ridx == ci->rpos) { + while (ci[0].ridx == ci[-1].ridx) { cipop(mrb); mrb->c->stack = ci->stackent; if (ci->acc == CI_ACC_SKIP && prev_jmp) { @@ -1803,7 +1805,7 @@ RETRY_TRY_BLOCK: ci = mrb->c->ci; if (ci == mrb->c->cibase) { mrb->c->stack = stk; - if (mrb->c->ridx == 0) { + if (ci->ridx == 0) { L_FTOP: /* fiber top */ if (mrb->c == mrb->root_c) { mrb->c->stack = mrb->c->stbase; @@ -1820,7 +1822,7 @@ RETRY_TRY_BLOCK: break; } /* call ensure only when we skip this callinfo */ - if (mrb->c->ridx == ci->rpos) { + if (ci[0].ridx == ci[-1].ridx) { while (mrb->c->eidx > ci->epos) { ecall(mrb, --mrb->c->eidx); ci = mrb->c->ci; @@ -1828,7 +1830,7 @@ RETRY_TRY_BLOCK: } } L_RESCUE: - if (mrb->c->ridx == 0) goto L_STOP; + if (ci->ridx == 0) goto L_STOP; proc = ci->proc; irep = proc->body.irep; pool = irep->pool; @@ -1836,7 +1838,7 @@ RETRY_TRY_BLOCK: if (ci != ci0) { mrb->c->stack = ci[1].stackent; } - pc = mrb->c->rescue[--mrb->c->ridx]; + pc = mrb->c->rescue[--ci->ridx]; } else { int acc; |
