]> gitweb.factorcode.org Git - factor.git/commitdiff
VM: allot_large_object fits better in the allot.hpp file
authorBjörn Lindqvist <bjourne@gmail.com>
Thu, 22 Sep 2016 11:13:55 +0000 (13:13 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Thu, 22 Sep 2016 11:13:55 +0000 (13:13 +0200)
vm/allot.hpp
vm/gc.cpp

index e7e11e46ef4dfeac317cf623203320f0329038b8..59c362a0b528547ea7bfd8a377623040ec004576 100644 (file)
@@ -1,7 +1,31 @@
 namespace factor {
 
-// It is up to the caller to fill in the object's fields in a meaningful
-// fashion!
+// It is up to the caller to fill in the object's fields in a
+// meaningful fashion!
+
+// Allocates memory
+inline object* factor_vm::allot_large_object(cell type, cell size) {
+  // If tenured space does not have enough room, collect and compact
+  cell requested_size = size + data->high_water_mark();
+  if (!data->tenured->can_allot_p(requested_size)) {
+    primitive_compact_gc();
+
+    // If it still won't fit, grow the heap
+    if (!data->tenured->can_allot_p(requested_size)) {
+      gc(collect_growing_heap_op, size);
+    }
+  }
+
+  object* obj = data->tenured->allot(size);
+
+  // Allows initialization code to store old->new pointers
+  // without hitting the write barrier in the common case of
+  // a nursery allocation
+  write_barrier(obj, size);
+
+  obj->initialize(type);
+  return obj;
+}
 
 // Allocates memory
 inline object* factor_vm::allot_object(cell type, cell size) {
@@ -20,6 +44,7 @@ inline object* factor_vm::allot_object(cell type, cell size) {
 
   object* obj = nursery->allot(size);
   obj->initialize(type);
+
   return obj;
 }
 
index 13b89ad8900a01348e85563f497de4d69c882525..ab8a48d9d35f8e76f9555ade5f5365b19819c871 100644 (file)
--- a/vm/gc.cpp
+++ b/vm/gc.cpp
@@ -189,33 +189,6 @@ void factor_vm::primitive_compact_gc() {
   gc(collect_compact_op, 0);
 }
 
-// It is up to the caller to fill in the object's fields in a meaningful
-// fashion!
-
-// Allocates memory
-object* factor_vm::allot_large_object(cell type, cell size) {
-  // If tenured space does not have enough room, collect and compact
-  cell requested_size = size + data->high_water_mark();
-  if (!data->tenured->can_allot_p(requested_size)) {
-    primitive_compact_gc();
-
-    // If it still won't fit, grow the heap
-    if (!data->tenured->can_allot_p(requested_size)) {
-      gc(collect_growing_heap_op, size);
-    }
-  }
-
-  object* obj = data->tenured->allot(size);
-
-  // Allows initialization code to store old->new pointers
-  // without hitting the write barrier in the common case of
-  // a nursery allocation
-  write_barrier(obj, size);
-
-  obj->initialize(type);
-  return obj;
-}
-
 void factor_vm::primitive_enable_gc_events() {
   gc_events = new std::vector<gc_event>();
 }