Unverified Commit d22b72a7 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #4957 from dearblue/excessive-arena

Fix `mrb_funcall_with_block()` uses more GC arena
parents 5acd802d 15dec838
...@@ -430,6 +430,7 @@ MRB_API mrb_value ...@@ -430,6 +430,7 @@ MRB_API mrb_value
mrb_funcall_with_block(mrb_state *mrb, mrb_value self, mrb_sym mid, mrb_int argc, const mrb_value *argv, mrb_value blk) mrb_funcall_with_block(mrb_state *mrb, mrb_value self, mrb_sym mid, mrb_int argc, const mrb_value *argv, mrb_value blk)
{ {
mrb_value val; mrb_value val;
int ai = mrb_gc_arena_save(mrb);
if (!mrb->jmp) { if (!mrb->jmp) {
struct mrb_jmpbuf c_jmp; struct mrb_jmpbuf c_jmp;
...@@ -518,19 +519,17 @@ mrb_funcall_with_block(mrb_state *mrb, mrb_value self, mrb_sym mid, mrb_int argc ...@@ -518,19 +519,17 @@ mrb_funcall_with_block(mrb_state *mrb, mrb_value self, mrb_sym mid, mrb_int argc
mrb->c->stack[argc+1] = blk; mrb->c->stack[argc+1] = blk;
if (MRB_METHOD_CFUNC_P(m)) { if (MRB_METHOD_CFUNC_P(m)) {
int ai = mrb_gc_arena_save(mrb);
ci->acc = CI_ACC_DIRECT; ci->acc = CI_ACC_DIRECT;
val = MRB_METHOD_CFUNC(m)(mrb, self); val = MRB_METHOD_CFUNC(m)(mrb, self);
mrb->c->stack = mrb->c->ci->stackent; mrb->c->stack = mrb->c->ci->stackent;
cipop(mrb); cipop(mrb);
mrb_gc_arena_restore(mrb, ai);
} }
else { else {
ci->acc = CI_ACC_SKIP; ci->acc = CI_ACC_SKIP;
val = mrb_run(mrb, MRB_METHOD_PROC(m), self); val = mrb_run(mrb, MRB_METHOD_PROC(m), self);
} }
} }
mrb_gc_arena_restore(mrb, ai);
mrb_gc_protect(mrb, val); mrb_gc_protect(mrb, val);
return val; return val;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment