comparison 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
comparison
equal deleted inserted replaced
5172:be6e5ea38dda 5179:14fda1dbdb26
3722 (object)) 3722 (object))
3723 { 3723 {
3724 return DISPLAYTABLE_SPECIFIERP (object) ? Qt : Qnil; 3724 return DISPLAYTABLE_SPECIFIERP (object) ? Qt : Qnil;
3725 } 3725 }
3726 3726
3727
3728
3729 #ifdef MEMORY_USAGE_STATS
3730
3731 struct specifier_stats
3732 {
3733 struct usage_stats u;
3734 /* Ancillary Lisp */
3735 Bytecount global, device, frame, window, buffer, fallback;
3736 Bytecount magic_parent;
3737 };
3738
3739 static void
3740 specifier_memory_usage (Lisp_Object specifier,
3741 struct generic_usage_stats *gustats)
3742 {
3743 struct specifier_stats *stats = (struct specifier_stats *) gustats;
3744 Lisp_Specifier *spec = XSPECIFIER (specifier);
3745
3746 stats->global = tree_memory_usage (spec->global_specs, 1);
3747 stats->device = tree_memory_usage (spec->device_specs, 1);
3748 stats->frame = tree_memory_usage (spec->frame_specs, 1);
3749 stats->window = tree_memory_usage (spec->window_specs, 1);
3750 stats->buffer = tree_memory_usage (spec->buffer_specs, 1);
3751 stats->fallback = tree_memory_usage (spec->fallback, 1);
3752 if (SPECIFIERP (spec->magic_parent))
3753 stats->magic_parent = lisp_object_memory_usage (spec->magic_parent);
3754 }
3755
3756 #endif /* MEMORY_USAGE_STATS */
3727 3757
3728 /************************************************************************/ 3758 /************************************************************************/
3729 /* Initialization */ 3759 /* Initialization */
3730 /************************************************************************/ 3760 /************************************************************************/
3761
3762 void
3763 specifier_objects_create (void)
3764 {
3765 #ifdef MEMORY_USAGE_STATS
3766 OBJECT_HAS_METHOD (specifier, memory_usage);
3767 #endif
3768 }
3731 3769
3732 void 3770 void
3733 syms_of_specifier (void) 3771 syms_of_specifier (void)
3734 { 3772 {
3735 INIT_LISP_OBJECT (specifier); 3773 INIT_LISP_OBJECT (specifier);
3850 } 3888 }
3851 3889
3852 void 3890 void
3853 vars_of_specifier (void) 3891 vars_of_specifier (void)
3854 { 3892 {
3893 #ifdef MEMORY_USAGE_STATS
3894 OBJECT_HAS_PROPERTY (specifier, memusage_stats_list,
3895 listu (Qt, Qglobal, Qdevice, Qframe, Qwindow, Qbuffer,
3896 Qfallback, intern ("magic-parent"),
3897 Qunbound));
3898 #endif /* MEMORY_USAGE_STATS */
3899
3855 Vcached_specifiers = Qnil; 3900 Vcached_specifiers = Qnil;
3856 staticpro (&Vcached_specifiers); 3901 staticpro (&Vcached_specifiers);
3857 3902
3858 /* Do NOT mark through this, or specifiers will never be GC'd. 3903 /* Do NOT mark through this, or specifiers will never be GC'd.
3859 This is the same deal as for weak hash tables. */ 3904 This is the same deal as for weak hash tables. */