]> gitweb.factorcode.org Git - factor.git/blob - vm/allot.hpp
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / vm / allot.hpp
1 namespace factor
2 {
3
4 /*
5  * It is up to the caller to fill in the object's fields in a meaningful
6  * fashion!
7  */
8 inline object *factor_vm::allot_object(cell type, cell size)
9 {
10 #ifdef FACTOR_DEBUG
11         assert(!current_gc);
12 #endif
13
14         /* If the object is smaller than the nursery, allocate it in the nursery,
15         after a GC if needed */
16         if(nursery.size > size)
17         {
18                 /* If there is insufficient room, collect the nursery */
19                 if(nursery.here + size > nursery.end)
20                         primitive_minor_gc();
21
22                 object *obj = nursery.allot(size);
23
24                 obj->initialize(type);
25                 return obj;
26         }
27         /* If the object is bigger than the nursery, allocate it in
28         tenured space */
29         else
30                 return allot_large_object(type,size);
31 }
32
33 }