Permalink
Browse files

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

  • Loading branch information...
matz committed Apr 12, 2017
1 parent 0fb05eb commit 4e84bdb507885bd37b4b0fa6b6359ac8c8b7b886
Showing with 7 additions and 5 deletions.
  1. +0 −2 mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
  2. +7 −3 src/vm.c
@@ -551,8 +551,6 @@ main(int argc, char **argv)
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);
View
@@ -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

0 comments on commit 4e84bdb

Please sign in to comment.