]> gitweb.factorcode.org Git - factor.git/blob - vm/code_gc.hpp
Merge Phil Dawes' VM work
[factor.git] / vm / code_gc.hpp
1 namespace factor
2 {
3
4 static const cell free_list_count = 16;
5 static const cell block_size_increment = 32;
6
7 struct heap_free_list {
8         free_heap_block *small_blocks[free_list_count];
9         free_heap_block *large_blocks;
10 };
11
12 struct heap {
13         segment *seg;
14         heap_free_list free;
15 };
16
17 typedef void (*heap_iterator)(heap_block *compiled,factorvm *vm);
18
19 inline static heap_block *next_block(heap *h, heap_block *block)
20 {
21         cell next = ((cell)block + block->size);
22         if(next == h->seg->end)
23                 return NULL;
24         else
25                 return (heap_block *)next;
26 }
27
28 inline static heap_block *first_block(heap *h)
29 {
30         return (heap_block *)h->seg->start;
31 }
32
33 inline static heap_block *last_block(heap *h)
34 {
35         return (heap_block *)h->seg->end;
36 }
37
38 }