Avoid crossing C function boundary from `OP_EPOP`; ref #3789

parent 7f4b57bb
...@@ -1319,14 +1319,30 @@ RETRY_TRY_BLOCK: ...@@ -1319,14 +1319,30 @@ RETRY_TRY_BLOCK:
CASE(OP_EPOP) { CASE(OP_EPOP) {
/* A A.times{ensure_pop().call} */ /* A A.times{ensure_pop().call} */
int a = GETARG_A(i); int a = GETARG_A(i);
mrb_callinfo *ci = mrb->c->ci; mrb_callinfo *ci, *nci;
int n, epos = ci->epos; mrb_value self = regs[0];
for (n=0; n<a && mrb->c->eidx > epos; n++) { /* temporary limitation */
ecall(mrb, --mrb->c->eidx); mrb_assert(a==1);
mrb_gc_arena_restore(mrb, ai); proc = mrb->c->ensure[--mrb->c->eidx];
} ci = mrb->c->ci;
NEXT; nci = cipush(mrb);
nci->mid = ci->mid;
nci->argc = 0;
nci->proc = proc;
nci->stackent = mrb->c->stack;
nci->nregs = irep->nregs;
nci->target_class = proc->target_class;
nci->pc = pc + 1;
nci->acc = nci->nregs;
mrb->c->stack += ci->nregs;
stack_extend(mrb, nci->nregs);
irep = proc->body.irep;
pool = irep->pool;
syms = irep->syms;
regs[0] = self;
pc = irep->iseq;
JUMP;
} }
CASE(OP_LOADNIL) { CASE(OP_LOADNIL) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment