• Yukihiro "Matz" Matsumoto's avatar
    Heavily refactored how lexical scope links are implemented; fix #3821 · 93f5f225
    Yukihiro "Matz" Matsumoto authored
    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`.
    93f5f225
proc.c 7.5 KB