]> gitweb.factorcode.org Git - factor.git/blob - vm/aging_space.hpp
VM: move next_object_after() and first_object() to aging_space (no iteration possible...
[factor.git] / vm / aging_space.hpp
1 namespace factor {
2
3 struct aging_space : bump_allocator<object> {
4   object_start_map starts;
5
6   aging_space(cell size, cell start)
7       : bump_allocator<object>(size, start), starts(size, start) {}
8
9   object* allot(cell size) {
10     if (here + size > end)
11       return NULL;
12
13     object* obj = bump_allocator<object>::allot(size);
14     starts.record_object_start_offset(obj);
15     return obj;
16   }
17
18   cell next_object_after(cell scan) {
19     cell size = ((object*)scan)->size();
20     if (scan + size < here)
21       return scan + size;
22     else
23       return 0;
24   }
25
26   cell first_object() {
27     if (start != here)
28       return start;
29     else
30       return 0;
31   }
32 };
33
34 }