VM: simplified logic for allot_object()
parent
1b1b275a1a
commit
59762009f1
23
vm/allot.hpp
23
vm/allot.hpp
|
@ -9,21 +9,20 @@ inline object* factor_vm::allot_object(cell type, cell size) {
|
||||||
FACTOR_ASSERT(!current_gc);
|
FACTOR_ASSERT(!current_gc);
|
||||||
|
|
||||||
bump_allocator *nursery = data->nursery;
|
bump_allocator *nursery = data->nursery;
|
||||||
|
|
||||||
|
/* If the object is bigger than the nursery, allocate it in tenured
|
||||||
|
space */
|
||||||
|
if (size >= nursery->size)
|
||||||
|
return allot_large_object(type, size);
|
||||||
|
|
||||||
/* If the object is smaller than the nursery, allocate it in the nursery,
|
/* If the object is smaller than the nursery, allocate it in the nursery,
|
||||||
after a GC if needed */
|
after a GC if needed */
|
||||||
if (nursery->size > size) {
|
if (nursery->here + size > nursery->end)
|
||||||
/* If there is insufficient room, collect the nursery */
|
primitive_minor_gc();
|
||||||
if (nursery->here + size > nursery->end)
|
|
||||||
primitive_minor_gc();
|
|
||||||
|
|
||||||
object* obj = nursery->allot(size);
|
object* obj = nursery->allot(size);
|
||||||
|
obj->initialize(type);
|
||||||
obj->initialize(type);
|
return obj;
|
||||||
return obj;
|
|
||||||
} /* If the object is bigger than the nursery, allocate it in
|
|
||||||
tenured space */
|
|
||||||
else
|
|
||||||
return allot_large_object(type, size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue