namespace factor {
-template <typename Block> struct bump_allocator {
- /* offset of 'here' and 'end' is hardcoded in compiler backends */
+struct bump_allocator {
+ // offset of 'here' and 'end' is hardcoded in compiler backends
cell here;
cell start;
cell end;
bump_allocator(cell size, cell start)
: here(start), start(start), end(start + size), size(size) {}
- bool contains_p(Block* block) { return ((cell)block - start) < size; }
+ bool contains_p(object* obj) {
+ return (cell)obj >= start && (cell)obj < end;
+ }
- Block* allot(cell size) {
+ object* allot(cell size) {
cell h = here;
here = h + align(size, data_alignment);
- return (Block*)h;
+ return (object*)h;
}
cell occupied_space() { return here - start; }
void flush() {
here = start;
#ifdef FACTOR_DEBUG
- /* In case of bugs, there may be bogus references pointing to the
- memory space after the gc has run. Filling it with a pattern
- makes accesses to such shadow data fail hard. */
+ // In case of bugs, there may be bogus references pointing to the
+ // memory space after the gc has run. Filling it with a pattern
+ // makes accesses to such shadow data fail hard.
memset_cell((void*)start, 0xbaadbaad, size);
#endif
}