Mercurial > hg > xemacs-beta
annotate lisp/objects.el @ 5157:1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
-------------------- ChangeLog entries follow: --------------------
lisp/ChangeLog addition:
2010-03-18 Ben Wing <ben@xemacs.org>
* diagnose.el (show-memory-usage):
Rewrite to take into account API changes in memory-usage functions.
src/ChangeLog addition:
2010-03-18 Ben Wing <ben@xemacs.org>
* alloc.c:
* alloc.c (disksave_object_finalization_1):
* alloc.c (lisp_object_storage_size):
* alloc.c (listu):
* alloc.c (listn):
* alloc.c (Fobject_memory_usage_stats):
* alloc.c (compute_memusage_stats_length):
* alloc.c (Fobject_memory_usage):
* alloc.c (Ftotal_object_memory_usage):
* alloc.c (malloced_storage_size):
* alloc.c (common_init_alloc_early):
* alloc.c (reinit_alloc_objects_early):
* alloc.c (reinit_alloc_early):
* alloc.c (init_alloc_once_early):
* alloc.c (syms_of_alloc):
* alloc.c (reinit_vars_of_alloc):
* buffer.c:
* buffer.c (struct buffer_stats):
* buffer.c (compute_buffer_text_usage):
* buffer.c (compute_buffer_usage):
* buffer.c (buffer_memory_usage):
* buffer.c (buffer_objects_create):
* buffer.c (syms_of_buffer):
* buffer.c (vars_of_buffer):
* console-impl.h (struct console_methods):
* dynarr.c (Dynarr_memory_usage):
* emacs.c (main_1):
* events.c (clear_event_resource):
* extents.c:
* extents.c (compute_buffer_extent_usage):
* extents.c (extent_objects_create):
* extents.h:
* faces.c:
* faces.c (compute_face_cachel_usage):
* faces.c (face_objects_create):
* faces.h:
* general-slots.h:
* glyphs.c:
* glyphs.c (compute_glyph_cachel_usage):
* glyphs.c (glyph_objects_create):
* glyphs.h:
* lisp.h:
* lisp.h (struct usage_stats):
* lrecord.h:
* lrecord.h (enum lrecord_type):
* lrecord.h (struct lrecord_implementation):
* lrecord.h (MC_ALLOC_CALL_FINALIZER_FOR_DISKSAVE):
* lrecord.h (DEFINE_DUMPABLE_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_SIZABLE_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_FROB_BLOCK_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_FROB_BLOCK_SIZABLE_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_SIZABLE_INTERNAL_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_SIZABLE_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_FROB_BLOCK_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_FROB_BLOCK_SIZABLE_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_INTERNAL_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_SIZABLE_INTERNAL_LISP_OBJECT):
* lrecord.h (MAKE_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_MODULE_LISP_OBJECT):
* lrecord.h (DEFINE_DUMPABLE_MODULE_SIZABLE_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_MODULE_LISP_OBJECT):
* lrecord.h (DEFINE_NODUMP_MODULE_SIZABLE_LISP_OBJECT):
* lrecord.h (MAKE_MODULE_LISP_OBJECT):
* lrecord.h (INIT_LISP_OBJECT):
* lrecord.h (INIT_MODULE_LISP_OBJECT):
* lrecord.h (UNDEF_LISP_OBJECT):
* lrecord.h (UNDEF_MODULE_LISP_OBJECT):
* lrecord.h (DECLARE_LISP_OBJECT):
* lrecord.h (DECLARE_MODULE_API_LISP_OBJECT):
* lrecord.h (DECLARE_MODULE_LISP_OBJECT):
* lstream.c:
* lstream.c (syms_of_lstream):
* lstream.c (vars_of_lstream):
* marker.c:
* marker.c (compute_buffer_marker_usage):
* mc-alloc.c (mc_alloced_storage_size):
* mc-alloc.h:
* mule-charset.c:
* mule-charset.c (struct charset_stats):
* mule-charset.c (compute_charset_usage):
* mule-charset.c (charset_memory_usage):
* mule-charset.c (mule_charset_objects_create):
* mule-charset.c (syms_of_mule_charset):
* mule-charset.c (vars_of_mule_charset):
* redisplay.c:
* redisplay.c (compute_rune_dynarr_usage):
* redisplay.c (compute_display_block_dynarr_usage):
* redisplay.c (compute_glyph_block_dynarr_usage):
* redisplay.c (compute_display_line_dynarr_usage):
* redisplay.c (compute_line_start_cache_dynarr_usage):
* redisplay.h:
* scrollbar-gtk.c (gtk_compute_scrollbar_instance_usage):
* scrollbar-msw.c (mswindows_compute_scrollbar_instance_usage):
* scrollbar-x.c (x_compute_scrollbar_instance_usage):
* scrollbar.c (compute_scrollbar_instance_usage):
* scrollbar.h:
* symbols.c:
* symbols.c (reinit_symbol_objects_early):
* symbols.c (init_symbols_once_early):
* symbols.c (reinit_symbols_early):
* symbols.c (defsymbol_massage_name_1):
* symsinit.h:
* ui-gtk.c:
* ui-gtk.c (emacs_gtk_object_getprop):
* ui-gtk.c (emacs_gtk_object_putprop):
* ui-gtk.c (ui_gtk_objects_create):
* unicode.c (compute_from_unicode_table_size_1):
* unicode.c (compute_to_unicode_table_size_1):
* unicode.c (compute_from_unicode_table_size):
* unicode.c (compute_to_unicode_table_size):
* window.c:
* window.c (struct window_stats):
* window.c (compute_window_mirror_usage):
* window.c (compute_window_usage):
* window.c (window_memory_usage):
* window.c (window_objects_create):
* window.c (syms_of_window):
* window.c (vars_of_window):
* window.h:
Redo memory-usage mechanism, make it general; add way of dynamically
initializing Lisp object types -- OBJECT_HAS_METHOD(), similar to
CONSOLE_HAS_METHOD().
(1) Create OBJECT_HAS_METHOD(), OBJECT_HAS_PROPERTY() etc. for
specifying that a Lisp object type has a particular method or
property. Call such methods with OBJECT_METH, MAYBE_OBJECT_METH,
OBJECT_METH_OR_GIVEN; retrieve properties with OBJECT_PROPERTY.
Methods that formerly required a DEFINE_*GENERAL_LISP_OBJECT() to
specify them (getprop, putprop, remprop, plist, disksave) now
instead use the dynamic-method mechanism. The main benefit of
this is that new methods or properties can be added without
requiring that the declaration statements of all existing methods
be modified. We have to make the `struct lrecord_implementation'
non-const, but I don't think this should have any effect on speed --
the only possible method that's really speed-critical is the
mark method, and we already extract those out into a separate
(non-const) array for increased cache locality.
Object methods need to be reinitialized after pdump, so we put
them in separate functions such as face_objects_create(),
extent_objects_create() and call them appropriately from emacs.c
The only current object property (`memusage_stats_list') that
objects can specify is a Lisp object and gets staticpro()ed so it
only needs to be set during dump time, but because it references
symbols that might not exist in a syms_of_() function, we
initialize it in vars_of_(). There is also an object property
(`num_extra_memusage_stats') that is automatically initialized based
on `memusage_stats_list'; we do that in reinit_vars_of_alloc(),
which is called after all vars_of_() functions are called.
`disksaver' method was renamed `disksave' to correspond with the
name normally given to the function (e.g. disksave_lstream()).
(2) Generalize the memory-usage mechanism in `buffer-memory-usage',
`window-memory-usage', `charset-memory-usage' into an object-type-
specific mechanism called by a single function
`object-memory-usage'. (Former function `object-memory-usage'
renamed to `total-object-memory-usage'). Generalize the mechanism
of different "slices" so that we can have different "classes" of
memory described and different "slices" onto each class; `t'
separates classes, `nil' separates slices. Currently we have
three classes defined: the memory of an object itself,
non-Lisp-object memory associated with the object (e.g. arrays or
dynarrs stored as fields in the object), and Lisp-object memory
associated with the object (other internal Lisp objects stored in
the object). This isn't completely finished yet and we might need
to further separate the "other internal Lisp objects" class into
two classes.
The memory-usage mechanism uses a `struct usage_stats' (renamed
from `struct overhead_stats') to describe a malloc-view onto a set
of allocated memory (listing how much was requested and various
types of overhead) and a more general `struct generic_usage_stats'
(with a `struct usage_stats' in it) to hold all statistics about
object memory. `struct generic_usage_stats' contains an array of
32 Bytecounts, which are statistics of unspecified semantics. The
intention is that individual types declare a corresponding struct
(e.g. `struct window_stats') with the same structure but with
specific fields in place of the array, corresponding to specific
statistics. The number of such statistics is an object property
computed from the list of tags (Lisp symbols describing the
statistics) stored in `memusage_stats_list'. The idea here is to
allow particular object types to customize the number and
semantics of the statistics where completely avoiding consing.
This doesn't matter so much yet, but the intention is to have the
memory usage of all objects computed at the end of GC, at the same
time as other statistics are currently computed. The values for
all statistics for a single type would be added up to compute
aggregate values for all objects of a specific type. To make this
efficient, we can't allow any memory allocation at all.
(3) Create some additional functions for creating lists that
specify the elements directly as args rather than indirectly through
an array: listn() (number of args given), listu() (list terminated
by Qunbound).
(4) Delete a bit of remaining unused C window_config stuff, also
unused lrecord_type_popup_data.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Thu, 18 Mar 2010 10:50:06 -0500 |
parents | 5502045ec510 |
children |
rev | line source |
---|---|
428 | 1 ;;; objects.el --- Lisp interface to C window-system objects |
2 | |
3 ;; Copyright (C) 1994, 1997 Free Software Foundation, Inc. | |
4 ;; Copyright (C) 1995 Ben Wing | |
5080
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4201
diff
changeset
|
5 ;; Copyright (C) 2010 Didier Verna |
428 | 6 |
7 ;; Author: Chuck Thompson <cthomp@xemacs.org> | |
8 ;; Author: Ben Wing <ben@xemacs.org> | |
9 ;; Maintainer: XEmacs Development Team | |
10 ;; Keywords: faces, internal, dumped | |
11 | |
12 ;; This file is part of XEmacs. | |
13 | |
14 ;; XEmacs is free software; you can redistribute it and/or modify it | |
15 ;; under the terms of the GNU General Public License as published by | |
16 ;; the Free Software Foundation; either version 2, or (at your option) | |
17 ;; any later version. | |
18 | |
19 ;; XEmacs is distributed in the hope that it will be useful, but | |
20 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
22 ;; General Public License for more details. | |
23 | |
24 ;; You should have received a copy of the GNU General Public License | |
25 ;; along with XEmacs; see the file COPYING. If not, write to the | |
26 ;; Free Software Foundation, 59 Temple Place - Suite 330, | |
27 ;; Boston, MA 02111-1307, USA. | |
28 | |
29 ;;; Synched up with: Not in FSF. | |
30 | |
31 ;;; Commentary: | |
32 | |
33 ;; This file is dumped with XEmacs. | |
34 | |
35 ;;; Code: | |
36 | |
37 (defun ws-object-property-1 (function object domain &optional matchspec) | |
38 (let ((instance (if matchspec | |
39 (specifier-matching-instance object matchspec domain) | |
40 (specifier-instance object domain)))) | |
41 (and instance (funcall function instance)))) | |
42 | |
43 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; font specifiers | |
44 | |
45 (defun make-font-specifier (spec-list) | |
46 "Return a new `font' specifier object with the given specification list. | |
47 SPEC-LIST can be a list of specifications (each of which is a cons of a | |
48 locale and a list of instantiators), a single instantiator, or a list | |
49 of instantiators. See `make-specifier' for more information about | |
442 | 50 specifiers. |
51 | |
52 Valid instantiators for font specifiers are: | |
53 | |
3111 | 54 -- a string naming a font; syntax is platform dependent. Some examples for |
55 a 14-point upright medium-weight Courier font: | |
56 X11 (and GTK1): \"-*-courier-medium-r-*-*-*-140-*-*-*-*-iso8859-*\" | |
57 Xft (and GTK2): \"Courier-14\" | |
58 MS-Windows: \"Courier:14:Western\" | |
442 | 59 -- a font instance (use that instance directly if the device matches, |
60 or use the string that generated it) | |
61 -- a vector of no elements (only on TTY's; this means to set no font | |
62 at all, thus using the \"natural\" font of the terminal's text) | |
63 -- a vector of one element (a face to inherit from) | |
64 " | |
428 | 65 (make-specifier-and-init 'font spec-list)) |
66 | |
67 (defun font-name (font &optional domain charset) | |
68 "Return the name of the FONT in the specified DOMAIN, if any. | |
69 FONT should be a font specifier object and DOMAIN is normally a window | |
70 and defaults to the selected window if omitted. This is equivalent | |
71 to using `specifier-instance' and applying `font-instance-name' to | |
72 the result. See `make-specifier' for more information about specifiers." | |
73 (ws-object-property-1 'font-instance-name font domain charset)) | |
74 | |
75 (defun font-ascent (font &optional domain charset) | |
76 "Return the ascent of the FONT in the specified DOMAIN, if any. | |
77 FONT should be a font specifier object and DOMAIN is normally a window | |
78 and defaults to the selected window if omitted. This is equivalent | |
79 to using `specifier-instance' and applying `font-instance-ascent' to | |
80 the result. See `make-specifier' for more information about specifiers." | |
81 (ws-object-property-1 'font-instance-ascent font domain charset)) | |
82 | |
83 (defun font-descent (font &optional domain charset) | |
84 "Return the descent of the FONT in the specified DOMAIN, if any. | |
85 FONT should be a font specifier object and DOMAIN is normally a window | |
86 and defaults to the selected window if omitted. This is equivalent | |
87 to using `specifier-instance' and applying `font-instance-descent' to | |
88 the result. See `make-specifier' for more information about specifiers." | |
89 (ws-object-property-1 'font-instance-descent font domain charset)) | |
90 | |
91 (defun font-width (font &optional domain charset) | |
92 "Return the width of the FONT in the specified DOMAIN, if any. | |
93 FONT should be a font specifier object and DOMAIN is normally a window | |
94 and defaults to the selected window if omitted. This is equivalent | |
95 to using `specifier-instance' and applying `font-instance-width' to | |
96 the result. See `make-specifier' for more information about specifiers." | |
97 (ws-object-property-1 'font-instance-width font domain charset)) | |
98 | |
99 (defun font-height (font &optional domain charset) | |
100 "Return the height of the FONT in the specified DOMAIN, if any. | |
101 FONT should be a font specifier object and DOMAIN is normally a window | |
102 and defaults to the selected window if omitted. This is equivalent | |
103 to using `specifier-instance' and applying `font-instance-height' to | |
104 the result. See `make-specifier' for more information about specifiers." | |
105 (ws-object-property-1 'font-instance-height font domain charset)) | |
106 | |
107 (defun font-proportional-p (font &optional domain charset) | |
108 "Return whether FONT is proportional in the specified DOMAIN, if known. | |
109 FONT should be a font specifier object and DOMAIN is normally a window | |
110 and defaults to the selected window if omitted. This is equivalent | |
111 to using `specifier-instance' and applying `font-instance-proportional-p' to | |
112 the result. See `make-specifier' for more information about specifiers." | |
113 (ws-object-property-1 'font-instance-proportional-p font domain charset)) | |
114 | |
115 (defun font-properties (font &optional domain charset) | |
116 "Return the properties of the FONT in the specified DOMAIN, if any. | |
117 FONT should be a font specifier object and DOMAIN is normally a window | |
118 and defaults to the selected window if omitted. This is equivalent | |
119 to using `specifier-instance' and applying `font-instance-properties' | |
120 to the result. See `make-specifier' for more information about specifiers." | |
121 (ws-object-property-1 'font-instance-properties font domain charset)) | |
122 | |
123 (defun font-truename (font &optional domain charset) | |
124 "Return the truename of the FONT in the specified DOMAIN, if any. | |
125 FONT should be a font specifier object and DOMAIN is normally a window | |
126 and defaults to the selected window if omitted. This is equivalent | |
127 to using `specifier-instance' and applying `font-instance-truename' | |
128 to the result. See `make-specifier' for more information about specifiers." | |
129 (ws-object-property-1 'font-instance-truename font domain charset)) | |
130 | |
131 (defun font-instance-height (font-instance) | |
132 "Return the height in pixels of FONT-INSTANCE. | |
133 The returned value is the maximum height for all characters in the font,\n\ | |
134 and is equivalent to the sum of the font instance's ascent and descent." | |
135 (+ (font-instance-ascent font-instance) | |
136 (font-instance-descent font-instance))) | |
137 | |
138 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; color specifiers | |
139 | |
140 (defun make-color-specifier (spec-list) | |
141 "Return a new `color' specifier object with the given specification list. | |
142 SPEC-LIST can be a list of specifications (each of which is a cons of a | |
143 locale and a list of instantiators), a single instantiator, or a list | |
144 of instantiators. See `make-specifier' for a detailed description of | |
442 | 145 how specifiers work. |
146 | |
147 Valid instantiators for color specifiers are: | |
148 | |
149 -- a string naming a color (e.g. under X this might be \"lightseagreen2\" | |
150 or \"#F534B2\") | |
151 -- a color instance (use that instance directly if the device matches, | |
152 or use the string that generated it) | |
153 -- a vector of no elements (only on TTY's; this means to set no color | |
154 at all, thus using the \"natural\" color of the terminal's text) | |
155 -- a vector of one or two elements: a face to inherit from, and | |
156 optionally a symbol naming which property of that face to inherit, | |
157 either `foreground' or `background' (if omitted, defaults to the same | |
158 property that this color specifier is used for; if this specifier is | |
159 not part of a face, the instantiator would not be valid)." | |
428 | 160 (make-specifier-and-init 'color spec-list)) |
161 | |
162 (defun color-name (color &optional domain) | |
163 "Return the name of the COLOR in the specified DOMAIN, if any. | |
164 COLOR should be a color specifier object and DOMAIN is normally a window | |
165 and defaults to the selected window if omitted. This is equivalent | |
166 to using `specifier-instance' and applying `color-instance-name' to | |
167 the result. See `make-specifier' for more information about specifiers." | |
168 (ws-object-property-1 'color-instance-name color domain)) | |
169 | |
170 (defun color-rgb-components (color &optional domain) | |
171 "Return the RGB components of the COLOR in the specified DOMAIN, if any. | |
172 COLOR should be a color specifier object and DOMAIN is normally a window | |
173 and defaults to the selected window if omitted. This is equivalent | |
174 to using `specifier-instance' and applying `color-instance-rgb-components' | |
175 to the result. See `make-specifier' for more information about specifiers." | |
176 (ws-object-property-1 'color-instance-rgb-components color domain)) | |
177 | |
442 | 178 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; face-boolean specifiers |
179 | |
180 (defun make-face-boolean-specifier (spec-list) | |
181 "Return a new `face-boolean' specifier object with the given spec list. | |
182 SPEC-LIST can be a list of specifications (each of which is a cons of a | |
183 locale and a list of instantiators), a single instantiator, or a list | |
184 of instantiators. See `make-specifier' for a detailed description of | |
185 how specifiers work. | |
186 | |
187 Valid instantiators for face-boolean specifiers are | |
188 | |
189 -- t or nil | |
4201 | 190 -- a vector of one, two or three elements: a face to inherit from, |
442 | 191 optionally a symbol naming the property of that face to inherit from |
192 (if omitted, defaults to the same property that this face-boolean | |
193 specifier is used for; if this specifier is not part of a face, | |
194 the instantiator would not be valid), and optionally a value which, | |
195 if non-nil, means to invert the sense of the inherited property." | |
4201 | 196 (make-specifier-and-init 'face-boolean spec-list)) |
442 | 197 |
5080
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4201
diff
changeset
|
198 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; face-background-placement specifiers |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4201
diff
changeset
|
199 |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4201
diff
changeset
|
200 (defun make-face-background-placement-specifier (spec-list) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4201
diff
changeset
|
201 "Return a new `face-background-placement' specifier object. |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4201
diff
changeset
|
202 SPEC-LIST can be a list of specifications (each of which is a cons of a |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4201
diff
changeset
|
203 locale and a list of instantiators), a single instantiator, or a list |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4201
diff
changeset
|
204 of instantiators. See `make-specifier' for a detailed description of |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4201
diff
changeset
|
205 how specifiers work. |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4201
diff
changeset
|
206 |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4201
diff
changeset
|
207 Valid instantiators for face-background-placement specifiers are: |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4201
diff
changeset
|
208 -- absolute or relative (symbols), |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4201
diff
changeset
|
209 -- a vector of one element: a face to inherit from." |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4201
diff
changeset
|
210 (make-specifier-and-init 'face-background-placement spec-list)) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4201
diff
changeset
|
211 |
428 | 212 ;;; objects.el ends here. |