add_heap_page should not be invoked in gc_alloc, but should be in obj_alloc

This commit is contained in:
Yuichi Nishiwaki 2013-11-25 00:24:03 +09:00
parent df20de5285
commit f11623f075
1 changed files with 6 additions and 4 deletions

View File

@ -139,8 +139,7 @@ gc_alloc(pic_state *pic, size_t size)
if (p->s.size >= nunits)
break;
if (p == freep) {
if ((p = add_heap_page(pic)) == NULL)
return NULL;
return NULL;
}
}
if (p->s.size == nunits) {
@ -494,8 +493,11 @@ pic_obj_alloc_unsafe(pic_state *pic, size_t size, enum pic_tt tt)
if (obj == NULL) {
pic_gc_run(pic);
obj = (struct pic_object *)gc_alloc(pic, size);
if (obj == NULL)
pic_abort(pic, "GC memory exhausted");
if (obj == NULL) {
if (add_heap_page(pic) == NULL)
pic_abort(pic, "GC memory exhausted");
obj = (struct pic_object *)gc_alloc(pic, size);
}
}
obj->tt = tt;