Skip to content

Commit

Permalink
Let 'mrb_vm_run()` to restore the calling fiber; ref #3537
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Apr 12, 2017
1 parent 0fb05eb commit 4e84bdb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 0 additions & 2 deletions mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 7 additions & 3 deletions src/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4e84bdb

Please sign in to comment.