VM: no need for a nursery_space class, it's just a bump_allocator
parent
ad71f79be3
commit
885b5c7043
|
@ -92,7 +92,6 @@ ifdef CONFIG
|
|||
vm/free_list_allocator.hpp \
|
||||
vm/write_barrier.hpp \
|
||||
vm/object_start_map.hpp \
|
||||
vm/nursery_space.hpp \
|
||||
vm/aging_space.hpp \
|
||||
vm/tenured_space.hpp \
|
||||
vm/data_heap.hpp \
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
namespace factor {
|
||||
|
||||
struct aging_space : bump_allocator<object> {
|
||||
struct aging_space : bump_allocator {
|
||||
object_start_map starts;
|
||||
|
||||
aging_space(cell size, cell start)
|
||||
: bump_allocator<object>(size, start), starts(size, start) {}
|
||||
: bump_allocator(size, start), starts(size, start) {}
|
||||
|
||||
object* allot(cell size) {
|
||||
if (here + size > end)
|
||||
return NULL;
|
||||
|
||||
object* obj = bump_allocator<object>::allot(size);
|
||||
object* obj = bump_allocator::allot(size);
|
||||
starts.record_object_start_offset(obj);
|
||||
return obj;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace factor {
|
|||
inline object* factor_vm::allot_object(cell type, cell size) {
|
||||
FACTOR_ASSERT(!current_gc);
|
||||
|
||||
nursery_space *nursery = data->nursery;
|
||||
bump_allocator *nursery = data->nursery;
|
||||
/* If the object is smaller than the nursery, allocate it in the nursery,
|
||||
after a GC if needed */
|
||||
if (nursery->size > size) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
namespace factor {
|
||||
|
||||
template <typename Block> struct bump_allocator {
|
||||
struct bump_allocator {
|
||||
/* offset of 'here' and 'end' is hardcoded in compiler backends */
|
||||
cell here;
|
||||
cell start;
|
||||
|
@ -10,12 +10,12 @@ template <typename Block> struct bump_allocator {
|
|||
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) < size; }
|
||||
|
||||
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; }
|
||||
|
|
|
@ -7,7 +7,7 @@ void factor_vm::init_card_decks() {
|
|||
decks_offset = (cell)data->decks - addr_to_deck(data->start);
|
||||
}
|
||||
|
||||
data_heap::data_heap(nursery_space* vm_nursery,
|
||||
data_heap::data_heap(bump_allocator* vm_nursery,
|
||||
cell young_size_,
|
||||
cell aging_size_,
|
||||
cell tenured_size_) {
|
||||
|
@ -59,7 +59,7 @@ data_heap::~data_heap() {
|
|||
delete[] decks;
|
||||
}
|
||||
|
||||
data_heap* data_heap::grow(nursery_space* vm_nursery, cell requested_bytes) {
|
||||
data_heap* data_heap::grow(bump_allocator* vm_nursery, cell requested_bytes) {
|
||||
FACTOR_ASSERT(vm_nursery->occupied_space() == 0);
|
||||
cell new_tenured_size = (tenured_size * 2) + requested_bytes;
|
||||
return new data_heap(vm_nursery, young_size, aging_size, new_tenured_size);
|
||||
|
@ -77,7 +77,7 @@ template <typename Generation> void data_heap::clear_decks(Generation* gen) {
|
|||
memset(&decks[first_deck], 0, last_deck - first_deck);
|
||||
}
|
||||
|
||||
void data_heap::reset_generation(nursery_space* gen) {
|
||||
void data_heap::reset_generation(bump_allocator* gen) {
|
||||
gen->flush();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ struct data_heap {
|
|||
segment* seg;
|
||||
|
||||
/* Borrowed reference to a factor_vm::nursery */
|
||||
nursery_space* nursery;
|
||||
bump_allocator* nursery;
|
||||
aging_space* aging;
|
||||
aging_space* aging_semispace;
|
||||
tenured_space* tenured;
|
||||
|
@ -21,15 +21,15 @@ struct data_heap {
|
|||
card_deck* decks;
|
||||
card_deck* decks_end;
|
||||
|
||||
data_heap(nursery_space* vm_nursery,
|
||||
data_heap(bump_allocator* vm_nursery,
|
||||
cell young_size,
|
||||
cell aging_size,
|
||||
cell tenured_size);
|
||||
~data_heap();
|
||||
data_heap* grow(nursery_space* vm_nursery, cell requested_size);
|
||||
data_heap* grow(bump_allocator* vm_nursery, cell requested_size);
|
||||
template <typename Generation> void clear_cards(Generation* gen);
|
||||
template <typename Generation> void clear_decks(Generation* gen);
|
||||
void reset_generation(nursery_space* gen);
|
||||
void reset_generation(bump_allocator* gen);
|
||||
void reset_generation(aging_space* gen);
|
||||
void reset_generation(tenured_space* gen);
|
||||
bool high_fragmentation_p();
|
||||
|
|
|
@ -111,7 +111,6 @@ namespace factor { struct factor_vm; }
|
|||
#include "free_list_allocator.hpp"
|
||||
#include "write_barrier.hpp"
|
||||
#include "object_start_map.hpp"
|
||||
#include "nursery_space.hpp"
|
||||
#include "aging_space.hpp"
|
||||
#include "tenured_space.hpp"
|
||||
#include "data_heap.hpp"
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
namespace factor {
|
||||
|
||||
struct nursery_space : bump_allocator<object> {
|
||||
nursery_space(cell size, cell start)
|
||||
: bump_allocator<object>(size, start) {}
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue