Mercurial > hg > xemacs-beta
annotate lisp/paths.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 | aa5ed11f473b |
children | 308d34e9f07d |
rev | line source |
---|---|
428 | 1 ;;; paths.el --- define pathnames for use by various Emacs commands. |
2 | |
3 ;; Copyright (C) 1986, 1988, 1993, 1994, 1997 Free Software Foundation, Inc. | |
4 | |
5 ;; Maintainer: FSF | |
6 ;; Keywords: internal, dumped | |
7 | |
8 ;; This file is part of XEmacs. | |
9 | |
10 ;; XEmacs is free software; you can redistribute it and/or modify it | |
11 ;; under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; XEmacs is distributed in the hope that it will be useful, but | |
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 ;; General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free | |
22 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
24 ;;; Synched up with: FSF 19.30. | |
25 | |
26 ;;; Commentary: | |
27 | |
28 ;; This file is dumped with XEmacs. | |
29 | |
30 ;; These are default settings for names of certain files and directories | |
31 ;; that Emacs needs to refer to from time to time. | |
32 | |
33 ;; If these settings are not right, override them with `setq' | |
34 ;; in site-start.el. Do not change this file. | |
35 | |
36 ;;; Code: | |
37 | |
38 ;Note: FSF's version is: | |
39 ;(defvar Info-default-directory-list | |
40 ; (let ((start (list "/usr/local/lib/info/" | |
41 ; ;; This comes second so that, if it is the same | |
42 ; ;; as configure-info-directory (which is usually true) | |
43 ; ;; and Emacs has been installed (also usually true) | |
44 ; ;; then the list will end with two copies of this; | |
45 ; ;; which means that the last dir file Info-insert-dir | |
46 ; ;; finds will be the one in this directory. | |
47 ; "/usr/local/info/")) | |
48 ; (configdir (file-name-as-directory configure-info-directory))) | |
49 ; (setq start (nconc start (list configdir))) | |
50 ; start) | |
51 ; "List of directories to search for Info documentation files. | |
52 ;They are searched in the order they are given in this list. | |
53 ;Therefore, the directory of Info files that come with Emacs | |
54 ;normally should come last (so that local files override standard ones).") | |
55 | |
56 ;Our commented-out version is: | |
57 ;(defvar Info-default-directory-list | |
58 ; (let ((start (list "/usr/local/info/" | |
59 ; "/usr/local/lib/info/")) | |
60 ; (configdir (file-name-as-directory configure-info-directory))) | |
61 ; (or (member configdir start) | |
62 ; (setq start (nconc start (list configdir)))) | |
63 ; (or (member (expand-file-name "../info/" data-directory) start) | |
64 ; (setq start | |
65 ; (nconc start | |
66 ; (list (expand-file-name "../info/" data-directory))))) | |
67 ; start) | |
68 ; "List of directories to search for Info documentation files.") | |
69 | |
70 (defvar news-path "/usr/spool/news/" | |
71 "The root directory below which all news files are stored.") | |
72 | |
73 (defvar news-inews-program nil | |
74 "Program to post news.") | |
75 | |
76 ;(defvar gnus-default-nntp-server "" | |
77 ; ;; set this to your local server | |
78 ; "The name of the host running an NNTP server. | |
79 ;If it is a string such as \":DIRECTORY\", then ~/DIRECTORY | |
80 ;is used as a news spool. `gnus-nntp-server' is initialized from NNTPSERVER | |
81 ;environment variable or, if none, this value.") | |
82 | |
83 ;(defvar gnus-nntp-service "nntp" | |
84 ; "NNTP service name, usually \"nntp\" or 119). | |
85 ;Go to a local news spool if its value is nil, in which case `gnus-nntp-server' | |
86 ;should be set to `(system-name)'.") | |
87 | |
88 (defvar mh-progs nil | |
89 "Directory containing MH commands.") | |
90 | |
91 (defvar mh-lib nil | |
92 "Directory of MH library.") | |
93 | |
444 | 94 (defvar rmail-file-name "~/RMAIL" |
428 | 95 "Name of user's primary mail file.") |
96 | |
97 (defconst rmail-spool-directory nil | |
98 "Name of directory used by system mailer for delivering new mail. | |
99 Its name should end with a slash.") | |
100 | |
101 (defconst sendmail-program nil | |
102 "Program used to send messages.") | |
103 | |
104 (defconst remote-shell-program nil | |
105 "Program used to execute shell commands on a remote machine.") | |
106 | |
444 | 107 (defconst term-file-prefix "term/" |
428 | 108 "If non-nil, Emacs startup does (load (concat term-file-prefix (getenv \"TERM\"))) |
109 You may set this variable to nil in your `.emacs' file if you do not wish | |
110 the terminal-initialization file to be loaded.") | |
111 | |
112 (defconst manual-program nil | |
113 "Program to run to print man pages.") | |
114 | |
444 | 115 (defconst abbrev-file-name "~/.abbrev_defs" |
428 | 116 "*Default name of file to read abbrevs from.") |
117 | |
118 (defconst directory-abbrev-alist nil) | |
119 | |
120 ;; Formerly, the values of these variables were computed once | |
121 ;; (at dump time). However, with the advent of pre-compiled binaries | |
122 ;; and homebrewed systems such as Linux where who knows where the | |
123 ;; hell the various programs may be located (if they even exist at all), | |
124 ;; it's clear that we need to recompute these values at run time. | |
125 ;; In typical short-sightedness, site administrators have been told up | |
126 ;; till now to do `setq's in site-init.el, which is run only once -- | |
127 ;; at dump time. So we have to do contortions to make sure we don't | |
128 ;; override values set in site-init.el. | |
129 | |
130 (defun initialize-xemacs-paths () | |
131 "Initialize the XEmacs path variables from the environment. | |
132 Called automatically at dump time and run time. Do not call this. | |
133 Will not override settings in site-init.el or site-run.el." | |
134 (let ((l #'(lambda (var value) | |
135 (let ((origsym (intern (concat "paths-el-original-" | |
136 (symbol-name var))))) | |
137 (if (running-temacs-p) | |
138 (progn | |
139 (set var value) | |
140 (set origsym value)) | |
141 (and (eq (symbol-value var) (symbol-value origsym)) | |
142 (set var value))))))) | |
143 (funcall | |
144 l 'news-inews-program | |
145 (cond ((file-exists-p "/usr/bin/inews") "/usr/bin/inews") | |
146 ((file-exists-p "/usr/local/inews") "/usr/local/inews") | |
147 ((file-exists-p "/usr/local/bin/inews") "/usr/local/bin/inews") | |
148 ((file-exists-p "/usr/lib/news/inews") "/usr/lib/news/inews") | |
149 (t "inews"))) | |
150 | |
151 (funcall | |
152 l 'mh-progs | |
4759
aa5ed11f473b
Remove support for obsolete systems. See xemacs-patches message with ID
Jerry James <james@xemacs.org>
parents:
444
diff
changeset
|
153 (cond ((file-directory-p "/usr/bin/mh") "/usr/bin/mh/") |
428 | 154 ((file-directory-p "/usr/local/bin/mh") "/usr/local/bin/mh/") |
155 ((file-directory-p "/usr/local/mh") "/usr/local/mh/") | |
156 (t "/usr/local/bin/"))) | |
157 | |
158 (funcall | |
159 l 'mh-libs | |
4759
aa5ed11f473b
Remove support for obsolete systems. See xemacs-patches message with ID
Jerry James <james@xemacs.org>
parents:
444
diff
changeset
|
160 (cond ((file-directory-p "/usr/lib/mh") "/usr/lib/mh/") |
428 | 161 ((file-directory-p "/usr/local/lib/mh") "/usr/local/lib/mh/") |
162 (t "/usr/local/bin/mh/"))) | |
163 | |
164 (funcall | |
165 l 'rmail-spool-directory | |
4759
aa5ed11f473b
Remove support for obsolete systems. See xemacs-patches message with ID
Jerry James <james@xemacs.org>
parents:
444
diff
changeset
|
166 (cond ;; SVR4 and recent BSD are said to use this. |
428 | 167 ;; Rather than trying to know precisely which systems use it, |
168 ;; let's assume this dir is never used for anything else. | |
169 ((file-exists-p "/var/mail") | |
170 "/var/mail/") | |
4759
aa5ed11f473b
Remove support for obsolete systems. See xemacs-patches message with ID
Jerry James <james@xemacs.org>
parents:
444
diff
changeset
|
171 ((memq system-type '(hpux usg-unix-v irix)) |
428 | 172 "/usr/mail/") |
173 ((memq system-type '(linux)) | |
174 "/var/spool/mail/") | |
175 (t "/usr/spool/mail/"))) | |
176 | |
177 (funcall | |
178 l 'sendmail-program | |
179 (cond | |
180 ((file-exists-p "/usr/lib/sendmail") "/usr/lib/sendmail") | |
181 ((file-exists-p "/usr/sbin/sendmail") "/usr/sbin/sendmail") | |
182 ((file-exists-p "/usr/ucblib/sendmail") "/usr/ucblib/sendmail") | |
183 (t "fakemail"))) ;In ../etc, to interface to /bin/mail. | |
184 | |
185 (funcall | |
186 l 'remote-shell-program | |
187 (cond | |
188 ;; Some systems use rsh for the remote shell; others use that | |
189 ;; name for the restricted shell and use remsh for the remote | |
190 ;; shell. Let's try to guess based on what we actually find | |
191 ;; out there. The restricted shell is almost certainly in | |
192 ;; /bin or /usr/bin, so it's probably safe to assume that an | |
193 ;; rsh found elsewhere is the remote shell program. The | |
194 ;; converse is not true: /usr/bin/rsh could be either one, so | |
195 ;; check that last. | |
196 ((file-exists-p "/usr/ucb/remsh") "/usr/ucb/remsh") | |
197 ((file-exists-p "/usr/bsd/remsh") "/usr/bsd/remsh") | |
198 ((file-exists-p "/bin/remsh") "/bin/remsh") | |
199 ((file-exists-p "/usr/bin/remsh") "/usr/bin/remsh") | |
200 ((file-exists-p "/usr/local/bin/remsh") "/usr/local/bin/remsh") | |
201 ((file-exists-p "/usr/ucb/rsh") "/usr/ucb/rsh") | |
202 ((file-exists-p "/usr/bsd/rsh") "/usr/bsd/rsh") | |
203 ((file-exists-p "/usr/local/bin/rsh") "/usr/local/bin/rsh") | |
204 ((file-exists-p "/usr/bin/rcmd") "/usr/bin/rcmd") | |
205 ((file-exists-p "/bin/rcmd") "/bin/rcmd") | |
206 ((file-exists-p "/bin/rsh") "/bin/rsh") | |
207 ((file-exists-p "/usr/bin/rsh") "/usr/bin/rsh") | |
208 (t "rsh"))) | |
209 | |
210 (funcall | |
211 l 'manual-program | |
212 ;; Solaris 2 has both of these files; prefer /usr/ucb/man | |
213 ;; because the other has nonstandard argument conventions. | |
214 (if (file-exists-p "/usr/ucb/man") | |
215 "/usr/ucb/man" "/usr/bin/man")) | |
216 | |
217 (funcall | |
218 l 'directory-abbrev-alist | |
219 ;; Try to match various conventions for automounter temporary | |
220 ;; mount points. These temporary mount points may go away, so | |
221 ;; it's important that we only try to read files under the | |
222 ;; "advertised" mount point, rather than the temporary one, or it | |
223 ;; will look like files have been deleted on us. Whoever came up | |
224 ;; with this design is clearly a moron of the first order, but | |
225 ;; now we're stuck with it, no doubt until the end of time. | |
226 ;; | |
227 ;; For best results, automounter junk should go near the front of this | |
228 ;; list, and other user translations should come after it. | |
229 ;; | |
230 ;; Our code handles the following empirically observed conventions: | |
231 ;; /net is an actual directory! (some systems are not broken!) | |
232 ;; /net/HOST -> /tmp_mnt/net/HOST (`standard' old Sun automounter) | |
233 ;; /net/HOST -> /tmp_mnt/HOST (BSDI 4.0) | |
234 ;; /net/HOST -> /a/HOST (Freebsd 2.2.x) | |
235 ;; /net/HOST -> /amd/HOST (seen in amd sample config files) | |
236 ;; | |
237 ;; If your system has a different convention, you may have to change this. | |
238 ;; Don't forget to send in a patch! | |
239 (when (file-directory-p "/net") | |
240 (append | |
241 (when (file-directory-p "/tmp_mnt") | |
242 (if (file-directory-p "/tmp_mnt/net") | |
243 '(("\\`/tmp_mnt/net/" . "/net/")) | |
244 '(("\\`/tmp_mnt/" . "/net/")))) | |
245 (when (file-directory-p "/a") | |
246 '(("\\`/a/" . "/net/"))) | |
247 (when (file-directory-p "/amd") | |
248 '(("\\`/amd/" . "/net/"))) | |
249 ))) | |
250 )) | |
251 | |
252 (if (running-temacs-p) | |
253 (initialize-xemacs-paths)) | |
254 | |
255 ;;; paths.el ends here |