From 93f5f225772c398be6e409da3d3ef0f07ffbe1cf Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Thu, 26 Oct 2017 01:13:57 +0900 Subject: Heavily refactored how lexical scope links are implemented; fix #3821 Instead of `irep` links, we added a `upper` link to `struct RProc`. To make a space for the `upper` link, we moved `target_class` reference. If a `Proc` does not have `env`, `target_class` is saved in an `union` shared with `env` (if a `Proc` has env, you can tell it by `MRB_PROC_ENV_P()). Otherwise `target_class` is referenced from `env->c`. We removed links in `env` as well. This change removes 2 members from `mrb_irep` struct, thus saving 2 words per method/proc/block. This also fixes potential memory leaks due to the circular references caused by a link from `mrb_irep`. --- mrbgems/mruby-bin-mirb/tools/mirb/mirb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mrbgems/mruby-bin-mirb/tools') diff --git a/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c b/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c index 891259a3f..3feb4270a 100644 --- a/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +++ b/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c @@ -544,11 +544,11 @@ done: if (args.verbose) { mrb_codedump_all(mrb, proc); } - /* adjest stack length of toplevel environment */ + /* adjust stack length of toplevel environment */ if (mrb->c->cibase->env) { struct REnv *e = mrb->c->cibase->env; - if (MRB_ENV_STACK_LEN(e) < proc->body.irep->nlocals) { - MRB_SET_ENV_STACK_LEN(e, proc->body.irep->nlocals); + if (e && MRB_ENV_STACK_LEN(e) < proc->body.irep->nlocals) { + MRB_ENV_SET_STACK_LEN(e, proc->body.irep->nlocals); } } /* pass a proc for evaluation */ -- cgit v1.2.3