]> gitweb.factorcode.org Git - factor.git/blob - vm/tenured_space.hpp
VM: Refactor tenured_space.hpp to Factor style
[factor.git] / vm / tenured_space.hpp
1 namespace factor {
2
3 struct tenured_space : free_list_allocator<object> {
4   object_start_map starts;
5
6   explicit tenured_space(cell size, cell start)
7       : free_list_allocator<object>(size, start), starts(size, start) {}
8
9   object* allot(cell size) {
10     object* obj = free_list_allocator<object>::allot(size);
11     if (obj) {
12       starts.record_object_start_offset(obj);
13       return obj;
14     } else
15       return NULL;
16   }
17
18   cell first_object() {
19     return (cell) next_allocated_block_after(this->first_block());
20   }
21
22   cell next_object_after(cell scan) {
23     cell size = ((object*)scan)->size();
24     object* next = (object*)(scan + size);
25     return (cell) next_allocated_block_after(next);
26   }
27
28   void clear_mark_bits() { state.clear_mark_bits(); }
29
30   bool marked_p(object* obj) { return this->state.marked_p(obj); }
31
32   void set_marked_p(object* obj) { this->state.set_marked_p(obj); }
33
34   void sweep() {
35     free_list_allocator<object>::sweep();
36     starts.update_for_sweep(&this->state);
37   }
38 };
39
40 }