Revise scope of role of mrb_vm_run()

`mrb_vm_run()` is,
  - It does not change the fiber context.
  - When control is returned, only one ci prepared by the caller is popped.
    If the ci equals cibase when called, the ci position does not change.

related commits:
  - commit 4e84bdb507
  - commit 34dd258c63
  - commit ebd6636a1e
  - commit c6736357a7
  - commit 23a4e7149d
  - commit 31a961acf1
This commit is contained in:
dearblue
2024-04-21 13:30:24 +09:00
parent ad476c3684
commit 5aa20f41ef
+4 -9
View File
@@ -1357,7 +1357,9 @@ mrb_vm_run(mrb_state *mrb, const struct RProc *proc, mrb_value self, mrb_int sta
const mrb_irep *irep = proc->body.irep;
mrb_value result;
struct mrb_context *c = mrb->c;
#ifdef MRB_DEBUG
ptrdiff_t cioff = c->ci - c->cibase;
#endif
mrb_int nregs = irep->nregs;
if (!c->stbase) {
@@ -1376,15 +1378,8 @@ mrb_vm_run(mrb_state *mrb, const struct RProc *proc, mrb_value self, mrb_int sta
stack_clear(c->ci->stack + stack_keep, nregs - stack_keep);
c->ci->stack[0] = self;
result = mrb_vm_exec(mrb, proc, irep->iseq);
if (mrb->c != c) {
if (mrb->c->fib) {
mrb_write_barrier(mrb, (struct RBasic*)mrb->c->fib);
}
mrb->c = c;
}
else if (c->ci - c->cibase > cioff) {
c->ci = c->cibase + cioff;
}
mrb_assert(mrb->c == c); /* do not switch fibers via mrb_vm_run(), unlike mrb_vm_exec() */
mrb_assert(c->ci == c->cibase || (c->ci - c->cibase) == cioff - 1);
return result;
}