Let 'mrb_vm_run()` to restore the calling fiber; ref #3537

parent 0fb05eb5
......@@ -551,8 +551,6 @@ done:
mrb_top_self(mrb),
stack_keep);
stack_keep = proc->body.irep->nlocals;
/* restore to fiber */
mrb->c = mrb->root_c;
/* did an exception occur? */
if (mrb->exc) {
p(mrb, mrb_obj_value(mrb->exc), 0);
......
......@@ -816,15 +816,19 @@ MRB_API mrb_value
mrb_vm_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stack_keep)
{
mrb_irep *irep = proc->body.irep;
mrb_value result;
struct mrb_context *c = mrb->c;
if (!mrb->c->stack) {
if (!c->stack) {
stack_init(mrb);
}
if (stack_keep < irep->nregs)
stack_keep = irep->nregs;
stack_extend(mrb, stack_keep);
mrb->c->stack[0] = self;
return mrb_vm_exec(mrb, proc, irep->iseq);
c->stack[0] = self;
result = mrb_vm_exec(mrb, proc, irep->iseq);
mrb->c = c;
return result;
}
MRB_API mrb_value
......
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