mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Removed push/pop instructions for rescue/ensure
`OP_PUSHERR`, `OP_POPERR`, `OP_EPUSH` and `OP_EPOP` are removed.
This commit is contained in:
committed by
Yukihiro "Matz" Matsumoto
parent
f467b02d45
commit
0d7b4deccf
@@ -62,13 +62,9 @@ sign) of operands.
|
||||
| OP_JMPIF | BS | if R(a) pc=b |
|
||||
| OP_JMPNOT | BS | if !R(a) pc=b |
|
||||
| OP_JMPNIL | BS | if R(a)==nil pc=b |
|
||||
| OP_ONERR | S | rescue_push(a) |
|
||||
| OP_EXCEPT | B | R(a) = exc |
|
||||
| OP_RESCUE | BB | R(b) = R(a).isa?(R(b)) |
|
||||
| OP_POPERR | B | a.times{rescue_pop()} |
|
||||
| OP_RAISEIF | B | raise(R(a)) if R(a) |
|
||||
| OP_EPUSH | B | ensure_push(SEQ[a]) |
|
||||
| OP_EPOP | B | A.times{ensure_pop().call} |
|
||||
| OP_SENDV | BB | R(a) = call(R(a),Syms(b),*R(a+1)) |
|
||||
| OP_SENDVB | BB | R(a) = call(R(a),Syms(b),*R(a+1),&R(a+2)) |
|
||||
| OP_SEND | BBB | R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c)) |
|
||||
|
||||
@@ -49,13 +49,9 @@ OPCODE(JMP, S) /* pc=a */
|
||||
OPCODE(JMPIF, BS) /* if R(a) pc=b */
|
||||
OPCODE(JMPNOT, BS) /* if !R(a) pc=b */
|
||||
OPCODE(JMPNIL, BS) /* if R(a)==nil pc=b */
|
||||
OPCODE(ONERR, S) /* rescue_push(a) */
|
||||
OPCODE(EXCEPT, B) /* R(a) = exc */
|
||||
OPCODE(RESCUE, BB) /* R(b) = R(a).isa?(R(b)) */
|
||||
OPCODE(POPERR, B) /* a.times{rescue_pop()} */
|
||||
OPCODE(RAISEIF, B) /* raise(R(a)) if R(a) */
|
||||
OPCODE(EPUSH, B) /* ensure_push(SEQ[a]) */
|
||||
OPCODE(EPOP, B) /* A.times{ensure_pop().call} */
|
||||
OPCODE(SENDV, BB) /* R(a) = call(R(a),Syms(b),*R(a+1)) */
|
||||
OPCODE(SENDVB, BB) /* R(a) = call(R(a),Syms(b),*R(a+1),&R(a+2)) */
|
||||
OPCODE(SEND, BBB) /* R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c)) */
|
||||
|
||||
@@ -493,12 +493,6 @@ codedump(mrb_state *mrb, const mrb_irep *irep)
|
||||
printf("OP_ERR\tL(%d)\n", a);
|
||||
}
|
||||
break;
|
||||
CASE(OP_EPUSH, B);
|
||||
printf("OP_EPUSH\t\t:I(%d:%p)\n", a, irep->reps[a]);
|
||||
break;
|
||||
CASE(OP_ONERR, S);
|
||||
printf("OP_ONERR\t%03d\n", a);
|
||||
break;
|
||||
CASE(OP_EXCEPT, B);
|
||||
printf("OP_EXCEPT\tR%d\t\t", a);
|
||||
print_lv_a(mrb, irep, a);
|
||||
@@ -511,12 +505,6 @@ codedump(mrb_state *mrb, const mrb_irep *irep)
|
||||
printf("OP_RAISEIF\tR%d\t\t", a);
|
||||
print_lv_a(mrb, irep, a);
|
||||
break;
|
||||
CASE(OP_POPERR, B);
|
||||
printf("OP_POPERR\t%d\t\t\n", a);
|
||||
break;
|
||||
CASE(OP_EPOP, B);
|
||||
printf("OP_EPOP\t%d\n", a);
|
||||
break;
|
||||
|
||||
CASE(OP_DEBUG, BBB);
|
||||
printf("OP_DEBUG\t%d\t%d\t%d\n", a, b, c);
|
||||
|
||||
@@ -1231,29 +1231,6 @@ RETRY_TRY_BLOCK:
|
||||
NEXT;
|
||||
}
|
||||
|
||||
CASE(OP_ONERR, S) {
|
||||
/* check rescue stack */
|
||||
if (mrb->c->ci->ridx == UINT16_MAX-1) {
|
||||
mrb_value exc = mrb_exc_new_str_lit(mrb, E_RUNTIME_ERROR, "too many nested rescues");
|
||||
mrb_exc_set(mrb, exc);
|
||||
goto L_RAISE;
|
||||
}
|
||||
/* expand rescue stack */
|
||||
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;
|
||||
if (mrb->c->rsize <= mrb->c->ci->ridx) {
|
||||
mrb->c->rsize = UINT16_MAX;
|
||||
}
|
||||
}
|
||||
mrb->c->rescue = (uint16_t*)mrb_realloc(mrb, mrb->c->rescue, sizeof(uint16_t)*mrb->c->rsize);
|
||||
}
|
||||
/* push rescue stack */
|
||||
mrb->c->rescue[mrb->c->ci->ridx++] = a;
|
||||
NEXT;
|
||||
}
|
||||
|
||||
CASE(OP_EXCEPT, B) {
|
||||
mrb_value exc;
|
||||
|
||||
@@ -1300,11 +1277,6 @@ RETRY_TRY_BLOCK:
|
||||
NEXT;
|
||||
}
|
||||
|
||||
CASE(OP_POPERR, B) {
|
||||
mrb->c->ci->ridx -= a;
|
||||
NEXT;
|
||||
}
|
||||
|
||||
CASE(OP_RAISEIF, B) {
|
||||
mrb_value exc = regs[a];
|
||||
if (mrb_break_p(exc)) {
|
||||
@@ -1318,64 +1290,6 @@ RETRY_TRY_BLOCK:
|
||||
NEXT;
|
||||
}
|
||||
|
||||
CASE(OP_EPUSH, B) {
|
||||
struct RProc *p;
|
||||
|
||||
p = mrb_closure_new(mrb, irep->reps[a]);
|
||||
/* check ensure stack */
|
||||
if (mrb->c->eidx == UINT16_MAX-1) {
|
||||
mrb_value exc = mrb_exc_new_str_lit(mrb, E_RUNTIME_ERROR, "too many nested ensures");
|
||||
mrb_exc_set(mrb, exc);
|
||||
goto L_RAISE;
|
||||
}
|
||||
/* expand ensure stack */
|
||||
if (mrb->c->esize <= mrb->c->eidx+1) {
|
||||
if (mrb->c->esize == 0) mrb->c->esize = ENSURE_STACK_INIT_SIZE;
|
||||
else {
|
||||
mrb->c->esize *= 2;
|
||||
if (mrb->c->esize <= mrb->c->eidx) {
|
||||
mrb->c->esize = UINT16_MAX;
|
||||
}
|
||||
}
|
||||
mrb->c->ensure = (struct RProc**)mrb_realloc(mrb, mrb->c->ensure, sizeof(struct RProc*)*mrb->c->esize);
|
||||
}
|
||||
/* push ensure stack */
|
||||
mrb->c->ensure[mrb->c->eidx++] = p;
|
||||
mrb->c->ensure[mrb->c->eidx] = NULL;
|
||||
mrb_gc_arena_restore(mrb, ai);
|
||||
NEXT;
|
||||
}
|
||||
|
||||
CASE(OP_EPOP, B) {
|
||||
mrb_callinfo *ci = mrb->c->ci;
|
||||
unsigned int n, epos = ci->epos;
|
||||
mrb_value self = regs[0];
|
||||
struct RClass *target_class = ci->target_class;
|
||||
|
||||
if (mrb->c->eidx <= epos) {
|
||||
NEXT;
|
||||
}
|
||||
|
||||
if (a > (int)mrb->c->eidx - epos)
|
||||
a = mrb->c->eidx - epos;
|
||||
for (n=0; n<a; n++) {
|
||||
int nregs = irep->nregs;
|
||||
|
||||
proc = mrb->c->ensure[epos+n];
|
||||
mrb->c->ensure[epos+n] = NULL;
|
||||
if (proc == NULL) continue;
|
||||
irep = proc->body.irep;
|
||||
ci = cipush(mrb, pc, nregs, nregs, target_class, proc, ci->mid, 0);
|
||||
mrb_stack_extend(mrb, irep->nregs);
|
||||
regs[0] = self;
|
||||
pc = irep->iseq;
|
||||
}
|
||||
pool = irep->pool;
|
||||
syms = irep->syms;
|
||||
mrb->c->eidx = epos;
|
||||
JUMP;
|
||||
}
|
||||
|
||||
CASE(OP_SENDV, BB) {
|
||||
c = CALL_MAXARGS;
|
||||
goto L_SEND;
|
||||
|
||||
Reference in New Issue
Block a user