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`. --- src/state.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src/state.c') diff --git a/src/state.c b/src/state.c index 596eecafa..44bcc0656 100644 --- a/src/state.c +++ b/src/state.c @@ -139,11 +139,6 @@ mrb_irep_cutref(mrb_state *mrb, mrb_irep *irep) irep->reps[i] = NULL; if (tmp) mrb_irep_decref(mrb, tmp); } - if (irep->outer) { - tmp = irep->outer; - irep->outer = NULL; - if (tmp) mrb_irep_decref(mrb, tmp); - } } void @@ -170,10 +165,6 @@ mrb_irep_free(mrb_state *mrb, mrb_irep *irep) if (irep->reps[i]) mrb_irep_decref(mrb, irep->reps[i]); } - if (irep->outer) { - if (irep->outer) - mrb_irep_decref(mrb, irep->outer); - } mrb_free(mrb, irep->reps); mrb_free(mrb, irep->lv); if (irep->own_filename) { -- cgit v1.2.3