Changes from arch/CVS synchronization
[bpt/guile.git] / libguile / private-gc.h
index e9c170f..7c0fd88 100644 (file)
@@ -55,7 +55,8 @@
  * all, this means that we have a numerically intensive application
  */
 #define SCM_DEFAULT_MIN_YIELD_2 40
-#define SCM_DEFAULT_MAX_SEGMENT_SIZE  2097000L /* a little less (adm) than 2 Mb */
+
+#define SCM_DEFAULT_MAX_SEGMENT_SIZE  (20*1024*1024L)
 
 
 
@@ -117,14 +118,43 @@ typedef struct scm_t_cell_type_statistics {
 } scm_t_cell_type_statistics;
 
 
+/* Sweep statistics.  */
+typedef struct scm_sweep_statistics
+{
+  /* Number of cells "swept", i.e., visited during the sweep operation.  */
+  unsigned swept;
+
+  /* Number of cells collected during the sweep operation.  This number must
+     alsways be lower than or equal to SWEPT.  */
+  unsigned collected;
+} scm_t_sweep_statistics;
+
+#define scm_i_sweep_statistics_init(_stats)    \
+  do                                           \
+   {                                           \
+     (_stats)->swept = (_stats)->collected = 0;        \
+   }                                           \
+  while (0)
+
+#define scm_i_sweep_statistics_sum(_sum, _addition)    \
+  do                                                   \
+   {                                                   \
+     (_sum)->swept += (_addition).swept;               \
+     (_sum)->collected += (_addition).collected;       \
+   }                                                   \
+  while (0)
+
+\f
 extern scm_t_cell_type_statistics scm_i_master_freelist;
 extern scm_t_cell_type_statistics scm_i_master_freelist2;
-extern unsigned long scm_gc_cells_collected_1;
 
-void scm_i_adjust_min_yield (scm_t_cell_type_statistics *freelist);
+void scm_i_adjust_min_yield (scm_t_cell_type_statistics *freelist,
+                            scm_t_sweep_statistics sweep_stats,
+                            scm_t_sweep_statistics sweep_stats_1);
 void scm_i_gc_sweep_freelist_reset (scm_t_cell_type_statistics *freelist);
 int scm_i_gc_grow_heap_p (scm_t_cell_type_statistics * freelist);
-     
+
+
 #define SCM_HEAP_SIZE \
   (scm_i_master_freelist.heap_size + scm_i_master_freelist2.heap_size)
 
@@ -132,7 +162,17 @@ int scm_i_gc_grow_heap_p (scm_t_cell_type_statistics * freelist);
 #define SCM_MAX(A, B) ((A) > (B) ? (A) : (B))
 #define SCM_MIN(A, B) ((A) < (B) ? (A) : (B))
 
-#define CELL_P(x)  (SCM_ITAG3 (x) == scm_tc3_cons)
+/* CELL_P checks a random word whether it has the right form for a
+   pointer to a cell.  Use scm_i_find_heap_segment_containing_object
+   to find out whether it actually points to a real cell.
+
+   The right form for a cell pointer is this: the low three bits must
+   be scm_tc3_cons, and when the scm_tc3_cons tag is stripped, the
+   resulting pointer must be correctly aligned.
+   scm_i_initialize_heap_segment_data guarantees that the test below
+   works.
+*/
+#define CELL_P(x)  ((SCM_UNPACK(x) & (sizeof(scm_t_cell)-1)) == scm_tc3_cons)
 
 /*
   gc-mark
@@ -210,25 +250,37 @@ extern size_t scm_i_heap_segment_table_size;
 
 int scm_i_init_card_freelist (scm_t_cell * card, SCM *free_list,scm_t_heap_segment*);
 int scm_i_sweep_card (scm_t_cell * card, SCM *free_list, scm_t_heap_segment*);
+void scm_i_card_statistics (scm_t_cell *p, SCM hashtab, scm_t_heap_segment *seg);
+char const *scm_i_tag_name (scm_t_bits tag); /* MOVEME */
+
 int scm_i_initialize_heap_segment_data (scm_t_heap_segment * segment, size_t requested);
 int scm_i_segment_card_count (scm_t_heap_segment * seg);
 int scm_i_segment_cell_count (scm_t_heap_segment * seg);
 
 void scm_i_clear_segment_mark_space (scm_t_heap_segment *seg);
 scm_t_heap_segment * scm_i_make_empty_heap_segment (scm_t_cell_type_statistics*);
-SCM scm_i_sweep_some_cards (scm_t_heap_segment *seg);
-void scm_i_sweep_segment (scm_t_heap_segment * seg);
+SCM scm_i_sweep_some_cards (scm_t_heap_segment *seg,
+                           scm_t_sweep_statistics *sweep_stats);
+void scm_i_sweep_segment (scm_t_heap_segment *seg,
+                         scm_t_sweep_statistics *sweep_stats);
+
+void scm_i_heap_segment_statistics (scm_t_heap_segment *seg, SCM tab);
 
      
 int scm_i_insert_segment (scm_t_heap_segment * seg);
 long int scm_i_find_heap_segment_containing_object (SCM obj);
-int scm_i_get_new_heap_segment (scm_t_cell_type_statistics *, policy_on_error);
+int scm_i_get_new_heap_segment (scm_t_cell_type_statistics *,
+                               scm_t_sweep_statistics,
+                               policy_on_error);
 void scm_i_clear_mark_space (void);
 void scm_i_sweep_segments (void);
-SCM scm_i_sweep_some_segments (scm_t_cell_type_statistics * fl);
+SCM scm_i_sweep_some_segments (scm_t_cell_type_statistics *fl,
+                              scm_t_sweep_statistics *sweep_stats);
 void scm_i_reset_segments (void);
-void scm_i_sweep_all_segments (char const *reason);
-void scm_i_make_initial_segment (size_t init_heap_size, scm_t_cell_type_statistics *freelist);
+void scm_i_sweep_all_segments (char const *reason,
+                              scm_t_sweep_statistics *sweep_stats);
+SCM scm_i_all_segments_statistics (SCM hashtab);
+void scm_i_make_initial_segment (int init_heap_size, scm_t_cell_type_statistics *freelist);
 
 extern long int scm_i_deprecated_memory_return;