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

This commit is contained in:
Yukihiro "Matz" Matsumoto
2017-04-12 11:01:23 +09:00
parent 0fb05eb55f
commit 4e84bdb507
2 changed files with 7 additions and 5 deletions
-2
View File
@@ -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);
+7 -3
View File
@@ -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