]> gitweb.factorcode.org Git - factor.git/commitdiff
VM: no need for a nursery_space class, it's just a bump_allocator
authorBjörn Lindqvist <bjourne@gmail.com>
Fri, 21 Nov 2014 09:34:23 +0000 (10:34 +0100)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 4 Dec 2014 18:23:33 +0000 (10:23 -0800)
GNUmakefile
vm/aging_space.hpp
vm/allot.hpp
vm/bump_allocator.hpp
vm/data_heap.cpp
vm/data_heap.hpp
vm/master.hpp
vm/nursery_space.hpp [deleted file]
vm/vm.hpp

index b94c833e84d293f3dbdb028a76f9fcff1a627bd2..4c3b1ccb2e4bb44ba0ba7d33714839149bdb5ec2 100644 (file)
@@ -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 \
index 1c17f71db17ced4bc23fed6c97e6a46746b12f5c..e504faf3170b46bf9ef1bc054012488ac4b5f3cf 100644 (file)
@@ -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;
   }
index 07129585ec75d33e5e145d218a50e9242e833650..8b965d91f5c1c2abbe2b67b61b20e2171ca6c3fc 100644 (file)
@@ -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) {
index cd4717032dcee646faefab1fad6cc991c1912af7..dc3339f2eea60a8ee236fef0d1612a046b3c4aae 100644 (file)
@@ -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; }
index f86fec9344c64a3942618bee248fc2c69c8f9534..79df16094c6a512cd1899e6dcb448807a9493724 100644 (file)
@@ -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();
 }
 
index 0cd212b124129ddb616a237f6835074e58b3bec1..3cd7781fc06915b1fc6b12c6c0f15c0927fcdcdf 100644 (file)
@@ -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();
index 2817b0348fe99096afda4d57166bca5350994036..01c7e7aa0d23822f0ebded399a695a76d08333c9 100644 (file)
@@ -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 (file)
index d293b68..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace factor {
-
-struct nursery_space : bump_allocator<object> {
-  nursery_space(cell size, cell start)
-      : bump_allocator<object>(size, start) {}
-};
-
-}
index 7f8eacb51ebe5fbca9c75b01bcf531a5732a2240..15895cbcb64a2d7b4fe003565e94a1431a620cff 100644 (file)
--- 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;