* backtrace.c, debug.c, debug.h, deprecation.c, eq.c, eval.c
[bpt/guile.git] / libguile / gc-freelist.c
index e986369..83c20f8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2006 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -12,7 +12,7 @@
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <assert.h>
@@ -72,13 +72,13 @@ SCM_DEFINE (scm_gc_set_debug_check_freelist_x, "gc-set-debug-check-freelist!", 1
 
 
 
-/*
-  This adjust FREELIST variables to decide wether or not to allocate
-  more heap in the next GC run. It uses scm_gc_cells_collected and scm_gc_cells_collected1
- */
-
+/* Adjust FREELIST variables to decide wether or not to allocate more heap in
+   the next GC run based on SWEEP_STATS on SWEEP_STATS_1 (statistics
+   collected after the two last full GC).  */
 void
-scm_i_adjust_min_yield (scm_t_cell_type_statistics *freelist)
+scm_i_adjust_min_yield (scm_t_cell_type_statistics *freelist,
+                       scm_t_sweep_statistics sweep_stats,
+                       scm_t_sweep_statistics sweep_stats_1)
 {
   /* min yield is adjusted upwards so that next predicted total yield
    * (allocated cells actually freed by GC) becomes
@@ -98,7 +98,8 @@ scm_i_adjust_min_yield (scm_t_cell_type_statistics *freelist)
     {
       /* Pick largest of last two yields. */
       long delta = ((SCM_HEAP_SIZE * freelist->min_yield_fraction / 100)
-                  - (long) SCM_MAX (scm_gc_cells_collected_1, scm_gc_cells_collected));
+                  - (long) SCM_MAX (sweep_stats.collected,
+                                    sweep_stats_1.collected));
 #ifdef DEBUGINFO
       fprintf (stderr, " after GC = %lu, delta = %ld\n",
               (unsigned long) scm_cells_allocated,
@@ -145,12 +146,6 @@ scm_gc_init_freelist (void)
   int init_heap_size_2
     = scm_getenv_int ("GUILE_INIT_SEGMENT_SIZE_2", SCM_DEFAULT_INIT_HEAP_SIZE_2);
 
-  /* These are the thread-local freelists. */
-  scm_key_create (&scm_i_freelist, free);
-  scm_key_create (&scm_i_freelist2, free);
-  SCM_FREELIST_CREATE (scm_i_freelist);
-  SCM_FREELIST_CREATE (scm_i_freelist2);
-  
   scm_init_freelist (&scm_i_master_freelist2, 2, 
                     scm_getenv_int ("GUILE_MIN_YIELD_2", SCM_DEFAULT_MIN_YIELD_2));
   scm_init_freelist (&scm_i_master_freelist, 1,