more arena freeing during compilation

This commit is contained in:
Yuichi Nishiwaki 2015-06-28 01:51:20 +09:00
parent bda1b93ec2
commit e5f7eda432
1 changed files with 7 additions and 2 deletions

View File

@ -1360,6 +1360,8 @@ pic_codegen(pic_state *pic, pic_value obj)
return codegen_context_destroy(pic, cxt);
}
#define SAVE(pic, ai, obj) pic_gc_arena_restore(pic, ai); pic_gc_protect(pic, obj)
struct pic_proc *
pic_compile(pic_state *pic, pic_value obj, struct pic_env *env)
{
@ -1385,6 +1387,8 @@ pic_compile(pic_state *pic, pic_value obj, struct pic_env *env)
fprintf(stdout, "ai = %zu\n", pic_gc_arena_preserve(pic));
#endif
SAVE(pic, ai, obj);
/* analyze */
obj = pic_analyze(pic, obj);
#if DEBUG
@ -1394,6 +1398,8 @@ pic_compile(pic_state *pic, pic_value obj, struct pic_env *env)
fprintf(stdout, "ai = %zu\n", pic_gc_arena_preserve(pic));
#endif
SAVE(pic, ai, obj);
/* codegen */
irep = pic_codegen(pic, obj);
#if DEBUG
@ -1406,8 +1412,7 @@ pic_compile(pic_state *pic, pic_value obj, struct pic_env *env)
puts("");
#endif
pic_gc_arena_restore(pic, ai);
pic_gc_protect(pic, pic_obj_value(irep));
SAVE(pic, ai, pic_obj_value(irep));
return pic_make_proc_irep(pic, irep, NULL);
}