add using
[factor/jcg.git] / vm / code_gc.h
blob4d4637d0e190fe11e7922e42066c12dbb1755db1
1 typedef enum
3 B_FREE,
4 B_ALLOCATED,
5 B_MARKED
6 } F_BLOCK_STATUS;
8 typedef struct _F_BLOCK
10 F_BLOCK_STATUS status;
12 /* In bytes, includes this header */
13 CELL size;
15 /* Filled in on image load */
16 struct _F_BLOCK *next_free;
18 /* Used during compaction */
19 struct _F_BLOCK *forwarding;
20 } F_BLOCK;
22 typedef struct {
23 F_SEGMENT *segment;
24 F_BLOCK *free_list;
25 } F_HEAP;
27 void new_heap(F_HEAP *heap, CELL size);
28 void build_free_list(F_HEAP *heap, CELL size);
29 void *heap_allot(F_HEAP *heap, CELL size);
30 void mark_block(F_BLOCK *block);
31 void unmark_marked(F_HEAP *heap);
32 void free_unmarked(F_HEAP *heap);
33 void heap_usage(F_HEAP *heap, CELL *used, CELL *total_free, CELL *max_free);
34 CELL heap_size(F_HEAP *heap);
35 CELL compute_heap_forwarding(F_HEAP *heap);
36 void compact_heap(F_HEAP *heap);
38 INLINE F_BLOCK *next_block(F_HEAP *heap, F_BLOCK *block)
40 CELL next = ((CELL)block + block->size);
41 if(next == heap->segment->end)
42 return NULL;
43 else
44 return (F_BLOCK *)next;
47 INLINE F_BLOCK *first_block(F_HEAP *heap)
49 return (F_BLOCK *)heap->segment->start;
52 INLINE F_BLOCK *last_block(F_HEAP *heap)
54 return (F_BLOCK *)heap->segment->end;