From: Björn Lindqvist Date: Fri, 21 Nov 2014 09:34:23 +0000 (+0100) Subject: VM: no need for a nursery_space class, it's just a bump_allocator X-Git-Tag: unmaintained~3168 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=885b5c70436576d2ef668bdcc7bf41203cb2d029 VM: no need for a nursery_space class, it's just a bump_allocator --- diff --git a/GNUmakefile b/GNUmakefile index b94c833e84..4c3b1ccb2e 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -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 \ diff --git a/vm/aging_space.hpp b/vm/aging_space.hpp index 1c17f71db1..e504faf317 100644 --- a/vm/aging_space.hpp +++ b/vm/aging_space.hpp @@ -1,16 +1,16 @@ namespace factor { -struct aging_space : bump_allocator { +struct aging_space : bump_allocator { object_start_map starts; aging_space(cell size, cell start) - : bump_allocator(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::allot(size); + object* obj = bump_allocator::allot(size); starts.record_object_start_offset(obj); return obj; } diff --git a/vm/allot.hpp b/vm/allot.hpp index 07129585ec..8b965d91f5 100644 --- a/vm/allot.hpp +++ b/vm/allot.hpp @@ -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) { diff --git a/vm/bump_allocator.hpp b/vm/bump_allocator.hpp index cd4717032d..dc3339f2ee 100644 --- a/vm/bump_allocator.hpp +++ b/vm/bump_allocator.hpp @@ -1,6 +1,6 @@ namespace factor { -template 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 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; } diff --git a/vm/data_heap.cpp b/vm/data_heap.cpp index f86fec9344..79df16094c 100644 --- a/vm/data_heap.cpp +++ b/vm/data_heap.cpp @@ -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 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(); } diff --git a/vm/data_heap.hpp b/vm/data_heap.hpp index 0cd212b124..3cd7781fc0 100644 --- a/vm/data_heap.hpp +++ b/vm/data_heap.hpp @@ -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 void clear_cards(Generation* gen); template 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(); diff --git a/vm/master.hpp b/vm/master.hpp index 2817b0348f..01c7e7aa0d 100644 --- a/vm/master.hpp +++ b/vm/master.hpp @@ -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" diff --git a/vm/nursery_space.hpp b/vm/nursery_space.hpp deleted file mode 100644 index d293b680d1..0000000000 --- a/vm/nursery_space.hpp +++ /dev/null @@ -1,8 +0,0 @@ -namespace factor { - -struct nursery_space : bump_allocator { - nursery_space(cell size, cell start) - : bump_allocator(size, start) {} -}; - -} diff --git a/vm/vm.hpp b/vm/vm.hpp index 7f8eacb51e..15895cbcb6 100644 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -18,7 +18,7 @@ struct factor_vm { /* New objects are allocated here, use the data->nursery reference instead from c++ code. */ - nursery_space nursery; + bump_allocator nursery; /* Add this to a shifted address to compute write barrier offsets */ cell cards_offset;