From 3acaa44a70a44a816076dee65310f0f2487aeebd Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Mon, 4 Sep 2017 06:51:31 +0900 Subject: Restructure `irep->outer` chain; fix #3804 Instead of `irep -> proc` chain, we use `irep -> irep` chain to avoid GC bugs like #3804. We added `target_class` reference to `mrb_irep` struct. That means one more word consumption per `irep`. --- src/kernel.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/kernel.c') diff --git a/src/kernel.c b/src/kernel.c index 9fcee2413..4e95ab24b 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -1151,8 +1151,8 @@ static mrb_value mrb_local_variables(mrb_state *mrb, mrb_value self) { struct RProc *proc; + mrb_irep *irep; mrb_value vars; - struct mrb_irep *irep; size_t i; proc = mrb->c->ci[-1].proc; @@ -1161,18 +1161,16 @@ mrb_local_variables(mrb_state *mrb, mrb_value self) return mrb_ary_new(mrb); } vars = mrb_hash_new(mrb); - while (proc) { - if (MRB_PROC_CFUNC_P(proc)) break; - irep = proc->body.irep; + irep = proc->body.irep; + while (irep) { if (!irep->lv) break; for (i = 0; i + 1 < irep->nlocals; ++i) { if (irep->lv[i].name) { mrb_hash_set(mrb, vars, mrb_symbol_value(irep->lv[i].name), mrb_true_value()); } } - if (MRB_PROC_CLASS_P(proc)) break; if (!proc->env) break; - proc = proc->body.irep->outer; + irep = irep->outer; } return mrb_hash_keys(mrb, vars); -- cgit v1.2.3