]> gitweb.factorcode.org Git - factor.git/blob - vm/allot.hpp
Merge optimizations from master branch
[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(header header, cell size)
9 {
10         /* If the object is smaller than the nursery, allocate it in the nursery,
11         after a GC if needed */
12         if(nursery.size > size)
13         {
14                 /* If there is insufficient room, collect the nursery */
15                 if(nursery.here + size > nursery.end)
16                         primitive_minor_gc();
17
18                 object *obj = nursery.allot(size);
19
20                 obj->h = header;
21                 return obj;
22         }
23         /* If the object is bigger than the nursery, allocate it in
24         tenured space */
25         else
26                 return allot_large_object(header,size);
27 }
28
29 }