VM: Refactor allot.hpp to Factor style
parent
22014f092e
commit
a437576dc9
36
vm/allot.hpp
36
vm/allot.hpp
|
@ -1,34 +1,30 @@
|
||||||
namespace factor
|
namespace factor {
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* It is up to the caller to fill in the object's fields in a meaningful
|
* It is up to the caller to fill in the object's fields in a meaningful
|
||||||
* fashion!
|
* fashion!
|
||||||
*/
|
*/
|
||||||
/* Allocates memory */
|
/* Allocates memory */
|
||||||
inline object *factor_vm::allot_object(cell type, cell size)
|
inline object* factor_vm::allot_object(cell type, cell size) {
|
||||||
{
|
|
||||||
#ifdef FACTOR_DEBUG
|
#ifdef FACTOR_DEBUG
|
||||||
FACTOR_ASSERT(!current_gc);
|
FACTOR_ASSERT(!current_gc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* 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.size > size) {
|
||||||
{
|
/* If there is insufficient room, collect the nursery */
|
||||||
/* If there is insufficient room, collect the nursery */
|
if (nursery.here + size > nursery.end)
|
||||||
if(nursery.here + size > nursery.end)
|
primitive_minor_gc();
|
||||||
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
|
||||||
/* If the object is bigger than the nursery, allocate it in
|
tenured space */
|
||||||
tenured space */
|
else
|
||||||
else
|
return allot_large_object(type, size);
|
||||||
return allot_large_object(type,size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue