diff src/specifier.c @ 5179:14fda1dbdb26

add memory usage info for specifiers -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2010-03-29 Ben Wing <ben@xemacs.org> * alloc.c: * alloc.c (lisp_object_storage_size): * alloc.c (Fobject_memory_usage): * alloc.c (lisp_object_memory_usage_full): Don't crash if passed a non-record object (int or char). * alloc.c (tree_memory_usage_1): * lrecord.h: New function tree_memory_usage() to return the memory usage of a tree of conses and/or vectors. * lisp.h: * lisp.h (PRIVATE_UNVERIFIED_LIST_LOOP_7): Add SAFE_LIST_LOOP_* functions for looping over a list not known to be correct or non-circular, but without signalling an error -- instead, just stop enumerating when an error detected. * emacs.c (main_1): * specifier.c: * specifier.c (specifier_memory_usage): * specifier.c (vars_of_specifier): * symsinit.h: Add memory usage info for specifiers.
author Ben Wing <ben@xemacs.org>
date Mon, 29 Mar 2010 22:47:55 -0500
parents 6c6d78781d59
children 71ee43b8a74d
line wrap: on
line diff
--- a/src/specifier.c	Mon Mar 29 00:11:03 2010 -0500
+++ b/src/specifier.c	Mon Mar 29 22:47:55 2010 -0500
@@ -3724,10 +3724,48 @@
   return DISPLAYTABLE_SPECIFIERP (object) ? Qt : Qnil;
 }
 
+
+
+#ifdef MEMORY_USAGE_STATS
+
+struct specifier_stats
+{
+  struct usage_stats u;
+  /* Ancillary Lisp */
+  Bytecount global, device, frame, window, buffer, fallback;
+  Bytecount magic_parent;
+};
+
+static void
+specifier_memory_usage (Lisp_Object specifier,
+			struct generic_usage_stats *gustats)
+{
+  struct specifier_stats *stats = (struct specifier_stats *) gustats;
+  Lisp_Specifier *spec = XSPECIFIER (specifier);
+
+  stats->global = tree_memory_usage (spec->global_specs, 1);
+  stats->device = tree_memory_usage (spec->device_specs, 1);
+  stats->frame = tree_memory_usage (spec->frame_specs, 1);
+  stats->window = tree_memory_usage (spec->window_specs, 1);
+  stats->buffer = tree_memory_usage (spec->buffer_specs, 1);
+  stats->fallback = tree_memory_usage (spec->fallback, 1);
+  if (SPECIFIERP (spec->magic_parent))
+    stats->magic_parent = lisp_object_memory_usage (spec->magic_parent);
+}
+
+#endif /* MEMORY_USAGE_STATS */
 
 /************************************************************************/
 /*                           Initialization                             */
 /************************************************************************/
+
+void
+specifier_objects_create (void)
+{
+#ifdef MEMORY_USAGE_STATS
+  OBJECT_HAS_METHOD (specifier, memory_usage);
+#endif
+}
 
 void
 syms_of_specifier (void)
@@ -3852,6 +3890,13 @@
 void
 vars_of_specifier (void)
 {
+#ifdef MEMORY_USAGE_STATS
+  OBJECT_HAS_PROPERTY (specifier, memusage_stats_list,
+		       listu (Qt, Qglobal, Qdevice, Qframe, Qwindow, Qbuffer,
+			      Qfallback, intern ("magic-parent"),
+			      Qunbound));
+#endif /* MEMORY_USAGE_STATS */
+
   Vcached_specifiers = Qnil;
   staticpro (&Vcached_specifiers);