diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-10-26 01:13:57 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-10-28 00:29:30 +0900 |
| commit | 93f5f225772c398be6e409da3d3ef0f07ffbe1cf (patch) | |
| tree | 37198a8c50baaf1a5714a581e049167073249ddc /src/gc.c | |
| parent | 3f9d00ded3ce987927d975f7ce70637a973de1fc (diff) | |
| download | mruby-93f5f225772c398be6e409da3d3ef0f07ffbe1cf.tar.gz mruby-93f5f225772c398be6e409da3d3ef0f07ffbe1cf.zip | |
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`.
Diffstat (limited to 'src/gc.c')
| -rw-r--r-- | src/gc.c | 13 |
1 files changed, 2 insertions, 11 deletions
@@ -647,11 +647,8 @@ gc_mark_children(mrb_state *mrb, mrb_gc *gc, struct RBasic *obj) { struct RProc *p = (struct RProc*)obj; - mrb_gc_mark(mrb, (struct RBasic*)p->env); - mrb_gc_mark(mrb, (struct RBasic*)p->target_class); - if (!MRB_PROC_CFUNC_P(p) && p->body.irep) { - mrb_gc_mark(mrb, (struct RBasic*)p->body.irep->target_class); - } + mrb_gc_mark(mrb, (struct RBasic*)p->upper); + mrb_gc_mark(mrb, (struct RBasic*)p->e.env); } break; @@ -660,12 +657,6 @@ gc_mark_children(mrb_state *mrb, mrb_gc *gc, struct RBasic *obj) struct REnv *e = (struct REnv*)obj; mrb_int i, len; - if (MRB_ENV_STACK_SHARED_P(e)) { - if (e->cxt.c->fib) { - mrb_gc_mark(mrb, (struct RBasic*)e->cxt.c->fib); - } - break; - } len = MRB_ENV_STACK_LEN(e); for (i=0; i<len; i++) { mrb_gc_mark_value(mrb, e->stack[i]); |
