7 address : lower heap bound address
8 curret : current tip of the heap
9 last : upper heap bound address
10 scan : GC scanner position
20 typedef struct heap
* rheap
;
22 rheap
heap_new(size_t size
);
23 int heap_deallocate(rheap h
);
24 int heap_allocate_memory(rheap h
);
25 int heap_allocate_extended(rheap h
);
26 int heap_reset(rheap h
);
27 int heap_enough_fields_p(rheap h
, int fields
);
28 int heap_allocated_p(rheap h
);
29 int heap_using_extended_p(rheap h
);
30 OBJECT
heap_copy_object(rheap h
, OBJECT obj
);
31 OBJECT
heap_next_object(rheap h
);
32 int heap_fully_scanned_p(rheap h
);
33 OBJECT
heap_next_unscanned(rheap h
);
34 int heap_enough_fields_p(rheap h
, int fields
);
36 /* controls fast heap allocation using inline functions on and off */
43 static inline address
heap_allocate(rheap h
, unsigned int size
) {
45 addr
= (address
)h
->current
;
46 memset((void*)addr
, 0, size
);
47 h
->current
= (address
)((uintptr_t)h
->current
+ size
);
52 #define heap_allocate_dirty(h, size) ({ \
53 address _a; _a = (address)h->current; h->current = (address)((uintptr_t)h->current + size); _a; })
55 #define heap_putback(h, size) (h->current = (address)((uintptr_t)h->current - size))
57 static inline unsigned int heap_enough_space_p(rheap h
, unsigned int size
) {
58 if((uintptr_t)h
->current
+ size
> (uintptr_t)h
->last
+ 1) return FALSE
;
62 static inline unsigned int heap_contains_p(rheap h
, address addr
) {
64 if(addr
< h
->address
) return FALSE
;
65 if(addr
>= (address
)((uintptr_t)h
->last
)) return FALSE
;
72 address
heap_allocate(rheap h
, unsigned int size
);
73 unsigned int heap_enough_space_p(rheap h
, unsigned int size
);