* gc.c (s_scm_gc_live_object_stats): return alist, not hashtable.
[bpt/guile.git] / libguile / gc-segment.c
index 2ba135c..fee06e7 100644 (file)
@@ -52,6 +52,19 @@ scm_i_make_empty_heap_segment (scm_t_cell_type_statistics *fl)
 }
 
 
+void
+scm_i_heap_segment_statistics (scm_t_heap_segment *seg, SCM tab)
+{
+  scm_t_cell *p = seg->bounds[0];
+  while (p <  seg->bounds[1])
+    {
+      scm_i_card_statistics (p, tab, seg); 
+      p += SCM_GC_CARD_N_CELLS;
+    }
+}
+
+
+
 /*
   Fill SEGMENT with memory both for data and mark bits.
 
@@ -331,8 +344,6 @@ scm_i_sweep_some_segments (scm_t_cell_type_statistics * fl)
 }
 
 
-
-
 void
 scm_i_reset_segments (void)
 {
@@ -344,6 +355,26 @@ scm_i_reset_segments (void)
     }
 }
 
+/*
+  Return a hashtab with counts of live objects, with tags as keys.
+ */
+
+
+SCM
+scm_i_all_segments_statistics (SCM tab)
+{
+  int i = 0;
+  for (; i < scm_i_heap_segment_table_size; i++)
+    {
+      scm_t_heap_segment * seg = scm_i_heap_segment_table[i];
+      scm_i_heap_segment_statistics (seg, tab);
+    }
+
+  return tab;
+}
+
+
+
 
 /*
   Determine whether the given value does actually represent a cell in