]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge optimizations from master branch
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 31 Oct 2009 08:02:19 +0000 (03:02 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 31 Oct 2009 08:02:19 +0000 (03:02 -0500)
1  2 
vm/arrays.cpp
vm/dispatch.cpp
vm/gc.cpp
vm/master.hpp
vm/utilities.hpp
vm/vm.hpp

diff --cc vm/arrays.cpp
index 3af8b0600b270ca2545c5a3fae39c99c1bf53cab,1f60515bb8c1c042bace203ac7b58977c1fcf9b7..3c69368f29152847f31153ec297918649e9e13bb
@@@ -7,18 -7,8 +7,8 @@@ namespace facto
  array *factor_vm::allot_array(cell capacity, cell fill_)
  {
        gc_root<object> fill(fill_,this);
 -      gc_root<array> new_array(allot_array_internal<array>(capacity),this);
 +      gc_root<array> new_array(allot_uninitialized_array<array>(capacity),this);
-       if(fill.value() == tag_fixnum(0))
-               memset(new_array->data(),'\0',capacity * sizeof(cell));
-       else
-       {
-               /* No need for write barrier here. Either the object is in
-               the nursery, or it was allocated directly in tenured space
-               and the write barrier is already hit for us in that case. */
-               for(cell i = 0; i < capacity; i++)
-                       new_array->data()[i] = fill.value();
-       }
+       memset_cell(new_array->data(),fill.value(),capacity * sizeof(cell));
        return new_array.untagged();
  }
  
diff --cc vm/dispatch.cpp
Simple merge
diff --cc vm/gc.cpp
index 6b1536bcde8deb70f625f83308d16297a848bed0,9e361a37e8ac6fb223786d0e023cf76cec4f6d5f..c382f3df54c15363f8bd0b4597e9a3398eaf0889
+++ b/vm/gc.cpp
@@@ -271,50 -211,29 +271,30 @@@ VM_C_API void inline_gc(cell *gc_roots_
   * It is up to the caller to fill in the object's fields in a meaningful
   * fashion!
   */
- object *factor_vm::allot_object(header header, cell size)
+ object *factor_vm::allot_large_object(header header, cell size)
  {
- #ifdef GC_DEBUG
-       if(!gc_off)
 -      /* If tenured space does not have enough room, collect */
 -      if(data->tenured->here + size > data->tenured->end)
--              primitive_full_gc();
- #endif
-       object *obj;
--
-       /* If the object is smaller than the nursery, allocate it in the nursery,
-       after a GC if needed */
-       if(size < nursery.size)
 -      /* If it still won't fit, grow the heap */
 -      if(data->tenured->here + size > data->tenured->end)
++      /* If tenured space does not have enough room, collect and compact */
++      if(!data->tenured->can_allot_p(size))
        {
-               /* If there is insufficient room, collect the nursery */
-               if(nursery.here + size > nursery.end)
-                       primitive_minor_gc();
 -              gc(collect_growing_heap_op,
 -                      size, /* requested size */
 -                      true, /* trace contexts? */
 -                      false /* compact code heap? */);
++              primitive_compact_gc();
 +
-               obj = nursery.allot(size);
-       }
-       else
-       {
-               /* If tenured space does not have enough room, collect and compact */
++              /* If it still won't fit, grow the heap */
 +              if(!data->tenured->can_allot_p(size))
 +              {
-                       primitive_compact_gc();
-                       /* If it still won't fit, grow the heap */
-                       if(!data->tenured->can_allot_p(size))
-                       {
-                               gc(collect_growing_heap_op,
-                                       size, /* requested size */
-                                       true /* trace contexts? */);
-                       }
++                      gc(collect_growing_heap_op,
++                              size, /* requested size */
++                              true /* trace contexts? */);
 +              }
+       }
  
-               obj = data->tenured->allot(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 */
-               char *start = (char *)obj;
-               for(cell offset = 0; offset < size; offset += card_size)
-                       write_barrier((cell *)(start + offset));
-       }
+       /* Allows initialization code to store old->new pointers
+       without hitting the write barrier in the common case of
+       a nursery allocation */
+       char *start = (char *)obj;
+       for(cell offset = 0; offset < size; offset += card_size)
+               write_barrier((cell *)(start + offset));
  
        obj->h = header;
        return obj;
diff --cc vm/master.hpp
index 9b525bd22e816fee0948dbda58d95c723f603f78,7c841d94f665f0ffc25d270c5b97cbacbf9a44ce..e4f478e7c1318ede1728d14b4ac5f552dc95e15d
@@@ -67,13 -78,16 +67,14 @@@ namespace facto
  #include "words.hpp"
  #include "float_bits.hpp"
  #include "io.hpp"
 -#include "mark_bits.hpp"
 -#include "heap.hpp"
  #include "image.hpp"
  #include "alien.hpp"
 -#include "code_heap.hpp"
  #include "callbacks.hpp"
  #include "vm.hpp"
+ #include "allot.hpp"
  #include "tagged.hpp"
  #include "local_roots.hpp"
 +#include "slot_visitor.hpp"
  #include "collector.hpp"
  #include "copying_collector.hpp"
  #include "nursery_collector.hpp"
index 497e1a3bfbac8e2331adf4543afac8d9bf414200,3552733f6b51d4f1d277bd81f3658bede8d8efd3..94b9de6f483d98cbaf9fd8a66a64e2fbae65d28c
@@@ -1,6 -1,37 +1,31 @@@
  namespace factor
  {
-       vm_char *safe_strdup(const vm_char *str);
-       void print_cell_hex_pad(cell x);
-       cell read_cell_hex();
+ inline static void memset_cell(void *dst, cell pattern, size_t size)
+ {
+ #ifdef __APPLE__
+       #ifdef FACTOR_64
+               memset_pattern8(dst,&pattern,size);
+       #else
+               memset_pattern4(dst,&pattern,size);
+       #endif
+ #else
+       if(pattern == 0)
+               memset(dst,0,size);
+       else
+       {
+               cell *start = (cell *)dst;
+               cell *end = (cell *)((cell)dst + size);
+               while(start < end)
+               {
+                       *start = pattern;
+                       start++;
+               }
+       }
+ #endif
+ }
+ vm_char *safe_strdup(const vm_char *str);
 -void print_string(const char *str);
 -void nl();
 -void print_cell(cell x);
 -void print_cell_hex(cell x);
 -void print_cell_hex_pad(cell x);
 -void print_fixnum(fixnum x);
+ cell read_cell_hex();
  }
diff --cc vm/vm.hpp
index 7860d4f23723ef6b527733950d381c1f65d61aec,d3686c743e882a6c811ce0e56dd446e23865041a..b5bbca525b926bf15b11adf905b1ca6829e49a4c
+++ b/vm/vm.hpp
@@@ -255,11 -261,14 +255,12 @@@ struct factor_v
        void primitive_minor_gc();
        void primitive_full_gc();
        void primitive_compact_gc();
 -      void primitive_gc_stats();
 -      void clear_gc_stats();
        void primitive_become();
        void inline_gc(cell *gc_roots_base, cell gc_roots_size);
-       object *allot_object(header header, cell size);
 +      void primitive_enable_gc_events();
 +      void primitive_disable_gc_events();
+       object *allot_object(header header, cell size);
+       object *allot_large_object(header header, cell size);
 -      void add_gc_stats(generation_statistics *stats, growable_array *result);
 -      void primitive_clear_gc_stats();
  
        template<typename Type> Type *allot(cell size)
        {
        void primitive_uninitialized_byte_array();
        void primitive_resize_byte_array();
  
 +      template<typename T> byte_array *byte_array_from_value(T *value);
 +      template<typename T> byte_array *byte_array_from_values(T *values, cell len);
 +
        //tuples
-       tuple *allot_tuple(cell layout_);
        void primitive_tuple();
        void primitive_tuple_boa();