mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Minimize zero initialization of the stack
This commit is contained in:
@@ -43,8 +43,8 @@ fiber_init_fiber(mrb_state *mrb, struct RFiber *f, const struct RProc *p)
|
||||
c->stend = c->stbase + slen;
|
||||
|
||||
{
|
||||
mrb_value *s = c->stbase;
|
||||
mrb_value *send = c->stend;
|
||||
mrb_value *s = c->stbase + 1;
|
||||
mrb_value *send = c->stbase + p->body.irep->nregs;
|
||||
|
||||
while (s < send) {
|
||||
SET_NIL_VALUE(*s);
|
||||
@@ -56,9 +56,11 @@ fiber_init_fiber(mrb_state *mrb, struct RFiber *f, const struct RProc *p)
|
||||
c->stbase[0] = mrb->c->ci->stack[0];
|
||||
|
||||
/* initialize callinfo stack */
|
||||
c->cibase = (mrb_callinfo*)mrb_calloc(mrb, FIBER_CI_INIT_SIZE, sizeof(mrb_callinfo));
|
||||
static const mrb_callinfo ci_zero = { 0 };
|
||||
c->cibase = (mrb_callinfo*)mrb_malloc(mrb, FIBER_CI_INIT_SIZE * sizeof(mrb_callinfo));
|
||||
c->ciend = c->cibase + FIBER_CI_INIT_SIZE;
|
||||
c->ci = c->cibase;
|
||||
c->cibase[0] = ci_zero;
|
||||
|
||||
/* adjust return callinfo */
|
||||
ci = c->ci;
|
||||
|
||||
@@ -116,12 +116,14 @@ stack_init(mrb_state *mrb)
|
||||
struct mrb_context *c = mrb->c;
|
||||
|
||||
/* mrb_assert(mrb->stack == NULL); */
|
||||
c->stbase = (mrb_value*)mrb_calloc(mrb, STACK_INIT_SIZE, sizeof(mrb_value));
|
||||
c->stbase = (mrb_value*)mrb_malloc(mrb, STACK_INIT_SIZE * sizeof(mrb_value));
|
||||
c->stend = c->stbase + STACK_INIT_SIZE;
|
||||
|
||||
/* mrb_assert(ci == NULL); */
|
||||
c->cibase = (mrb_callinfo*)mrb_calloc(mrb, CALLINFO_INIT_SIZE, sizeof(mrb_callinfo));
|
||||
static const mrb_callinfo ci_zero = { 0 };
|
||||
c->cibase = (mrb_callinfo*)mrb_malloc(mrb, CALLINFO_INIT_SIZE * sizeof(mrb_callinfo));
|
||||
c->ciend = c->cibase + CALLINFO_INIT_SIZE;
|
||||
c->cibase[0] = ci_zero;
|
||||
c->ci = c->cibase;
|
||||
c->ci->u.target_class = mrb->object_class;
|
||||
c->ci->stack = c->stbase;
|
||||
|
||||
Reference in New Issue
Block a user