factor/vm/data_heap.hpp

63 lines
1.0 KiB
C++
Raw Normal View History

2009-05-04 02:46:13 -04:00
namespace factor
{
2009-05-02 05:04:19 -04:00
/* generational copying GC divides memory into zones */
2009-05-04 05:50:24 -04:00
struct zone {
2009-05-02 05:04:19 -04:00
/* allocation pointer is 'here'; its offset is hardcoded in the
2009-05-02 10:19:09 -04:00
compiler backends */
2009-05-04 05:50:24 -04:00
cell start;
cell here;
cell size;
cell end;
2009-10-07 09:33:54 -04:00
cell init_zone(cell size_, cell start_)
{
size = size_;
start = here = start_;
end = start_ + size_;
return end;
}
2009-10-07 09:33:54 -04:00
2009-10-05 23:16:08 -04:00
inline bool contains_p(object *pointer)
{
2009-10-06 07:47:56 -04:00
return ((cell)pointer - start) < size;
2009-10-05 23:16:08 -04:00
}
2009-10-07 09:33:54 -04:00
inline object *allot(cell size)
{
cell h = here;
here = h + align8(size);
return (object *)h;
}
2009-05-02 10:19:09 -04:00
};
2009-05-02 05:04:19 -04:00
2009-05-04 05:50:24 -04:00
struct data_heap {
segment *seg;
2009-05-02 05:04:19 -04:00
2009-05-04 05:50:24 -04:00
cell young_size;
cell aging_size;
cell tenured_size;
2009-05-02 05:04:19 -04:00
2009-05-04 05:50:24 -04:00
zone *generations;
zone *semispaces;
2009-05-02 05:04:19 -04:00
char *allot_markers;
char *allot_markers_end;
2009-05-02 05:04:19 -04:00
char *cards;
char *cards_end;
2009-05-02 05:04:19 -04:00
char *decks;
char *decks_end;
explicit data_heap(factor_vm *myvm, cell young_size, cell aging_size, cell tenured_size);
~data_heap();
2009-05-02 10:19:09 -04:00
};
2009-05-02 05:04:19 -04:00
2009-10-07 09:33:54 -04:00
static const cell nursery_gen = 0;
static const cell aging_gen = 1;
static const cell tenured_gen = 2;
static const cell gen_count = 3;
2009-05-02 05:04:19 -04:00
2009-05-04 02:46:13 -04:00
}