Mercurial > emacs
annotate src/alloc.c @ 107256:122dff72a8ee
* net/tramp.el (tramp-handle-write-region): START can be a string.
Take care in the checks.
author | Michael Albinus <albinus@detlef> |
---|---|
date | Sun, 28 Feb 2010 12:36:39 +0100 |
parents | ddd257e3f816 |
children | 3447e262f426 d14945d39811 |
rev | line source |
---|---|
300 | 1 /* Storage allocation and gc for GNU Emacs Lisp interpreter. |
57098
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
2 Copyright (C) 1985, 1986, 1988, 1993, 1994, 1995, 1997, 1998, 1999, |
106815 | 3 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
79759 | 4 Free Software Foundation, Inc. |
300 | 5 |
6 This file is part of GNU Emacs. | |
7 | |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94293
diff
changeset
|
8 GNU Emacs is free software: you can redistribute it and/or modify |
300 | 9 it under the terms of the GNU General Public License as published by |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94293
diff
changeset
|
10 the Free Software Foundation, either version 3 of the License, or |
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94293
diff
changeset
|
11 (at your option) any later version. |
300 | 12 |
13 GNU Emacs is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94293
diff
changeset
|
19 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
300 | 20 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25762
diff
changeset
|
21 #include <config.h> |
28374
7a3e8a76057b
Include stdio.h. Test STDC_HEADERS, not __STDC__.
Dave Love <fx@gnu.org>
parents:
28365
diff
changeset
|
22 #include <stdio.h> |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
23 #include <limits.h> /* For CHAR_BIT. */ |
105669
68dd71358159
* alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
104582
diff
changeset
|
24 #include <setjmp.h> |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25762
diff
changeset
|
25 |
69876
272487a77b8e
[STDC_HEADERS]: Include stddef.h.
Eli Zaretskii <eliz@gnu.org>
parents:
69873
diff
changeset
|
26 #ifdef STDC_HEADERS |
272487a77b8e
[STDC_HEADERS]: Include stddef.h.
Eli Zaretskii <eliz@gnu.org>
parents:
69873
diff
changeset
|
27 #include <stddef.h> /* For offsetof, used by PSEUDOVECSIZE. */ |
272487a77b8e
[STDC_HEADERS]: Include stddef.h.
Eli Zaretskii <eliz@gnu.org>
parents:
69873
diff
changeset
|
28 #endif |
272487a77b8e
[STDC_HEADERS]: Include stddef.h.
Eli Zaretskii <eliz@gnu.org>
parents:
69873
diff
changeset
|
29 |
47185
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
30 #ifdef ALLOC_DEBUG |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
31 #undef INLINE |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
32 #endif |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
33 |
3003
5a73d384f45e
* syssignal.h: Don't #include <signal.h>
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
34 #include <signal.h> |
300 | 35 |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
36 #ifdef HAVE_GTK_AND_PTHREAD |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
37 #include <pthread.h> |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
38 #endif |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
39 |
26164
d39ec0a27081
more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents:
26088
diff
changeset
|
40 /* This file is part of the core Lisp implementation, and thus must |
d39ec0a27081
more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents:
26088
diff
changeset
|
41 deal with the real data structures. If the Lisp implementation is |
d39ec0a27081
more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents:
26088
diff
changeset
|
42 replaced, this file likely will not be used. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
43 |
26164
d39ec0a27081
more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents:
26088
diff
changeset
|
44 #undef HIDE_LISP_IMPLEMENTATION |
300 | 45 #include "lisp.h" |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
46 #include "process.h" |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
47 #include "intervals.h" |
356 | 48 #include "puresize.h" |
300 | 49 #include "buffer.h" |
50 #include "window.h" | |
31102
6a0caa788013
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30914
diff
changeset
|
51 #include "keyboard.h" |
764 | 52 #include "frame.h" |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
53 #include "blockinput.h" |
88353
8e996bb689ca
Include "character.h" instead of "charset.h".
Kenichi Handa <handa@m17n.org>
parents:
43314
diff
changeset
|
54 #include "character.h" |
638 | 55 #include "syssignal.h" |
84693
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
56 #include "termhooks.h" /* For struct terminal. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
57 #include <setjmp.h> |
638 | 58 |
52547
623355edbb1d
(GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents:
52475
diff
changeset
|
59 /* GC_MALLOC_CHECK defined means perform validity checks of malloc'd |
623355edbb1d
(GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents:
52475
diff
changeset
|
60 memory. Can do this only if using gmalloc.c. */ |
623355edbb1d
(GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents:
52475
diff
changeset
|
61 |
623355edbb1d
(GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents:
52475
diff
changeset
|
62 #if defined SYSTEM_MALLOC || defined DOUG_LEA_MALLOC |
623355edbb1d
(GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents:
52475
diff
changeset
|
63 #undef GC_MALLOC_CHECK |
623355edbb1d
(GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents:
52475
diff
changeset
|
64 #endif |
623355edbb1d
(GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents:
52475
diff
changeset
|
65 |
30784
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
66 #ifdef HAVE_UNISTD_H |
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
67 #include <unistd.h> |
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
68 #else |
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
69 extern POINTER_TYPE *sbrk (); |
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
70 #endif |
12096 | 71 |
67216
fc58516afccd
Include fcntl.h. Define O_WRONLY if not defined.
Kim F. Storm <storm@cua.dk>
parents:
66889
diff
changeset
|
72 #ifdef HAVE_FCNTL_H |
fc58516afccd
Include fcntl.h. Define O_WRONLY if not defined.
Kim F. Storm <storm@cua.dk>
parents:
66889
diff
changeset
|
73 #define INCLUDED_FCNTL |
fc58516afccd
Include fcntl.h. Define O_WRONLY if not defined.
Kim F. Storm <storm@cua.dk>
parents:
66889
diff
changeset
|
74 #include <fcntl.h> |
fc58516afccd
Include fcntl.h. Define O_WRONLY if not defined.
Kim F. Storm <storm@cua.dk>
parents:
66889
diff
changeset
|
75 #endif |
fc58516afccd
Include fcntl.h. Define O_WRONLY if not defined.
Kim F. Storm <storm@cua.dk>
parents:
66889
diff
changeset
|
76 #ifndef O_WRONLY |
fc58516afccd
Include fcntl.h. Define O_WRONLY if not defined.
Kim F. Storm <storm@cua.dk>
parents:
66889
diff
changeset
|
77 #define O_WRONLY 1 |
fc58516afccd
Include fcntl.h. Define O_WRONLY if not defined.
Kim F. Storm <storm@cua.dk>
parents:
66889
diff
changeset
|
78 #endif |
fc58516afccd
Include fcntl.h. Define O_WRONLY if not defined.
Kim F. Storm <storm@cua.dk>
parents:
66889
diff
changeset
|
79 |
72177
4eba80d54b43
[WINDOWSNT]: Include fcntl.h, to fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
72167
diff
changeset
|
80 #ifdef WINDOWSNT |
4eba80d54b43
[WINDOWSNT]: Include fcntl.h, to fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
72167
diff
changeset
|
81 #include <fcntl.h> |
72288 | 82 #include "w32.h" |
72177
4eba80d54b43
[WINDOWSNT]: Include fcntl.h, to fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
72167
diff
changeset
|
83 #endif |
4eba80d54b43
[WINDOWSNT]: Include fcntl.h, to fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
72167
diff
changeset
|
84 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
85 #ifdef DOUG_LEA_MALLOC |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
86 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
87 #include <malloc.h> |
31892
2f3d88ac2b38
(__malloc_size_t) [DOUG_LEA_MALLOC]: Don't redefine it.
Dave Love <fx@gnu.org>
parents:
31889
diff
changeset
|
88 /* malloc.h #defines this as size_t, at least in glibc2. */ |
2f3d88ac2b38
(__malloc_size_t) [DOUG_LEA_MALLOC]: Don't redefine it.
Dave Love <fx@gnu.org>
parents:
31889
diff
changeset
|
89 #ifndef __malloc_size_t |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
90 #define __malloc_size_t int |
31892
2f3d88ac2b38
(__malloc_size_t) [DOUG_LEA_MALLOC]: Don't redefine it.
Dave Love <fx@gnu.org>
parents:
31889
diff
changeset
|
91 #endif |
23973
2eb9e2f5aa33
(MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
23958
diff
changeset
|
92 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
93 /* Specify maximum number of areas to mmap. It would be nice to use a |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
94 value that explicitly means "no limit". */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
95 |
23973
2eb9e2f5aa33
(MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
23958
diff
changeset
|
96 #define MMAP_MAX_AREAS 100000000 |
2eb9e2f5aa33
(MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
23958
diff
changeset
|
97 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
98 #else /* not DOUG_LEA_MALLOC */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
99 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
100 /* The following come from gmalloc.c. */ |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
101 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
102 #define __malloc_size_t size_t |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
103 extern __malloc_size_t _bytes_used; |
31892
2f3d88ac2b38
(__malloc_size_t) [DOUG_LEA_MALLOC]: Don't redefine it.
Dave Love <fx@gnu.org>
parents:
31889
diff
changeset
|
104 extern __malloc_size_t __malloc_extra_blocks; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
105 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
106 #endif /* not DOUG_LEA_MALLOC */ |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
107 |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
108 #if ! defined (SYSTEM_MALLOC) && defined (HAVE_GTK_AND_PTHREAD) |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
109 |
58831
408c5135b0a2
* alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
110 /* When GTK uses the file chooser dialog, different backends can be loaded |
408c5135b0a2
* alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
111 dynamically. One such a backend is the Gnome VFS backend that gets loaded |
408c5135b0a2
* alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
112 if you run Gnome. That backend creates several threads and also allocates |
408c5135b0a2
* alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
113 memory with malloc. |
408c5135b0a2
* alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
114 |
408c5135b0a2
* alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
115 If Emacs sets malloc hooks (! SYSTEM_MALLOC) and the emacs_blocked_* |
408c5135b0a2
* alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
116 functions below are called from malloc, there is a chance that one |
408c5135b0a2
* alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
117 of these threads preempts the Emacs main thread and the hook variables |
58986
59945307b86b
* syssignal.h: Declare main_thread.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58831
diff
changeset
|
118 end up in an inconsistent state. So we have a mutex to prevent that (note |
58831
408c5135b0a2
* alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
119 that the backend handles concurrent access to malloc within its own threads |
408c5135b0a2
* alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
120 but Emacs code running in the main thread is not included in that control). |
408c5135b0a2
* alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
121 |
59359
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
122 When UNBLOCK_INPUT is called, reinvoke_input_signal may be called. If this |
58831
408c5135b0a2
* alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
123 happens in one of the backend threads we will have two threads that tries |
408c5135b0a2
* alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
124 to run Emacs code at once, and the code is not prepared for that. |
408c5135b0a2
* alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
125 To prevent that, we only call BLOCK/UNBLOCK from the main thread. */ |
408c5135b0a2
* alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
126 |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
127 static pthread_mutex_t alloc_mutex; |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
128 |
75192
a62f8b0494a2
(BLOCK_INPUT_ALLOC, UNBLOCK_INPUT_ALLOC): Use pthread_equal,
Jan Djärv <jan.h.d@swipnet.se>
parents:
73964
diff
changeset
|
129 #define BLOCK_INPUT_ALLOC \ |
a62f8b0494a2
(BLOCK_INPUT_ALLOC, UNBLOCK_INPUT_ALLOC): Use pthread_equal,
Jan Djärv <jan.h.d@swipnet.se>
parents:
73964
diff
changeset
|
130 do \ |
a62f8b0494a2
(BLOCK_INPUT_ALLOC, UNBLOCK_INPUT_ALLOC): Use pthread_equal,
Jan Djärv <jan.h.d@swipnet.se>
parents:
73964
diff
changeset
|
131 { \ |
a62f8b0494a2
(BLOCK_INPUT_ALLOC, UNBLOCK_INPUT_ALLOC): Use pthread_equal,
Jan Djärv <jan.h.d@swipnet.se>
parents:
73964
diff
changeset
|
132 if (pthread_equal (pthread_self (), main_thread)) \ |
75406
b176aeeb7253
(BLOCK_INPUT_ALLOC, UNBLOCK_INPUT_ALLOC): Use
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
75348
diff
changeset
|
133 BLOCK_INPUT; \ |
75192
a62f8b0494a2
(BLOCK_INPUT_ALLOC, UNBLOCK_INPUT_ALLOC): Use pthread_equal,
Jan Djärv <jan.h.d@swipnet.se>
parents:
73964
diff
changeset
|
134 pthread_mutex_lock (&alloc_mutex); \ |
a62f8b0494a2
(BLOCK_INPUT_ALLOC, UNBLOCK_INPUT_ALLOC): Use pthread_equal,
Jan Djärv <jan.h.d@swipnet.se>
parents:
73964
diff
changeset
|
135 } \ |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
136 while (0) |
75192
a62f8b0494a2
(BLOCK_INPUT_ALLOC, UNBLOCK_INPUT_ALLOC): Use pthread_equal,
Jan Djärv <jan.h.d@swipnet.se>
parents:
73964
diff
changeset
|
137 #define UNBLOCK_INPUT_ALLOC \ |
a62f8b0494a2
(BLOCK_INPUT_ALLOC, UNBLOCK_INPUT_ALLOC): Use pthread_equal,
Jan Djärv <jan.h.d@swipnet.se>
parents:
73964
diff
changeset
|
138 do \ |
a62f8b0494a2
(BLOCK_INPUT_ALLOC, UNBLOCK_INPUT_ALLOC): Use pthread_equal,
Jan Djärv <jan.h.d@swipnet.se>
parents:
73964
diff
changeset
|
139 { \ |
a62f8b0494a2
(BLOCK_INPUT_ALLOC, UNBLOCK_INPUT_ALLOC): Use pthread_equal,
Jan Djärv <jan.h.d@swipnet.se>
parents:
73964
diff
changeset
|
140 pthread_mutex_unlock (&alloc_mutex); \ |
a62f8b0494a2
(BLOCK_INPUT_ALLOC, UNBLOCK_INPUT_ALLOC): Use pthread_equal,
Jan Djärv <jan.h.d@swipnet.se>
parents:
73964
diff
changeset
|
141 if (pthread_equal (pthread_self (), main_thread)) \ |
75406
b176aeeb7253
(BLOCK_INPUT_ALLOC, UNBLOCK_INPUT_ALLOC): Use
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
75348
diff
changeset
|
142 UNBLOCK_INPUT; \ |
75192
a62f8b0494a2
(BLOCK_INPUT_ALLOC, UNBLOCK_INPUT_ALLOC): Use pthread_equal,
Jan Djärv <jan.h.d@swipnet.se>
parents:
73964
diff
changeset
|
143 } \ |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
144 while (0) |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
145 |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
146 #else /* SYSTEM_MALLOC || not HAVE_GTK_AND_PTHREAD */ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
147 |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
148 #define BLOCK_INPUT_ALLOC BLOCK_INPUT |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
149 #define UNBLOCK_INPUT_ALLOC UNBLOCK_INPUT |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
150 |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
151 #endif /* SYSTEM_MALLOC || not HAVE_GTK_AND_PTHREAD */ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
152 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
153 /* Value of _bytes_used, when spare_memory was freed. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
154 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
155 static __malloc_size_t bytes_used_when_full; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
156 |
66547
9373f926904a
(BYTES_USED): Use uordblks, not arena.
Richard M. Stallman <rms@gnu.org>
parents:
66541
diff
changeset
|
157 static __malloc_size_t bytes_used_when_reconsidered; |
9373f926904a
(BYTES_USED): Use uordblks, not arena.
Richard M. Stallman <rms@gnu.org>
parents:
66541
diff
changeset
|
158 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
159 /* Mark, unmark, query mark bit of a Lisp string. S must be a pointer |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
160 to a struct Lisp_String. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
161 |
51985
b52e88c3d6d0
(MARK_STRING, UNMARK_STRING, STRING_MARKED_P)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51974
diff
changeset
|
162 #define MARK_STRING(S) ((S)->size |= ARRAY_MARK_FLAG) |
b52e88c3d6d0
(MARK_STRING, UNMARK_STRING, STRING_MARKED_P)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51974
diff
changeset
|
163 #define UNMARK_STRING(S) ((S)->size &= ~ARRAY_MARK_FLAG) |
59657
f3aa25eacdb3
(STRING_MARKED_P, VECTOR_MARKED_P): Return boolean.
Kim F. Storm <storm@cua.dk>
parents:
59400
diff
changeset
|
164 #define STRING_MARKED_P(S) (((S)->size & ARRAY_MARK_FLAG) != 0) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
165 |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
166 #define VECTOR_MARK(V) ((V)->size |= ARRAY_MARK_FLAG) |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
167 #define VECTOR_UNMARK(V) ((V)->size &= ~ARRAY_MARK_FLAG) |
59657
f3aa25eacdb3
(STRING_MARKED_P, VECTOR_MARKED_P): Return boolean.
Kim F. Storm <storm@cua.dk>
parents:
59400
diff
changeset
|
168 #define VECTOR_MARKED_P(V) (((V)->size & ARRAY_MARK_FLAG) != 0) |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
169 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
170 /* Value is the number of bytes/chars of S, a pointer to a struct |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
171 Lisp_String. This must be used instead of STRING_BYTES (S) or |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
172 S->size during GC, because S->size contains the mark bit for |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
173 strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
174 |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
175 #define GC_STRING_BYTES(S) (STRING_BYTES (S)) |
51985
b52e88c3d6d0
(MARK_STRING, UNMARK_STRING, STRING_MARKED_P)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51974
diff
changeset
|
176 #define GC_STRING_CHARS(S) ((S)->size & ~ARRAY_MARK_FLAG) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
177 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
178 /* Number of bytes of consing done since the last gc. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
179 |
300 | 180 int consing_since_gc; |
181 | |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
182 /* Count the amount of consing of various sorts of space. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
183 |
43713
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
184 EMACS_INT cons_cells_consed; |
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
185 EMACS_INT floats_consed; |
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
186 EMACS_INT vector_cells_consed; |
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
187 EMACS_INT symbols_consed; |
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
188 EMACS_INT string_chars_consed; |
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
189 EMACS_INT misc_objects_consed; |
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
190 EMACS_INT intervals_consed; |
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
191 EMACS_INT strings_consed; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
192 |
64611
47f158dcf216
(gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents:
64273
diff
changeset
|
193 /* Minimum number of bytes of consing since GC before next GC. */ |
47f158dcf216
(gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents:
64273
diff
changeset
|
194 |
47f158dcf216
(gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents:
64273
diff
changeset
|
195 EMACS_INT gc_cons_threshold; |
47f158dcf216
(gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents:
64273
diff
changeset
|
196 |
47f158dcf216
(gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents:
64273
diff
changeset
|
197 /* Similar minimum, computed from Vgc_cons_percentage. */ |
47f158dcf216
(gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents:
64273
diff
changeset
|
198 |
47f158dcf216
(gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents:
64273
diff
changeset
|
199 EMACS_INT gc_relative_threshold; |
47f158dcf216
(gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents:
64273
diff
changeset
|
200 |
64267
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
201 static Lisp_Object Vgc_cons_percentage; |
300 | 202 |
66530
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
203 /* Minimum number of bytes of consing since GC before next GC, |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
204 when memory is full. */ |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
205 |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
206 EMACS_INT memory_full_cons_threshold; |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
207 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
208 /* Nonzero during GC. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
209 |
300 | 210 int gc_in_progress; |
211 | |
50745
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
212 /* Nonzero means abort if try to GC. |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
213 This is for code which is written on the assumption that |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
214 no GC will happen, so as to verify that assumption. */ |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
215 |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
216 int abort_on_gc; |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
217 |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
218 /* Nonzero means display messages at beginning and end of GC. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
219 |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
220 int garbage_collection_messages; |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
221 |
300 | 222 #ifndef VIRT_ADDR_VARIES |
223 extern | |
224 #endif /* VIRT_ADDR_VARIES */ | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
225 int malloc_sbrk_used; |
300 | 226 |
227 #ifndef VIRT_ADDR_VARIES | |
228 extern | |
229 #endif /* VIRT_ADDR_VARIES */ | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
230 int malloc_sbrk_unused; |
300 | 231 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
232 /* Number of live and free conses etc. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
233 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
234 static int total_conses, total_markers, total_symbols, total_vector_size; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
235 static int total_free_conses, total_free_markers, total_free_symbols; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
236 static int total_free_floats, total_floats; |
19332
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
237 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
238 /* Points to memory space allocated as "spare", to be freed if we run |
66530
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
239 out of memory. We keep one large block, four cons-blocks, and |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
240 two string blocks. */ |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
241 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
242 static char *spare_memory[7]; |
66530
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
243 |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
244 /* Amount of spare memory to keep in large reserve block. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
245 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
246 #define SPARE_MEMORY (1 << 14) |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
247 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
248 /* Number of extra blocks malloc should get when it needs more core. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
249 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
250 static int malloc_hysteresis; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
251 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
252 /* Non-nil means defun should do purecopy on the function definition. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
253 |
300 | 254 Lisp_Object Vpurify_flag; |
255 | |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
256 /* Non-nil means we are handling a memory-full error. */ |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
257 |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
258 Lisp_Object Vmemory_full; |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
259 |
300 | 260 #ifndef HAVE_SHM |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
261 |
57137 | 262 /* Initialize it to a nonzero value to force it into data space |
263 (rather than bss space). That way unexec will remap it into text | |
264 space (pure), on some systems. We have not implemented the | |
265 remapping on more recent systems because this is less important | |
266 nowadays than in the days of small memories and timesharing. */ | |
51908
cb3976b5e59f
(pure, staticvec): Initialize these arrays to nonzero, so that they're
Paul Eggert <eggert@twinsun.com>
parents:
51907
diff
changeset
|
267 |
78593
5d078cae9374
(pure): Round PURESIZE up.
Andreas Schwab <schwab@suse.de>
parents:
78260
diff
changeset
|
268 EMACS_INT pure[(PURESIZE + sizeof (EMACS_INT) - 1) / sizeof (EMACS_INT)] = {1,}; |
300 | 269 #define PUREBEG (char *) pure |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
270 |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
271 #else /* HAVE_SHM */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
272 |
300 | 273 #define pure PURE_SEG_BITS /* Use shared memory segment */ |
274 #define PUREBEG (char *)PURE_SEG_BITS | |
356 | 275 |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
276 #endif /* HAVE_SHM */ |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
277 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
278 /* Pointer to the pure area, and its size. */ |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
279 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
280 static char *purebeg; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
281 static size_t pure_size; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
282 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
283 /* Number of bytes of pure storage used before pure storage overflowed. |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
284 If this is non-zero, this implies that an overflow occurred. */ |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
285 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
286 static size_t pure_bytes_used_before_overflow; |
300 | 287 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
288 /* Value is non-zero if P points into pure space. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
289 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
290 #define PURE_POINTER_P(P) \ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
291 (((PNTR_COMPARISON_TYPE) (P) \ |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
292 < (PNTR_COMPARISON_TYPE) ((char *) purebeg + pure_size)) \ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
293 && ((PNTR_COMPARISON_TYPE) (P) \ |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
294 >= (PNTR_COMPARISON_TYPE) purebeg)) |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
295 |
72027
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
296 /* Total number of bytes allocated in pure storage. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
297 |
43713
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
298 EMACS_INT pure_bytes_used; |
300 | 299 |
72027
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
300 /* Index in pure at which next pure Lisp object will be allocated.. */ |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
301 |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
302 static EMACS_INT pure_bytes_used_lisp; |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
303 |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
304 /* Number of bytes allocated for non-Lisp objects in pure storage. */ |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
305 |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
306 static EMACS_INT pure_bytes_used_non_lisp; |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
307 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
308 /* If nonzero, this is a warning delivered by malloc and not yet |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
309 displayed. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
310 |
300 | 311 char *pending_malloc_warning; |
312 | |
6116
64417bbbb128
(memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents:
5874
diff
changeset
|
313 /* Pre-computed signal argument for use when memory is exhausted. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
314 |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
315 Lisp_Object Vmemory_signal_data; |
6116
64417bbbb128
(memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents:
5874
diff
changeset
|
316 |
300 | 317 /* Maximum amount of C stack to save when a GC happens. */ |
318 | |
319 #ifndef MAX_SAVE_STACK | |
320 #define MAX_SAVE_STACK 16000 | |
321 #endif | |
322 | |
323 /* Buffer in which we save a copy of the C stack at each GC. */ | |
324 | |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
325 static char *stack_copy; |
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
326 static int stack_copy_size; |
300 | 327 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
328 /* Non-zero means ignore malloc warnings. Set during initialization. |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
329 Currently not used. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
330 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
331 static int ignore_warnings; |
1318 | 332 |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
333 Lisp_Object Qgc_cons_threshold, Qchar_table_extra_slots; |
11374
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
334 |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
335 /* Hook run after GC has finished. */ |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
336 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
337 Lisp_Object Vpost_gc_hook, Qpost_gc_hook; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
338 |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
339 Lisp_Object Vgc_elapsed; /* accumulated elapsed time in GC */ |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
340 EMACS_INT gcs_done; /* accumulated GCs */ |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
341 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
342 static void mark_buffer P_ ((Lisp_Object)); |
84693
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
343 static void mark_terminals P_ ((void)); |
51578
42f25a716cb8
(mark_kboards): Move to keyboard.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51318
diff
changeset
|
344 extern void mark_kboards P_ ((void)); |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
53093
diff
changeset
|
345 extern void mark_ttys P_ ((void)); |
55798
a1bb695e9a0c
(struct backtrace): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55767
diff
changeset
|
346 extern void mark_backtrace P_ ((void)); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
347 static void gc_sweep P_ ((void)); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
348 static void mark_glyph_matrix P_ ((struct glyph_matrix *)); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
349 static void mark_face_cache P_ ((struct face_cache *)); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
350 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
351 #ifdef HAVE_WINDOW_SYSTEM |
59400
eeb8b96d077d
(mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents:
59359
diff
changeset
|
352 extern void mark_fringe_data P_ ((void)); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
353 #endif /* HAVE_WINDOW_SYSTEM */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
354 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
355 static struct Lisp_String *allocate_string P_ ((void)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
356 static void compact_small_strings P_ ((void)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
357 static void free_large_strings P_ ((void)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
358 static void sweep_strings P_ ((void)); |
20495 | 359 |
360 extern int message_enable_multibyte; | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
361 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
362 /* When scanning the C stack for live Lisp objects, Emacs keeps track |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
363 of what memory allocated via lisp_malloc is intended for what |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
364 purpose. This enumeration specifies the type of memory. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
365 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
366 enum mem_type |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
367 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
368 MEM_TYPE_NON_LISP, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
369 MEM_TYPE_BUFFER, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
370 MEM_TYPE_CONS, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
371 MEM_TYPE_STRING, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
372 MEM_TYPE_MISC, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
373 MEM_TYPE_SYMBOL, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
374 MEM_TYPE_FLOAT, |
84978
33b7fe948502
(enum mem_type): Replace all vector subtypes -> MEM_TYPE_VECTORLIKE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84977
diff
changeset
|
375 /* We used to keep separate mem_types for subtypes of vectors such as |
33b7fe948502
(enum mem_type): Replace all vector subtypes -> MEM_TYPE_VECTORLIKE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84977
diff
changeset
|
376 process, hash_table, frame, terminal, and window, but we never made |
33b7fe948502
(enum mem_type): Replace all vector subtypes -> MEM_TYPE_VECTORLIKE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84977
diff
changeset
|
377 use of the distinction, so it only caused source-code complexity |
33b7fe948502
(enum mem_type): Replace all vector subtypes -> MEM_TYPE_VECTORLIKE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84977
diff
changeset
|
378 and runtime slowdown. Minor but pointless. */ |
33b7fe948502
(enum mem_type): Replace all vector subtypes -> MEM_TYPE_VECTORLIKE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84977
diff
changeset
|
379 MEM_TYPE_VECTORLIKE |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
380 }; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
381 |
66530
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
382 static POINTER_TYPE *lisp_align_malloc P_ ((size_t, enum mem_type)); |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
383 static POINTER_TYPE *lisp_malloc P_ ((size_t, enum mem_type)); |
66662
6ab8d86f8a2b
(refill_memory_reserve): Move decl out of conditionals.
Richard M. Stallman <rms@gnu.org>
parents:
66547
diff
changeset
|
384 void refill_memory_reserve (); |
6ab8d86f8a2b
(refill_memory_reserve): Move decl out of conditionals.
Richard M. Stallman <rms@gnu.org>
parents:
66547
diff
changeset
|
385 |
66530
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
386 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
387 #if GC_MARK_STACK || defined GC_MALLOC_CHECK |
27746
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
388 |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
389 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
390 #include <stdio.h> /* For fprintf. */ |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
391 #endif |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
392 |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
393 /* A unique object in pure space used to make some Lisp objects |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
394 on free lists recognizable in O(1). */ |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
395 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
396 static Lisp_Object Vdead; |
27746
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
397 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
398 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
399 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
400 enum mem_type allocated_mem_type; |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
401 static int dont_register_blocks; |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
402 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
403 #endif /* GC_MALLOC_CHECK */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
404 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
405 /* A node in the red-black tree describing allocated memory containing |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
406 Lisp data. Each such block is recorded with its start and end |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
407 address when it is allocated, and removed from the tree when it |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
408 is freed. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
409 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
410 A red-black tree is a balanced binary tree with the following |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
411 properties: |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
412 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
413 1. Every node is either red or black. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
414 2. Every leaf is black. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
415 3. If a node is red, then both of its children are black. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
416 4. Every simple path from a node to a descendant leaf contains |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
417 the same number of black nodes. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
418 5. The root is always black. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
419 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
420 When nodes are inserted into the tree, or deleted from the tree, |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
421 the tree is "fixed" so that these properties are always true. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
422 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
423 A red-black tree with N internal nodes has height at most 2 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
424 log(N+1). Searches, insertions and deletions are done in O(log N). |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
425 Please see a text book about data structures for a detailed |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
426 description of red-black trees. Any book worth its salt should |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
427 describe them. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
428 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
429 struct mem_node |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
430 { |
48907 | 431 /* Children of this node. These pointers are never NULL. When there |
432 is no child, the value is MEM_NIL, which points to a dummy node. */ | |
433 struct mem_node *left, *right; | |
434 | |
435 /* The parent of this node. In the root node, this is NULL. */ | |
436 struct mem_node *parent; | |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
437 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
438 /* Start and end of allocated region. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
439 void *start, *end; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
440 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
441 /* Node color. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
442 enum {MEM_BLACK, MEM_RED} color; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
443 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
444 /* Memory type. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
445 enum mem_type type; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
446 }; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
447 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
448 /* Base address of stack. Set in main. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
449 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
450 Lisp_Object *stack_base; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
451 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
452 /* Root of the tree describing allocated Lisp memory. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
453 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
454 static struct mem_node *mem_root; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
455 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
456 /* Lowest and highest known address in the heap. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
457 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
458 static void *min_heap_address, *max_heap_address; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
459 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
460 /* Sentinel node of the tree. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
461 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
462 static struct mem_node mem_z; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
463 #define MEM_NIL &mem_z |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
464 |
30914
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
465 static POINTER_TYPE *lisp_malloc P_ ((size_t, enum mem_type)); |
84978
33b7fe948502
(enum mem_type): Replace all vector subtypes -> MEM_TYPE_VECTORLIKE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84977
diff
changeset
|
466 static struct Lisp_Vector *allocate_vectorlike P_ ((EMACS_INT)); |
30784
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
467 static void lisp_free P_ ((POINTER_TYPE *)); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
468 static void mark_stack P_ ((void)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
469 static int live_vector_p P_ ((struct mem_node *, void *)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
470 static int live_buffer_p P_ ((struct mem_node *, void *)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
471 static int live_string_p P_ ((struct mem_node *, void *)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
472 static int live_cons_p P_ ((struct mem_node *, void *)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
473 static int live_symbol_p P_ ((struct mem_node *, void *)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
474 static int live_float_p P_ ((struct mem_node *, void *)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
475 static int live_misc_p P_ ((struct mem_node *, void *)); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
476 static void mark_maybe_object P_ ((Lisp_Object)); |
73964
b684c6771753
(mark_memory): New argument OFFSET. All uses changed.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72537
diff
changeset
|
477 static void mark_memory P_ ((void *, void *, int)); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
478 static void mem_init P_ ((void)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
479 static struct mem_node *mem_insert P_ ((void *, void *, enum mem_type)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
480 static void mem_insert_fixup P_ ((struct mem_node *)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
481 static void mem_rotate_left P_ ((struct mem_node *)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
482 static void mem_rotate_right P_ ((struct mem_node *)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
483 static void mem_delete P_ ((struct mem_node *)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
484 static void mem_delete_fixup P_ ((struct mem_node *)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
485 static INLINE struct mem_node *mem_find P_ ((void *)); |
66530
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
486 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
487 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
488 #if GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
489 static void check_gcpros P_ ((void)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
490 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
491 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
492 #endif /* GC_MARK_STACK || GC_MALLOC_CHECK */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
493 |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
494 /* Recording what needs to be marked for gc. */ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
495 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
496 struct gcpro *gcprolist; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
497 |
51908
cb3976b5e59f
(pure, staticvec): Initialize these arrays to nonzero, so that they're
Paul Eggert <eggert@twinsun.com>
parents:
51907
diff
changeset
|
498 /* Addresses of staticpro'd variables. Initialize it to a nonzero |
cb3976b5e59f
(pure, staticvec): Initialize these arrays to nonzero, so that they're
Paul Eggert <eggert@twinsun.com>
parents:
51907
diff
changeset
|
499 value; otherwise some compilers put it into BSS. */ |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
500 |
97230 | 501 #define NSTATICS 0x640 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
502 static Lisp_Object *staticvec[NSTATICS] = {&Vpurify_flag}; |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
503 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
504 /* Index of next unused slot in staticvec. */ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
505 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
506 static int staticidx = 0; |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
507 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
508 static POINTER_TYPE *pure_alloc P_ ((size_t, int)); |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
509 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
510 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
511 /* Value is SZ rounded up to the next multiple of ALIGNMENT. |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
512 ALIGNMENT must be a power of 2. */ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
513 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
514 #define ALIGN(ptr, ALIGNMENT) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
515 ((POINTER_TYPE *) ((((EMACS_UINT)(ptr)) + (ALIGNMENT) - 1) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
516 & ~((ALIGNMENT) - 1))) |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
517 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
518 |
300 | 519 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
520 /************************************************************************ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
521 Malloc |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
522 ************************************************************************/ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
523 |
47185
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
524 /* Function malloc calls this if it finds we are near exhausting storage. */ |
20375
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
525 |
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
526 void |
300 | 527 malloc_warning (str) |
528 char *str; | |
529 { | |
530 pending_malloc_warning = str; | |
531 } | |
532 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
533 |
47185
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
534 /* Display an already-pending malloc warning. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
535 |
20375
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
536 void |
300 | 537 display_malloc_warning () |
538 { | |
47185
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
539 call3 (intern ("display-warning"), |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
540 intern ("alloc"), |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
541 build_string (pending_malloc_warning), |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
542 intern ("emergency")); |
300 | 543 pending_malloc_warning = 0; |
544 } | |
545 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
546 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
547 #ifdef DOUG_LEA_MALLOC |
66547
9373f926904a
(BYTES_USED): Use uordblks, not arena.
Richard M. Stallman <rms@gnu.org>
parents:
66541
diff
changeset
|
548 # define BYTES_USED (mallinfo ().uordblks) |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
549 #else |
17831
9238a2254a23
(BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents:
17348
diff
changeset
|
550 # define BYTES_USED _bytes_used |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
551 #endif |
65832
5159ee08b219
(refill_memory_reserve): Conditionalize the body, not the function's existence.
Richard M. Stallman <rms@gnu.org>
parents:
65764
diff
changeset
|
552 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
553 /* Called if we can't allocate relocatable space for a buffer. */ |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
554 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
555 void |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
556 buffer_memory_full () |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
557 { |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
558 /* If buffers use the relocating allocator, no need to free |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
559 spare_memory, because we may have plenty of malloc space left |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
560 that we could get, and if we don't, the malloc that fails will |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
561 itself cause spare_memory to be freed. If buffers don't use the |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
562 relocating allocator, treat this like any other failing |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
563 malloc. */ |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
564 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
565 #ifndef REL_ALLOC |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
566 memory_full (); |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
567 #endif |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
568 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
569 /* This used to call error, but if we've run out of memory, we could |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
570 get infinite recursion trying to build the string. */ |
71967
3254b987edcb
(buffer_memory_full, memory_full): Use xsignal. Remove loop.
Kim F. Storm <storm@cua.dk>
parents:
69876
diff
changeset
|
571 xsignal (Qnil, Vmemory_signal_data); |
300 | 572 } |
573 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
574 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
575 #ifdef XMALLOC_OVERRUN_CHECK |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
576 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
577 /* Check for overrun in malloc'ed buffers by wrapping a 16 byte header |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
578 and a 16 byte trailer around each block. |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
579 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
580 The header consists of 12 fixed bytes + a 4 byte integer contaning the |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
581 original block size, while the trailer consists of 16 fixed bytes. |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
582 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
583 The header is used to detect whether this block has been allocated |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
584 through these functions -- as it seems that some low-level libc |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
585 functions may bypass the malloc hooks. |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
586 */ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
587 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
588 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
589 #define XMALLOC_OVERRUN_CHECK_SIZE 16 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
590 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
591 static char xmalloc_overrun_check_header[XMALLOC_OVERRUN_CHECK_SIZE-4] = |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
592 { 0x9a, 0x9b, 0xae, 0xaf, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
593 0xbf, 0xbe, 0xce, 0xcf, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
594 0xea, 0xeb, 0xec, 0xed }; |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
595 |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
596 static char xmalloc_overrun_check_trailer[XMALLOC_OVERRUN_CHECK_SIZE] = |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
597 { 0xaa, 0xab, 0xac, 0xad, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
598 0xba, 0xbb, 0xbc, 0xbd, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
599 0xca, 0xcb, 0xcc, 0xcd, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
600 0xda, 0xdb, 0xdc, 0xdd }; |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
601 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
602 /* Macros to insert and extract the block size in the header. */ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
603 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
604 #define XMALLOC_PUT_SIZE(ptr, size) \ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
605 (ptr[-1] = (size & 0xff), \ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
606 ptr[-2] = ((size >> 8) & 0xff), \ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
607 ptr[-3] = ((size >> 16) & 0xff), \ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
608 ptr[-4] = ((size >> 24) & 0xff)) |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
609 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
610 #define XMALLOC_GET_SIZE(ptr) \ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
611 (size_t)((unsigned)(ptr[-1]) | \ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
612 ((unsigned)(ptr[-2]) << 8) | \ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
613 ((unsigned)(ptr[-3]) << 16) | \ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
614 ((unsigned)(ptr[-4]) << 24)) |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
615 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
616 |
59083
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
617 /* The call depth in overrun_check functions. For example, this might happen: |
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
618 xmalloc() |
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
619 overrun_check_malloc() |
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
620 -> malloc -> (via hook)_-> emacs_blocked_malloc |
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
621 -> overrun_check_malloc |
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
622 call malloc (hooks are NULL, so real malloc is called). |
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
623 malloc returns 10000. |
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
624 add overhead, return 10016. |
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
625 <- (back in overrun_check_malloc) |
59082
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
626 add overhead again, return 10032 |
59083
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
627 xmalloc returns 10032. |
59082
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
628 |
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
629 (time passes). |
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
630 |
59083
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
631 xfree(10032) |
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
632 overrun_check_free(10032) |
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
633 decrease overhed |
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
634 free(10016) <- crash, because 10000 is the original pointer. */ |
59082
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
635 |
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
636 static int check_depth; |
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
637 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
638 /* Like malloc, but wraps allocated block with header and trailer. */ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
639 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
640 POINTER_TYPE * |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
641 overrun_check_malloc (size) |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
642 size_t size; |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
643 { |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
644 register unsigned char *val; |
59082
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
645 size_t overhead = ++check_depth == 1 ? XMALLOC_OVERRUN_CHECK_SIZE*2 : 0; |
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
646 |
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
647 val = (unsigned char *) malloc (size + overhead); |
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
648 if (val && check_depth == 1) |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
649 { |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
650 bcopy (xmalloc_overrun_check_header, val, XMALLOC_OVERRUN_CHECK_SIZE - 4); |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
651 val += XMALLOC_OVERRUN_CHECK_SIZE; |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
652 XMALLOC_PUT_SIZE(val, size); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
653 bcopy (xmalloc_overrun_check_trailer, val + size, XMALLOC_OVERRUN_CHECK_SIZE); |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
654 } |
59082
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
655 --check_depth; |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
656 return (POINTER_TYPE *)val; |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
657 } |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
658 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
659 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
660 /* Like realloc, but checks old block for overrun, and wraps new block |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
661 with header and trailer. */ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
662 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
663 POINTER_TYPE * |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
664 overrun_check_realloc (block, size) |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
665 POINTER_TYPE *block; |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
666 size_t size; |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
667 { |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
668 register unsigned char *val = (unsigned char *)block; |
59082
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
669 size_t overhead = ++check_depth == 1 ? XMALLOC_OVERRUN_CHECK_SIZE*2 : 0; |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
670 |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
671 if (val |
59082
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
672 && check_depth == 1 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
673 && bcmp (xmalloc_overrun_check_header, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
674 val - XMALLOC_OVERRUN_CHECK_SIZE, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
675 XMALLOC_OVERRUN_CHECK_SIZE - 4) == 0) |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
676 { |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
677 size_t osize = XMALLOC_GET_SIZE (val); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
678 if (bcmp (xmalloc_overrun_check_trailer, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
679 val + osize, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
680 XMALLOC_OVERRUN_CHECK_SIZE)) |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
681 abort (); |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
682 bzero (val + osize, XMALLOC_OVERRUN_CHECK_SIZE); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
683 val -= XMALLOC_OVERRUN_CHECK_SIZE; |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
684 bzero (val, XMALLOC_OVERRUN_CHECK_SIZE); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
685 } |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
686 |
59082
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
687 val = (unsigned char *) realloc ((POINTER_TYPE *)val, size + overhead); |
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
688 |
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
689 if (val && check_depth == 1) |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
690 { |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
691 bcopy (xmalloc_overrun_check_header, val, XMALLOC_OVERRUN_CHECK_SIZE - 4); |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
692 val += XMALLOC_OVERRUN_CHECK_SIZE; |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
693 XMALLOC_PUT_SIZE(val, size); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
694 bcopy (xmalloc_overrun_check_trailer, val + size, XMALLOC_OVERRUN_CHECK_SIZE); |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
695 } |
59082
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
696 --check_depth; |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
697 return (POINTER_TYPE *)val; |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
698 } |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
699 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
700 /* Like free, but checks block for overrun. */ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
701 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
702 void |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
703 overrun_check_free (block) |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
704 POINTER_TYPE *block; |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
705 { |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
706 unsigned char *val = (unsigned char *)block; |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
707 |
59082
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
708 ++check_depth; |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
709 if (val |
59082
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
710 && check_depth == 1 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
711 && bcmp (xmalloc_overrun_check_header, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
712 val - XMALLOC_OVERRUN_CHECK_SIZE, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
713 XMALLOC_OVERRUN_CHECK_SIZE - 4) == 0) |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
714 { |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
715 size_t osize = XMALLOC_GET_SIZE (val); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
716 if (bcmp (xmalloc_overrun_check_trailer, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
717 val + osize, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
718 XMALLOC_OVERRUN_CHECK_SIZE)) |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
719 abort (); |
59400
eeb8b96d077d
(mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents:
59359
diff
changeset
|
720 #ifdef XMALLOC_CLEAR_FREE_MEMORY |
eeb8b96d077d
(mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents:
59359
diff
changeset
|
721 val -= XMALLOC_OVERRUN_CHECK_SIZE; |
eeb8b96d077d
(mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents:
59359
diff
changeset
|
722 memset (val, 0xff, osize + XMALLOC_OVERRUN_CHECK_SIZE*2); |
eeb8b96d077d
(mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents:
59359
diff
changeset
|
723 #else |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
724 bzero (val + osize, XMALLOC_OVERRUN_CHECK_SIZE); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
725 val -= XMALLOC_OVERRUN_CHECK_SIZE; |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
726 bzero (val, XMALLOC_OVERRUN_CHECK_SIZE); |
59400
eeb8b96d077d
(mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents:
59359
diff
changeset
|
727 #endif |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
728 } |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
729 |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
730 free (val); |
59082
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
731 --check_depth; |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
732 } |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
733 |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
734 #undef malloc |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
735 #undef realloc |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
736 #undef free |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
737 #define malloc overrun_check_malloc |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
738 #define realloc overrun_check_realloc |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
739 #define free overrun_check_free |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
740 #endif |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
741 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
742 #ifdef SYNC_INPUT |
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
743 /* When using SYNC_INPUT, we don't call malloc from a signal handler, so |
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
744 there's no need to block input around malloc. */ |
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
745 #define MALLOC_BLOCK_INPUT ((void)0) |
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
746 #define MALLOC_UNBLOCK_INPUT ((void)0) |
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
747 #else |
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
748 #define MALLOC_BLOCK_INPUT BLOCK_INPUT |
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
749 #define MALLOC_UNBLOCK_INPUT UNBLOCK_INPUT |
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
750 #endif |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
751 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
752 /* Like malloc but check for no memory and block interrupt input.. */ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
753 |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
754 POINTER_TYPE * |
300 | 755 xmalloc (size) |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
756 size_t size; |
300 | 757 { |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
758 register POINTER_TYPE *val; |
300 | 759 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
760 MALLOC_BLOCK_INPUT; |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
761 val = (POINTER_TYPE *) malloc (size); |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
762 MALLOC_UNBLOCK_INPUT; |
300 | 763 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
764 if (!val && size) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
765 memory_full (); |
300 | 766 return val; |
767 } | |
768 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
769 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
770 /* Like realloc but check for no memory and block interrupt input.. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
771 |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
772 POINTER_TYPE * |
300 | 773 xrealloc (block, size) |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
774 POINTER_TYPE *block; |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
775 size_t size; |
300 | 776 { |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
777 register POINTER_TYPE *val; |
300 | 778 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
779 MALLOC_BLOCK_INPUT; |
590 | 780 /* We must call malloc explicitly when BLOCK is 0, since some |
781 reallocs don't do this. */ | |
782 if (! block) | |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
783 val = (POINTER_TYPE *) malloc (size); |
600
a8d78999e46d
*** empty log message ***
Noah Friedman <friedman@splode.com>
parents:
590
diff
changeset
|
784 else |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
785 val = (POINTER_TYPE *) realloc (block, size); |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
786 MALLOC_UNBLOCK_INPUT; |
300 | 787 |
788 if (!val && size) memory_full (); | |
789 return val; | |
790 } | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
791 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
792 |
52276
5623f26dff58
(lisp_align_malloc): Change type of `aligned'.
Dave Love <fx@gnu.org>
parents:
52256
diff
changeset
|
793 /* Like free but block interrupt input. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
794 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
795 void |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
796 xfree (block) |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
797 POINTER_TYPE *block; |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
798 { |
95481
4390d64d3328
Make "xfree (NULL)" a no-op; remove useless if-before-xfree.
Jim Meyering <jim@meyering.net>
parents:
94993
diff
changeset
|
799 if (!block) |
4390d64d3328
Make "xfree (NULL)" a no-op; remove useless if-before-xfree.
Jim Meyering <jim@meyering.net>
parents:
94993
diff
changeset
|
800 return; |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
801 MALLOC_BLOCK_INPUT; |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
802 free (block); |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
803 MALLOC_UNBLOCK_INPUT; |
66530
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
804 /* We don't call refill_memory_reserve here |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
805 because that duplicates doing so in emacs_blocked_free |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
806 and the criterion should go there. */ |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
807 } |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
808 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
809 |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
810 /* Like strdup, but uses xmalloc. */ |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
811 |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
812 char * |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
813 xstrdup (s) |
46459
0a9cbcbdbe45
(xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents:
46418
diff
changeset
|
814 const char *s; |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
815 { |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
816 size_t len = strlen (s) + 1; |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
817 char *p = (char *) xmalloc (len); |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
818 bcopy (s, p, len); |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
819 return p; |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
820 } |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
821 |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
822 |
56187
e3720731abbb
(safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents:
55838
diff
changeset
|
823 /* Unwind for SAFE_ALLOCA */ |
e3720731abbb
(safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents:
55838
diff
changeset
|
824 |
e3720731abbb
(safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents:
55838
diff
changeset
|
825 Lisp_Object |
e3720731abbb
(safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents:
55838
diff
changeset
|
826 safe_alloca_unwind (arg) |
e3720731abbb
(safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents:
55838
diff
changeset
|
827 Lisp_Object arg; |
e3720731abbb
(safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents:
55838
diff
changeset
|
828 { |
56202
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
829 register struct Lisp_Save_Value *p = XSAVE_VALUE (arg); |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
830 |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
831 p->dogc = 0; |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
832 xfree (p->pointer); |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
833 p->pointer = 0; |
56239
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
834 free_misc (arg); |
56187
e3720731abbb
(safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents:
55838
diff
changeset
|
835 return Qnil; |
e3720731abbb
(safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents:
55838
diff
changeset
|
836 } |
e3720731abbb
(safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents:
55838
diff
changeset
|
837 |
e3720731abbb
(safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents:
55838
diff
changeset
|
838 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
839 /* Like malloc but used for allocating Lisp data. NBYTES is the |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
840 number of bytes to allocate, TYPE describes the intended use of the |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
841 allcated memory block (for strings, for conses, ...). */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
842 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
843 #ifndef USE_LSB_TAG |
50468
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
844 static void *lisp_malloc_loser; |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
845 #endif |
50468
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
846 |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
847 static POINTER_TYPE * |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
848 lisp_malloc (nbytes, type) |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
849 size_t nbytes; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
850 enum mem_type type; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
851 { |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
852 register void *val; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
853 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
854 MALLOC_BLOCK_INPUT; |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
855 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
856 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
857 allocated_mem_type = type; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
858 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
859 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
860 val = (void *) malloc (nbytes); |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
861 |
53650
5558449888ec
(lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53582
diff
changeset
|
862 #ifndef USE_LSB_TAG |
50468
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
863 /* If the memory just allocated cannot be addressed thru a Lisp |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
864 object's pointer, and it needs to be, |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
865 that's equivalent to running out of memory. */ |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
866 if (val && type != MEM_TYPE_NON_LISP) |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
867 { |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
868 Lisp_Object tem; |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
869 XSETCONS (tem, (char *) val + nbytes - 1); |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
870 if ((char *) XCONS (tem) != (char *) val + nbytes - 1) |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
871 { |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
872 lisp_malloc_loser = val; |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
873 free (val); |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
874 val = 0; |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
875 } |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
876 } |
53650
5558449888ec
(lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53582
diff
changeset
|
877 #endif |
50468
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
878 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
879 #if GC_MARK_STACK && !defined GC_MALLOC_CHECK |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
880 if (val && type != MEM_TYPE_NON_LISP) |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
881 mem_insert (val, (char *) val + nbytes, type); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
882 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
883 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
884 MALLOC_UNBLOCK_INPUT; |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
885 if (!val && nbytes) |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
886 memory_full (); |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
887 return val; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
888 } |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
889 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
890 /* Free BLOCK. This must be called to free memory allocated with a |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
891 call to lisp_malloc. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
892 |
30784
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
893 static void |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
894 lisp_free (block) |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
895 POINTER_TYPE *block; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
896 { |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
897 MALLOC_BLOCK_INPUT; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
898 free (block); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
899 #if GC_MARK_STACK && !defined GC_MALLOC_CHECK |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
900 mem_delete (mem_find (block)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
901 #endif |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
902 MALLOC_UNBLOCK_INPUT; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
903 } |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
904 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
905 /* Allocation of aligned blocks of memory to store Lisp data. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
906 /* The entry point is lisp_align_malloc which returns blocks of at most */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
907 /* BLOCK_BYTES and guarantees they are aligned on a BLOCK_ALIGN boundary. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
908 |
69348
2c8e608f28e7
(USE_POSIX_MEMALIGN): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68974
diff
changeset
|
909 /* Use posix_memalloc if the system has it and we're using the system's |
2c8e608f28e7
(USE_POSIX_MEMALIGN): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68974
diff
changeset
|
910 malloc (because our gmalloc.c routines don't have posix_memalign although |
2c8e608f28e7
(USE_POSIX_MEMALIGN): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68974
diff
changeset
|
911 its memalloc could be used). */ |
69355
a685fca1ccb6
(USE_POSIX_MEMALIGN): Fix last change.
Kim F. Storm <storm@cua.dk>
parents:
69348
diff
changeset
|
912 #if defined (HAVE_POSIX_MEMALIGN) && defined (SYSTEM_MALLOC) |
a685fca1ccb6
(USE_POSIX_MEMALIGN): Fix last change.
Kim F. Storm <storm@cua.dk>
parents:
69348
diff
changeset
|
913 #define USE_POSIX_MEMALIGN 1 |
a685fca1ccb6
(USE_POSIX_MEMALIGN): Fix last change.
Kim F. Storm <storm@cua.dk>
parents:
69348
diff
changeset
|
914 #endif |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
915 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
916 /* BLOCK_ALIGN has to be a power of 2. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
917 #define BLOCK_ALIGN (1 << 10) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
918 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
919 /* Padding to leave at the end of a malloc'd block. This is to give |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
920 malloc a chance to minimize the amount of memory wasted to alignment. |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
921 It should be tuned to the particular malloc library used. |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
922 On glibc-2.3.2, malloc never tries to align, so a padding of 0 is best. |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
923 posix_memalign on the other hand would ideally prefer a value of 4 |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
924 because otherwise, there's 1020 bytes wasted between each ablocks. |
60143
84ff5b7a4139
(BLOCK_BYTES): Harmless typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59657
diff
changeset
|
925 In Emacs, testing shows that those 1020 can most of the time be |
84ff5b7a4139
(BLOCK_BYTES): Harmless typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59657
diff
changeset
|
926 efficiently used by malloc to place other objects, so a value of 0 can |
84ff5b7a4139
(BLOCK_BYTES): Harmless typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59657
diff
changeset
|
927 still preferable unless you have a lot of aligned blocks and virtually |
84ff5b7a4139
(BLOCK_BYTES): Harmless typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59657
diff
changeset
|
928 nothing else. */ |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
929 #define BLOCK_PADDING 0 |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
930 #define BLOCK_BYTES \ |
60143
84ff5b7a4139
(BLOCK_BYTES): Harmless typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59657
diff
changeset
|
931 (BLOCK_ALIGN - sizeof (struct ablock *) - BLOCK_PADDING) |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
932 |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
933 /* Internal data structures and constants. */ |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
934 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
935 #define ABLOCKS_SIZE 16 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
936 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
937 /* An aligned block of memory. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
938 struct ablock |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
939 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
940 union |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
941 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
942 char payload[BLOCK_BYTES]; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
943 struct ablock *next_free; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
944 } x; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
945 /* `abase' is the aligned base of the ablocks. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
946 /* It is overloaded to hold the virtual `busy' field that counts |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
947 the number of used ablock in the parent ablocks. |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
948 The first ablock has the `busy' field, the others have the `abase' |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
949 field. To tell the difference, we assume that pointers will have |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
950 integer values larger than 2 * ABLOCKS_SIZE. The lowest bit of `busy' |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
951 is used to tell whether the real base of the parent ablocks is `abase' |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
952 (if not, the word before the first ablock holds a pointer to the |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
953 real base). */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
954 struct ablocks *abase; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
955 /* The padding of all but the last ablock is unused. The padding of |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
956 the last ablock in an ablocks is not allocated. */ |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
957 #if BLOCK_PADDING |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
958 char padding[BLOCK_PADDING]; |
51758
ff38ea4b40ed
(struct ablock): Only include padding when there is some.
Jason Rumney <jasonr@gnu.org>
parents:
51723
diff
changeset
|
959 #endif |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
960 }; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
961 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
962 /* A bunch of consecutive aligned blocks. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
963 struct ablocks |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
964 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
965 struct ablock blocks[ABLOCKS_SIZE]; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
966 }; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
967 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
968 /* Size of the block requested from malloc or memalign. */ |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
969 #define ABLOCKS_BYTES (sizeof (struct ablocks) - BLOCK_PADDING) |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
970 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
971 #define ABLOCK_ABASE(block) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
972 (((unsigned long) (block)->abase) <= (1 + 2 * ABLOCKS_SIZE) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
973 ? (struct ablocks *)(block) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
974 : (block)->abase) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
975 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
976 /* Virtual `busy' field. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
977 #define ABLOCKS_BUSY(abase) ((abase)->blocks[0].abase) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
978 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
979 /* Pointer to the (not necessarily aligned) malloc block. */ |
69348
2c8e608f28e7
(USE_POSIX_MEMALIGN): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68974
diff
changeset
|
980 #ifdef USE_POSIX_MEMALIGN |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
981 #define ABLOCKS_BASE(abase) (abase) |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
982 #else |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
983 #define ABLOCKS_BASE(abase) \ |
52453
62fcd311bb98
Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
984 (1 & (long) ABLOCKS_BUSY (abase) ? abase : ((void**)abase)[-1]) |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
985 #endif |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
986 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
987 /* The list of free ablock. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
988 static struct ablock *free_ablock; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
989 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
990 /* Allocate an aligned block of nbytes. |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
991 Alignment is on a multiple of BLOCK_ALIGN and `nbytes' has to be |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
992 smaller or equal to BLOCK_BYTES. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
993 static POINTER_TYPE * |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
994 lisp_align_malloc (nbytes, type) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
995 size_t nbytes; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
996 enum mem_type type; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
997 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
998 void *base, *val; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
999 struct ablocks *abase; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1000 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1001 eassert (nbytes <= BLOCK_BYTES); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1002 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
1003 MALLOC_BLOCK_INPUT; |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1004 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1005 #ifdef GC_MALLOC_CHECK |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1006 allocated_mem_type = type; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1007 #endif |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1008 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1009 if (!free_ablock) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1010 { |
52276
5623f26dff58
(lisp_align_malloc): Change type of `aligned'.
Dave Love <fx@gnu.org>
parents:
52256
diff
changeset
|
1011 int i; |
5623f26dff58
(lisp_align_malloc): Change type of `aligned'.
Dave Love <fx@gnu.org>
parents:
52256
diff
changeset
|
1012 EMACS_INT aligned; /* int gets warning casting to 64-bit pointer. */ |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1013 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1014 #ifdef DOUG_LEA_MALLOC |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1015 /* Prevent mmap'ing the chunk. Lisp data may not be mmap'ed |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1016 because mapped region contents are not preserved in |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1017 a dumped Emacs. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1018 mallopt (M_MMAP_MAX, 0); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1019 #endif |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1020 |
69348
2c8e608f28e7
(USE_POSIX_MEMALIGN): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68974
diff
changeset
|
1021 #ifdef USE_POSIX_MEMALIGN |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
1022 { |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
1023 int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES); |
55836
a05a653f63af
(lisp_align_malloc): Check for base == 0 regardless of HAVE_POSIX_MEMALIGN.
Richard M. Stallman <rms@gnu.org>
parents:
55816
diff
changeset
|
1024 if (err) |
a05a653f63af
(lisp_align_malloc): Check for base == 0 regardless of HAVE_POSIX_MEMALIGN.
Richard M. Stallman <rms@gnu.org>
parents:
55816
diff
changeset
|
1025 base = NULL; |
a05a653f63af
(lisp_align_malloc): Check for base == 0 regardless of HAVE_POSIX_MEMALIGN.
Richard M. Stallman <rms@gnu.org>
parents:
55816
diff
changeset
|
1026 abase = base; |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
1027 } |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
1028 #else |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1029 base = malloc (ABLOCKS_BYTES); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1030 abase = ALIGN (base, BLOCK_ALIGN); |
55836
a05a653f63af
(lisp_align_malloc): Check for base == 0 regardless of HAVE_POSIX_MEMALIGN.
Richard M. Stallman <rms@gnu.org>
parents:
55816
diff
changeset
|
1031 #endif |
a05a653f63af
(lisp_align_malloc): Check for base == 0 regardless of HAVE_POSIX_MEMALIGN.
Richard M. Stallman <rms@gnu.org>
parents:
55816
diff
changeset
|
1032 |
52837
1bbf3f566879
(lisp_align_malloc): If BASE is 0, call memory_full.
Richard M. Stallman <rms@gnu.org>
parents:
52547
diff
changeset
|
1033 if (base == 0) |
1bbf3f566879
(lisp_align_malloc): If BASE is 0, call memory_full.
Richard M. Stallman <rms@gnu.org>
parents:
52547
diff
changeset
|
1034 { |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
1035 MALLOC_UNBLOCK_INPUT; |
52837
1bbf3f566879
(lisp_align_malloc): If BASE is 0, call memory_full.
Richard M. Stallman <rms@gnu.org>
parents:
52547
diff
changeset
|
1036 memory_full (); |
1bbf3f566879
(lisp_align_malloc): If BASE is 0, call memory_full.
Richard M. Stallman <rms@gnu.org>
parents:
52547
diff
changeset
|
1037 } |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1038 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1039 aligned = (base == abase); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1040 if (!aligned) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1041 ((void**)abase)[-1] = base; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1042 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1043 #ifdef DOUG_LEA_MALLOC |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1044 /* Back to a reasonable maximum of mmap'ed areas. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1045 mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1046 #endif |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1047 |
53650
5558449888ec
(lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53582
diff
changeset
|
1048 #ifndef USE_LSB_TAG |
52256
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1049 /* If the memory just allocated cannot be addressed thru a Lisp |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1050 object's pointer, and it needs to be, that's equivalent to |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1051 running out of memory. */ |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1052 if (type != MEM_TYPE_NON_LISP) |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1053 { |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1054 Lisp_Object tem; |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1055 char *end = (char *) base + ABLOCKS_BYTES - 1; |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1056 XSETCONS (tem, end); |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1057 if ((char *) XCONS (tem) != end) |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1058 { |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1059 lisp_malloc_loser = base; |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1060 free (base); |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
1061 MALLOC_UNBLOCK_INPUT; |
52256
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1062 memory_full (); |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1063 } |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1064 } |
53650
5558449888ec
(lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53582
diff
changeset
|
1065 #endif |
52256
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1066 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1067 /* Initialize the blocks and put them on the free list. |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1068 Is `base' was not properly aligned, we can't use the last block. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1069 for (i = 0; i < (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1); i++) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1070 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1071 abase->blocks[i].abase = abase; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1072 abase->blocks[i].x.next_free = free_ablock; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1073 free_ablock = &abase->blocks[i]; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1074 } |
52453
62fcd311bb98
Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1075 ABLOCKS_BUSY (abase) = (struct ablocks *) (long) aligned; |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1076 |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
1077 eassert (0 == ((EMACS_UINT)abase) % BLOCK_ALIGN); |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1078 eassert (ABLOCK_ABASE (&abase->blocks[3]) == abase); /* 3 is arbitrary */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1079 eassert (ABLOCK_ABASE (&abase->blocks[0]) == abase); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1080 eassert (ABLOCKS_BASE (abase) == base); |
52453
62fcd311bb98
Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1081 eassert (aligned == (long) ABLOCKS_BUSY (abase)); |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1082 } |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1083 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1084 abase = ABLOCK_ABASE (free_ablock); |
52453
62fcd311bb98
Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1085 ABLOCKS_BUSY (abase) = (struct ablocks *) (2 + (long) ABLOCKS_BUSY (abase)); |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1086 val = free_ablock; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1087 free_ablock = free_ablock->x.next_free; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1088 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1089 #if GC_MARK_STACK && !defined GC_MALLOC_CHECK |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1090 if (val && type != MEM_TYPE_NON_LISP) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1091 mem_insert (val, (char *) val + nbytes, type); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1092 #endif |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1093 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
1094 MALLOC_UNBLOCK_INPUT; |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1095 if (!val && nbytes) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1096 memory_full (); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1097 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1098 eassert (0 == ((EMACS_UINT)val) % BLOCK_ALIGN); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1099 return val; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1100 } |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1101 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1102 static void |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1103 lisp_align_free (block) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1104 POINTER_TYPE *block; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1105 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1106 struct ablock *ablock = block; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1107 struct ablocks *abase = ABLOCK_ABASE (ablock); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1108 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
1109 MALLOC_BLOCK_INPUT; |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1110 #if GC_MARK_STACK && !defined GC_MALLOC_CHECK |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1111 mem_delete (mem_find (block)); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1112 #endif |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1113 /* Put on free list. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1114 ablock->x.next_free = free_ablock; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1115 free_ablock = ablock; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1116 /* Update busy count. */ |
52453
62fcd311bb98
Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1117 ABLOCKS_BUSY (abase) = (struct ablocks *) (-2 + (long) ABLOCKS_BUSY (abase)); |
55634
d3542bbadad7
(mark_object): Ignore Lisp_Misc_Free objects.
Kim F. Storm <storm@cua.dk>
parents:
55159
diff
changeset
|
1118 |
52453
62fcd311bb98
Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1119 if (2 > (long) ABLOCKS_BUSY (abase)) |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1120 { /* All the blocks are free. */ |
52453
62fcd311bb98
Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1121 int i = 0, aligned = (long) ABLOCKS_BUSY (abase); |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1122 struct ablock **tem = &free_ablock; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1123 struct ablock *atop = &abase->blocks[aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1]; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1124 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1125 while (*tem) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1126 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1127 if (*tem >= (struct ablock *) abase && *tem < atop) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1128 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1129 i++; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1130 *tem = (*tem)->x.next_free; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1131 } |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1132 else |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1133 tem = &(*tem)->x.next_free; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1134 } |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1135 eassert ((aligned & 1) == aligned); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1136 eassert (i == (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1)); |
69348
2c8e608f28e7
(USE_POSIX_MEMALIGN): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68974
diff
changeset
|
1137 #ifdef USE_POSIX_MEMALIGN |
68350
263a4edafafa
(lisp_align_free): Add an assertion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
67494
diff
changeset
|
1138 eassert ((unsigned long)ABLOCKS_BASE (abase) % BLOCK_ALIGN == 0); |
263a4edafafa
(lisp_align_free): Add an assertion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
67494
diff
changeset
|
1139 #endif |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1140 free (ABLOCKS_BASE (abase)); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1141 } |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
1142 MALLOC_UNBLOCK_INPUT; |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1143 } |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1144 |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1145 /* Return a new buffer structure allocated from the heap with |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1146 a call to lisp_malloc. */ |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1147 |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1148 struct buffer * |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1149 allocate_buffer () |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1150 { |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1151 struct buffer *b |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1152 = (struct buffer *) lisp_malloc (sizeof (struct buffer), |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1153 MEM_TYPE_BUFFER); |
85328
d0d527210b0c
* lisp.h (enum Lisp_Misc_Type): Del Lisp_Misc_Some_Buffer_Local_Value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85023
diff
changeset
|
1154 b->size = sizeof (struct buffer) / sizeof (EMACS_INT); |
d0d527210b0c
* lisp.h (enum Lisp_Misc_Type): Del Lisp_Misc_Some_Buffer_Local_Value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85023
diff
changeset
|
1155 XSETPVECTYPE (b, PVEC_BUFFER); |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1156 return b; |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1157 } |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1158 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1159 |
59359
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1160 #ifndef SYSTEM_MALLOC |
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1161 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1162 /* Arranging to disable input signals while we're in malloc. |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1163 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1164 This only works with GNU malloc. To help out systems which can't |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1165 use GNU malloc, all the calls to malloc, realloc, and free |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1166 elsewhere in the code should be inside a BLOCK_INPUT/UNBLOCK_INPUT |
59359
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1167 pair; unfortunately, we have no idea what C library functions |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1168 might call malloc, so we can't really protect them unless you're |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
1169 using GNU malloc. Fortunately, most of the major operating systems |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
1170 can use GNU malloc. */ |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1171 |
59359
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1172 #ifndef SYNC_INPUT |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
1173 /* When using SYNC_INPUT, we don't call malloc from a signal handler, so |
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
1174 there's no need to block input around malloc. */ |
59359
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1175 |
30914
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
1176 #ifndef DOUG_LEA_MALLOC |
65764
375ab086d366
* image.c (slurp_file, xbm_read_bitmap_data): Cast to the correct
Dan Nicolaescu <dann@ics.uci.edu>
parents:
64611
diff
changeset
|
1177 extern void * (*__malloc_hook) P_ ((size_t, const void *)); |
375ab086d366
* image.c (slurp_file, xbm_read_bitmap_data): Cast to the correct
Dan Nicolaescu <dann@ics.uci.edu>
parents:
64611
diff
changeset
|
1178 extern void * (*__realloc_hook) P_ ((void *, size_t, const void *)); |
375ab086d366
* image.c (slurp_file, xbm_read_bitmap_data): Cast to the correct
Dan Nicolaescu <dann@ics.uci.edu>
parents:
64611
diff
changeset
|
1179 extern void (*__free_hook) P_ ((void *, const void *)); |
30914
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
1180 /* Else declared in malloc.h, perhaps with an extra arg. */ |
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
1181 #endif /* DOUG_LEA_MALLOC */ |
65764
375ab086d366
* image.c (slurp_file, xbm_read_bitmap_data): Cast to the correct
Dan Nicolaescu <dann@ics.uci.edu>
parents:
64611
diff
changeset
|
1182 static void * (*old_malloc_hook) P_ ((size_t, const void *)); |
375ab086d366
* image.c (slurp_file, xbm_read_bitmap_data): Cast to the correct
Dan Nicolaescu <dann@ics.uci.edu>
parents:
64611
diff
changeset
|
1183 static void * (*old_realloc_hook) P_ ((void *, size_t, const void*)); |
375ab086d366
* image.c (slurp_file, xbm_read_bitmap_data): Cast to the correct
Dan Nicolaescu <dann@ics.uci.edu>
parents:
64611
diff
changeset
|
1184 static void (*old_free_hook) P_ ((void*, const void*)); |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1185 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
1186 /* This function is used as the hook for free to call. */ |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
1187 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1188 static void |
65764
375ab086d366
* image.c (slurp_file, xbm_read_bitmap_data): Cast to the correct
Dan Nicolaescu <dann@ics.uci.edu>
parents:
64611
diff
changeset
|
1189 emacs_blocked_free (ptr, ptr2) |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1190 void *ptr; |
65764
375ab086d366
* image.c (slurp_file, xbm_read_bitmap_data): Cast to the correct
Dan Nicolaescu <dann@ics.uci.edu>
parents:
64611
diff
changeset
|
1191 const void *ptr2; |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1192 { |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1193 BLOCK_INPUT_ALLOC; |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1194 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1195 #ifdef GC_MALLOC_CHECK |
32776
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1196 if (ptr) |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1197 { |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1198 struct mem_node *m; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1199 |
32776
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1200 m = mem_find (ptr); |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1201 if (m == MEM_NIL || m->start != ptr) |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1202 { |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1203 fprintf (stderr, |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1204 "Freeing `%p' which wasn't allocated with malloc\n", ptr); |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1205 abort (); |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1206 } |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1207 else |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1208 { |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1209 /* fprintf (stderr, "free %p...%p (%p)\n", m->start, m->end, ptr); */ |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1210 mem_delete (m); |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1211 } |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1212 } |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1213 #endif /* GC_MALLOC_CHECK */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1214 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1215 __free_hook = old_free_hook; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1216 free (ptr); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1217 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
1218 /* If we released our reserve (due to running out of memory), |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
1219 and we have a fair amount free once again, |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
1220 try to set aside another reserve in case we run out once more. */ |
66530
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
1221 if (! NILP (Vmemory_full) |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
1222 /* Verify there is enough space that even with the malloc |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
1223 hysteresis this call won't run out again. |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
1224 The code here is correct as long as SPARE_MEMORY |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
1225 is substantially larger than the block size malloc uses. */ |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
1226 && (bytes_used_when_full |
66547
9373f926904a
(BYTES_USED): Use uordblks, not arena.
Richard M. Stallman <rms@gnu.org>
parents:
66541
diff
changeset
|
1227 > ((bytes_used_when_reconsidered = BYTES_USED) |
66541
60d77f0435af
* alloc.c (emacs_blocked_free): Fix typo.
Chong Yidong <cyd@stupidchicken.com>
parents:
66530
diff
changeset
|
1228 + max (malloc_hysteresis, 4) * SPARE_MEMORY))) |
66530
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
1229 refill_memory_reserve (); |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
1230 |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
1231 __free_hook = emacs_blocked_free; |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1232 UNBLOCK_INPUT_ALLOC; |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1233 } |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1234 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1235 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
1236 /* This function is the malloc hook that Emacs uses. */ |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
1237 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1238 static void * |
65764
375ab086d366
* image.c (slurp_file, xbm_read_bitmap_data): Cast to the correct
Dan Nicolaescu <dann@ics.uci.edu>
parents:
64611
diff
changeset
|
1239 emacs_blocked_malloc (size, ptr) |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
1240 size_t size; |
65764
375ab086d366
* image.c (slurp_file, xbm_read_bitmap_data): Cast to the correct
Dan Nicolaescu <dann@ics.uci.edu>
parents:
64611
diff
changeset
|
1241 const void *ptr; |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1242 { |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1243 void *value; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1244 |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1245 BLOCK_INPUT_ALLOC; |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1246 __malloc_hook = old_malloc_hook; |
17831
9238a2254a23
(BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents:
17348
diff
changeset
|
1247 #ifdef DOUG_LEA_MALLOC |
83543
6b25ef5cc276
Fix obvious runtime errors after merge.
Karoly Lorentey <lorentey@elte.hu>
parents:
83541
diff
changeset
|
1248 /* Segfaults on my system. --lorentey */ |
6b25ef5cc276
Fix obvious runtime errors after merge.
Karoly Lorentey <lorentey@elte.hu>
parents:
83541
diff
changeset
|
1249 /* mallopt (M_TOP_PAD, malloc_hysteresis * 4096); */ |
17831
9238a2254a23
(BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents:
17348
diff
changeset
|
1250 #else |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
1251 __malloc_extra_blocks = malloc_hysteresis; |
17831
9238a2254a23
(BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents:
17348
diff
changeset
|
1252 #endif |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1253 |
3581
152fd924c7bb
* alloc.c (emacs_blocked_malloc, emacs_blocked_realloc): Cast the
Jim Blandy <jimb@redhat.com>
parents:
3536
diff
changeset
|
1254 value = (void *) malloc (size); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1255 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1256 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1257 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1258 struct mem_node *m = mem_find (value); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1259 if (m != MEM_NIL) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1260 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1261 fprintf (stderr, "Malloc returned %p which is already in use\n", |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1262 value); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1263 fprintf (stderr, "Region in use is %p...%p, %u bytes, type %d\n", |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1264 m->start, m->end, (char *) m->end - (char *) m->start, |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1265 m->type); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1266 abort (); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1267 } |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1268 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1269 if (!dont_register_blocks) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1270 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1271 mem_insert (value, (char *) value + max (1, size), allocated_mem_type); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1272 allocated_mem_type = MEM_TYPE_NON_LISP; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1273 } |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1274 } |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1275 #endif /* GC_MALLOC_CHECK */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1276 |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
1277 __malloc_hook = emacs_blocked_malloc; |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1278 UNBLOCK_INPUT_ALLOC; |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1279 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1280 /* fprintf (stderr, "%p malloc\n", value); */ |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1281 return value; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1282 } |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1283 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1284 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1285 /* This function is the realloc hook that Emacs uses. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1286 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1287 static void * |
65764
375ab086d366
* image.c (slurp_file, xbm_read_bitmap_data): Cast to the correct
Dan Nicolaescu <dann@ics.uci.edu>
parents:
64611
diff
changeset
|
1288 emacs_blocked_realloc (ptr, size, ptr2) |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1289 void *ptr; |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
1290 size_t size; |
65764
375ab086d366
* image.c (slurp_file, xbm_read_bitmap_data): Cast to the correct
Dan Nicolaescu <dann@ics.uci.edu>
parents:
64611
diff
changeset
|
1291 const void *ptr2; |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1292 { |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1293 void *value; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1294 |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1295 BLOCK_INPUT_ALLOC; |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1296 __realloc_hook = old_realloc_hook; |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1297 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1298 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1299 if (ptr) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1300 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1301 struct mem_node *m = mem_find (ptr); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1302 if (m == MEM_NIL || m->start != ptr) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1303 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1304 fprintf (stderr, |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1305 "Realloc of %p which wasn't allocated with malloc\n", |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1306 ptr); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1307 abort (); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1308 } |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1309 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1310 mem_delete (m); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1311 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1312 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1313 /* fprintf (stderr, "%p -> realloc\n", ptr); */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1314 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1315 /* Prevent malloc from registering blocks. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1316 dont_register_blocks = 1; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1317 #endif /* GC_MALLOC_CHECK */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1318 |
3581
152fd924c7bb
* alloc.c (emacs_blocked_malloc, emacs_blocked_realloc): Cast the
Jim Blandy <jimb@redhat.com>
parents:
3536
diff
changeset
|
1319 value = (void *) realloc (ptr, size); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1320 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1321 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1322 dont_register_blocks = 0; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1323 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1324 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1325 struct mem_node *m = mem_find (value); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1326 if (m != MEM_NIL) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1327 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1328 fprintf (stderr, "Realloc returns memory that is already in use\n"); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1329 abort (); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1330 } |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1331 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1332 /* Can't handle zero size regions in the red-black tree. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1333 mem_insert (value, (char *) value + max (size, 1), MEM_TYPE_NON_LISP); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1334 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1335 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1336 /* fprintf (stderr, "%p <- realloc\n", value); */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1337 #endif /* GC_MALLOC_CHECK */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1338 |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
1339 __realloc_hook = emacs_blocked_realloc; |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1340 UNBLOCK_INPUT_ALLOC; |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1341 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1342 return value; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1343 } |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1344 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1345 |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1346 #ifdef HAVE_GTK_AND_PTHREAD |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1347 /* Called from Fdump_emacs so that when the dumped Emacs starts, it has a |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1348 normal malloc. Some thread implementations need this as they call |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1349 malloc before main. The pthread_self call in BLOCK_INPUT_ALLOC then |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1350 calls malloc because it is the first call, and we have an endless loop. */ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1351 |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1352 void |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1353 reset_malloc_hooks () |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1354 { |
78811
6ebdc9c66c94
(reset_malloc_hooks): Set the hooks to the previous
Andreas Schwab <schwab@suse.de>
parents:
78593
diff
changeset
|
1355 __free_hook = old_free_hook; |
6ebdc9c66c94
(reset_malloc_hooks): Set the hooks to the previous
Andreas Schwab <schwab@suse.de>
parents:
78593
diff
changeset
|
1356 __malloc_hook = old_malloc_hook; |
6ebdc9c66c94
(reset_malloc_hooks): Set the hooks to the previous
Andreas Schwab <schwab@suse.de>
parents:
78593
diff
changeset
|
1357 __realloc_hook = old_realloc_hook; |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1358 } |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1359 #endif /* HAVE_GTK_AND_PTHREAD */ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1360 |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1361 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1362 /* Called from main to set up malloc to use our hooks. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1363 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1364 void |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1365 uninterrupt_malloc () |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1366 { |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1367 #ifdef HAVE_GTK_AND_PTHREAD |
80502
07f3d63ad3d3
[!SYSTEM_MALLOC && !SYNC_INPUT] (uninterrupt_malloc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
79759
diff
changeset
|
1368 #ifdef DOUG_LEA_MALLOC |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1369 pthread_mutexattr_t attr; |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1370 |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1371 /* GLIBC has a faster way to do this, but lets keep it portable. |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1372 This is according to the Single UNIX Specification. */ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1373 pthread_mutexattr_init (&attr); |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1374 pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1375 pthread_mutex_init (&alloc_mutex, &attr); |
80502
07f3d63ad3d3
[!SYSTEM_MALLOC && !SYNC_INPUT] (uninterrupt_malloc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
79759
diff
changeset
|
1376 #else /* !DOUG_LEA_MALLOC */ |
07f3d63ad3d3
[!SYSTEM_MALLOC && !SYNC_INPUT] (uninterrupt_malloc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
79759
diff
changeset
|
1377 /* Some systems such as Solaris 2.6 doesn't have a recursive mutex, |
07f3d63ad3d3
[!SYSTEM_MALLOC && !SYNC_INPUT] (uninterrupt_malloc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
79759
diff
changeset
|
1378 and the bundled gmalloc.c doesn't require it. */ |
07f3d63ad3d3
[!SYSTEM_MALLOC && !SYNC_INPUT] (uninterrupt_malloc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
79759
diff
changeset
|
1379 pthread_mutex_init (&alloc_mutex, NULL); |
07f3d63ad3d3
[!SYSTEM_MALLOC && !SYNC_INPUT] (uninterrupt_malloc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
79759
diff
changeset
|
1380 #endif /* !DOUG_LEA_MALLOC */ |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1381 #endif /* HAVE_GTK_AND_PTHREAD */ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1382 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1383 if (__free_hook != emacs_blocked_free) |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1384 old_free_hook = __free_hook; |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
1385 __free_hook = emacs_blocked_free; |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1386 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1387 if (__malloc_hook != emacs_blocked_malloc) |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1388 old_malloc_hook = __malloc_hook; |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
1389 __malloc_hook = emacs_blocked_malloc; |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1390 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1391 if (__realloc_hook != emacs_blocked_realloc) |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1392 old_realloc_hook = __realloc_hook; |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
1393 __realloc_hook = emacs_blocked_realloc; |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1394 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1395 |
59359
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1396 #endif /* not SYNC_INPUT */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1397 #endif /* not SYSTEM_MALLOC */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1398 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1399 |
300 | 1400 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1401 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1402 Interval Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1403 ***********************************************************************/ |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
1404 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1405 /* Number of intervals allocated in an interval_block structure. |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1406 The 1020 is 1024 minus malloc overhead. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1407 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1408 #define INTERVAL_BLOCK_SIZE \ |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1409 ((1020 - sizeof (struct interval_block *)) / sizeof (struct interval)) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1410 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1411 /* Intervals are allocated in chunks in form of an interval_block |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1412 structure. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1413 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1414 struct interval_block |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1415 { |
53582
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
1416 /* Place `intervals' first, to preserve alignment. */ |
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
1417 struct interval intervals[INTERVAL_BLOCK_SIZE]; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1418 struct interval_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1419 }; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1420 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1421 /* Current interval block. Its `next' pointer points to older |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1422 blocks. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1423 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
1424 static struct interval_block *interval_block; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1425 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1426 /* Index in interval_block above of the next unused interval |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1427 structure. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1428 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1429 static int interval_block_index; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1430 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1431 /* Number of free and live intervals. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1432 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1433 static int total_free_intervals, total_intervals; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1434 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1435 /* List of free intervals. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1436 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1437 INTERVAL interval_free_list; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1438 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1439 /* Total number of interval blocks now in use. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1440 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
1441 static int n_interval_blocks; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1442 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1443 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1444 /* Initialize interval allocation. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1445 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1446 static void |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1447 init_intervals () |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1448 { |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
1449 interval_block = NULL; |
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
1450 interval_block_index = INTERVAL_BLOCK_SIZE; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1451 interval_free_list = 0; |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
1452 n_interval_blocks = 0; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1453 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1454 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1455 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1456 /* Return a new interval. */ |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1457 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1458 INTERVAL |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1459 make_interval () |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1460 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1461 INTERVAL val; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1462 |
68430
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
1463 /* eassert (!handling_signal); */ |
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
1464 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
1465 MALLOC_BLOCK_INPUT; |
68350
263a4edafafa
(lisp_align_free): Add an assertion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
67494
diff
changeset
|
1466 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1467 if (interval_free_list) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1468 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1469 val = interval_free_list; |
28269
fd13be8ae190
Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents:
28220
diff
changeset
|
1470 interval_free_list = INTERVAL_PARENT (interval_free_list); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1471 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1472 else |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1473 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1474 if (interval_block_index == INTERVAL_BLOCK_SIZE) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1475 { |
12529 | 1476 register struct interval_block *newi; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1477 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1478 newi = (struct interval_block *) lisp_malloc (sizeof *newi, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1479 MEM_TYPE_NON_LISP); |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1480 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1481 newi->next = interval_block; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1482 interval_block = newi; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1483 interval_block_index = 0; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1484 n_interval_blocks++; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1485 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1486 val = &interval_block->intervals[interval_block_index++]; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1487 } |
68430
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
1488 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
1489 MALLOC_UNBLOCK_INPUT; |
68430
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
1490 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1491 consing_since_gc += sizeof (struct interval); |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
1492 intervals_consed++; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1493 RESET_INTERVAL (val); |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
1494 val->gcmarkbit = 0; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1495 return val; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1496 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1497 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1498 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1499 /* Mark Lisp objects in interval I. */ |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1500 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1501 static void |
1957
54c8c66cd9ac
(mark_interval): Add ignored arg.
Richard M. Stallman <rms@gnu.org>
parents:
1939
diff
changeset
|
1502 mark_interval (i, dummy) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1503 register INTERVAL i; |
1957
54c8c66cd9ac
(mark_interval): Add ignored arg.
Richard M. Stallman <rms@gnu.org>
parents:
1939
diff
changeset
|
1504 Lisp_Object dummy; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1505 { |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
1506 eassert (!i->gcmarkbit); /* Intervals are never shared. */ |
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
1507 i->gcmarkbit = 1; |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
1508 mark_object (i->plist); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1509 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1510 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1511 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1512 /* Mark the interval tree rooted in TREE. Don't call this directly; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1513 use the macro MARK_INTERVAL_TREE instead. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1514 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1515 static void |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1516 mark_interval_tree (tree) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1517 register INTERVAL tree; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1518 { |
4139
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
1519 /* No need to test if this tree has been marked already; this |
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
1520 function is always called through the MARK_INTERVAL_TREE macro, |
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
1521 which takes care of that. */ |
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
1522 |
39859
36068b62b4c1
(mark_interval_tree): Use traverse_intervals_noorder.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39682
diff
changeset
|
1523 traverse_intervals_noorder (tree, mark_interval, Qnil); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1524 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1525 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1526 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1527 /* Mark the interval tree rooted in I. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1528 |
4139
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
1529 #define MARK_INTERVAL_TREE(i) \ |
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
1530 do { \ |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
1531 if (!NULL_INTERVAL_P (i) && !i->gcmarkbit) \ |
4139
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
1532 mark_interval_tree (i); \ |
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
1533 } while (0) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1534 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1535 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1536 #define UNMARK_BALANCE_INTERVALS(i) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1537 do { \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1538 if (! NULL_INTERVAL_P (i)) \ |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
1539 (i) = balance_intervals (i); \ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1540 } while (0) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1541 |
28469
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1542 |
96602 | 1543 /* Number support. If USE_LISP_UNION_TYPE is in effect, we |
28469
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1544 can't create number objects in macros. */ |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1545 #ifndef make_number |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1546 Lisp_Object |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1547 make_number (n) |
60896
25e4a0f171b5
(make_number): The arg can be bigger than `int'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60143
diff
changeset
|
1548 EMACS_INT n; |
28469
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1549 { |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1550 Lisp_Object obj; |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1551 obj.s.val = n; |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1552 obj.s.type = Lisp_Int; |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1553 return obj; |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1554 } |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1555 #endif |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1556 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1557 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1558 String Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1559 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1560 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1561 /* Lisp_Strings are allocated in string_block structures. When a new |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1562 string_block is allocated, all the Lisp_Strings it contains are |
41831
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
1563 added to a free-list string_free_list. When a new Lisp_String is |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1564 needed, it is taken from that list. During the sweep phase of GC, |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1565 string_blocks that are entirely free are freed, except two which |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1566 we keep. |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1567 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1568 String data is allocated from sblock structures. Strings larger |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1569 than LARGE_STRING_BYTES, get their own sblock, data for smaller |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1570 strings is sub-allocated out of sblocks of size SBLOCK_SIZE. |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1571 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1572 Sblocks consist internally of sdata structures, one for each |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1573 Lisp_String. The sdata structure points to the Lisp_String it |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1574 belongs to. The Lisp_String points back to the `u.data' member of |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1575 its sdata structure. |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1576 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1577 When a Lisp_String is freed during GC, it is put back on |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1578 string_free_list, and its `data' member and its sdata's `string' |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1579 pointer is set to null. The size of the string is recorded in the |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1580 `u.nbytes' member of the sdata. So, sdata structures that are no |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1581 longer used, can be easily recognized, and it's easy to compact the |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1582 sblocks of small strings which we do in compact_small_strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1583 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1584 /* Size in bytes of an sblock structure used for small strings. This |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1585 is 8192 minus malloc overhead. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1586 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1587 #define SBLOCK_SIZE 8188 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1588 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1589 /* Strings larger than this are considered large strings. String data |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1590 for large strings is allocated from individual sblocks. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1591 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1592 #define LARGE_STRING_BYTES 1024 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1593 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1594 /* Structure describing string memory sub-allocated from an sblock. |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1595 This is where the contents of Lisp strings are stored. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1596 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1597 struct sdata |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1598 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1599 /* Back-pointer to the string this sdata belongs to. If null, this |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1600 structure is free, and the NBYTES member of the union below |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1601 contains the string's byte size (the same value that STRING_BYTES |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1602 would return if STRING were non-null). If non-null, STRING_BYTES |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1603 (STRING) is the size of the data, and DATA contains the string's |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1604 contents. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1605 struct Lisp_String *string; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1606 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1607 #ifdef GC_CHECK_STRING_BYTES |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1608 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1609 EMACS_INT nbytes; |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1610 unsigned char data[1]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1611 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1612 #define SDATA_NBYTES(S) (S)->nbytes |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1613 #define SDATA_DATA(S) (S)->data |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1614 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1615 #else /* not GC_CHECK_STRING_BYTES */ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1616 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1617 union |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1618 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1619 /* When STRING in non-null. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1620 unsigned char data[1]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1621 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1622 /* When STRING is null. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1623 EMACS_INT nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1624 } u; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1625 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1626 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1627 #define SDATA_NBYTES(S) (S)->u.nbytes |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1628 #define SDATA_DATA(S) (S)->u.data |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1629 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1630 #endif /* not GC_CHECK_STRING_BYTES */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1631 }; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1632 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1633 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1634 /* Structure describing a block of memory which is sub-allocated to |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1635 obtain string data memory for strings. Blocks for small strings |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1636 are of fixed size SBLOCK_SIZE. Blocks for large strings are made |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1637 as large as needed. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1638 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1639 struct sblock |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1640 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1641 /* Next in list. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1642 struct sblock *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1643 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1644 /* Pointer to the next free sdata block. This points past the end |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1645 of the sblock if there isn't any space left in this block. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1646 struct sdata *next_free; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1647 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1648 /* Start of data. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1649 struct sdata first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1650 }; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1651 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1652 /* Number of Lisp strings in a string_block structure. The 1020 is |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1653 1024 minus malloc overhead. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1654 |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
1655 #define STRING_BLOCK_SIZE \ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1656 ((1020 - sizeof (struct string_block *)) / sizeof (struct Lisp_String)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1657 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1658 /* Structure describing a block from which Lisp_String structures |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1659 are allocated. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1660 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1661 struct string_block |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1662 { |
53582
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
1663 /* Place `strings' first, to preserve alignment. */ |
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
1664 struct Lisp_String strings[STRING_BLOCK_SIZE]; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1665 struct string_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1666 }; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1667 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1668 /* Head and tail of the list of sblock structures holding Lisp string |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1669 data. We always allocate from current_sblock. The NEXT pointers |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1670 in the sblock structures go from oldest_sblock to current_sblock. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1671 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1672 static struct sblock *oldest_sblock, *current_sblock; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1673 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1674 /* List of sblocks for large strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1675 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1676 static struct sblock *large_sblocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1677 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1678 /* List of string_block structures, and how many there are. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1679 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1680 static struct string_block *string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1681 static int n_string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1682 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1683 /* Free-list of Lisp_Strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1684 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1685 static struct Lisp_String *string_free_list; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1686 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1687 /* Number of live and free Lisp_Strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1688 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1689 static int total_strings, total_free_strings; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1690 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1691 /* Number of bytes used by live strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1692 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1693 static int total_string_size; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1694 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1695 /* Given a pointer to a Lisp_String S which is on the free-list |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1696 string_free_list, return a pointer to its successor in the |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1697 free-list. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1698 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1699 #define NEXT_FREE_LISP_STRING(S) (*(struct Lisp_String **) (S)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1700 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1701 /* Return a pointer to the sdata structure belonging to Lisp string S. |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1702 S must be live, i.e. S->data must not be null. S->data is actually |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1703 a pointer to the `u.data' member of its sdata structure; the |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1704 structure starts at a constant offset in front of that. */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1705 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1706 #ifdef GC_CHECK_STRING_BYTES |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1707 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1708 #define SDATA_OF_STRING(S) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1709 ((struct sdata *) ((S)->data - sizeof (struct Lisp_String *) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1710 - sizeof (EMACS_INT))) |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1711 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1712 #else /* not GC_CHECK_STRING_BYTES */ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1713 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1714 #define SDATA_OF_STRING(S) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1715 ((struct sdata *) ((S)->data - sizeof (struct Lisp_String *))) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1716 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1717 #endif /* not GC_CHECK_STRING_BYTES */ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1718 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1719 |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1720 #ifdef GC_CHECK_STRING_OVERRUN |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1721 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1722 /* We check for overrun in string data blocks by appending a small |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1723 "cookie" after each allocated string data block, and check for the |
62681
d140f1408030
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
62335
diff
changeset
|
1724 presence of this cookie during GC. */ |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1725 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1726 #define GC_STRING_OVERRUN_COOKIE_SIZE 4 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1727 static char string_overrun_cookie[GC_STRING_OVERRUN_COOKIE_SIZE] = |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1728 { 0xde, 0xad, 0xbe, 0xef }; |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1729 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1730 #else |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1731 #define GC_STRING_OVERRUN_COOKIE_SIZE 0 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1732 #endif |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1733 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1734 /* Value is the size of an sdata structure large enough to hold NBYTES |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1735 bytes of string data. The value returned includes a terminating |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1736 NUL byte, the size of the sdata structure, and padding. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1737 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1738 #ifdef GC_CHECK_STRING_BYTES |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1739 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1740 #define SDATA_SIZE(NBYTES) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1741 ((sizeof (struct Lisp_String *) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1742 + (NBYTES) + 1 \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1743 + sizeof (EMACS_INT) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1744 + sizeof (EMACS_INT) - 1) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1745 & ~(sizeof (EMACS_INT) - 1)) |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1746 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1747 #else /* not GC_CHECK_STRING_BYTES */ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1748 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1749 #define SDATA_SIZE(NBYTES) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1750 ((sizeof (struct Lisp_String *) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1751 + (NBYTES) + 1 \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1752 + sizeof (EMACS_INT) - 1) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1753 & ~(sizeof (EMACS_INT) - 1)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1754 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1755 #endif /* not GC_CHECK_STRING_BYTES */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1756 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1757 /* Extra bytes to allocate for each string. */ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1758 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1759 #define GC_STRING_EXTRA (GC_STRING_OVERRUN_COOKIE_SIZE) |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1760 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1761 /* Initialize string allocation. Called from init_alloc_once. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1762 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
1763 static void |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1764 init_strings () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1765 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1766 total_strings = total_free_strings = total_string_size = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1767 oldest_sblock = current_sblock = large_sblocks = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1768 string_blocks = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1769 n_string_blocks = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1770 string_free_list = NULL; |
81272
1842d7137ff2
(init_strings): Initialize canonical empty strings.
Juanma Barranquero <lekktu@gmail.com>
parents:
77260
diff
changeset
|
1771 empty_unibyte_string = make_pure_string ("", 0, 0, 0); |
1842d7137ff2
(init_strings): Initialize canonical empty strings.
Juanma Barranquero <lekktu@gmail.com>
parents:
77260
diff
changeset
|
1772 empty_multibyte_string = make_pure_string ("", 0, 0, 1); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1773 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1774 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1775 |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1776 #ifdef GC_CHECK_STRING_BYTES |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1777 |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1778 static int check_string_bytes_count; |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1779 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
1780 static void check_string_bytes P_ ((int)); |
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
1781 static void check_sblock P_ ((struct sblock *)); |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1782 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1783 #define CHECK_STRING_BYTES(S) STRING_BYTES (S) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1784 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1785 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1786 /* Like GC_STRING_BYTES, but with debugging check. */ |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1787 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1788 int |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1789 string_bytes (s) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1790 struct Lisp_String *s; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1791 { |
51985
b52e88c3d6d0
(MARK_STRING, UNMARK_STRING, STRING_MARKED_P)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51974
diff
changeset
|
1792 int nbytes = (s->size_byte < 0 ? s->size & ~ARRAY_MARK_FLAG : s->size_byte); |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1793 if (!PURE_POINTER_P (s) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1794 && s->data |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1795 && nbytes != SDATA_NBYTES (SDATA_OF_STRING (s))) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1796 abort (); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1797 return nbytes; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1798 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1799 |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
1800 /* Check validity of Lisp strings' string_bytes member in B. */ |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1801 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
1802 static void |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1803 check_sblock (b) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1804 struct sblock *b; |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1805 { |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1806 struct sdata *from, *end, *from_end; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1807 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1808 end = b->next_free; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1809 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1810 for (from = &b->first_data; from < end; from = from_end) |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1811 { |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1812 /* Compute the next FROM here because copying below may |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1813 overwrite data we need to compute it. */ |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1814 int nbytes; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1815 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1816 /* Check that the string size recorded in the string is the |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1817 same as the one recorded in the sdata structure. */ |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1818 if (from->string) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1819 CHECK_STRING_BYTES (from->string); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1820 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1821 if (from->string) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1822 nbytes = GC_STRING_BYTES (from->string); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1823 else |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1824 nbytes = SDATA_NBYTES (from); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1825 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1826 nbytes = SDATA_SIZE (nbytes); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1827 from_end = (struct sdata *) ((char *) from + nbytes + GC_STRING_EXTRA); |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1828 } |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1829 } |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1830 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1831 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1832 /* Check validity of Lisp strings' string_bytes member. ALL_P |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1833 non-zero means check all strings, otherwise check only most |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1834 recently allocated strings. Used for hunting a bug. */ |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1835 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
1836 static void |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1837 check_string_bytes (all_p) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1838 int all_p; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1839 { |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1840 if (all_p) |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1841 { |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1842 struct sblock *b; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1843 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1844 for (b = large_sblocks; b; b = b->next) |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1845 { |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1846 struct Lisp_String *s = b->first_data.string; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1847 if (s) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1848 CHECK_STRING_BYTES (s); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1849 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1850 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1851 for (b = oldest_sblock; b; b = b->next) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1852 check_sblock (b); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1853 } |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1854 else |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1855 check_sblock (current_sblock); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1856 } |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1857 |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1858 #endif /* GC_CHECK_STRING_BYTES */ |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1859 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1860 #ifdef GC_CHECK_STRING_FREE_LIST |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1861 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1862 /* Walk through the string free list looking for bogus next pointers. |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1863 This may catch buffer overrun from a previous string. */ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1864 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1865 static void |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1866 check_string_free_list () |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1867 { |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1868 struct Lisp_String *s; |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1869 |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1870 /* Pop a Lisp_String off the free-list. */ |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1871 s = string_free_list; |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1872 while (s != NULL) |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1873 { |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1874 if ((unsigned)s < 1024) |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1875 abort(); |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1876 s = NEXT_FREE_LISP_STRING (s); |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1877 } |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1878 } |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1879 #else |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1880 #define check_string_free_list() |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1881 #endif |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1882 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1883 /* Return a new Lisp_String. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1884 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1885 static struct Lisp_String * |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1886 allocate_string () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1887 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1888 struct Lisp_String *s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1889 |
68430
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
1890 /* eassert (!handling_signal); */ |
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
1891 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
1892 MALLOC_BLOCK_INPUT; |
68350
263a4edafafa
(lisp_align_free): Add an assertion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
67494
diff
changeset
|
1893 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1894 /* If the free-list is empty, allocate a new string_block, and |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1895 add all the Lisp_Strings in it to the free-list. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1896 if (string_free_list == NULL) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1897 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1898 struct string_block *b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1899 int i; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1900 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1901 b = (struct string_block *) lisp_malloc (sizeof *b, MEM_TYPE_STRING); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1902 bzero (b, sizeof *b); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1903 b->next = string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1904 string_blocks = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1905 ++n_string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1906 |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
1907 for (i = STRING_BLOCK_SIZE - 1; i >= 0; --i) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1908 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1909 s = b->strings + i; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1910 NEXT_FREE_LISP_STRING (s) = string_free_list; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1911 string_free_list = s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1912 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1913 |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
1914 total_free_strings += STRING_BLOCK_SIZE; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1915 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1916 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1917 check_string_free_list (); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1918 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1919 /* Pop a Lisp_String off the free-list. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1920 s = string_free_list; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1921 string_free_list = NEXT_FREE_LISP_STRING (s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1922 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
1923 MALLOC_UNBLOCK_INPUT; |
68430
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
1924 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1925 /* Probably not strictly necessary, but play it safe. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1926 bzero (s, sizeof *s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1927 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1928 --total_free_strings; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1929 ++total_strings; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1930 ++strings_consed; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1931 consing_since_gc += sizeof *s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1932 |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1933 #ifdef GC_CHECK_STRING_BYTES |
87730 | 1934 if (!noninteractive) |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1935 { |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1936 if (++check_string_bytes_count == 200) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1937 { |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1938 check_string_bytes_count = 0; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1939 check_string_bytes (1); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1940 } |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1941 else |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1942 check_string_bytes (0); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1943 } |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1944 #endif /* GC_CHECK_STRING_BYTES */ |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1945 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1946 return s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1947 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1948 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1949 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1950 /* Set up Lisp_String S for holding NCHARS characters, NBYTES bytes, |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1951 plus a NUL byte at the end. Allocate an sdata structure for S, and |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1952 set S->data to its `u.data' member. Store a NUL byte at the end of |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1953 S->data. Set S->size to NCHARS and S->size_byte to NBYTES. Free |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1954 S->data if it was initially non-null. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1955 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1956 void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1957 allocate_string_data (s, nchars, nbytes) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1958 struct Lisp_String *s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1959 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1960 { |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1961 struct sdata *data, *old_data; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1962 struct sblock *b; |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1963 int needed, old_nbytes; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1964 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1965 /* Determine the number of bytes needed to store NBYTES bytes |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1966 of string data. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1967 needed = SDATA_SIZE (nbytes); |
68430
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
1968 old_data = s->data ? SDATA_OF_STRING (s) : NULL; |
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
1969 old_nbytes = GC_STRING_BYTES (s); |
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
1970 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
1971 MALLOC_BLOCK_INPUT; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1972 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1973 if (nbytes > LARGE_STRING_BYTES) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1974 { |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
1975 size_t size = sizeof *b - sizeof (struct sdata) + needed; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1976 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1977 #ifdef DOUG_LEA_MALLOC |
31576
717e7e2ca4fd
Add some comments about DOUG_LEA_MALLOC's use of mmap
Gerd Moellmann <gerd@gnu.org>
parents:
31102
diff
changeset
|
1978 /* Prevent mmap'ing the chunk. Lisp data may not be mmap'ed |
717e7e2ca4fd
Add some comments about DOUG_LEA_MALLOC's use of mmap
Gerd Moellmann <gerd@gnu.org>
parents:
31102
diff
changeset
|
1979 because mapped region contents are not preserved in |
51318 | 1980 a dumped Emacs. |
1981 | |
1982 In case you think of allowing it in a dumped Emacs at the | |
1983 cost of not being able to re-dump, there's another reason: | |
1984 mmap'ed data typically have an address towards the top of the | |
1985 address space, which won't fit into an EMACS_INT (at least on | |
1986 32-bit systems with the current tagging scheme). --fx */ | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1987 mallopt (M_MMAP_MAX, 0); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1988 #endif |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1989 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1990 b = (struct sblock *) lisp_malloc (size + GC_STRING_EXTRA, MEM_TYPE_NON_LISP); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1991 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1992 #ifdef DOUG_LEA_MALLOC |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1993 /* Back to a reasonable maximum of mmap'ed areas. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1994 mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1995 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1996 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1997 b->next_free = &b->first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1998 b->first_data.string = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1999 b->next = large_sblocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2000 large_sblocks = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2001 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2002 else if (current_sblock == NULL |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2003 || (((char *) current_sblock + SBLOCK_SIZE |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2004 - (char *) current_sblock->next_free) |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2005 < (needed + GC_STRING_EXTRA))) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2006 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2007 /* Not enough room in the current sblock. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2008 b = (struct sblock *) lisp_malloc (SBLOCK_SIZE, MEM_TYPE_NON_LISP); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2009 b->next_free = &b->first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2010 b->first_data.string = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2011 b->next = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2012 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2013 if (current_sblock) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2014 current_sblock->next = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2015 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2016 oldest_sblock = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2017 current_sblock = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2018 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2019 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2020 b = current_sblock; |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
2021 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2022 data = b->next_free; |
68369
3422c551ad06
* alloc.c (allocate_string_data): Update next_free immediately, to
Chong Yidong <cyd@stupidchicken.com>
parents:
68350
diff
changeset
|
2023 b->next_free = (struct sdata *) ((char *) data + needed + GC_STRING_EXTRA); |
3422c551ad06
* alloc.c (allocate_string_data): Update next_free immediately, to
Chong Yidong <cyd@stupidchicken.com>
parents:
68350
diff
changeset
|
2024 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
2025 MALLOC_UNBLOCK_INPUT; |
68430
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
2026 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2027 data->string = s; |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2028 s->data = SDATA_DATA (data); |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2029 #ifdef GC_CHECK_STRING_BYTES |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2030 SDATA_NBYTES (data) = nbytes; |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2031 #endif |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2032 s->size = nchars; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2033 s->size_byte = nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2034 s->data[nbytes] = '\0'; |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2035 #ifdef GC_CHECK_STRING_OVERRUN |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
2036 bcopy (string_overrun_cookie, (char *) data + needed, |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
2037 GC_STRING_OVERRUN_COOKIE_SIZE); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2038 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2039 |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
2040 /* If S had already data assigned, mark that as free by setting its |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
2041 string back-pointer to null, and recording the size of the data |
30317
96e65dc07fd7
(allocate_string_data): Don't copy old string contents.
Gerd Moellmann <gerd@gnu.org>
parents:
30293
diff
changeset
|
2042 in it. */ |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
2043 if (old_data) |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
2044 { |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2045 SDATA_NBYTES (old_data) = old_nbytes; |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
2046 old_data->string = NULL; |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
2047 } |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
2048 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2049 consing_since_gc += needed; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2050 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2051 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2052 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2053 /* Sweep and compact strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2054 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2055 static void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2056 sweep_strings () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2057 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2058 struct string_block *b, *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2059 struct string_block *live_blocks = NULL; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2060 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2061 string_free_list = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2062 total_strings = total_free_strings = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2063 total_string_size = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2064 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2065 /* Scan strings_blocks, free Lisp_Strings that aren't marked. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2066 for (b = string_blocks; b; b = next) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2067 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2068 int i, nfree = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2069 struct Lisp_String *free_list_before = string_free_list; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2070 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2071 next = b->next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2072 |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
2073 for (i = 0; i < STRING_BLOCK_SIZE; ++i) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2074 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2075 struct Lisp_String *s = b->strings + i; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2076 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2077 if (s->data) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2078 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2079 /* String was not on free-list before. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2080 if (STRING_MARKED_P (s)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2081 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2082 /* String is live; unmark it and its intervals. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2083 UNMARK_STRING (s); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2084 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2085 if (!NULL_INTERVAL_P (s->intervals)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2086 UNMARK_BALANCE_INTERVALS (s->intervals); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2087 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2088 ++total_strings; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2089 total_string_size += STRING_BYTES (s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2090 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2091 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2092 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2093 /* String is dead. Put it on the free-list. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2094 struct sdata *data = SDATA_OF_STRING (s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2095 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2096 /* Save the size of S in its sdata so that we know |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2097 how large that is. Reset the sdata's string |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2098 back-pointer so that we know it's free. */ |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2099 #ifdef GC_CHECK_STRING_BYTES |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2100 if (GC_STRING_BYTES (s) != SDATA_NBYTES (data)) |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2101 abort (); |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2102 #else |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2103 data->u.nbytes = GC_STRING_BYTES (s); |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2104 #endif |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2105 data->string = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2106 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2107 /* Reset the strings's `data' member so that we |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2108 know it's free. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2109 s->data = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2110 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2111 /* Put the string on the free-list. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2112 NEXT_FREE_LISP_STRING (s) = string_free_list; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2113 string_free_list = s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2114 ++nfree; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2115 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2116 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2117 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2118 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2119 /* S was on the free-list before. Put it there again. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2120 NEXT_FREE_LISP_STRING (s) = string_free_list; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2121 string_free_list = s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2122 ++nfree; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2123 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2124 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2125 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2126 /* Free blocks that contain free Lisp_Strings only, except |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2127 the first two of them. */ |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
2128 if (nfree == STRING_BLOCK_SIZE |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
2129 && total_free_strings > STRING_BLOCK_SIZE) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2130 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2131 lisp_free (b); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2132 --n_string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2133 string_free_list = free_list_before; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2134 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2135 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2136 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2137 total_free_strings += nfree; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2138 b->next = live_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2139 live_blocks = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2140 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2141 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2142 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
2143 check_string_free_list (); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2144 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2145 string_blocks = live_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2146 free_large_strings (); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2147 compact_small_strings (); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2148 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
2149 check_string_free_list (); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2150 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2151 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2152 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2153 /* Free dead large strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2154 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2155 static void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2156 free_large_strings () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2157 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2158 struct sblock *b, *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2159 struct sblock *live_blocks = NULL; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2160 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2161 for (b = large_sblocks; b; b = next) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2162 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2163 next = b->next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2164 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2165 if (b->first_data.string == NULL) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2166 lisp_free (b); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2167 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2168 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2169 b->next = live_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2170 live_blocks = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2171 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2172 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2173 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2174 large_sblocks = live_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2175 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2176 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2177 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2178 /* Compact data of small strings. Free sblocks that don't contain |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2179 data of live strings after compaction. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2180 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2181 static void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2182 compact_small_strings () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2183 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2184 struct sblock *b, *tb, *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2185 struct sdata *from, *to, *end, *tb_end; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2186 struct sdata *to_end, *from_end; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2187 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2188 /* TB is the sblock we copy to, TO is the sdata within TB we copy |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2189 to, and TB_END is the end of TB. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2190 tb = oldest_sblock; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2191 tb_end = (struct sdata *) ((char *) tb + SBLOCK_SIZE); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2192 to = &tb->first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2193 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2194 /* Step through the blocks from the oldest to the youngest. We |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2195 expect that old blocks will stabilize over time, so that less |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2196 copying will happen this way. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2197 for (b = oldest_sblock; b; b = b->next) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2198 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2199 end = b->next_free; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2200 xassert ((char *) end <= (char *) b + SBLOCK_SIZE); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2201 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2202 for (from = &b->first_data; from < end; from = from_end) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2203 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2204 /* Compute the next FROM here because copying below may |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2205 overwrite data we need to compute it. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2206 int nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2207 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2208 #ifdef GC_CHECK_STRING_BYTES |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2209 /* Check that the string size recorded in the string is the |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2210 same as the one recorded in the sdata structure. */ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2211 if (from->string |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2212 && GC_STRING_BYTES (from->string) != SDATA_NBYTES (from)) |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2213 abort (); |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2214 #endif /* GC_CHECK_STRING_BYTES */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2215 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2216 if (from->string) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2217 nbytes = GC_STRING_BYTES (from->string); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2218 else |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2219 nbytes = SDATA_NBYTES (from); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2220 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2221 if (nbytes > LARGE_STRING_BYTES) |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2222 abort (); |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2223 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2224 nbytes = SDATA_SIZE (nbytes); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2225 from_end = (struct sdata *) ((char *) from + nbytes + GC_STRING_EXTRA); |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2226 |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2227 #ifdef GC_CHECK_STRING_OVERRUN |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
2228 if (bcmp (string_overrun_cookie, |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
2229 ((char *) from_end) - GC_STRING_OVERRUN_COOKIE_SIZE, |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
2230 GC_STRING_OVERRUN_COOKIE_SIZE)) |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2231 abort (); |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2232 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2233 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2234 /* FROM->string non-null means it's alive. Copy its data. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2235 if (from->string) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2236 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2237 /* If TB is full, proceed with the next sblock. */ |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2238 to_end = (struct sdata *) ((char *) to + nbytes + GC_STRING_EXTRA); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2239 if (to_end > tb_end) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2240 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2241 tb->next_free = to; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2242 tb = tb->next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2243 tb_end = (struct sdata *) ((char *) tb + SBLOCK_SIZE); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2244 to = &tb->first_data; |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2245 to_end = (struct sdata *) ((char *) to + nbytes + GC_STRING_EXTRA); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2246 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2247 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2248 /* Copy, and update the string's `data' pointer. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2249 if (from != to) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2250 { |
30823
8ee3740aaf60
(compact_small_strings): Use safe_bcopy, add an
Gerd Moellmann <gerd@gnu.org>
parents:
30784
diff
changeset
|
2251 xassert (tb != b || to <= from); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2252 safe_bcopy ((char *) from, (char *) to, nbytes + GC_STRING_EXTRA); |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2253 to->string->data = SDATA_DATA (to); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2254 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2255 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2256 /* Advance past the sdata we copied to. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2257 to = to_end; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2258 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2259 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2260 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2261 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2262 /* The rest of the sblocks following TB don't contain live data, so |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2263 we can free them. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2264 for (b = tb->next; b; b = next) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2265 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2266 next = b->next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2267 lisp_free (b); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2268 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2269 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2270 tb->next_free = to; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2271 tb->next = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2272 current_sblock = tb; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2273 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2274 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2275 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2276 DEFUN ("make-string", Fmake_string, Smake_string, 2, 2, 0, |
55745
1c3b8ce97c63
(Fmake_string): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
55720
diff
changeset
|
2277 doc: /* Return a newly created string of length LENGTH, with INIT in each element. |
1c3b8ce97c63
(Fmake_string): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
55720
diff
changeset
|
2278 LENGTH must be an integer. |
1c3b8ce97c63
(Fmake_string): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
55720
diff
changeset
|
2279 INIT must be an integer that represents a character. */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2280 (length, init) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2281 Lisp_Object length, init; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2282 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2283 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2284 register unsigned char *p, *end; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2285 int c, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2286 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
2287 CHECK_NATNUM (length); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
2288 CHECK_NUMBER (init); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2289 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2290 c = XINT (init); |
88898
ac49af641799
(Fmake_string): Use ASCII_CHAR_P, not SINGLE_BYTE_CHAR_P.
Kenichi Handa <handa@m17n.org>
parents:
88353
diff
changeset
|
2291 if (ASCII_CHAR_P (c)) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2292 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2293 nbytes = XINT (length); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2294 val = make_uninit_string (nbytes); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
2295 p = SDATA (val); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
2296 end = p + SCHARS (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2297 while (p != end) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2298 *p++ = c; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2299 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2300 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2301 { |
33800
7f148cfbd1f7
(Fmake_string): Use MAX_MULTIBYTE_LENGTH, instead of hard coded `4'.
Kenichi Handa <handa@m17n.org>
parents:
33764
diff
changeset
|
2302 unsigned char str[MAX_MULTIBYTE_LENGTH]; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2303 int len = CHAR_STRING (c, str); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2304 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2305 nbytes = len * XINT (length); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2306 val = make_uninit_multibyte_string (XINT (length), nbytes); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
2307 p = SDATA (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2308 end = p + nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2309 while (p != end) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2310 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2311 bcopy (str, p, len); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2312 p += len; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2313 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2314 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2315 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2316 *p = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2317 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2318 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2319 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2320 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2321 DEFUN ("make-bool-vector", Fmake_bool_vector, Smake_bool_vector, 2, 2, 0, |
68741
2892a36e596e
(Fmake_bool_vector, Fpurecopy): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
68430
diff
changeset
|
2322 doc: /* Return a new bool-vector of length LENGTH, using INIT for each element. |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2323 LENGTH must be a number. INIT matters only in whether it is t or nil. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2324 (length, init) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2325 Lisp_Object length, init; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2326 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2327 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2328 struct Lisp_Bool_Vector *p; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2329 int real_init, i; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2330 int length_in_chars, length_in_elts, bits_per_value; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2331 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
2332 CHECK_NATNUM (length); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2333 |
55159
e4e9ec547c6f
(Fmake_bool_vector): Use BOOL_VECTOR_BITS_PER_CHAR instead of
Andreas Schwab <schwab@suse.de>
parents:
53705
diff
changeset
|
2334 bits_per_value = sizeof (EMACS_INT) * BOOL_VECTOR_BITS_PER_CHAR; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2335 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2336 length_in_elts = (XFASTINT (length) + bits_per_value - 1) / bits_per_value; |
55159
e4e9ec547c6f
(Fmake_bool_vector): Use BOOL_VECTOR_BITS_PER_CHAR instead of
Andreas Schwab <schwab@suse.de>
parents:
53705
diff
changeset
|
2337 length_in_chars = ((XFASTINT (length) + BOOL_VECTOR_BITS_PER_CHAR - 1) |
e4e9ec547c6f
(Fmake_bool_vector): Use BOOL_VECTOR_BITS_PER_CHAR instead of
Andreas Schwab <schwab@suse.de>
parents:
53705
diff
changeset
|
2338 / BOOL_VECTOR_BITS_PER_CHAR); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2339 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2340 /* We must allocate one more elements than LENGTH_IN_ELTS for the |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2341 slot `size' of the struct Lisp_Bool_Vector. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2342 val = Fmake_vector (make_number (length_in_elts + 1), Qnil); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2343 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2344 /* Get rid of any bits that would cause confusion. */ |
85019
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
2345 XVECTOR (val)->size = 0; /* No Lisp_Object to trace in there. */ |
85022
96eb42c9e0e3
* window.h (struct window):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85021
diff
changeset
|
2346 /* Use XVECTOR (val) rather than `p' because p->size is not TRT. */ |
85019
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
2347 XSETPVECTYPE (XVECTOR (val), PVEC_BOOL_VECTOR); |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
2348 |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
2349 p = XBOOL_VECTOR (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2350 p->size = XFASTINT (length); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2351 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2352 real_init = (NILP (init) ? 0 : -1); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2353 for (i = 0; i < length_in_chars ; i++) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2354 p->data[i] = real_init; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2355 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2356 /* Clear the extraneous bits in the last byte. */ |
55159
e4e9ec547c6f
(Fmake_bool_vector): Use BOOL_VECTOR_BITS_PER_CHAR instead of
Andreas Schwab <schwab@suse.de>
parents:
53705
diff
changeset
|
2357 if (XINT (length) != length_in_chars * BOOL_VECTOR_BITS_PER_CHAR) |
85019
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
2358 p->data[length_in_chars - 1] |
55159
e4e9ec547c6f
(Fmake_bool_vector): Use BOOL_VECTOR_BITS_PER_CHAR instead of
Andreas Schwab <schwab@suse.de>
parents:
53705
diff
changeset
|
2359 &= (1 << (XINT (length) % BOOL_VECTOR_BITS_PER_CHAR)) - 1; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2360 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2361 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2362 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2363 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2364 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2365 /* Make a string from NBYTES bytes at CONTENTS, and compute the number |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2366 of characters from the contents. This string may be unibyte or |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2367 multibyte, depending on the contents. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2368 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2369 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2370 make_string (contents, nbytes) |
46459
0a9cbcbdbe45
(xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents:
46418
diff
changeset
|
2371 const char *contents; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2372 int nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2373 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2374 register Lisp_Object val; |
28997
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
2375 int nchars, multibyte_nbytes; |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
2376 |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
2377 parse_str_as_multibyte (contents, nbytes, &nchars, &multibyte_nbytes); |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
2378 if (nbytes == nchars || nbytes != multibyte_nbytes) |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
2379 /* CONTENTS contains no multibyte sequences or contains an invalid |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
2380 multibyte sequence. We must make unibyte string. */ |
33623
dda5cbf94928
(make_string): Fix previous change. Be sure to make
Kenichi Handa <handa@m17n.org>
parents:
32776
diff
changeset
|
2381 val = make_unibyte_string (contents, nbytes); |
dda5cbf94928
(make_string): Fix previous change. Be sure to make
Kenichi Handa <handa@m17n.org>
parents:
32776
diff
changeset
|
2382 else |
dda5cbf94928
(make_string): Fix previous change. Be sure to make
Kenichi Handa <handa@m17n.org>
parents:
32776
diff
changeset
|
2383 val = make_multibyte_string (contents, nchars, nbytes); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2384 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2385 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2386 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2387 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2388 /* Make an unibyte string from LENGTH bytes at CONTENTS. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2389 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2390 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2391 make_unibyte_string (contents, length) |
46459
0a9cbcbdbe45
(xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents:
46418
diff
changeset
|
2392 const char *contents; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2393 int length; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2394 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2395 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2396 val = make_uninit_string (length); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
2397 bcopy (contents, SDATA (val), length); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
2398 STRING_SET_UNIBYTE (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2399 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2400 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2401 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2402 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2403 /* Make a multibyte string from NCHARS characters occupying NBYTES |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2404 bytes at CONTENTS. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2405 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2406 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2407 make_multibyte_string (contents, nchars, nbytes) |
46459
0a9cbcbdbe45
(xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents:
46418
diff
changeset
|
2408 const char *contents; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2409 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2410 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2411 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2412 val = make_uninit_multibyte_string (nchars, nbytes); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
2413 bcopy (contents, SDATA (val), nbytes); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2414 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2415 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2416 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2417 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2418 /* Make a string from NCHARS characters occupying NBYTES bytes at |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2419 CONTENTS. It is a multibyte string if NBYTES != NCHARS. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2420 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2421 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2422 make_string_from_bytes (contents, nchars, nbytes) |
50274
a617ca0d5d85
(make_string_from_bytes): Add `const' for the arg
Kenichi Handa <handa@m17n.org>
parents:
50200
diff
changeset
|
2423 const char *contents; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2424 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2425 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2426 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2427 val = make_uninit_multibyte_string (nchars, nbytes); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
2428 bcopy (contents, SDATA (val), nbytes); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
2429 if (SBYTES (val) == SCHARS (val)) |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
2430 STRING_SET_UNIBYTE (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2431 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2432 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2433 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2434 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2435 /* Make a string from NCHARS characters occupying NBYTES bytes at |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2436 CONTENTS. The argument MULTIBYTE controls whether to label the |
50200
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2437 string as multibyte. If NCHARS is negative, it counts the number of |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2438 characters by itself. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2439 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2440 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2441 make_specified_string (contents, nchars, nbytes, multibyte) |
50274
a617ca0d5d85
(make_string_from_bytes): Add `const' for the arg
Kenichi Handa <handa@m17n.org>
parents:
50200
diff
changeset
|
2442 const char *contents; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2443 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2444 int multibyte; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2445 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2446 register Lisp_Object val; |
50200
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2447 |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2448 if (nchars < 0) |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2449 { |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2450 if (multibyte) |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2451 nchars = multibyte_chars_in_text (contents, nbytes); |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2452 else |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2453 nchars = nbytes; |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2454 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2455 val = make_uninit_multibyte_string (nchars, nbytes); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
2456 bcopy (contents, SDATA (val), nbytes); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2457 if (!multibyte) |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
2458 STRING_SET_UNIBYTE (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2459 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2460 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2461 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2462 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2463 /* Make a string from the data at STR, treating it as multibyte if the |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2464 data warrants. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2465 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2466 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2467 build_string (str) |
46459
0a9cbcbdbe45
(xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents:
46418
diff
changeset
|
2468 const char *str; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2469 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2470 return make_string (str, strlen (str)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2471 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2472 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2473 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2474 /* Return an unibyte Lisp_String set up to hold LENGTH characters |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2475 occupying LENGTH bytes. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2476 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2477 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2478 make_uninit_string (length) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2479 int length; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2480 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2481 Lisp_Object val; |
81272
1842d7137ff2
(init_strings): Initialize canonical empty strings.
Juanma Barranquero <lekktu@gmail.com>
parents:
77260
diff
changeset
|
2482 |
1842d7137ff2
(init_strings): Initialize canonical empty strings.
Juanma Barranquero <lekktu@gmail.com>
parents:
77260
diff
changeset
|
2483 if (!length) |
1842d7137ff2
(init_strings): Initialize canonical empty strings.
Juanma Barranquero <lekktu@gmail.com>
parents:
77260
diff
changeset
|
2484 return empty_unibyte_string; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2485 val = make_uninit_multibyte_string (length, length); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
2486 STRING_SET_UNIBYTE (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2487 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2488 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2489 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2490 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2491 /* Return a multibyte Lisp_String set up to hold NCHARS characters |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2492 which occupy NBYTES bytes. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2493 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2494 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2495 make_uninit_multibyte_string (nchars, nbytes) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2496 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2497 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2498 Lisp_Object string; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2499 struct Lisp_String *s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2500 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2501 if (nchars < 0) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2502 abort (); |
81272
1842d7137ff2
(init_strings): Initialize canonical empty strings.
Juanma Barranquero <lekktu@gmail.com>
parents:
77260
diff
changeset
|
2503 if (!nbytes) |
1842d7137ff2
(init_strings): Initialize canonical empty strings.
Juanma Barranquero <lekktu@gmail.com>
parents:
77260
diff
changeset
|
2504 return empty_multibyte_string; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2505 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2506 s = allocate_string (); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2507 allocate_string_data (s, nchars, nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2508 XSETSTRING (string, s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2509 string_chars_consed += nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2510 return string; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2511 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2512 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2513 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2514 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2515 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2516 Float Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2517 ***********************************************************************/ |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
2518 |
300 | 2519 /* We store float cells inside of float_blocks, allocating a new |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2520 float_block with malloc whenever necessary. Float cells reclaimed |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2521 by GC are put on a free list to be reallocated before allocating |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2522 any new float cells from the latest float_block. */ |
300 | 2523 |
53582
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
2524 #define FLOAT_BLOCK_SIZE \ |
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
2525 (((BLOCK_BYTES - sizeof (struct float_block *) \ |
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
2526 /* The compiler might add padding at the end. */ \ |
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
2527 - (sizeof (struct Lisp_Float) - sizeof (int))) * CHAR_BIT) \ |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2528 / (sizeof (struct Lisp_Float) * CHAR_BIT + 1)) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2529 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2530 #define GETMARKBIT(block,n) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2531 (((block)->gcmarkbits[(n) / (sizeof(int) * CHAR_BIT)] \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2532 >> ((n) % (sizeof(int) * CHAR_BIT))) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2533 & 1) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2534 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2535 #define SETMARKBIT(block,n) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2536 (block)->gcmarkbits[(n) / (sizeof(int) * CHAR_BIT)] \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2537 |= 1 << ((n) % (sizeof(int) * CHAR_BIT)) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2538 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2539 #define UNSETMARKBIT(block,n) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2540 (block)->gcmarkbits[(n) / (sizeof(int) * CHAR_BIT)] \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2541 &= ~(1 << ((n) % (sizeof(int) * CHAR_BIT))) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2542 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2543 #define FLOAT_BLOCK(fptr) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2544 ((struct float_block *)(((EMACS_UINT)(fptr)) & ~(BLOCK_ALIGN - 1))) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2545 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2546 #define FLOAT_INDEX(fptr) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2547 ((((EMACS_UINT)(fptr)) & (BLOCK_ALIGN - 1)) / sizeof (struct Lisp_Float)) |
300 | 2548 |
2549 struct float_block | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2550 { |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2551 /* Place `floats' at the beginning, to ease up FLOAT_INDEX's job. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2552 struct Lisp_Float floats[FLOAT_BLOCK_SIZE]; |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2553 int gcmarkbits[1 + FLOAT_BLOCK_SIZE / (sizeof(int) * CHAR_BIT)]; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2554 struct float_block *next; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2555 }; |
300 | 2556 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2557 #define FLOAT_MARKED_P(fptr) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2558 GETMARKBIT (FLOAT_BLOCK (fptr), FLOAT_INDEX ((fptr))) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2559 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2560 #define FLOAT_MARK(fptr) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2561 SETMARKBIT (FLOAT_BLOCK (fptr), FLOAT_INDEX ((fptr))) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2562 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2563 #define FLOAT_UNMARK(fptr) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2564 UNSETMARKBIT (FLOAT_BLOCK (fptr), FLOAT_INDEX ((fptr))) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2565 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2566 /* Current float_block. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2567 |
300 | 2568 struct float_block *float_block; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2569 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2570 /* Index of first unused Lisp_Float in the current float_block. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2571 |
300 | 2572 int float_block_index; |
2573 | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2574 /* Total number of float blocks now in use. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2575 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2576 int n_float_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2577 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2578 /* Free-list of Lisp_Floats. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2579 |
300 | 2580 struct Lisp_Float *float_free_list; |
2581 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2582 |
39297
aff361cfdccb
Fix a typo in a comment. From Pavel Janik.
Eli Zaretskii <eliz@gnu.org>
parents:
39228
diff
changeset
|
2583 /* Initialize float allocation. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2584 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
2585 static void |
300 | 2586 init_float () |
2587 { | |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2588 float_block = NULL; |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2589 float_block_index = FLOAT_BLOCK_SIZE; /* Force alloc of new float_block. */ |
300 | 2590 float_free_list = 0; |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2591 n_float_blocks = 0; |
300 | 2592 } |
2593 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2594 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2595 /* Explicitly free a float cell by putting it on the free-list. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2596 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
2597 static void |
300 | 2598 free_float (ptr) |
2599 struct Lisp_Float *ptr; | |
2600 { | |
66889
e485868e3caf
(free_float): Make free list chaining aliasing-safe.
Andreas Schwab <schwab@suse.de>
parents:
66777
diff
changeset
|
2601 ptr->u.chain = float_free_list; |
300 | 2602 float_free_list = ptr; |
2603 } | |
2604 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2605 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2606 /* Return a new float object with value FLOAT_VALUE. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2607 |
300 | 2608 Lisp_Object |
2609 make_float (float_value) | |
2610 double float_value; | |
2611 { | |
2612 register Lisp_Object val; | |
2613 | |
68430
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
2614 /* eassert (!handling_signal); */ |
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
2615 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
2616 MALLOC_BLOCK_INPUT; |
68350
263a4edafafa
(lisp_align_free): Add an assertion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
67494
diff
changeset
|
2617 |
300 | 2618 if (float_free_list) |
2619 { | |
19666
81957e8b80e2
(free_float, free_cons): Don't use the same field for chaining as for marking.
Richard M. Stallman <rms@gnu.org>
parents:
19621
diff
changeset
|
2620 /* We use the data field for chaining the free list |
81957e8b80e2
(free_float, free_cons): Don't use the same field for chaining as for marking.
Richard M. Stallman <rms@gnu.org>
parents:
19621
diff
changeset
|
2621 so that we won't use the same field that has the mark bit. */ |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
2622 XSETFLOAT (val, float_free_list); |
66889
e485868e3caf
(free_float): Make free list chaining aliasing-safe.
Andreas Schwab <schwab@suse.de>
parents:
66777
diff
changeset
|
2623 float_free_list = float_free_list->u.chain; |
300 | 2624 } |
2625 else | |
2626 { | |
2627 if (float_block_index == FLOAT_BLOCK_SIZE) | |
2628 { | |
12529 | 2629 register struct float_block *new; |
2630 | |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2631 new = (struct float_block *) lisp_align_malloc (sizeof *new, |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2632 MEM_TYPE_FLOAT); |
300 | 2633 new->next = float_block; |
53093
e8f5463f3d5b
(make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52837
diff
changeset
|
2634 bzero ((char *) new->gcmarkbits, sizeof new->gcmarkbits); |
300 | 2635 float_block = new; |
2636 float_block_index = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2637 n_float_blocks++; |
300 | 2638 } |
53093
e8f5463f3d5b
(make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52837
diff
changeset
|
2639 XSETFLOAT (val, &float_block->floats[float_block_index]); |
e8f5463f3d5b
(make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52837
diff
changeset
|
2640 float_block_index++; |
300 | 2641 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2642 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
2643 MALLOC_UNBLOCK_INPUT; |
68430
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
2644 |
104313
73f76307d49b
* lisp.h (XFLOAT_DATA): Produce an rvalue by adding 0 to the value.
Ken Raeburn <raeburn@raeburn.org>
parents:
101689
diff
changeset
|
2645 XFLOAT_INIT (val, float_value); |
53093
e8f5463f3d5b
(make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52837
diff
changeset
|
2646 eassert (!FLOAT_MARKED_P (XFLOAT (val))); |
300 | 2647 consing_since_gc += sizeof (struct Lisp_Float); |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
2648 floats_consed++; |
300 | 2649 return val; |
2650 } | |
2651 | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2652 |
300 | 2653 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2654 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2655 Cons Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2656 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2657 |
300 | 2658 /* We store cons cells inside of cons_blocks, allocating a new |
2659 cons_block with malloc whenever necessary. Cons cells reclaimed by | |
2660 GC are put on a free list to be reallocated before allocating | |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2661 any new cons cells from the latest cons_block. */ |
300 | 2662 |
2663 #define CONS_BLOCK_SIZE \ | |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2664 (((BLOCK_BYTES - sizeof (struct cons_block *)) * CHAR_BIT) \ |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2665 / (sizeof (struct Lisp_Cons) * CHAR_BIT + 1)) |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2666 |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2667 #define CONS_BLOCK(fptr) \ |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2668 ((struct cons_block *)(((EMACS_UINT)(fptr)) & ~(BLOCK_ALIGN - 1))) |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2669 |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2670 #define CONS_INDEX(fptr) \ |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2671 ((((EMACS_UINT)(fptr)) & (BLOCK_ALIGN - 1)) / sizeof (struct Lisp_Cons)) |
300 | 2672 |
2673 struct cons_block | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2674 { |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2675 /* Place `conses' at the beginning, to ease up CONS_INDEX's job. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2676 struct Lisp_Cons conses[CONS_BLOCK_SIZE]; |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2677 int gcmarkbits[1 + CONS_BLOCK_SIZE / (sizeof(int) * CHAR_BIT)]; |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2678 struct cons_block *next; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2679 }; |
300 | 2680 |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2681 #define CONS_MARKED_P(fptr) \ |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2682 GETMARKBIT (CONS_BLOCK (fptr), CONS_INDEX ((fptr))) |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2683 |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2684 #define CONS_MARK(fptr) \ |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2685 SETMARKBIT (CONS_BLOCK (fptr), CONS_INDEX ((fptr))) |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2686 |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2687 #define CONS_UNMARK(fptr) \ |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2688 UNSETMARKBIT (CONS_BLOCK (fptr), CONS_INDEX ((fptr))) |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2689 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2690 /* Current cons_block. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2691 |
300 | 2692 struct cons_block *cons_block; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2693 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2694 /* Index of first unused Lisp_Cons in the current block. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2695 |
300 | 2696 int cons_block_index; |
2697 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2698 /* Free-list of Lisp_Cons structures. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2699 |
300 | 2700 struct Lisp_Cons *cons_free_list; |
2701 | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2702 /* Total number of cons blocks now in use. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2703 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
2704 static int n_cons_blocks; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2705 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2706 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2707 /* Initialize cons allocation. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2708 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
2709 static void |
300 | 2710 init_cons () |
2711 { | |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2712 cons_block = NULL; |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2713 cons_block_index = CONS_BLOCK_SIZE; /* Force alloc of new cons_block. */ |
300 | 2714 cons_free_list = 0; |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2715 n_cons_blocks = 0; |
300 | 2716 } |
2717 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2718 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2719 /* Explicitly free a cons cell by putting it on the free-list. */ |
20375
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
2720 |
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
2721 void |
300 | 2722 free_cons (ptr) |
2723 struct Lisp_Cons *ptr; | |
2724 { | |
66889
e485868e3caf
(free_float): Make free list chaining aliasing-safe.
Andreas Schwab <schwab@suse.de>
parents:
66777
diff
changeset
|
2725 ptr->u.chain = cons_free_list; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2726 #if GC_MARK_STACK |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2727 ptr->car = Vdead; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2728 #endif |
300 | 2729 cons_free_list = ptr; |
2730 } | |
2731 | |
2732 DEFUN ("cons", Fcons, Scons, 2, 2, 0, | |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
2733 doc: /* Create a new cons, give it CAR and CDR as components, and return it. */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2734 (car, cdr) |
300 | 2735 Lisp_Object car, cdr; |
2736 { | |
2737 register Lisp_Object val; | |
2738 | |
68430
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
2739 /* eassert (!handling_signal); */ |
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
2740 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
2741 MALLOC_BLOCK_INPUT; |
68350
263a4edafafa
(lisp_align_free): Add an assertion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
67494
diff
changeset
|
2742 |
300 | 2743 if (cons_free_list) |
2744 { | |
19666
81957e8b80e2
(free_float, free_cons): Don't use the same field for chaining as for marking.
Richard M. Stallman <rms@gnu.org>
parents:
19621
diff
changeset
|
2745 /* We use the cdr for chaining the free list |
81957e8b80e2
(free_float, free_cons): Don't use the same field for chaining as for marking.
Richard M. Stallman <rms@gnu.org>
parents:
19621
diff
changeset
|
2746 so that we won't use the same field that has the mark bit. */ |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
2747 XSETCONS (val, cons_free_list); |
66889
e485868e3caf
(free_float): Make free list chaining aliasing-safe.
Andreas Schwab <schwab@suse.de>
parents:
66777
diff
changeset
|
2748 cons_free_list = cons_free_list->u.chain; |
300 | 2749 } |
2750 else | |
2751 { | |
2752 if (cons_block_index == CONS_BLOCK_SIZE) | |
2753 { | |
12529 | 2754 register struct cons_block *new; |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2755 new = (struct cons_block *) lisp_align_malloc (sizeof *new, |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2756 MEM_TYPE_CONS); |
53093
e8f5463f3d5b
(make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52837
diff
changeset
|
2757 bzero ((char *) new->gcmarkbits, sizeof new->gcmarkbits); |
300 | 2758 new->next = cons_block; |
2759 cons_block = new; | |
2760 cons_block_index = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2761 n_cons_blocks++; |
300 | 2762 } |
53093
e8f5463f3d5b
(make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52837
diff
changeset
|
2763 XSETCONS (val, &cons_block->conses[cons_block_index]); |
e8f5463f3d5b
(make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52837
diff
changeset
|
2764 cons_block_index++; |
300 | 2765 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2766 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
2767 MALLOC_UNBLOCK_INPUT; |
68430
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
2768 |
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
2769 XSETCAR (val, car); |
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
2770 XSETCDR (val, cdr); |
53093
e8f5463f3d5b
(make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52837
diff
changeset
|
2771 eassert (!CONS_MARKED_P (XCONS (val))); |
300 | 2772 consing_since_gc += sizeof (struct Lisp_Cons); |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
2773 cons_cells_consed++; |
300 | 2774 return val; |
2775 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2776 |
56539
9fc5aae4053e
(check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents:
56401
diff
changeset
|
2777 /* Get an error now if there's any junk in the cons free list. */ |
9fc5aae4053e
(check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents:
56401
diff
changeset
|
2778 void |
9fc5aae4053e
(check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents:
56401
diff
changeset
|
2779 check_cons_list () |
9fc5aae4053e
(check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents:
56401
diff
changeset
|
2780 { |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2781 #ifdef GC_CHECK_CONS_LIST |
56539
9fc5aae4053e
(check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents:
56401
diff
changeset
|
2782 struct Lisp_Cons *tail = cons_free_list; |
9fc5aae4053e
(check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents:
56401
diff
changeset
|
2783 |
9fc5aae4053e
(check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents:
56401
diff
changeset
|
2784 while (tail) |
66889
e485868e3caf
(free_float): Make free list chaining aliasing-safe.
Andreas Schwab <schwab@suse.de>
parents:
66777
diff
changeset
|
2785 tail = tail->u.chain; |
56539
9fc5aae4053e
(check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents:
56401
diff
changeset
|
2786 #endif |
9fc5aae4053e
(check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents:
56401
diff
changeset
|
2787 } |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2788 |
71967
3254b987edcb
(buffer_memory_full, memory_full): Use xsignal. Remove loop.
Kim F. Storm <storm@cua.dk>
parents:
69876
diff
changeset
|
2789 /* Make a list of 1, 2, 3, 4 or 5 specified objects. */ |
3254b987edcb
(buffer_memory_full, memory_full): Use xsignal. Remove loop.
Kim F. Storm <storm@cua.dk>
parents:
69876
diff
changeset
|
2790 |
3254b987edcb
(buffer_memory_full, memory_full): Use xsignal. Remove loop.
Kim F. Storm <storm@cua.dk>
parents:
69876
diff
changeset
|
2791 Lisp_Object |
3254b987edcb
(buffer_memory_full, memory_full): Use xsignal. Remove loop.
Kim F. Storm <storm@cua.dk>
parents:
69876
diff
changeset
|
2792 list1 (arg1) |
3254b987edcb
(buffer_memory_full, memory_full): Use xsignal. Remove loop.
Kim F. Storm <storm@cua.dk>
parents:
69876
diff
changeset
|
2793 Lisp_Object arg1; |
3254b987edcb
(buffer_memory_full, memory_full): Use xsignal. Remove loop.
Kim F. Storm <storm@cua.dk>
parents:
69876
diff
changeset
|
2794 { |
3254b987edcb
(buffer_memory_full, memory_full): Use xsignal. Remove loop.
Kim F. Storm <storm@cua.dk>
parents:
69876
diff
changeset
|
2795 return Fcons (arg1, Qnil); |
3254b987edcb
(buffer_memory_full, memory_full): Use xsignal. Remove loop.
Kim F. Storm <storm@cua.dk>
parents:
69876
diff
changeset
|
2796 } |
20849
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2797 |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2798 Lisp_Object |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2799 list2 (arg1, arg2) |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2800 Lisp_Object arg1, arg2; |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2801 { |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2802 return Fcons (arg1, Fcons (arg2, Qnil)); |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2803 } |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2804 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2805 |
20849
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2806 Lisp_Object |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2807 list3 (arg1, arg2, arg3) |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2808 Lisp_Object arg1, arg2, arg3; |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2809 { |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2810 return Fcons (arg1, Fcons (arg2, Fcons (arg3, Qnil))); |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2811 } |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2812 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2813 |
20849
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2814 Lisp_Object |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2815 list4 (arg1, arg2, arg3, arg4) |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2816 Lisp_Object arg1, arg2, arg3, arg4; |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2817 { |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2818 return Fcons (arg1, Fcons (arg2, Fcons (arg3, Fcons (arg4, Qnil)))); |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2819 } |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2820 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2821 |
20849
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2822 Lisp_Object |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2823 list5 (arg1, arg2, arg3, arg4, arg5) |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2824 Lisp_Object arg1, arg2, arg3, arg4, arg5; |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2825 { |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2826 return Fcons (arg1, Fcons (arg2, Fcons (arg3, Fcons (arg4, |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2827 Fcons (arg5, Qnil))))); |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2828 } |
300 | 2829 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2830 |
300 | 2831 DEFUN ("list", Flist, Slist, 0, MANY, 0, |
40977 | 2832 doc: /* Return a newly created list with specified arguments as elements. |
40113
66132b83e52a
(Fmake_byte_code, Fvector, Flist): Add usage: string to doc string.
Miles Bader <miles@gnu.org>
parents:
40107
diff
changeset
|
2833 Any number of arguments, even zero arguments, are allowed. |
66132b83e52a
(Fmake_byte_code, Fvector, Flist): Add usage: string to doc string.
Miles Bader <miles@gnu.org>
parents:
40107
diff
changeset
|
2834 usage: (list &rest OBJECTS) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2835 (nargs, args) |
300 | 2836 int nargs; |
2837 register Lisp_Object *args; | |
2838 { | |
13610
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2839 register Lisp_Object val; |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2840 val = Qnil; |
300 | 2841 |
13610
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2842 while (nargs > 0) |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2843 { |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2844 nargs--; |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2845 val = Fcons (args[nargs], val); |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2846 } |
300 | 2847 return val; |
2848 } | |
2849 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2850 |
300 | 2851 DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
2852 doc: /* Return a newly created list of length LENGTH, with each element being INIT. */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2853 (length, init) |
300 | 2854 register Lisp_Object length, init; |
2855 { | |
2856 register Lisp_Object val; | |
2857 register int size; | |
2858 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
2859 CHECK_NATNUM (length); |
9953
e0672d4cf470
(Fmake_list, Fmake_vector, Fmake_string): Use CHECK_NATNUM instead of its
Karl Heuer <kwzh@gnu.org>
parents:
9942
diff
changeset
|
2860 size = XFASTINT (length); |
300 | 2861 |
2862 val = Qnil; | |
35762
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2863 while (size > 0) |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2864 { |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2865 val = Fcons (init, val); |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2866 --size; |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2867 |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2868 if (size > 0) |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2869 { |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2870 val = Fcons (init, val); |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2871 --size; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2872 |
35762
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2873 if (size > 0) |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2874 { |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2875 val = Fcons (init, val); |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2876 --size; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2877 |
35762
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2878 if (size > 0) |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2879 { |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2880 val = Fcons (init, val); |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2881 --size; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2882 |
35762
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2883 if (size > 0) |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2884 { |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2885 val = Fcons (init, val); |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2886 --size; |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2887 } |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2888 } |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2889 } |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2890 } |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2891 |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2892 QUIT; |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2893 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2894 |
300 | 2895 return val; |
2896 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2897 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2898 |
300 | 2899 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2900 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2901 Vector Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2902 ***********************************************************************/ |
300 | 2903 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2904 /* Singly-linked list of all vectors. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2905 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
2906 static struct Lisp_Vector *all_vectors; |
300 | 2907 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2908 /* Total number of vector-like objects now in use. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2909 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
2910 static int n_vectors; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2911 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2912 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2913 /* Value is a pointer to a newly allocated Lisp_Vector structure |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2914 with room for LEN Lisp_Objects. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2915 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2916 static struct Lisp_Vector * |
84978
33b7fe948502
(enum mem_type): Replace all vector subtypes -> MEM_TYPE_VECTORLIKE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84977
diff
changeset
|
2917 allocate_vectorlike (len) |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2918 EMACS_INT len; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2919 { |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2920 struct Lisp_Vector *p; |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
2921 size_t nbytes; |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2922 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
2923 MALLOC_BLOCK_INPUT; |
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
2924 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
2925 #ifdef DOUG_LEA_MALLOC |
31576
717e7e2ca4fd
Add some comments about DOUG_LEA_MALLOC's use of mmap
Gerd Moellmann <gerd@gnu.org>
parents:
31102
diff
changeset
|
2926 /* Prevent mmap'ing the chunk. Lisp data may not be mmap'ed |
717e7e2ca4fd
Add some comments about DOUG_LEA_MALLOC's use of mmap
Gerd Moellmann <gerd@gnu.org>
parents:
31102
diff
changeset
|
2927 because mapped region contents are not preserved in |
717e7e2ca4fd
Add some comments about DOUG_LEA_MALLOC's use of mmap
Gerd Moellmann <gerd@gnu.org>
parents:
31102
diff
changeset
|
2928 a dumped Emacs. */ |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
2929 mallopt (M_MMAP_MAX, 0); |
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
2930 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2931 |
68350
263a4edafafa
(lisp_align_free): Add an assertion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
67494
diff
changeset
|
2932 /* This gets triggered by code which I haven't bothered to fix. --Stef */ |
263a4edafafa
(lisp_align_free): Add an assertion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
67494
diff
changeset
|
2933 /* eassert (!handling_signal); */ |
263a4edafafa
(lisp_align_free): Add an assertion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
67494
diff
changeset
|
2934 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2935 nbytes = sizeof *p + (len - 1) * sizeof p->contents[0]; |
84978
33b7fe948502
(enum mem_type): Replace all vector subtypes -> MEM_TYPE_VECTORLIKE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84977
diff
changeset
|
2936 p = (struct Lisp_Vector *) lisp_malloc (nbytes, MEM_TYPE_VECTORLIKE); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2937 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
2938 #ifdef DOUG_LEA_MALLOC |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2939 /* Back to a reasonable maximum of mmap'ed areas. */ |
23973
2eb9e2f5aa33
(MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
23958
diff
changeset
|
2940 mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
2941 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2942 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2943 consing_since_gc += nbytes; |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
2944 vector_cells_consed += len; |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2945 |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2946 p->next = all_vectors; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2947 all_vectors = p; |
68430
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
2948 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
2949 MALLOC_UNBLOCK_INPUT; |
68430
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
2950 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2951 ++n_vectors; |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2952 return p; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2953 } |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2954 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2955 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2956 /* Allocate a vector with NSLOTS slots. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2957 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2958 struct Lisp_Vector * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2959 allocate_vector (nslots) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2960 EMACS_INT nslots; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2961 { |
84978
33b7fe948502
(enum mem_type): Replace all vector subtypes -> MEM_TYPE_VECTORLIKE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84977
diff
changeset
|
2962 struct Lisp_Vector *v = allocate_vectorlike (nslots); |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2963 v->size = nslots; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2964 return v; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2965 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2966 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2967 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2968 /* Allocate other vector-like structures. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2969 |
86160
1ede747999c6
* alloc.c (ALLOCATE_PSEUDOVECTOR): Move to lisp.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85674
diff
changeset
|
2970 struct Lisp_Vector * |
85019
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
2971 allocate_pseudovector (memlen, lisplen, tag) |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
2972 int memlen, lisplen; |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
2973 EMACS_INT tag; |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2974 { |
85019
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
2975 struct Lisp_Vector *v = allocate_vectorlike (memlen); |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2976 EMACS_INT i; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2977 |
85019
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
2978 /* Only the first lisplen slots will be traced normally by the GC. */ |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
2979 v->size = lisplen; |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
2980 for (i = 0; i < lisplen; ++i) |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2981 v->contents[i] = Qnil; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2982 |
85019
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
2983 XSETPVECTYPE (v, tag); /* Add the appropriate tag. */ |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
2984 return v; |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
2985 } |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
2986 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2987 struct Lisp_Hash_Table * |
85021
a0c901e4e649
* lisp.h (struct Lisp_Hash_Table): Move non-traced elements at the end.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85020
diff
changeset
|
2988 allocate_hash_table (void) |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2989 { |
85021
a0c901e4e649
* lisp.h (struct Lisp_Hash_Table): Move non-traced elements at the end.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85020
diff
changeset
|
2990 return ALLOCATE_PSEUDOVECTOR (struct Lisp_Hash_Table, count, PVEC_HASH_TABLE); |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2991 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2992 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2993 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2994 struct window * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2995 allocate_window () |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2996 { |
85019
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
2997 return ALLOCATE_PSEUDOVECTOR(struct window, current_matrix, PVEC_WINDOW); |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2998 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2999 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3000 |
84693
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
3001 struct terminal * |
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
3002 allocate_terminal () |
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
3003 { |
85019
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
3004 struct terminal *t = ALLOCATE_PSEUDOVECTOR (struct terminal, |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
3005 next_terminal, PVEC_TERMINAL); |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
3006 /* Zero out the non-GC'd fields. FIXME: This should be made unnecessary. */ |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
3007 bzero (&(t->next_terminal), |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
3008 ((char*)(t+1)) - ((char*)&(t->next_terminal))); |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
3009 |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
3010 return t; |
84693
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
3011 } |
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
3012 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3013 struct frame * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3014 allocate_frame () |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3015 { |
85019
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
3016 struct frame *f = ALLOCATE_PSEUDOVECTOR (struct frame, |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
3017 face_cache, PVEC_FRAME); |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
3018 /* Zero out the non-GC'd fields. FIXME: This should be made unnecessary. */ |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
3019 bzero (&(f->face_cache), |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
3020 ((char*)(f+1)) - ((char*)&(f->face_cache))); |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
3021 return f; |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3022 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3023 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3024 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3025 struct Lisp_Process * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3026 allocate_process () |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3027 { |
85019
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
3028 return ALLOCATE_PSEUDOVECTOR (struct Lisp_Process, pid, PVEC_PROCESS); |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3029 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3030 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3031 |
300 | 3032 DEFUN ("make-vector", Fmake_vector, Smake_vector, 2, 2, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
3033 doc: /* Return a newly created vector of length LENGTH, with each element being INIT. |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
3034 See also the function `vector'. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
3035 (length, init) |
300 | 3036 register Lisp_Object length, init; |
3037 { | |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
3038 Lisp_Object vector; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
3039 register EMACS_INT sizei; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
3040 register int index; |
300 | 3041 register struct Lisp_Vector *p; |
3042 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
3043 CHECK_NATNUM (length); |
9953
e0672d4cf470
(Fmake_list, Fmake_vector, Fmake_string): Use CHECK_NATNUM instead of its
Karl Heuer <kwzh@gnu.org>
parents:
9942
diff
changeset
|
3044 sizei = XFASTINT (length); |
300 | 3045 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3046 p = allocate_vector (sizei); |
300 | 3047 for (index = 0; index < sizei; index++) |
3048 p->contents[index] = init; | |
3049 | |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
3050 XSETVECTOR (vector, p); |
300 | 3051 return vector; |
3052 } | |
3053 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3054 |
300 | 3055 DEFUN ("vector", Fvector, Svector, 0, MANY, 0, |
40977 | 3056 doc: /* Return a newly created vector with specified arguments as elements. |
40113
66132b83e52a
(Fmake_byte_code, Fvector, Flist): Add usage: string to doc string.
Miles Bader <miles@gnu.org>
parents:
40107
diff
changeset
|
3057 Any number of arguments, even zero arguments, are allowed. |
66132b83e52a
(Fmake_byte_code, Fvector, Flist): Add usage: string to doc string.
Miles Bader <miles@gnu.org>
parents:
40107
diff
changeset
|
3058 usage: (vector &rest OBJECTS) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
3059 (nargs, args) |
300 | 3060 register int nargs; |
3061 Lisp_Object *args; | |
3062 { | |
3063 register Lisp_Object len, val; | |
3064 register int index; | |
3065 register struct Lisp_Vector *p; | |
3066 | |
9295
17d393a8eed6
(free_float, make_float, free_cons, Flist, Fvector, Fmake_byte_code,
Karl Heuer <kwzh@gnu.org>
parents:
9261
diff
changeset
|
3067 XSETFASTINT (len, nargs); |
300 | 3068 val = Fmake_vector (len, Qnil); |
3069 p = XVECTOR (val); | |
3070 for (index = 0; index < nargs; index++) | |
3071 p->contents[index] = args[index]; | |
3072 return val; | |
3073 } | |
3074 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3075 |
300 | 3076 DEFUN ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
3077 doc: /* Create a byte-code object with specified arguments as elements. |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
3078 The arguments should be the arglist, bytecode-string, constant vector, |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
3079 stack size, (optional) doc string, and (optional) interactive spec. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
3080 The first four arguments are required; at most six have any |
40113
66132b83e52a
(Fmake_byte_code, Fvector, Flist): Add usage: string to doc string.
Miles Bader <miles@gnu.org>
parents:
40107
diff
changeset
|
3081 significance. |
50626
a5a77c7717cb
(Fmake_byte_code): Improve the `usage' string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50468
diff
changeset
|
3082 usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INTERACTIVE-SPEC &rest ELEMENTS) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
3083 (nargs, args) |
300 | 3084 register int nargs; |
3085 Lisp_Object *args; | |
3086 { | |
3087 register Lisp_Object len, val; | |
3088 register int index; | |
3089 register struct Lisp_Vector *p; | |
3090 | |
9295
17d393a8eed6
(free_float, make_float, free_cons, Flist, Fvector, Fmake_byte_code,
Karl Heuer <kwzh@gnu.org>
parents:
9261
diff
changeset
|
3091 XSETFASTINT (len, nargs); |
485 | 3092 if (!NILP (Vpurify_flag)) |
16101
039e96495054
(Fmake_byte_code): Call make_pure_vector using nargs.
Richard M. Stallman <rms@gnu.org>
parents:
16100
diff
changeset
|
3093 val = make_pure_vector ((EMACS_INT) nargs); |
300 | 3094 else |
3095 val = Fmake_vector (len, Qnil); | |
28997
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
3096 |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
3097 if (STRINGP (args[1]) && STRING_MULTIBYTE (args[1])) |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
3098 /* BYTECODE-STRING must have been produced by Emacs 20.2 or the |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
3099 earlier because they produced a raw 8-bit string for byte-code |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
3100 and now such a byte-code string is loaded as multibyte while |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
3101 raw 8-bit characters converted to multibyte form. Thus, now we |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
3102 must convert them back to the original unibyte form. */ |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
3103 args[1] = Fstring_as_unibyte (args[1]); |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
3104 |
300 | 3105 p = XVECTOR (val); |
3106 for (index = 0; index < nargs; index++) | |
3107 { | |
485 | 3108 if (!NILP (Vpurify_flag)) |
300 | 3109 args[index] = Fpurecopy (args[index]); |
3110 p->contents[index] = args[index]; | |
3111 } | |
85019
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
3112 XSETPVECTYPE (p, PVEC_COMPILED); |
18104
b2a669ef69b1
(Fmake_byte_code): Set val from p, not from val.
Richard M. Stallman <rms@gnu.org>
parents:
18010
diff
changeset
|
3113 XSETCOMPILED (val, p); |
300 | 3114 return val; |
3115 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3116 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3117 |
300 | 3118 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3119 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3120 Symbol Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3121 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3122 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3123 /* Each symbol_block is just under 1020 bytes long, since malloc |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3124 really allocates in units of powers of two and uses 4 bytes for its |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3125 own overhead. */ |
300 | 3126 |
3127 #define SYMBOL_BLOCK_SIZE \ | |
3128 ((1020 - sizeof (struct symbol_block *)) / sizeof (struct Lisp_Symbol)) | |
3129 | |
3130 struct symbol_block | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3131 { |
53582
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
3132 /* Place `symbols' first, to preserve alignment. */ |
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
3133 struct Lisp_Symbol symbols[SYMBOL_BLOCK_SIZE]; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3134 struct symbol_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3135 }; |
300 | 3136 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3137 /* Current symbol block and index of first unused Lisp_Symbol |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3138 structure in it. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3139 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
3140 static struct symbol_block *symbol_block; |
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
3141 static int symbol_block_index; |
300 | 3142 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3143 /* List of free symbols. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3144 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
3145 static struct Lisp_Symbol *symbol_free_list; |
300 | 3146 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
3147 /* Total number of symbol blocks now in use. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3148 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
3149 static int n_symbol_blocks; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
3150 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3151 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3152 /* Initialize symbol allocation. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3153 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
3154 static void |
300 | 3155 init_symbol () |
3156 { | |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
3157 symbol_block = NULL; |
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
3158 symbol_block_index = SYMBOL_BLOCK_SIZE; |
300 | 3159 symbol_free_list = 0; |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
3160 n_symbol_blocks = 0; |
300 | 3161 } |
3162 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3163 |
300 | 3164 DEFUN ("make-symbol", Fmake_symbol, Smake_symbol, 1, 1, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
3165 doc: /* Return a newly allocated uninterned symbol whose name is NAME. |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
3166 Its value and function definition are void, and its property list is nil. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
3167 (name) |
14093
338f645e6b9a
(Fmake_symbol): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
3168 Lisp_Object name; |
300 | 3169 { |
3170 register Lisp_Object val; | |
3171 register struct Lisp_Symbol *p; | |
3172 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
3173 CHECK_STRING (name); |
300 | 3174 |
68974
977852fb2e3b
(Fmake_symbol): Comment-out left-over assert from before we added BLOCK_INPUTs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68741
diff
changeset
|
3175 /* eassert (!handling_signal); */ |
68350
263a4edafafa
(lisp_align_free): Add an assertion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
67494
diff
changeset
|
3176 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
3177 MALLOC_BLOCK_INPUT; |
68430
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
3178 |
300 | 3179 if (symbol_free_list) |
3180 { | |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
3181 XSETSYMBOL (val, symbol_free_list); |
66889
e485868e3caf
(free_float): Make free list chaining aliasing-safe.
Andreas Schwab <schwab@suse.de>
parents:
66777
diff
changeset
|
3182 symbol_free_list = symbol_free_list->next; |
300 | 3183 } |
3184 else | |
3185 { | |
3186 if (symbol_block_index == SYMBOL_BLOCK_SIZE) | |
3187 { | |
12529 | 3188 struct symbol_block *new; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3189 new = (struct symbol_block *) lisp_malloc (sizeof *new, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3190 MEM_TYPE_SYMBOL); |
300 | 3191 new->next = symbol_block; |
3192 symbol_block = new; | |
3193 symbol_block_index = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
3194 n_symbol_blocks++; |
300 | 3195 } |
53093
e8f5463f3d5b
(make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52837
diff
changeset
|
3196 XSETSYMBOL (val, &symbol_block->symbols[symbol_block_index]); |
e8f5463f3d5b
(make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52837
diff
changeset
|
3197 symbol_block_index++; |
300 | 3198 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3199 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
3200 MALLOC_UNBLOCK_INPUT; |
68430
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
3201 |
300 | 3202 p = XSYMBOL (val); |
45392
f3d7ab65641f
* alloc.c (Fmake_symbol): Set symbol xname field instead of name.
Ken Raeburn <raeburn@raeburn.org>
parents:
44890
diff
changeset
|
3203 p->xname = name; |
300 | 3204 p->plist = Qnil; |
3205 p->value = Qunbound; | |
3206 p->function = Qunbound; | |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
3207 p->next = NULL; |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
3208 p->gcmarkbit = 0; |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
3209 p->interned = SYMBOL_UNINTERNED; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
3210 p->constant = 0; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
3211 p->indirect_variable = 0; |
300 | 3212 consing_since_gc += sizeof (struct Lisp_Symbol); |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
3213 symbols_consed++; |
300 | 3214 return val; |
3215 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3216 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3217 |
300 | 3218 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3219 /*********************************************************************** |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3220 Marker (Misc) Allocation |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3221 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3222 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3223 /* Allocation of markers and other objects that share that structure. |
300 | 3224 Works like allocation of conses. */ |
3225 | |
3226 #define MARKER_BLOCK_SIZE \ | |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3227 ((1020 - sizeof (struct marker_block *)) / sizeof (union Lisp_Misc)) |
300 | 3228 |
3229 struct marker_block | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
3230 { |
53582
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
3231 /* Place `markers' first, to preserve alignment. */ |
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
3232 union Lisp_Misc markers[MARKER_BLOCK_SIZE]; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3233 struct marker_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3234 }; |
300 | 3235 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
3236 static struct marker_block *marker_block; |
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
3237 static int marker_block_index; |
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
3238 |
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
3239 static union Lisp_Misc *marker_free_list; |
300 | 3240 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
3241 /* Total number of marker blocks now in use. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3242 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
3243 static int n_marker_blocks; |
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
3244 |
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
3245 static void |
300 | 3246 init_marker () |
3247 { | |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
3248 marker_block = NULL; |
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
3249 marker_block_index = MARKER_BLOCK_SIZE; |
300 | 3250 marker_free_list = 0; |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
3251 n_marker_blocks = 0; |
300 | 3252 } |
3253 | |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3254 /* Return a newly allocated Lisp_Misc object, with no substructure. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3255 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3256 Lisp_Object |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3257 allocate_misc () |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3258 { |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3259 Lisp_Object val; |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3260 |
68430
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
3261 /* eassert (!handling_signal); */ |
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
3262 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
3263 MALLOC_BLOCK_INPUT; |
68350
263a4edafafa
(lisp_align_free): Add an assertion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
67494
diff
changeset
|
3264 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3265 if (marker_free_list) |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3266 { |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3267 XSETMISC (val, marker_free_list); |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3268 marker_free_list = marker_free_list->u_free.chain; |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3269 } |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3270 else |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3271 { |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3272 if (marker_block_index == MARKER_BLOCK_SIZE) |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3273 { |
12529 | 3274 struct marker_block *new; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3275 new = (struct marker_block *) lisp_malloc (sizeof *new, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3276 MEM_TYPE_MISC); |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3277 new->next = marker_block; |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3278 marker_block = new; |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3279 marker_block_index = 0; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
3280 n_marker_blocks++; |
56239
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3281 total_free_markers += MARKER_BLOCK_SIZE; |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3282 } |
53093
e8f5463f3d5b
(make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52837
diff
changeset
|
3283 XSETMISC (val, &marker_block->markers[marker_block_index]); |
e8f5463f3d5b
(make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52837
diff
changeset
|
3284 marker_block_index++; |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3285 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3286 |
84977
3747382d60e9
(MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): New macros
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84954
diff
changeset
|
3287 MALLOC_UNBLOCK_INPUT; |
68430
47782d80f30b
* alloc.c (make_interval, allocate_string)
Chong Yidong <cyd@stupidchicken.com>
parents:
68398
diff
changeset
|
3288 |
56239
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3289 --total_free_markers; |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3290 consing_since_gc += sizeof (union Lisp_Misc); |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
3291 misc_objects_consed++; |
85328
d0d527210b0c
* lisp.h (enum Lisp_Misc_Type): Del Lisp_Misc_Some_Buffer_Local_Value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85023
diff
changeset
|
3292 XMISCANY (val)->gcmarkbit = 0; |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3293 return val; |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3294 } |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3295 |
56239
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3296 /* Free a Lisp_Misc object */ |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3297 |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3298 void |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3299 free_misc (misc) |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3300 Lisp_Object misc; |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3301 { |
85344
99492f857499
(free_misc): Use XMISCTYPE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85329
diff
changeset
|
3302 XMISCTYPE (misc) = Lisp_Misc_Free; |
56239
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3303 XMISC (misc)->u_free.chain = marker_free_list; |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3304 marker_free_list = XMISC (misc); |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3305 |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3306 total_free_markers++; |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3307 } |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3308 |
49055
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3309 /* Return a Lisp_Misc_Save_Value object containing POINTER and |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3310 INTEGER. This is used to package C values to call record_unwind_protect. |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3311 The unwind function can get the C values back using XSAVE_VALUE. */ |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3312 |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3313 Lisp_Object |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3314 make_save_value (pointer, integer) |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3315 void *pointer; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3316 int integer; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3317 { |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3318 register Lisp_Object val; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3319 register struct Lisp_Save_Value *p; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3320 |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3321 val = allocate_misc (); |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3322 XMISCTYPE (val) = Lisp_Misc_Save_Value; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3323 p = XSAVE_VALUE (val); |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3324 p->pointer = pointer; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3325 p->integer = integer; |
56202
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
3326 p->dogc = 0; |
49055
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3327 return val; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3328 } |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3329 |
300 | 3330 DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
3331 doc: /* Return a newly allocated marker which does not point at any place. */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
3332 () |
300 | 3333 { |
3334 register Lisp_Object val; | |
3335 register struct Lisp_Marker *p; | |
638 | 3336 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3337 val = allocate_misc (); |
11243
054ecfce1820
(Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents:
11048
diff
changeset
|
3338 XMISCTYPE (val) = Lisp_Misc_Marker; |
300 | 3339 p = XMARKER (val); |
3340 p->buffer = 0; | |
20565
aa9b7c5f0f62
(Fmake_marker): Initialize marker's bytepos and charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20495
diff
changeset
|
3341 p->bytepos = 0; |
aa9b7c5f0f62
(Fmake_marker): Initialize marker's bytepos and charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20495
diff
changeset
|
3342 p->charpos = 0; |
51668
0f333fd92a1d
(survives_gc_p): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51658
diff
changeset
|
3343 p->next = NULL; |
13008
f042ef632b22
(Fmake_marker): Initialize insertion_type to 0.
Richard M. Stallman <rms@gnu.org>
parents:
12748
diff
changeset
|
3344 p->insertion_type = 0; |
300 | 3345 return val; |
3346 } | |
19332
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
3347 |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
3348 /* Put MARKER back on the free list after using it temporarily. */ |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
3349 |
20375
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
3350 void |
19332
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
3351 free_marker (marker) |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
3352 Lisp_Object marker; |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
3353 { |
51668
0f333fd92a1d
(survives_gc_p): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51658
diff
changeset
|
3354 unchain_marker (XMARKER (marker)); |
56239
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3355 free_misc (marker); |
19332
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
3356 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3357 |
21258
693573ac0944
(make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
3358 |
300 | 3359 /* Return a newly created vector or string with specified arguments as |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
3360 elements. If all the arguments are characters that can fit |
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
3361 in a string of events, make a string; otherwise, make a vector. |
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
3362 |
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
3363 Any number of arguments, even zero arguments, are allowed. */ |
300 | 3364 |
3365 Lisp_Object | |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
3366 make_event_array (nargs, args) |
300 | 3367 register int nargs; |
3368 Lisp_Object *args; | |
3369 { | |
3370 int i; | |
3371 | |
3372 for (i = 0; i < nargs; i++) | |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
3373 /* The things that fit in a string |
3536
58d5ee6ec253
(make_event_array): Ignore bits above CHAR_META.
Richard M. Stallman <rms@gnu.org>
parents:
3181
diff
changeset
|
3374 are characters that are in 0...127, |
58d5ee6ec253
(make_event_array): Ignore bits above CHAR_META.
Richard M. Stallman <rms@gnu.org>
parents:
3181
diff
changeset
|
3375 after discarding the meta bit and all the bits above it. */ |
9144
0e29f6a4fe7c
(Fmake_list, Fmake_vector, Fmake_string, make_event_array): Use type test
Karl Heuer <kwzh@gnu.org>
parents:
8940
diff
changeset
|
3376 if (!INTEGERP (args[i]) |
3536
58d5ee6ec253
(make_event_array): Ignore bits above CHAR_META.
Richard M. Stallman <rms@gnu.org>
parents:
3181
diff
changeset
|
3377 || (XUINT (args[i]) & ~(-CHAR_META)) >= 0200) |
300 | 3378 return Fvector (nargs, args); |
3379 | |
3380 /* Since the loop exited, we know that all the things in it are | |
3381 characters, so we can make a string. */ | |
3382 { | |
6492
8372dce85f8a
(make_event_array): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6227
diff
changeset
|
3383 Lisp_Object result; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3384 |
18104
b2a669ef69b1
(Fmake_byte_code): Set val from p, not from val.
Richard M. Stallman <rms@gnu.org>
parents:
18010
diff
changeset
|
3385 result = Fmake_string (make_number (nargs), make_number (0)); |
300 | 3386 for (i = 0; i < nargs; i++) |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
3387 { |
46418
b12a32662433
* alloc.c (make_event_array): Use SSET for storing into a string.
Ken Raeburn <raeburn@raeburn.org>
parents:
46370
diff
changeset
|
3388 SSET (result, i, XINT (args[i])); |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
3389 /* Move the meta bit to the right place for a string char. */ |
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
3390 if (XINT (args[i]) & CHAR_META) |
46418
b12a32662433
* alloc.c (make_event_array): Use SSET for storing into a string.
Ken Raeburn <raeburn@raeburn.org>
parents:
46370
diff
changeset
|
3391 SSET (result, i, SREF (result, i) | 0x80); |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
3392 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3393 |
300 | 3394 return result; |
3395 } | |
3396 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3397 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3398 |
300 | 3399 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3400 /************************************************************************ |
66530
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3401 Memory Full Handling |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3402 ************************************************************************/ |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3403 |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3404 |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3405 /* Called if malloc returns zero. */ |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3406 |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3407 void |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3408 memory_full () |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3409 { |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3410 int i; |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3411 |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3412 Vmemory_full = Qt; |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3413 |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3414 memory_full_cons_threshold = sizeof (struct cons_block); |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3415 |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3416 /* The first time we get here, free the spare memory. */ |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3417 for (i = 0; i < sizeof (spare_memory) / sizeof (char *); i++) |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3418 if (spare_memory[i]) |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3419 { |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3420 if (i == 0) |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3421 free (spare_memory[i]); |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3422 else if (i >= 1 && i <= 4) |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3423 lisp_align_free (spare_memory[i]); |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3424 else |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3425 lisp_free (spare_memory[i]); |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3426 spare_memory[i] = 0; |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3427 } |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3428 |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3429 /* Record the space now used. When it decreases substantially, |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3430 we can refill the memory reserve. */ |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3431 #ifndef SYSTEM_MALLOC |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3432 bytes_used_when_full = BYTES_USED; |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3433 #endif |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3434 |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3435 /* This used to call error, but if we've run out of memory, we could |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3436 get infinite recursion trying to build the string. */ |
71967
3254b987edcb
(buffer_memory_full, memory_full): Use xsignal. Remove loop.
Kim F. Storm <storm@cua.dk>
parents:
69876
diff
changeset
|
3437 xsignal (Qnil, Vmemory_signal_data); |
66530
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3438 } |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3439 |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3440 /* If we released our reserve (due to running out of memory), |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3441 and we have a fair amount free once again, |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3442 try to set aside another reserve in case we run out once more. |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3443 |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3444 This is called when a relocatable block is freed in ralloc.c, |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3445 and also directly from this file, in case we're not using ralloc.c. */ |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3446 |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3447 void |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3448 refill_memory_reserve () |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3449 { |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3450 #ifndef SYSTEM_MALLOC |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3451 if (spare_memory[0] == 0) |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3452 spare_memory[0] = (char *) malloc ((size_t) SPARE_MEMORY); |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3453 if (spare_memory[1] == 0) |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3454 spare_memory[1] = (char *) lisp_align_malloc (sizeof (struct cons_block), |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3455 MEM_TYPE_CONS); |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3456 if (spare_memory[2] == 0) |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3457 spare_memory[2] = (char *) lisp_align_malloc (sizeof (struct cons_block), |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3458 MEM_TYPE_CONS); |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3459 if (spare_memory[3] == 0) |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3460 spare_memory[3] = (char *) lisp_align_malloc (sizeof (struct cons_block), |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3461 MEM_TYPE_CONS); |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3462 if (spare_memory[4] == 0) |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3463 spare_memory[4] = (char *) lisp_align_malloc (sizeof (struct cons_block), |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3464 MEM_TYPE_CONS); |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3465 if (spare_memory[5] == 0) |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3466 spare_memory[5] = (char *) lisp_malloc (sizeof (struct string_block), |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3467 MEM_TYPE_STRING); |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3468 if (spare_memory[6] == 0) |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3469 spare_memory[6] = (char *) lisp_malloc (sizeof (struct string_block), |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3470 MEM_TYPE_STRING); |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3471 if (spare_memory[0] && spare_memory[1] && spare_memory[5]) |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3472 Vmemory_full = Qnil; |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3473 #endif |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3474 } |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3475 |
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
3476 /************************************************************************ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3477 C Stack Marking |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3478 ************************************************************************/ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3479 |
32700
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
3480 #if GC_MARK_STACK || defined GC_MALLOC_CHECK |
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
3481 |
42403 | 3482 /* Conservative C stack marking requires a method to identify possibly |
3483 live Lisp objects given a pointer value. We do this by keeping | |
3484 track of blocks of Lisp data that are allocated in a red-black tree | |
3485 (see also the comment of mem_node which is the type of nodes in | |
3486 that tree). Function lisp_malloc adds information for an allocated | |
3487 block to the red-black tree with calls to mem_insert, and function | |
3488 lisp_free removes it with mem_delete. Functions live_string_p etc | |
3489 call mem_find to lookup information about a given pointer in the | |
3490 tree, and use that to determine if the pointer points to a Lisp | |
3491 object or not. */ | |
3492 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3493 /* Initialize this part of alloc.c. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3494 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3495 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3496 mem_init () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3497 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3498 mem_z.left = mem_z.right = MEM_NIL; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3499 mem_z.parent = NULL; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3500 mem_z.color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3501 mem_z.start = mem_z.end = NULL; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3502 mem_root = MEM_NIL; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3503 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3504 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3505 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3506 /* Value is a pointer to the mem_node containing START. Value is |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3507 MEM_NIL if there is no node in the tree containing START. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3508 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3509 static INLINE struct mem_node * |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3510 mem_find (start) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3511 void *start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3512 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3513 struct mem_node *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3514 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3515 if (start < min_heap_address || start > max_heap_address) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3516 return MEM_NIL; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3517 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3518 /* Make the search always successful to speed up the loop below. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3519 mem_z.start = start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3520 mem_z.end = (char *) start + 1; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3521 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3522 p = mem_root; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3523 while (start < p->start || start >= p->end) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3524 p = start < p->start ? p->left : p->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3525 return p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3526 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3527 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3528 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3529 /* Insert a new node into the tree for a block of memory with start |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3530 address START, end address END, and type TYPE. Value is a |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3531 pointer to the node that was inserted. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3532 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3533 static struct mem_node * |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3534 mem_insert (start, end, type) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3535 void *start, *end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3536 enum mem_type type; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3537 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3538 struct mem_node *c, *parent, *x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3539 |
77260
a6fbfb6a0580
(mem_insert): Set min_heap_address and max_heap_address
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
75406
diff
changeset
|
3540 if (min_heap_address == NULL || start < min_heap_address) |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3541 min_heap_address = start; |
77260
a6fbfb6a0580
(mem_insert): Set min_heap_address and max_heap_address
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
75406
diff
changeset
|
3542 if (max_heap_address == NULL || end > max_heap_address) |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3543 max_heap_address = end; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3544 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3545 /* See where in the tree a node for START belongs. In this |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3546 particular application, it shouldn't happen that a node is already |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3547 present. For debugging purposes, let's check that. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3548 c = mem_root; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3549 parent = NULL; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3550 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3551 #if GC_MARK_STACK != GC_MAKE_GCPROS_NOOPS |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3552 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3553 while (c != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3554 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3555 if (start >= c->start && start < c->end) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3556 abort (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3557 parent = c; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3558 c = start < c->start ? c->left : c->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3559 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3560 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3561 #else /* GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3562 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3563 while (c != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3564 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3565 parent = c; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3566 c = start < c->start ? c->left : c->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3567 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3568 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3569 #endif /* GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3570 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3571 /* Create a new node. */ |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3572 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3573 x = (struct mem_node *) _malloc_internal (sizeof *x); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3574 if (x == NULL) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3575 abort (); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3576 #else |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3577 x = (struct mem_node *) xmalloc (sizeof *x); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3578 #endif |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3579 x->start = start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3580 x->end = end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3581 x->type = type; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3582 x->parent = parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3583 x->left = x->right = MEM_NIL; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3584 x->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3585 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3586 /* Insert it as child of PARENT or install it as root. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3587 if (parent) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3588 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3589 if (start < parent->start) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3590 parent->left = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3591 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3592 parent->right = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3593 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3594 else |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3595 mem_root = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3596 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3597 /* Re-establish red-black tree properties. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3598 mem_insert_fixup (x); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3599 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3600 return x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3601 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3602 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3603 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3604 /* Re-establish the red-black properties of the tree, and thereby |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3605 balance the tree, after node X has been inserted; X is always red. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3606 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3607 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3608 mem_insert_fixup (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3609 struct mem_node *x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3610 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3611 while (x != mem_root && x->parent->color == MEM_RED) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3612 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3613 /* X is red and its parent is red. This is a violation of |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3614 red-black tree property #3. */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3615 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3616 if (x->parent == x->parent->parent->left) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3617 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3618 /* We're on the left side of our grandparent, and Y is our |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3619 "uncle". */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3620 struct mem_node *y = x->parent->parent->right; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3621 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3622 if (y->color == MEM_RED) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3623 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3624 /* Uncle and parent are red but should be black because |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3625 X is red. Change the colors accordingly and proceed |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3626 with the grandparent. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3627 x->parent->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3628 y->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3629 x->parent->parent->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3630 x = x->parent->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3631 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3632 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3633 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3634 /* Parent and uncle have different colors; parent is |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3635 red, uncle is black. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3636 if (x == x->parent->right) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3637 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3638 x = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3639 mem_rotate_left (x); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3640 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3641 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3642 x->parent->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3643 x->parent->parent->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3644 mem_rotate_right (x->parent->parent); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3645 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3646 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3647 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3648 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3649 /* This is the symmetrical case of above. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3650 struct mem_node *y = x->parent->parent->left; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3651 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3652 if (y->color == MEM_RED) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3653 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3654 x->parent->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3655 y->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3656 x->parent->parent->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3657 x = x->parent->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3658 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3659 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3660 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3661 if (x == x->parent->left) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3662 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3663 x = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3664 mem_rotate_right (x); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3665 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3666 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3667 x->parent->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3668 x->parent->parent->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3669 mem_rotate_left (x->parent->parent); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3670 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3671 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3672 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3673 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3674 /* The root may have been changed to red due to the algorithm. Set |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3675 it to black so that property #5 is satisfied. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3676 mem_root->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3677 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3678 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3679 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3680 /* (x) (y) |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3681 / \ / \ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3682 a (y) ===> (x) c |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3683 / \ / \ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3684 b c a b */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3685 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3686 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3687 mem_rotate_left (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3688 struct mem_node *x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3689 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3690 struct mem_node *y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3691 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3692 /* Turn y's left sub-tree into x's right sub-tree. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3693 y = x->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3694 x->right = y->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3695 if (y->left != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3696 y->left->parent = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3697 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3698 /* Y's parent was x's parent. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3699 if (y != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3700 y->parent = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3701 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3702 /* Get the parent to point to y instead of x. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3703 if (x->parent) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3704 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3705 if (x == x->parent->left) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3706 x->parent->left = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3707 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3708 x->parent->right = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3709 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3710 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3711 mem_root = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3712 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3713 /* Put x on y's left. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3714 y->left = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3715 if (x != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3716 x->parent = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3717 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3718 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3719 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3720 /* (x) (Y) |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3721 / \ / \ |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3722 (y) c ===> a (x) |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3723 / \ / \ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3724 a b b c */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3725 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3726 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3727 mem_rotate_right (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3728 struct mem_node *x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3729 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3730 struct mem_node *y = x->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3731 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3732 x->left = y->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3733 if (y->right != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3734 y->right->parent = x; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3735 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3736 if (y != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3737 y->parent = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3738 if (x->parent) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3739 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3740 if (x == x->parent->right) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3741 x->parent->right = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3742 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3743 x->parent->left = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3744 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3745 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3746 mem_root = y; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3747 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3748 y->right = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3749 if (x != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3750 x->parent = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3751 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3752 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3753 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3754 /* Delete node Z from the tree. If Z is null or MEM_NIL, do nothing. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3755 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3756 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3757 mem_delete (z) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3758 struct mem_node *z; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3759 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3760 struct mem_node *x, *y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3761 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3762 if (!z || z == MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3763 return; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3764 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3765 if (z->left == MEM_NIL || z->right == MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3766 y = z; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3767 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3768 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3769 y = z->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3770 while (y->left != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3771 y = y->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3772 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3773 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3774 if (y->left != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3775 x = y->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3776 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3777 x = y->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3778 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3779 x->parent = y->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3780 if (y->parent) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3781 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3782 if (y == y->parent->left) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3783 y->parent->left = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3784 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3785 y->parent->right = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3786 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3787 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3788 mem_root = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3789 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3790 if (y != z) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3791 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3792 z->start = y->start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3793 z->end = y->end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3794 z->type = y->type; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3795 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3796 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3797 if (y->color == MEM_BLACK) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3798 mem_delete_fixup (x); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3799 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3800 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3801 _free_internal (y); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3802 #else |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3803 xfree (y); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3804 #endif |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3805 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3806 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3807 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3808 /* Re-establish the red-black properties of the tree, after a |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3809 deletion. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3810 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3811 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3812 mem_delete_fixup (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3813 struct mem_node *x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3814 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3815 while (x != mem_root && x->color == MEM_BLACK) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3816 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3817 if (x == x->parent->left) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3818 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3819 struct mem_node *w = x->parent->right; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3820 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3821 if (w->color == MEM_RED) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3822 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3823 w->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3824 x->parent->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3825 mem_rotate_left (x->parent); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3826 w = x->parent->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3827 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3828 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3829 if (w->left->color == MEM_BLACK && w->right->color == MEM_BLACK) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3830 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3831 w->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3832 x = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3833 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3834 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3835 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3836 if (w->right->color == MEM_BLACK) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3837 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3838 w->left->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3839 w->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3840 mem_rotate_right (w); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3841 w = x->parent->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3842 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3843 w->color = x->parent->color; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3844 x->parent->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3845 w->right->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3846 mem_rotate_left (x->parent); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3847 x = mem_root; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3848 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3849 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3850 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3851 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3852 struct mem_node *w = x->parent->left; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3853 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3854 if (w->color == MEM_RED) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3855 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3856 w->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3857 x->parent->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3858 mem_rotate_right (x->parent); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3859 w = x->parent->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3860 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3861 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3862 if (w->right->color == MEM_BLACK && w->left->color == MEM_BLACK) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3863 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3864 w->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3865 x = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3866 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3867 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3868 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3869 if (w->left->color == MEM_BLACK) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3870 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3871 w->right->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3872 w->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3873 mem_rotate_left (w); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3874 w = x->parent->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3875 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3876 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3877 w->color = x->parent->color; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3878 x->parent->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3879 w->left->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3880 mem_rotate_right (x->parent); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3881 x = mem_root; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3882 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3883 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3884 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3885 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3886 x->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3887 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3888 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3889 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3890 /* Value is non-zero if P is a pointer to a live Lisp string on |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3891 the heap. M is a pointer to the mem_block for P. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3892 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3893 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3894 live_string_p (m, p) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3895 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3896 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3897 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3898 if (m->type == MEM_TYPE_STRING) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3899 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3900 struct string_block *b = (struct string_block *) m->start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3901 int offset = (char *) p - (char *) &b->strings[0]; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3902 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3903 /* P must point to the start of a Lisp_String structure, and it |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3904 must not be on the free-list. */ |
37049
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3905 return (offset >= 0 |
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3906 && offset % sizeof b->strings[0] == 0 |
53582
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
3907 && offset < (STRING_BLOCK_SIZE * sizeof b->strings[0]) |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3908 && ((struct Lisp_String *) p)->data != NULL); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3909 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3910 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3911 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3912 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3913 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3914 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3915 /* Value is non-zero if P is a pointer to a live Lisp cons on |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3916 the heap. M is a pointer to the mem_block for P. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3917 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3918 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3919 live_cons_p (m, p) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3920 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3921 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3922 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3923 if (m->type == MEM_TYPE_CONS) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3924 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3925 struct cons_block *b = (struct cons_block *) m->start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3926 int offset = (char *) p - (char *) &b->conses[0]; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3927 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3928 /* P must point to the start of a Lisp_Cons, not be |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3929 one of the unused cells in the current cons block, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3930 and not be on the free-list. */ |
37049
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3931 return (offset >= 0 |
53582
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
3932 && offset % sizeof b->conses[0] == 0 |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
3933 && offset < (CONS_BLOCK_SIZE * sizeof b->conses[0]) |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3934 && (b != cons_block |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3935 || offset / sizeof b->conses[0] < cons_block_index) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3936 && !EQ (((struct Lisp_Cons *) p)->car, Vdead)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3937 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3938 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3939 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3940 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3941 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3942 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3943 /* Value is non-zero if P is a pointer to a live Lisp symbol on |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3944 the heap. M is a pointer to the mem_block for P. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3945 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3946 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3947 live_symbol_p (m, p) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3948 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3949 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3950 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3951 if (m->type == MEM_TYPE_SYMBOL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3952 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3953 struct symbol_block *b = (struct symbol_block *) m->start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3954 int offset = (char *) p - (char *) &b->symbols[0]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3955 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3956 /* P must point to the start of a Lisp_Symbol, not be |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3957 one of the unused cells in the current symbol block, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3958 and not be on the free-list. */ |
37049
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3959 return (offset >= 0 |
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3960 && offset % sizeof b->symbols[0] == 0 |
53582
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
3961 && offset < (SYMBOL_BLOCK_SIZE * sizeof b->symbols[0]) |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3962 && (b != symbol_block |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3963 || offset / sizeof b->symbols[0] < symbol_block_index) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3964 && !EQ (((struct Lisp_Symbol *) p)->function, Vdead)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3965 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3966 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3967 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3968 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3969 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3970 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3971 /* Value is non-zero if P is a pointer to a live Lisp float on |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3972 the heap. M is a pointer to the mem_block for P. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3973 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3974 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3975 live_float_p (m, p) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3976 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3977 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3978 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3979 if (m->type == MEM_TYPE_FLOAT) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3980 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3981 struct float_block *b = (struct float_block *) m->start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3982 int offset = (char *) p - (char *) &b->floats[0]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3983 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
3984 /* P must point to the start of a Lisp_Float and not be |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
3985 one of the unused cells in the current float block. */ |
37049
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3986 return (offset >= 0 |
53582
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
3987 && offset % sizeof b->floats[0] == 0 |
51779
f01acdb936f9
(live_float_p): Check that p is not past the `floats' array,
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51770
diff
changeset
|
3988 && offset < (FLOAT_BLOCK_SIZE * sizeof b->floats[0]) |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3989 && (b != float_block |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
3990 || offset / sizeof b->floats[0] < float_block_index)); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3991 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3992 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3993 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3994 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3995 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3996 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3997 /* Value is non-zero if P is a pointer to a live Lisp Misc on |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3998 the heap. M is a pointer to the mem_block for P. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3999 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4000 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4001 live_misc_p (m, p) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4002 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4003 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4004 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4005 if (m->type == MEM_TYPE_MISC) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4006 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4007 struct marker_block *b = (struct marker_block *) m->start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4008 int offset = (char *) p - (char *) &b->markers[0]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4009 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4010 /* P must point to the start of a Lisp_Misc, not be |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4011 one of the unused cells in the current misc block, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4012 and not be on the free-list. */ |
37049
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
4013 return (offset >= 0 |
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
4014 && offset % sizeof b->markers[0] == 0 |
53582
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
4015 && offset < (MARKER_BLOCK_SIZE * sizeof b->markers[0]) |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4016 && (b != marker_block |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4017 || offset / sizeof b->markers[0] < marker_block_index) |
85344
99492f857499
(free_misc): Use XMISCTYPE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85329
diff
changeset
|
4018 && ((union Lisp_Misc *) p)->u_any.type != Lisp_Misc_Free); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4019 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4020 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4021 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4022 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4023 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4024 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4025 /* Value is non-zero if P is a pointer to a live vector-like object. |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4026 M is a pointer to the mem_block for P. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4027 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4028 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4029 live_vector_p (m, p) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4030 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4031 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4032 { |
84978
33b7fe948502
(enum mem_type): Replace all vector subtypes -> MEM_TYPE_VECTORLIKE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84977
diff
changeset
|
4033 return (p == m->start && m->type == MEM_TYPE_VECTORLIKE); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4034 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4035 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4036 |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
4037 /* Value is non-zero if P is a pointer to a live buffer. M is a |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4038 pointer to the mem_block for P. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4039 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4040 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4041 live_buffer_p (m, p) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4042 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4043 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4044 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4045 /* P must point to the start of the block, and the buffer |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4046 must not have been killed. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4047 return (m->type == MEM_TYPE_BUFFER |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4048 && p == m->start |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4049 && !NILP (((struct buffer *) p)->name)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4050 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4051 |
32700
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
4052 #endif /* GC_MARK_STACK || defined GC_MALLOC_CHECK */ |
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
4053 |
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
4054 #if GC_MARK_STACK |
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
4055 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4056 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4057 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4058 /* Array of objects that are kept alive because the C stack contains |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4059 a pattern that looks like a reference to them . */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4060 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4061 #define MAX_ZOMBIES 10 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4062 static Lisp_Object zombies[MAX_ZOMBIES]; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4063 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4064 /* Number of zombie objects. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4065 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4066 static int nzombies; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4067 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4068 /* Number of garbage collections. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4069 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4070 static int ngcs; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4071 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4072 /* Average percentage of zombies per collection. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4073 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4074 static double avg_zombies; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4075 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4076 /* Max. number of live and zombie objects. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4077 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4078 static int max_live, max_zombies; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4079 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4080 /* Average number of live objects per GC. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4081 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4082 static double avg_live; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4083 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4084 DEFUN ("gc-status", Fgc_status, Sgc_status, 0, 0, "", |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
4085 doc: /* Show information about live and zombie objects. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
4086 () |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4087 { |
49357 | 4088 Lisp_Object args[8], zombie_list = Qnil; |
4089 int i; | |
4090 for (i = 0; i < nzombies; i++) | |
4091 zombie_list = Fcons (zombies[i], zombie_list); | |
4092 args[0] = build_string ("%d GCs, avg live/zombies = %.2f/%.2f (%f%%), max %d/%d\nzombies: %S"); | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4093 args[1] = make_number (ngcs); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4094 args[2] = make_float (avg_live); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4095 args[3] = make_float (avg_zombies); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4096 args[4] = make_float (avg_zombies / avg_live / 100); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4097 args[5] = make_number (max_live); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4098 args[6] = make_number (max_zombies); |
49357 | 4099 args[7] = zombie_list; |
4100 return Fmessage (8, args); | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4101 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4102 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4103 #endif /* GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4104 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4105 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4106 /* Mark OBJ if we can prove it's a Lisp_Object. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4107 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4108 static INLINE void |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4109 mark_maybe_object (obj) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4110 Lisp_Object obj; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4111 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4112 void *po = (void *) XPNTR (obj); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4113 struct mem_node *m = mem_find (po); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4114 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4115 if (m != MEM_NIL) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4116 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4117 int mark_p = 0; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4118 |
90970
3371fc48749b
Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
90918
diff
changeset
|
4119 switch (XTYPE (obj)) |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4120 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4121 case Lisp_String: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4122 mark_p = (live_string_p (m, po) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4123 && !STRING_MARKED_P ((struct Lisp_String *) po)); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4124 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4125 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4126 case Lisp_Cons: |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
4127 mark_p = (live_cons_p (m, po) && !CONS_MARKED_P (XCONS (obj))); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4128 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4129 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4130 case Lisp_Symbol: |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
4131 mark_p = (live_symbol_p (m, po) && !XSYMBOL (obj)->gcmarkbit); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4132 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4133 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4134 case Lisp_Float: |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
4135 mark_p = (live_float_p (m, po) && !FLOAT_MARKED_P (XFLOAT (obj))); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4136 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4137 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4138 case Lisp_Vectorlike: |
90970
3371fc48749b
Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
90918
diff
changeset
|
4139 /* Note: can't check BUFFERP before we know it's a |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4140 buffer because checking that dereferences the pointer |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4141 PO which might point anywhere. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4142 if (live_vector_p (m, po)) |
90970
3371fc48749b
Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
90918
diff
changeset
|
4143 mark_p = !SUBRP (obj) && !VECTOR_MARKED_P (XVECTOR (obj)); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4144 else if (live_buffer_p (m, po)) |
90970
3371fc48749b
Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
90918
diff
changeset
|
4145 mark_p = BUFFERP (obj) && !VECTOR_MARKED_P (XBUFFER (obj)); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4146 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4147 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4148 case Lisp_Misc: |
85328
d0d527210b0c
* lisp.h (enum Lisp_Misc_Type): Del Lisp_Misc_Some_Buffer_Local_Value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85023
diff
changeset
|
4149 mark_p = (live_misc_p (m, po) && !XMISCANY (obj)->gcmarkbit); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4150 break; |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
4151 |
105885
8103235103a7
Let integers use up 2 tags to give them one extra bit and double their range.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105881
diff
changeset
|
4152 default: |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
4153 break; |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4154 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4155 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4156 if (mark_p) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4157 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4158 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4159 if (nzombies < MAX_ZOMBIES) |
49357 | 4160 zombies[nzombies] = obj; |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4161 ++nzombies; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4162 #endif |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4163 mark_object (obj); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4164 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4165 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4166 } |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4167 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4168 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4169 /* If P points to Lisp data, mark that as live if it isn't already |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4170 marked. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4171 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4172 static INLINE void |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4173 mark_maybe_pointer (p) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4174 void *p; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4175 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4176 struct mem_node *m; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4177 |
81798
3b39669cb653
(mark_maybe_pointer): Enforce mult-of-8 alignment when using
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81272
diff
changeset
|
4178 /* Quickly rule out some values which can't point to Lisp data. */ |
3b39669cb653
(mark_maybe_pointer): Enforce mult-of-8 alignment when using
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81272
diff
changeset
|
4179 if ((EMACS_INT) p % |
3b39669cb653
(mark_maybe_pointer): Enforce mult-of-8 alignment when using
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81272
diff
changeset
|
4180 #ifdef USE_LSB_TAG |
3b39669cb653
(mark_maybe_pointer): Enforce mult-of-8 alignment when using
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81272
diff
changeset
|
4181 8 /* USE_LSB_TAG needs Lisp data to be aligned on multiples of 8. */ |
3b39669cb653
(mark_maybe_pointer): Enforce mult-of-8 alignment when using
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81272
diff
changeset
|
4182 #else |
3b39669cb653
(mark_maybe_pointer): Enforce mult-of-8 alignment when using
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81272
diff
changeset
|
4183 2 /* We assume that Lisp data is aligned on even addresses. */ |
3b39669cb653
(mark_maybe_pointer): Enforce mult-of-8 alignment when using
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81272
diff
changeset
|
4184 #endif |
3b39669cb653
(mark_maybe_pointer): Enforce mult-of-8 alignment when using
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81272
diff
changeset
|
4185 ) |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4186 return; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4187 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4188 m = mem_find (p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4189 if (m != MEM_NIL) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4190 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4191 Lisp_Object obj = Qnil; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4192 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4193 switch (m->type) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4194 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4195 case MEM_TYPE_NON_LISP: |
36487
4df2ac60690e
(mark_maybe_pointer): Fix a typo in a comment.
Eli Zaretskii <eliz@gnu.org>
parents:
36435
diff
changeset
|
4196 /* Nothing to do; not a pointer to Lisp memory. */ |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4197 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4198 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4199 case MEM_TYPE_BUFFER: |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4200 if (live_buffer_p (m, p) && !VECTOR_MARKED_P((struct buffer *)p)) |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4201 XSETVECTOR (obj, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4202 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4203 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4204 case MEM_TYPE_CONS: |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
4205 if (live_cons_p (m, p) && !CONS_MARKED_P ((struct Lisp_Cons *) p)) |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4206 XSETCONS (obj, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4207 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4208 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4209 case MEM_TYPE_STRING: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4210 if (live_string_p (m, p) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4211 && !STRING_MARKED_P ((struct Lisp_String *) p)) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4212 XSETSTRING (obj, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4213 break; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4214 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4215 case MEM_TYPE_MISC: |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
4216 if (live_misc_p (m, p) && !((struct Lisp_Free *) p)->gcmarkbit) |
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
4217 XSETMISC (obj, p); |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4218 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4219 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4220 case MEM_TYPE_SYMBOL: |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
4221 if (live_symbol_p (m, p) && !((struct Lisp_Symbol *) p)->gcmarkbit) |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4222 XSETSYMBOL (obj, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4223 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4224 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4225 case MEM_TYPE_FLOAT: |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
4226 if (live_float_p (m, p) && !FLOAT_MARKED_P (p)) |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4227 XSETFLOAT (obj, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4228 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4229 |
84978
33b7fe948502
(enum mem_type): Replace all vector subtypes -> MEM_TYPE_VECTORLIKE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84977
diff
changeset
|
4230 case MEM_TYPE_VECTORLIKE: |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4231 if (live_vector_p (m, p)) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4232 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4233 Lisp_Object tem; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4234 XSETVECTOR (tem, p); |
90970
3371fc48749b
Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
90918
diff
changeset
|
4235 if (!SUBRP (tem) && !VECTOR_MARKED_P (XVECTOR (tem))) |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4236 obj = tem; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4237 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4238 break; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4239 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4240 default: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4241 abort (); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4242 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4243 |
90970
3371fc48749b
Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
90918
diff
changeset
|
4244 if (!NILP (obj)) |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4245 mark_object (obj); |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4246 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4247 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4248 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4249 |
73964
b684c6771753
(mark_memory): New argument OFFSET. All uses changed.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72537
diff
changeset
|
4250 /* Mark Lisp objects referenced from the address range START+OFFSET..END |
b684c6771753
(mark_memory): New argument OFFSET. All uses changed.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72537
diff
changeset
|
4251 or END+OFFSET..START. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4252 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4253 static void |
73964
b684c6771753
(mark_memory): New argument OFFSET. All uses changed.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72537
diff
changeset
|
4254 mark_memory (start, end, offset) |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4255 void *start, *end; |
73964
b684c6771753
(mark_memory): New argument OFFSET. All uses changed.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72537
diff
changeset
|
4256 int offset; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4257 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4258 Lisp_Object *p; |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4259 void **pp; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4260 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4261 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4262 nzombies = 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4263 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4264 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4265 /* Make START the pointer to the start of the memory region, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4266 if it isn't already. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4267 if (end < start) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4268 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4269 void *tem = start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4270 start = end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4271 end = tem; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4272 } |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4273 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4274 /* Mark Lisp_Objects. */ |
73964
b684c6771753
(mark_memory): New argument OFFSET. All uses changed.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72537
diff
changeset
|
4275 for (p = (Lisp_Object *) ((char *) start + offset); (void *) p < end; ++p) |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4276 mark_maybe_object (*p); |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4277 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4278 /* Mark Lisp data pointed to. This is necessary because, in some |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4279 situations, the C compiler optimizes Lisp objects away, so that |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4280 only a pointer to them remains. Example: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4281 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4282 DEFUN ("testme", Ftestme, Stestme, 0, 0, 0, "") |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
4283 () |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4284 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4285 Lisp_Object obj = build_string ("test"); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4286 struct Lisp_String *s = XSTRING (obj); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4287 Fgarbage_collect (); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4288 fprintf (stderr, "test `%s'\n", s->data); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4289 return Qnil; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4290 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4291 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4292 Here, `obj' isn't really used, and the compiler optimizes it |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4293 away. The only reference to the life string is through the |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4294 pointer `s'. */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4295 |
73964
b684c6771753
(mark_memory): New argument OFFSET. All uses changed.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72537
diff
changeset
|
4296 for (pp = (void **) ((char *) start + offset); (void *) pp < end; ++pp) |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4297 mark_maybe_pointer (*pp); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4298 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4299 |
48316 | 4300 /* setjmp will work with GCC unless NON_SAVING_SETJMP is defined in |
4301 the GCC system configuration. In gcc 3.2, the only systems for | |
4302 which this is so are i386-sco5 non-ELF, i386-sysv3 (maybe included | |
4303 by others?) and ns32k-pc532-min. */ | |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4304 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4305 #if !defined GC_SAVE_REGISTERS_ON_STACK && !defined GC_SETJMP_WORKS |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4306 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4307 static int setjmp_tested_p, longjmps_done; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4308 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4309 #define SETJMP_WILL_LIKELY_WORK "\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4310 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4311 Emacs garbage collector has been changed to use conservative stack\n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4312 marking. Emacs has determined that the method it uses to do the\n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4313 marking will likely work on your system, but this isn't sure.\n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4314 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4315 If you are a system-programmer, or can get the help of a local wizard\n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4316 who is, please take a look at the function mark_stack in alloc.c, and\n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4317 verify that the methods used are appropriate for your system.\n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4318 \n\ |
43200
4082674ce69b
(SETJMP_WILL_LIKELY_WORK, SETJMP_WILL_NOT_WORK):
Kim F. Storm <storm@cua.dk>
parents:
43161
diff
changeset
|
4319 Please mail the result to <emacs-devel@gnu.org>.\n\ |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4320 " |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4321 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4322 #define SETJMP_WILL_NOT_WORK "\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4323 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4324 Emacs garbage collector has been changed to use conservative stack\n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4325 marking. Emacs has determined that the default method it uses to do the\n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4326 marking will not work on your system. We will need a system-dependent\n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4327 solution for your system.\n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4328 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4329 Please take a look at the function mark_stack in alloc.c, and\n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4330 try to find a way to make it work on your system.\n\ |
48316 | 4331 \n\ |
4332 Note that you may get false negatives, depending on the compiler.\n\ | |
4333 In particular, you need to use -O with GCC for this test.\n\ | |
4334 \n\ | |
43200
4082674ce69b
(SETJMP_WILL_LIKELY_WORK, SETJMP_WILL_NOT_WORK):
Kim F. Storm <storm@cua.dk>
parents:
43161
diff
changeset
|
4335 Please mail the result to <emacs-devel@gnu.org>.\n\ |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4336 " |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4337 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4338 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4339 /* Perform a quick check if it looks like setjmp saves registers in a |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4340 jmp_buf. Print a message to stderr saying so. When this test |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4341 succeeds, this is _not_ a proof that setjmp is sufficient for |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4342 conservative stack marking. Only the sources or a disassembly |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4343 can prove that. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4344 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4345 static void |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4346 test_setjmp () |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4347 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4348 char buf[10]; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4349 register int x; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4350 jmp_buf jbuf; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4351 int result = 0; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4352 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4353 /* Arrange for X to be put in a register. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4354 sprintf (buf, "1"); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4355 x = strlen (buf); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4356 x = 2 * x - 1; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4357 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4358 setjmp (jbuf); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4359 if (longjmps_done == 1) |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4360 { |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4361 /* Came here after the longjmp at the end of the function. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4362 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4363 If x == 1, the longjmp has restored the register to its |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4364 value before the setjmp, and we can hope that setjmp |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4365 saves all such registers in the jmp_buf, although that |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4366 isn't sure. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4367 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4368 For other values of X, either something really strange is |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4369 taking place, or the setjmp just didn't save the register. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4370 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4371 if (x == 1) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4372 fprintf (stderr, SETJMP_WILL_LIKELY_WORK); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4373 else |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4374 { |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4375 fprintf (stderr, SETJMP_WILL_NOT_WORK); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4376 exit (1); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4377 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4378 } |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4379 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4380 ++longjmps_done; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4381 x = 2; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4382 if (longjmps_done == 1) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4383 longjmp (jbuf, 1); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4384 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4385 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4386 #endif /* not GC_SAVE_REGISTERS_ON_STACK && not GC_SETJMP_WORKS */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4387 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4388 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4389 #if GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4390 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4391 /* Abort if anything GCPRO'd doesn't survive the GC. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4392 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4393 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4394 check_gcpros () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4395 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4396 struct gcpro *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4397 int i; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4398 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4399 for (p = gcprolist; p; p = p->next) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4400 for (i = 0; i < p->nvars; ++i) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4401 if (!survives_gc_p (p->var[i])) |
50626
a5a77c7717cb
(Fmake_byte_code): Improve the `usage' string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50468
diff
changeset
|
4402 /* FIXME: It's not necessarily a bug. It might just be that the |
a5a77c7717cb
(Fmake_byte_code): Improve the `usage' string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50468
diff
changeset
|
4403 GCPRO is unnecessary or should release the object sooner. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4404 abort (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4405 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4406 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4407 #elif GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4408 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4409 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4410 dump_zombies () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4411 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4412 int i; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4413 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4414 fprintf (stderr, "\nZombies kept alive = %d:\n", nzombies); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4415 for (i = 0; i < min (MAX_ZOMBIES, nzombies); ++i) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4416 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4417 fprintf (stderr, " %d = ", i); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4418 debug_print (zombies[i]); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4419 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4420 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4421 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4422 #endif /* GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4423 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4424 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4425 /* Mark live Lisp objects on the C stack. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4426 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4427 There are several system-dependent problems to consider when |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4428 porting this to new architectures: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4429 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4430 Processor Registers |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4431 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4432 We have to mark Lisp objects in CPU registers that can hold local |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4433 variables or are used to pass parameters. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4434 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4435 If GC_SAVE_REGISTERS_ON_STACK is defined, it should expand to |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4436 something that either saves relevant registers on the stack, or |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4437 calls mark_maybe_object passing it each register's contents. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4438 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4439 If GC_SAVE_REGISTERS_ON_STACK is not defined, the current |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4440 implementation assumes that calling setjmp saves registers we need |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4441 to see in a jmp_buf which itself lies on the stack. This doesn't |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4442 have to be true! It must be verified for each system, possibly |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4443 by taking a look at the source code of setjmp. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4444 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4445 Stack Layout |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4446 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4447 Architectures differ in the way their processor stack is organized. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4448 For example, the stack might look like this |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4449 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4450 +----------------+ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4451 | Lisp_Object | size = 4 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4452 +----------------+ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4453 | something else | size = 2 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4454 +----------------+ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4455 | Lisp_Object | size = 4 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4456 +----------------+ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4457 | ... | |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4458 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4459 In such a case, not every Lisp_Object will be aligned equally. To |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4460 find all Lisp_Object on the stack it won't be sufficient to walk |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4461 the stack in steps of 4 bytes. Instead, two passes will be |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4462 necessary, one starting at the start of the stack, and a second |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4463 pass starting at the start of the stack + 2. Likewise, if the |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4464 minimal alignment of Lisp_Objects on the stack is 1, four passes |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4465 would be necessary, each one starting with one byte more offset |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4466 from the stack start. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4467 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4468 The current code assumes by default that Lisp_Objects are aligned |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4469 equally on the stack. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4470 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4471 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4472 mark_stack () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4473 { |
43160
630c8b6deafd
(mark_stack): Don't assume sizeof (Lisp_Object) is 4.
Andreas Schwab <schwab@suse.de>
parents:
43005
diff
changeset
|
4474 int i; |
73964
b684c6771753
(mark_memory): New argument OFFSET. All uses changed.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72537
diff
changeset
|
4475 /* jmp_buf may not be aligned enough on darwin-ppc64 */ |
b684c6771753
(mark_memory): New argument OFFSET. All uses changed.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72537
diff
changeset
|
4476 union aligned_jmpbuf { |
b684c6771753
(mark_memory): New argument OFFSET. All uses changed.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72537
diff
changeset
|
4477 Lisp_Object o; |
b684c6771753
(mark_memory): New argument OFFSET. All uses changed.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72537
diff
changeset
|
4478 jmp_buf j; |
b684c6771753
(mark_memory): New argument OFFSET. All uses changed.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72537
diff
changeset
|
4479 } j; |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
4480 volatile int stack_grows_down_p = (char *) &j > (char *) stack_base; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4481 void *end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4482 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4483 /* This trick flushes the register windows so that all the state of |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4484 the process is contained in the stack. */ |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
4485 /* Fixme: Code in the Boehm GC suggests flushing (with `flushrs') is |
49414
668c96afa702
(mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents:
49357
diff
changeset
|
4486 needed on ia64 too. See mach_dep.c, where it also says inline |
668c96afa702
(mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents:
49357
diff
changeset
|
4487 assembler doesn't work with relevant proprietary compilers. */ |
96545
4cb0e945175d
Use __sparc__ rather than sparc. (Bug#507.)
Glenn Morris <rgm@gnu.org>
parents:
95481
diff
changeset
|
4488 #ifdef __sparc__ |
101689
697627d7beda
(mark_stack): Properly conditionalize previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101387
diff
changeset
|
4489 #if defined (__sparc64__) && defined (__FreeBSD__) |
697627d7beda
(mark_stack): Properly conditionalize previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101387
diff
changeset
|
4490 /* FreeBSD does not have a ta 3 handler. */ |
101387
b19b16732fb0
(mark_stack): Use "flushw" instead of "ta 3" assembly call for
Chong Yidong <cyd@stupidchicken.com>
parents:
100951
diff
changeset
|
4491 asm ("flushw"); |
b19b16732fb0
(mark_stack): Use "flushw" instead of "ta 3" assembly call for
Chong Yidong <cyd@stupidchicken.com>
parents:
100951
diff
changeset
|
4492 #else |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4493 asm ("ta 3"); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4494 #endif |
101387
b19b16732fb0
(mark_stack): Use "flushw" instead of "ta 3" assembly call for
Chong Yidong <cyd@stupidchicken.com>
parents:
100951
diff
changeset
|
4495 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4496 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4497 /* Save registers that we need to see on the stack. We need to see |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4498 registers used to hold register variables and registers used to |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4499 pass parameters. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4500 #ifdef GC_SAVE_REGISTERS_ON_STACK |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4501 GC_SAVE_REGISTERS_ON_STACK (end); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4502 #else /* not GC_SAVE_REGISTERS_ON_STACK */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4503 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4504 #ifndef GC_SETJMP_WORKS /* If it hasn't been checked yet that |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4505 setjmp will definitely work, test it |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4506 and print a message with the result |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4507 of the test. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4508 if (!setjmp_tested_p) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4509 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4510 setjmp_tested_p = 1; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4511 test_setjmp (); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4512 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4513 #endif /* GC_SETJMP_WORKS */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4514 |
73964
b684c6771753
(mark_memory): New argument OFFSET. All uses changed.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72537
diff
changeset
|
4515 setjmp (j.j); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4516 end = stack_grows_down_p ? (char *) &j + sizeof j : (char *) &j; |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4517 #endif /* not GC_SAVE_REGISTERS_ON_STACK */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4518 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4519 /* This assumes that the stack is a contiguous region in memory. If |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4520 that's not the case, something has to be done here to iterate |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4521 over the stack segments. */ |
43160
630c8b6deafd
(mark_stack): Don't assume sizeof (Lisp_Object) is 4.
Andreas Schwab <schwab@suse.de>
parents:
43005
diff
changeset
|
4522 #ifndef GC_LISP_OBJECT_ALIGNMENT |
49414
668c96afa702
(mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents:
49357
diff
changeset
|
4523 #ifdef __GNUC__ |
668c96afa702
(mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents:
49357
diff
changeset
|
4524 #define GC_LISP_OBJECT_ALIGNMENT __alignof__ (Lisp_Object) |
668c96afa702
(mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents:
49357
diff
changeset
|
4525 #else |
43160
630c8b6deafd
(mark_stack): Don't assume sizeof (Lisp_Object) is 4.
Andreas Schwab <schwab@suse.de>
parents:
43005
diff
changeset
|
4526 #define GC_LISP_OBJECT_ALIGNMENT sizeof (Lisp_Object) |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4527 #endif |
49414
668c96afa702
(mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents:
49357
diff
changeset
|
4528 #endif |
43161
8a549ab185a2
Fix thinko in last change.
Andreas Schwab <schwab@suse.de>
parents:
43160
diff
changeset
|
4529 for (i = 0; i < sizeof (Lisp_Object); i += GC_LISP_OBJECT_ALIGNMENT) |
73964
b684c6771753
(mark_memory): New argument OFFSET. All uses changed.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72537
diff
changeset
|
4530 mark_memory (stack_base, end, i); |
58593
ff0c144203a1
(mark_stack): Call GC_MARK_SECONDARY_STACK if defined.
Andreas Schwab <schwab@suse.de>
parents:
57137
diff
changeset
|
4531 /* Allow for marking a secondary stack, like the register stack on the |
ff0c144203a1
(mark_stack): Call GC_MARK_SECONDARY_STACK if defined.
Andreas Schwab <schwab@suse.de>
parents:
57137
diff
changeset
|
4532 ia64. */ |
ff0c144203a1
(mark_stack): Call GC_MARK_SECONDARY_STACK if defined.
Andreas Schwab <schwab@suse.de>
parents:
57137
diff
changeset
|
4533 #ifdef GC_MARK_SECONDARY_STACK |
ff0c144203a1
(mark_stack): Call GC_MARK_SECONDARY_STACK if defined.
Andreas Schwab <schwab@suse.de>
parents:
57137
diff
changeset
|
4534 GC_MARK_SECONDARY_STACK (); |
ff0c144203a1
(mark_stack): Call GC_MARK_SECONDARY_STACK if defined.
Andreas Schwab <schwab@suse.de>
parents:
57137
diff
changeset
|
4535 #endif |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4536 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4537 #if GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4538 check_gcpros (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4539 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4540 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4541 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4542 #endif /* GC_MARK_STACK != 0 */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4543 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4544 |
72156
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4545 /* Determine whether it is safe to access memory at address P. */ |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
4546 static int |
72167 | 4547 valid_pointer_p (p) |
72156
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4548 void *p; |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4549 { |
72288 | 4550 #ifdef WINDOWSNT |
4551 return w32_valid_pointer_p (p, 16); | |
4552 #else | |
72156
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4553 int fd; |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4554 |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4555 /* Obviously, we cannot just access it (we would SEGV trying), so we |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4556 trick the o/s to tell us whether p is a valid pointer. |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4557 Unfortunately, we cannot use NULL_DEVICE here, as emacs_write may |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4558 not validate p in that case. */ |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4559 |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4560 if ((fd = emacs_open ("__Valid__Lisp__Object__", O_CREAT | O_WRONLY | O_TRUNC, 0666)) >= 0) |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4561 { |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4562 int valid = (emacs_write (fd, (char *)p, 16) == 16); |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4563 emacs_close (fd); |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4564 unlink ("__Valid__Lisp__Object__"); |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4565 return valid; |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4566 } |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4567 |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4568 return -1; |
72288 | 4569 #endif |
72156
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4570 } |
66777
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4571 |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4572 /* Return 1 if OBJ is a valid lisp object. |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4573 Return 0 if OBJ is NOT a valid lisp object. |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4574 Return -1 if we cannot validate OBJ. |
67494
28fd92314a04
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
67216
diff
changeset
|
4575 This function can be quite slow, |
28fd92314a04
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
67216
diff
changeset
|
4576 so it should only be used in code for manual debugging. */ |
66777
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4577 |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4578 int |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4579 valid_lisp_object_p (obj) |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4580 Lisp_Object obj; |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4581 { |
67216
fc58516afccd
Include fcntl.h. Define O_WRONLY if not defined.
Kim F. Storm <storm@cua.dk>
parents:
66889
diff
changeset
|
4582 void *p; |
72156
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4583 #if GC_MARK_STACK |
66777
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4584 struct mem_node *m; |
67216
fc58516afccd
Include fcntl.h. Define O_WRONLY if not defined.
Kim F. Storm <storm@cua.dk>
parents:
66889
diff
changeset
|
4585 #endif |
66777
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4586 |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4587 if (INTEGERP (obj)) |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4588 return 1; |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4589 |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4590 p = (void *) XPNTR (obj); |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4591 if (PURE_POINTER_P (p)) |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4592 return 1; |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4593 |
67216
fc58516afccd
Include fcntl.h. Define O_WRONLY if not defined.
Kim F. Storm <storm@cua.dk>
parents:
66889
diff
changeset
|
4594 #if !GC_MARK_STACK |
72156
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4595 return valid_pointer_p (p); |
67216
fc58516afccd
Include fcntl.h. Define O_WRONLY if not defined.
Kim F. Storm <storm@cua.dk>
parents:
66889
diff
changeset
|
4596 #else |
fc58516afccd
Include fcntl.h. Define O_WRONLY if not defined.
Kim F. Storm <storm@cua.dk>
parents:
66889
diff
changeset
|
4597 |
66777
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4598 m = mem_find (p); |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4599 |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4600 if (m == MEM_NIL) |
72156
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4601 { |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4602 int valid = valid_pointer_p (p); |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4603 if (valid <= 0) |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4604 return valid; |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4605 |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4606 if (SUBRP (obj)) |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4607 return 1; |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4608 |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4609 return 0; |
b4ec5a95c687
(valid_pointer_p): New function (from valid_lisp_object_p).
Kim F. Storm <storm@cua.dk>
parents:
72114
diff
changeset
|
4610 } |
66777
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4611 |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4612 switch (m->type) |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4613 { |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4614 case MEM_TYPE_NON_LISP: |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4615 return 0; |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4616 |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4617 case MEM_TYPE_BUFFER: |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4618 return live_buffer_p (m, p); |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4619 |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4620 case MEM_TYPE_CONS: |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4621 return live_cons_p (m, p); |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4622 |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4623 case MEM_TYPE_STRING: |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4624 return live_string_p (m, p); |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4625 |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4626 case MEM_TYPE_MISC: |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4627 return live_misc_p (m, p); |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4628 |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4629 case MEM_TYPE_SYMBOL: |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4630 return live_symbol_p (m, p); |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4631 |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4632 case MEM_TYPE_FLOAT: |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4633 return live_float_p (m, p); |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4634 |
84978
33b7fe948502
(enum mem_type): Replace all vector subtypes -> MEM_TYPE_VECTORLIKE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84977
diff
changeset
|
4635 case MEM_TYPE_VECTORLIKE: |
66777
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4636 return live_vector_p (m, p); |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4637 |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4638 default: |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4639 break; |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4640 } |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4641 |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4642 return 0; |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4643 #endif |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4644 } |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4645 |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4646 |
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
4647 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4648 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4649 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4650 Pure Storage Management |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4651 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4652 |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4653 /* Allocate room for SIZE bytes from pure Lisp storage and return a |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4654 pointer to it. TYPE is the Lisp type for which the memory is |
72027
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
4655 allocated. TYPE < 0 means it's not used for a Lisp object. */ |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4656 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4657 static POINTER_TYPE * |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4658 pure_alloc (size, type) |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4659 size_t size; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4660 int type; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4661 { |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4662 POINTER_TYPE *result; |
53650
5558449888ec
(lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53582
diff
changeset
|
4663 #ifdef USE_LSB_TAG |
5558449888ec
(lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53582
diff
changeset
|
4664 size_t alignment = (1 << GCTYPEBITS); |
5558449888ec
(lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53582
diff
changeset
|
4665 #else |
49159
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4666 size_t alignment = sizeof (EMACS_INT); |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4667 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4668 /* Give Lisp_Floats an extra alignment. */ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4669 if (type == Lisp_Float) |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4670 { |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4671 #if defined __GNUC__ && __GNUC__ >= 2 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4672 alignment = __alignof (struct Lisp_Float); |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4673 #else |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4674 alignment = sizeof (struct Lisp_Float); |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4675 #endif |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4676 } |
53650
5558449888ec
(lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53582
diff
changeset
|
4677 #endif |
49159
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4678 |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4679 again: |
72027
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
4680 if (type >= 0) |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
4681 { |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
4682 /* Allocate space for a Lisp object from the beginning of the free |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
4683 space with taking account of alignment. */ |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
4684 result = ALIGN (purebeg + pure_bytes_used_lisp, alignment); |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
4685 pure_bytes_used_lisp = ((char *)result - (char *)purebeg) + size; |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
4686 } |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
4687 else |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
4688 { |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
4689 /* Allocate space for a non-Lisp object from the end of the free |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
4690 space. */ |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
4691 pure_bytes_used_non_lisp += size; |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
4692 result = purebeg + pure_size - pure_bytes_used_non_lisp; |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
4693 } |
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
4694 pure_bytes_used = pure_bytes_used_lisp + pure_bytes_used_non_lisp; |
49159
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4695 |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4696 if (pure_bytes_used <= pure_size) |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4697 return result; |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4698 |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4699 /* Don't allocate a large amount here, |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4700 because it might get mmap'd and then its address |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4701 might not be usable. */ |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4702 purebeg = (char *) xmalloc (10000); |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4703 pure_size = 10000; |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4704 pure_bytes_used_before_overflow += pure_bytes_used - size; |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4705 pure_bytes_used = 0; |
72027
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
4706 pure_bytes_used_lisp = pure_bytes_used_non_lisp = 0; |
49159
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4707 goto again; |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4708 } |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4709 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4710 |
44149
a3e6cfa20afd
(check_pure_size): Update the comment.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44100
diff
changeset
|
4711 /* Print a warning if PURESIZE is too small. */ |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4712 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4713 void |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4714 check_pure_size () |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4715 { |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4716 if (pure_bytes_used_before_overflow) |
68398
cec05baae14f
(check_pure_size): Make overflow message an "error message".
Richard M. Stallman <rms@gnu.org>
parents:
68369
diff
changeset
|
4717 message ("emacs:0:Pure Lisp storage overflow (approx. %d bytes needed)", |
44100
57e965380c39
(check_pure_size): Only output a warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43751
diff
changeset
|
4718 (int) (pure_bytes_used + pure_bytes_used_before_overflow)); |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4719 } |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4720 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4721 |
72114
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4722 /* Find the byte sequence {DATA[0], ..., DATA[NBYTES-1], '\0'} from |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4723 the non-Lisp data pool of the pure storage, and return its start |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4724 address. Return NULL if not found. */ |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4725 |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4726 static char * |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4727 find_string_data_in_pure (data, nbytes) |
106950
ddd257e3f816
Make string pointer args point to const as in other string allocation functions.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
106815
diff
changeset
|
4728 const char *data; |
72114
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4729 int nbytes; |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4730 { |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4731 int i, skip, bm_skip[256], last_char_skip, infinity, start, start_max; |
106950
ddd257e3f816
Make string pointer args point to const as in other string allocation functions.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
106815
diff
changeset
|
4732 const unsigned char *p; |
72114
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4733 char *non_lisp_beg; |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4734 |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4735 if (pure_bytes_used_non_lisp < nbytes + 1) |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4736 return NULL; |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4737 |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4738 /* Set up the Boyer-Moore table. */ |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4739 skip = nbytes + 1; |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4740 for (i = 0; i < 256; i++) |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4741 bm_skip[i] = skip; |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4742 |
106950
ddd257e3f816
Make string pointer args point to const as in other string allocation functions.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
106815
diff
changeset
|
4743 p = (const unsigned char *) data; |
72114
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4744 while (--skip > 0) |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4745 bm_skip[*p++] = skip; |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4746 |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4747 last_char_skip = bm_skip['\0']; |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4748 |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4749 non_lisp_beg = purebeg + pure_size - pure_bytes_used_non_lisp; |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4750 start_max = pure_bytes_used_non_lisp - (nbytes + 1); |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4751 |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4752 /* See the comments in the function `boyer_moore' (search.c) for the |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4753 use of `infinity'. */ |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4754 infinity = pure_bytes_used_non_lisp + 1; |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4755 bm_skip['\0'] = infinity; |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4756 |
106950
ddd257e3f816
Make string pointer args point to const as in other string allocation functions.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
106815
diff
changeset
|
4757 p = (const unsigned char *) non_lisp_beg + nbytes; |
72114
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4758 start = 0; |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4759 do |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4760 { |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4761 /* Check the last character (== '\0'). */ |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4762 do |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4763 { |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4764 start += bm_skip[*(p + start)]; |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4765 } |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4766 while (start <= start_max); |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4767 |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4768 if (start < infinity) |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4769 /* Couldn't find the last character. */ |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4770 return NULL; |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4771 |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4772 /* No less than `infinity' means we could find the last |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4773 character at `p[start - infinity]'. */ |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4774 start -= infinity; |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4775 |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4776 /* Check the remaining characters. */ |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4777 if (memcmp (data, non_lisp_beg + start, nbytes) == 0) |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4778 /* Found. */ |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4779 return non_lisp_beg + start; |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4780 |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4781 start += last_char_skip; |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4782 } |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4783 while (start <= start_max); |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4784 |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4785 return NULL; |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4786 } |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4787 |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4788 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4789 /* Return a string allocated in pure space. DATA is a buffer holding |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4790 NCHARS characters, and NBYTES bytes of string data. MULTIBYTE |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4791 non-zero means make the result string multibyte. |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4792 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4793 Must get an error if pure storage is full, since if it cannot hold |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4794 a large string it may be able to hold conses that point to that |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4795 string; then the string is not protected from gc. */ |
300 | 4796 |
4797 Lisp_Object | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4798 make_pure_string (data, nchars, nbytes, multibyte) |
106950
ddd257e3f816
Make string pointer args point to const as in other string allocation functions.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
106815
diff
changeset
|
4799 const char *data; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4800 int nchars, nbytes; |
21258
693573ac0944
(make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
4801 int multibyte; |
300 | 4802 { |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4803 Lisp_Object string; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4804 struct Lisp_String *s; |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4805 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4806 s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String); |
72114
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4807 s->data = find_string_data_in_pure (data, nbytes); |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4808 if (s->data == NULL) |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4809 { |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4810 s->data = (unsigned char *) pure_alloc (nbytes + 1, -1); |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4811 bcopy (data, s->data, nbytes); |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4812 s->data[nbytes] = '\0'; |
fe7f8d2385f8
(find_string_data_in_pure): New function.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
72027
diff
changeset
|
4813 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4814 s->size = nchars; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4815 s->size_byte = multibyte ? nbytes : -1; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4816 s->intervals = NULL_INTERVAL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4817 XSETSTRING (string, s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4818 return string; |
300 | 4819 } |
4820 | |
105871
1fa408e42f53
* alloc.c (make_pure_c_string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
4821 /* Return a string a string allocated in pure space. Do not allocate |
1fa408e42f53
* alloc.c (make_pure_c_string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
4822 the string data, just point to DATA. */ |
1fa408e42f53
* alloc.c (make_pure_c_string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
4823 |
1fa408e42f53
* alloc.c (make_pure_c_string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
4824 Lisp_Object |
1fa408e42f53
* alloc.c (make_pure_c_string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
4825 make_pure_c_string (const char *data) |
1fa408e42f53
* alloc.c (make_pure_c_string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
4826 { |
1fa408e42f53
* alloc.c (make_pure_c_string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
4827 Lisp_Object string; |
1fa408e42f53
* alloc.c (make_pure_c_string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
4828 struct Lisp_String *s; |
1fa408e42f53
* alloc.c (make_pure_c_string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
4829 int nchars = strlen (data); |
1fa408e42f53
* alloc.c (make_pure_c_string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
4830 |
1fa408e42f53
* alloc.c (make_pure_c_string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
4831 s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String); |
1fa408e42f53
* alloc.c (make_pure_c_string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
4832 s->size = nchars; |
1fa408e42f53
* alloc.c (make_pure_c_string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
4833 s->size_byte = -1; |
105881
7d244791c020
(make_pure_c_string): Fix last change to avoid compiler warning.
Eli Zaretskii <eliz@gnu.org>
parents:
105877
diff
changeset
|
4834 s->data = (unsigned char *) data; |
105871
1fa408e42f53
* alloc.c (make_pure_c_string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
4835 s->intervals = NULL_INTERVAL; |
1fa408e42f53
* alloc.c (make_pure_c_string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
4836 XSETSTRING (string, s); |
1fa408e42f53
* alloc.c (make_pure_c_string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
4837 return string; |
1fa408e42f53
* alloc.c (make_pure_c_string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105669
diff
changeset
|
4838 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4839 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4840 /* Return a cons allocated from pure space. Give it pure copies |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4841 of CAR as car and CDR as cdr. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4842 |
300 | 4843 Lisp_Object |
4844 pure_cons (car, cdr) | |
4845 Lisp_Object car, cdr; | |
4846 { | |
4847 register Lisp_Object new; | |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4848 struct Lisp_Cons *p; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4849 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4850 p = (struct Lisp_Cons *) pure_alloc (sizeof *p, Lisp_Cons); |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4851 XSETCONS (new, p); |
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
4852 XSETCAR (new, Fpurecopy (car)); |
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
4853 XSETCDR (new, Fpurecopy (cdr)); |
300 | 4854 return new; |
4855 } | |
4856 | |
4857 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4858 /* Value is a float object with value NUM allocated from pure space. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4859 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
4860 static Lisp_Object |
300 | 4861 make_pure_float (num) |
4862 double num; | |
4863 { | |
4864 register Lisp_Object new; | |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4865 struct Lisp_Float *p; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4866 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4867 p = (struct Lisp_Float *) pure_alloc (sizeof *p, Lisp_Float); |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4868 XSETFLOAT (new, p); |
104313
73f76307d49b
* lisp.h (XFLOAT_DATA): Produce an rvalue by adding 0 to the value.
Ken Raeburn <raeburn@raeburn.org>
parents:
101689
diff
changeset
|
4869 XFLOAT_INIT (new, num); |
300 | 4870 return new; |
4871 } | |
4872 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4873 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4874 /* Return a vector with room for LEN Lisp_Objects allocated from |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4875 pure space. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4876 |
300 | 4877 Lisp_Object |
4878 make_pure_vector (len) | |
8817
48ff00bebef6
(pure, pure_size): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
4879 EMACS_INT len; |
300 | 4880 { |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4881 Lisp_Object new; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4882 struct Lisp_Vector *p; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4883 size_t size = sizeof *p + (len - 1) * sizeof (Lisp_Object); |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4884 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4885 p = (struct Lisp_Vector *) pure_alloc (size, Lisp_Vectorlike); |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4886 XSETVECTOR (new, p); |
300 | 4887 XVECTOR (new)->size = len; |
4888 return new; | |
4889 } | |
4890 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4891 |
300 | 4892 DEFUN ("purecopy", Fpurecopy, Spurecopy, 1, 1, 0, |
68741
2892a36e596e
(Fmake_bool_vector, Fpurecopy): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
68430
diff
changeset
|
4893 doc: /* Make a copy of object OBJ in pure storage. |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
4894 Recursively copies contents of vectors and cons cells. |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
4895 Does not copy symbols. Copies strings without text properties. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
4896 (obj) |
300 | 4897 register Lisp_Object obj; |
4898 { | |
485 | 4899 if (NILP (Vpurify_flag)) |
300 | 4900 return obj; |
4901 | |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4902 if (PURE_POINTER_P (XPNTR (obj))) |
300 | 4903 return obj; |
4904 | |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4905 if (CONSP (obj)) |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4906 return pure_cons (XCAR (obj), XCDR (obj)); |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4907 else if (FLOATP (obj)) |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4908 return make_pure_float (XFLOAT_DATA (obj)); |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4909 else if (STRINGP (obj)) |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
4910 return make_pure_string (SDATA (obj), SCHARS (obj), |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
4911 SBYTES (obj), |
21258
693573ac0944
(make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
4912 STRING_MULTIBYTE (obj)); |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4913 else if (COMPILEDP (obj) || VECTORP (obj)) |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4914 { |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4915 register struct Lisp_Vector *vec; |
53705
db8cbe59ee5c
(Fpurecopy): Declare size as EMACS_INT to not lose bits.
Andreas Schwab <schwab@suse.de>
parents:
53650
diff
changeset
|
4916 register int i; |
db8cbe59ee5c
(Fpurecopy): Declare size as EMACS_INT to not lose bits.
Andreas Schwab <schwab@suse.de>
parents:
53650
diff
changeset
|
4917 EMACS_INT size; |
300 | 4918 |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4919 size = XVECTOR (obj)->size; |
10427
5faba1b094d5
(Fpurecopy): Mask size field when copying pseudovector.
Karl Heuer <kwzh@gnu.org>
parents:
10414
diff
changeset
|
4920 if (size & PSEUDOVECTOR_FLAG) |
5faba1b094d5
(Fpurecopy): Mask size field when copying pseudovector.
Karl Heuer <kwzh@gnu.org>
parents:
10414
diff
changeset
|
4921 size &= PSEUDOVECTOR_SIZE_MASK; |
53705
db8cbe59ee5c
(Fpurecopy): Declare size as EMACS_INT to not lose bits.
Andreas Schwab <schwab@suse.de>
parents:
53650
diff
changeset
|
4922 vec = XVECTOR (make_pure_vector (size)); |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4923 for (i = 0; i < size; i++) |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4924 vec->contents[i] = Fpurecopy (XVECTOR (obj)->contents[i]); |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4925 if (COMPILEDP (obj)) |
85329
ad9922c079e4
(Fpurecopy): Set the pvec tag on pseudo vectors.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85328
diff
changeset
|
4926 { |
ad9922c079e4
(Fpurecopy): Set the pvec tag on pseudo vectors.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85328
diff
changeset
|
4927 XSETPVECTYPE (vec, PVEC_COMPILED); |
ad9922c079e4
(Fpurecopy): Set the pvec tag on pseudo vectors.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85328
diff
changeset
|
4928 XSETCOMPILED (obj, vec); |
ad9922c079e4
(Fpurecopy): Set the pvec tag on pseudo vectors.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85328
diff
changeset
|
4929 } |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4930 else |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4931 XSETVECTOR (obj, vec); |
300 | 4932 return obj; |
4933 } | |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4934 else if (MARKERP (obj)) |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4935 error ("Attempt to copy a marker to pure storage"); |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
4936 |
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
4937 return obj; |
300 | 4938 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4939 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4940 |
300 | 4941 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4942 /*********************************************************************** |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4943 Protection from GC |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4944 ***********************************************************************/ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4945 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4946 /* Put an entry in staticvec, pointing at the variable with address |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4947 VARADDRESS. */ |
300 | 4948 |
4949 void | |
4950 staticpro (varaddress) | |
4951 Lisp_Object *varaddress; | |
4952 { | |
4953 staticvec[staticidx++] = varaddress; | |
4954 if (staticidx >= NSTATICS) | |
4955 abort (); | |
4956 } | |
4957 | |
4958 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4959 /*********************************************************************** |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4960 Protection from GC |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4961 ***********************************************************************/ |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
4962 |
11374
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4963 /* Temporarily prevent garbage collection. */ |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4964 |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4965 int |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4966 inhibit_garbage_collection () |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4967 { |
46293
1fb8f75062c6
Use macro SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents:
46285
diff
changeset
|
4968 int count = SPECPDL_INDEX (); |
41867
a555c6419185
(inhibit_garbage_collection): Don't exceed value an int can hold.
Andreas Schwab <schwab@suse.de>
parents:
41831
diff
changeset
|
4969 int nbits = min (VALBITS, BITS_PER_INT); |
a555c6419185
(inhibit_garbage_collection): Don't exceed value an int can hold.
Andreas Schwab <schwab@suse.de>
parents:
41831
diff
changeset
|
4970 |
a555c6419185
(inhibit_garbage_collection): Don't exceed value an int can hold.
Andreas Schwab <schwab@suse.de>
parents:
41831
diff
changeset
|
4971 specbind (Qgc_cons_threshold, make_number (((EMACS_INT) 1 << (nbits - 1)) - 1)); |
11374
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4972 return count; |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4973 } |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4974 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4975 |
300 | 4976 DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "", |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
4977 doc: /* Reclaim storage for Lisp objects no longer needed. |
51788
43d663a05e2d
(Fgarbage_collect): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
51779
diff
changeset
|
4978 Garbage collection happens automatically if you cons more than |
43d663a05e2d
(Fgarbage_collect): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
51779
diff
changeset
|
4979 `gc-cons-threshold' bytes of Lisp data since previous garbage collection. |
43d663a05e2d
(Fgarbage_collect): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
51779
diff
changeset
|
4980 `garbage-collect' normally returns a list with info on amount of space in use: |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
4981 ((USED-CONSES . FREE-CONSES) (USED-SYMS . FREE-SYMS) |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
4982 (USED-MARKERS . FREE-MARKERS) USED-STRING-CHARS USED-VECTOR-SLOTS |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
4983 (USED-FLOATS . FREE-FLOATS) (USED-INTERVALS . FREE-INTERVALS) |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
4984 (USED-STRINGS . FREE-STRINGS)) |
51788
43d663a05e2d
(Fgarbage_collect): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
51779
diff
changeset
|
4985 However, if there was overflow in pure space, `garbage-collect' |
43d663a05e2d
(Fgarbage_collect): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
51779
diff
changeset
|
4986 returns nil, because real GC can't be done. */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
4987 () |
300 | 4988 { |
4989 register struct specbinding *bind; | |
4990 struct catchtag *catch; | |
4991 struct handler *handler; | |
4992 char stack_top_variable; | |
4993 register int i; | |
25343
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
4994 int message_p; |
34270
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
4995 Lisp_Object total[8]; |
46285
3f111801efb4
Rename BINDING_STACK_SIZE to SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents:
45392
diff
changeset
|
4996 int count = SPECPDL_INDEX (); |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4997 EMACS_TIME t1, t2, t3; |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4998 |
50745
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
4999 if (abort_on_gc) |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
5000 abort (); |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
5001 |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5002 /* Can't GC if pure storage overflowed because we can't determine |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5003 if something is a pure object or not. */ |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5004 if (pure_bytes_used_before_overflow) |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5005 return Qnil; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5006 |
61252
d24c6e8f9add
(Fgarbage_collect): Call CHECK_CONS_LIST before and after gc.
Kim F. Storm <storm@cua.dk>
parents:
61225
diff
changeset
|
5007 CHECK_CONS_LIST (); |
d24c6e8f9add
(Fgarbage_collect): Call CHECK_CONS_LIST before and after gc.
Kim F. Storm <storm@cua.dk>
parents:
61225
diff
changeset
|
5008 |
59047
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5009 /* Don't keep undo information around forever. |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5010 Do this early on, so it is no problem if the user quits. */ |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5011 { |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5012 register struct buffer *nextb = all_buffers; |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5013 |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5014 while (nextb) |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5015 { |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5016 /* If a buffer's undo list is Qt, that means that undo is |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5017 turned off in that buffer. Calling truncate_undo_list on |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5018 Qt tends to return NULL, which effectively turns undo back on. |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5019 So don't call truncate_undo_list if undo_list is Qt. */ |
59314
9c620c1aa7fa
(Fgarbage_collect): Don't truncate_undo_list on dead buffers.
Richard M. Stallman <rms@gnu.org>
parents:
59083
diff
changeset
|
5020 if (! NILP (nextb->name) && ! EQ (nextb->undo_list, Qt)) |
59047
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5021 truncate_undo_list (nextb); |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5022 |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5023 /* Shrink buffer gaps, but skip indirect and dead buffers. */ |
90774
81fa456eb1dc
(Fgarbage_collect): If nextb->text->inhibit_shrinking is
Kenichi Handa <handa@m17n.org>
parents:
90743
diff
changeset
|
5024 if (nextb->base_buffer == 0 && !NILP (nextb->name) |
81fa456eb1dc
(Fgarbage_collect): If nextb->text->inhibit_shrinking is
Kenichi Handa <handa@m17n.org>
parents:
90743
diff
changeset
|
5025 && ! nextb->text->inhibit_shrinking) |
59047
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5026 { |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5027 /* If a buffer's gap size is more than 10% of the buffer |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5028 size, or larger than 2000 bytes, then shrink it |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5029 accordingly. Keep a minimum size of 20 bytes. */ |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5030 int size = min (2000, max (20, (nextb->text->z_byte / 10))); |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5031 |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5032 if (nextb->text->gap_size > size) |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5033 { |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5034 struct buffer *save_current = current_buffer; |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5035 current_buffer = nextb; |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5036 make_gap (-(nextb->text->gap_size - size)); |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5037 current_buffer = save_current; |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5038 } |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5039 } |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5040 |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5041 nextb = nextb->next; |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5042 } |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5043 } |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5044 |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5045 EMACS_GET_TIME (t1); |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
5046 |
11892
6be0b7a0ac44
(Fgarbage_collect): Clear consing_since_gc first thing.
Karl Heuer <kwzh@gnu.org>
parents:
11727
diff
changeset
|
5047 /* In case user calls debug_print during GC, |
6be0b7a0ac44
(Fgarbage_collect): Clear consing_since_gc first thing.
Karl Heuer <kwzh@gnu.org>
parents:
11727
diff
changeset
|
5048 don't let that cause a recursive GC. */ |
6be0b7a0ac44
(Fgarbage_collect): Clear consing_since_gc first thing.
Karl Heuer <kwzh@gnu.org>
parents:
11727
diff
changeset
|
5049 consing_since_gc = 0; |
6be0b7a0ac44
(Fgarbage_collect): Clear consing_since_gc first thing.
Karl Heuer <kwzh@gnu.org>
parents:
11727
diff
changeset
|
5050 |
25343
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
5051 /* Save what's currently displayed in the echo area. */ |
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
5052 message_p = push_message (); |
47391
1afd007f814f
(Fgarbage_collect): Use pop_message_unwind.
Richard M. Stallman <rms@gnu.org>
parents:
47185
diff
changeset
|
5053 record_unwind_protect (pop_message_unwind, Qnil); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5054 |
300 | 5055 /* Save a copy of the contents of the stack, for debugging. */ |
5056 #if MAX_SAVE_STACK > 0 | |
485 | 5057 if (NILP (Vpurify_flag)) |
300 | 5058 { |
5059 i = &stack_top_variable - stack_bottom; | |
5060 if (i < 0) i = -i; | |
5061 if (i < MAX_SAVE_STACK) | |
5062 { | |
5063 if (stack_copy == 0) | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
5064 stack_copy = (char *) xmalloc (stack_copy_size = i); |
300 | 5065 else if (stack_copy_size < i) |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
5066 stack_copy = (char *) xrealloc (stack_copy, (stack_copy_size = i)); |
300 | 5067 if (stack_copy) |
5068 { | |
8817
48ff00bebef6
(pure, pure_size): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
5069 if ((EMACS_INT) (&stack_top_variable - stack_bottom) > 0) |
300 | 5070 bcopy (stack_bottom, stack_copy, i); |
5071 else | |
5072 bcopy (&stack_top_variable, stack_copy, i); | |
5073 } | |
5074 } | |
5075 } | |
5076 #endif /* MAX_SAVE_STACK > 0 */ | |
5077 | |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
5078 if (garbage_collection_messages) |
10395
c121703d35c7
(Fgarbage_collect): Don't log the GC message.
Karl Heuer <kwzh@gnu.org>
parents:
10389
diff
changeset
|
5079 message1_nolog ("Garbage collecting..."); |
300 | 5080 |
23534
6f9c70db3a58
(Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents:
22382
diff
changeset
|
5081 BLOCK_INPUT; |
6f9c70db3a58
(Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents:
22382
diff
changeset
|
5082 |
22220
a0cd311af6e3
(Fgarbage_collect): Call shrink_regexp_cache.
Richard M. Stallman <rms@gnu.org>
parents:
21948
diff
changeset
|
5083 shrink_regexp_cache (); |
a0cd311af6e3
(Fgarbage_collect): Call shrink_regexp_cache.
Richard M. Stallman <rms@gnu.org>
parents:
21948
diff
changeset
|
5084 |
300 | 5085 gc_in_progress = 1; |
5086 | |
16231 | 5087 /* clear_marks (); */ |
300 | 5088 |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
5089 /* Mark all the special slots that serve as the roots of accessibility. */ |
300 | 5090 |
5091 for (i = 0; i < staticidx; i++) | |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5092 mark_object (*staticvec[i]); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5093 |
57098
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
5094 for (bind = specpdl; bind != specpdl_ptr; bind++) |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
5095 { |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
5096 mark_object (bind->symbol); |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
5097 mark_object (bind->old_value); |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
5098 } |
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83420
diff
changeset
|
5099 mark_terminals (); |
57098
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
5100 mark_kboards (); |
83206 | 5101 mark_ttys (); |
57098
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
5102 |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
5103 #ifdef USE_GTK |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
5104 { |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
5105 extern void xg_mark_data (); |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
5106 xg_mark_data (); |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
5107 } |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
5108 #endif |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
5109 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5110 #if (GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS \ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5111 || GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5112 mark_stack (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5113 #else |
51228
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
5114 { |
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
5115 register struct gcpro *tail; |
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
5116 for (tail = gcprolist; tail; tail = tail->next) |
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
5117 for (i = 0; i < tail->nvars; i++) |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
5118 mark_object (tail->var[i]); |
51228
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
5119 } |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5120 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5121 |
26364
7b0217d9259c
(Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents:
26164
diff
changeset
|
5122 mark_byte_stack (); |
300 | 5123 for (catch = catchlist; catch; catch = catch->next) |
5124 { | |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5125 mark_object (catch->tag); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5126 mark_object (catch->val); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5127 } |
300 | 5128 for (handler = handlerlist; handler; handler = handler->next) |
5129 { | |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5130 mark_object (handler->handler); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5131 mark_object (handler->var); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5132 } |
55798
a1bb695e9a0c
(struct backtrace): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55767
diff
changeset
|
5133 mark_backtrace (); |
300 | 5134 |
59400
eeb8b96d077d
(mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents:
59359
diff
changeset
|
5135 #ifdef HAVE_WINDOW_SYSTEM |
eeb8b96d077d
(mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents:
59359
diff
changeset
|
5136 mark_fringe_data (); |
eeb8b96d077d
(mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents:
59359
diff
changeset
|
5137 #endif |
eeb8b96d077d
(mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents:
59359
diff
changeset
|
5138 |
55667
57f4a242e8f4
(Fgarbage_collect): Do all the marking before flushing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55635
diff
changeset
|
5139 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
57f4a242e8f4
(Fgarbage_collect): Do all the marking before flushing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55635
diff
changeset
|
5140 mark_stack (); |
57f4a242e8f4
(Fgarbage_collect): Do all the marking before flushing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55635
diff
changeset
|
5141 #endif |
57f4a242e8f4
(Fgarbage_collect): Do all the marking before flushing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55635
diff
changeset
|
5142 |
55816
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5143 /* Everything is now marked, except for the things that require special |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5144 finalization, i.e. the undo_list. |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5145 Look thru every buffer's undo list |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5146 for elements that update markers that were not marked, |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5147 and delete them. */ |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5148 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5149 register struct buffer *nextb = all_buffers; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5150 |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5151 while (nextb) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5152 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5153 /* If a buffer's undo list is Qt, that means that undo is |
55816
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5154 turned off in that buffer. Calling truncate_undo_list on |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5155 Qt tends to return NULL, which effectively turns undo back on. |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5156 So don't call truncate_undo_list if undo_list is Qt. */ |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5157 if (! EQ (nextb->undo_list, Qt)) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5158 { |
55816
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5159 Lisp_Object tail, prev; |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5160 tail = nextb->undo_list; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5161 prev = Qnil; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5162 while (CONSP (tail)) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5163 { |
90970
3371fc48749b
Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
90918
diff
changeset
|
5164 if (CONSP (XCAR (tail)) |
3371fc48749b
Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
90918
diff
changeset
|
5165 && MARKERP (XCAR (XCAR (tail))) |
55816
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5166 && !XMARKER (XCAR (XCAR (tail)))->gcmarkbit) |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5167 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5168 if (NILP (prev)) |
55816
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5169 nextb->undo_list = tail = XCDR (tail); |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5170 else |
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
5171 { |
55816
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5172 tail = XCDR (tail); |
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
5173 XSETCDR (prev, tail); |
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
5174 } |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5175 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5176 else |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5177 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5178 prev = tail; |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
5179 tail = XCDR (tail); |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5180 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5181 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5182 } |
55816
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5183 /* Now that we have stripped the elements that need not be in the |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5184 undo_list any more, we can finally mark the list. */ |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5185 mark_object (nextb->undo_list); |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5186 |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5187 nextb = nextb->next; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5188 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5189 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5190 |
55816
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5191 gc_sweep (); |
55767
ee3a30045908
(marker_blocks_pending_free): New var.
Kim F. Storm <storm@cua.dk>
parents:
55745
diff
changeset
|
5192 |
300 | 5193 /* Clear the mark bits that we set in certain root slots. */ |
5194 | |
26378
cbf297593a79
(Fgarbage_collect): Call unmark_byte_stack.
Gerd Moellmann <gerd@gnu.org>
parents:
26372
diff
changeset
|
5195 unmark_byte_stack (); |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5196 VECTOR_UNMARK (&buffer_defaults); |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5197 VECTOR_UNMARK (&buffer_local_symbols); |
300 | 5198 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5199 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES && 0 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5200 dump_zombies (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5201 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5202 |
23534
6f9c70db3a58
(Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents:
22382
diff
changeset
|
5203 UNBLOCK_INPUT; |
6f9c70db3a58
(Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents:
22382
diff
changeset
|
5204 |
61252
d24c6e8f9add
(Fgarbage_collect): Call CHECK_CONS_LIST before and after gc.
Kim F. Storm <storm@cua.dk>
parents:
61225
diff
changeset
|
5205 CHECK_CONS_LIST (); |
d24c6e8f9add
(Fgarbage_collect): Call CHECK_CONS_LIST before and after gc.
Kim F. Storm <storm@cua.dk>
parents:
61225
diff
changeset
|
5206 |
16231 | 5207 /* clear_marks (); */ |
300 | 5208 gc_in_progress = 0; |
5209 | |
5210 consing_since_gc = 0; | |
5211 if (gc_cons_threshold < 10000) | |
5212 gc_cons_threshold = 10000; | |
5213 | |
64267
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
5214 if (FLOATP (Vgc_cons_percentage)) |
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
5215 { /* Set gc_cons_combined_threshold. */ |
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
5216 EMACS_INT total = 0; |
64611
47f158dcf216
(gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents:
64273
diff
changeset
|
5217 |
64267
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
5218 total += total_conses * sizeof (struct Lisp_Cons); |
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
5219 total += total_symbols * sizeof (struct Lisp_Symbol); |
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
5220 total += total_markers * sizeof (union Lisp_Misc); |
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
5221 total += total_string_size; |
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
5222 total += total_vector_size * sizeof (Lisp_Object); |
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
5223 total += total_floats * sizeof (struct Lisp_Float); |
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
5224 total += total_intervals * sizeof (struct interval); |
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
5225 total += total_strings * sizeof (struct Lisp_String); |
66777
25bf8ea82843
(valid_lisp_object_p): New function to validate that
Kim F. Storm <storm@cua.dk>
parents:
66662
diff
changeset
|
5226 |
64611
47f158dcf216
(gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents:
64273
diff
changeset
|
5227 gc_relative_threshold = total * XFLOAT_DATA (Vgc_cons_percentage); |
64267
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
5228 } |
64611
47f158dcf216
(gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents:
64273
diff
changeset
|
5229 else |
47f158dcf216
(gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents:
64273
diff
changeset
|
5230 gc_relative_threshold = 0; |
64267
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
5231 |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
5232 if (garbage_collection_messages) |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
5233 { |
25343
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
5234 if (message_p || minibuf_level > 0) |
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
5235 restore_message (); |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
5236 else |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
5237 message1_nolog ("Garbage collecting...done"); |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
5238 } |
300 | 5239 |
35170
a9b677239421
(Fgarbage_collect): Use a record_unwind_protect to
Gerd Moellmann <gerd@gnu.org>
parents:
34325
diff
changeset
|
5240 unbind_to (count, Qnil); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5241 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5242 total[0] = Fcons (make_number (total_conses), |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5243 make_number (total_free_conses)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5244 total[1] = Fcons (make_number (total_symbols), |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5245 make_number (total_free_symbols)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5246 total[2] = Fcons (make_number (total_markers), |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5247 make_number (total_free_markers)); |
34270
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
5248 total[3] = make_number (total_string_size); |
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
5249 total[4] = make_number (total_vector_size); |
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
5250 total[5] = Fcons (make_number (total_floats), |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5251 make_number (total_free_floats)); |
34270
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
5252 total[6] = Fcons (make_number (total_intervals), |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5253 make_number (total_free_intervals)); |
34270
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
5254 total[7] = Fcons (make_number (total_strings), |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5255 make_number (total_free_strings)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5256 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5257 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5258 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5259 /* Compute average percentage of zombies. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5260 double nlive = 0; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5261 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5262 for (i = 0; i < 7; ++i) |
49357 | 5263 if (CONSP (total[i])) |
5264 nlive += XFASTINT (XCAR (total[i])); | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5265 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5266 avg_live = (avg_live * ngcs + nlive) / (ngcs + 1); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5267 max_live = max (nlive, max_live); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5268 avg_zombies = (avg_zombies * ngcs + nzombies) / (ngcs + 1); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5269 max_zombies = max (nzombies, max_zombies); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5270 ++ngcs; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5271 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5272 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5273 |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5274 if (!NILP (Vpost_gc_hook)) |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5275 { |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5276 int count = inhibit_garbage_collection (); |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5277 safe_run_hooks (Qpost_gc_hook); |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5278 unbind_to (count, Qnil); |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5279 } |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5280 |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5281 /* Accumulate statistics. */ |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5282 EMACS_GET_TIME (t2); |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5283 EMACS_SUB_TIME (t3, t2, t1); |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5284 if (FLOATP (Vgc_elapsed)) |
49911
d9ade23e09df
(Fgarbage_collect): Don't use XSETFLOAT.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49600
diff
changeset
|
5285 Vgc_elapsed = make_float (XFLOAT_DATA (Vgc_elapsed) + |
d9ade23e09df
(Fgarbage_collect): Don't use XSETFLOAT.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49600
diff
changeset
|
5286 EMACS_SECS (t3) + |
d9ade23e09df
(Fgarbage_collect): Don't use XSETFLOAT.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49600
diff
changeset
|
5287 EMACS_USECS (t3) * 1.0e-6); |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5288 gcs_done++; |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5289 |
34270
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
5290 return Flist (sizeof total / sizeof *total, total); |
300 | 5291 } |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5292 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5293 |
25367
823e14641544
(mark_glyph_matrix): Mark strings only.
Gerd Moellmann <gerd@gnu.org>
parents:
25343
diff
changeset
|
5294 /* Mark Lisp objects in glyph matrix MATRIX. Currently the |
823e14641544
(mark_glyph_matrix): Mark strings only.
Gerd Moellmann <gerd@gnu.org>
parents:
25343
diff
changeset
|
5295 only interesting objects referenced from glyphs are strings. */ |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5296 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5297 static void |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5298 mark_glyph_matrix (matrix) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5299 struct glyph_matrix *matrix; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5300 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5301 struct glyph_row *row = matrix->rows; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5302 struct glyph_row *end = row + matrix->nrows; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5303 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5304 for (; row < end; ++row) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5305 if (row->enabled_p) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5306 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5307 int area; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5308 for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5309 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5310 struct glyph *glyph = row->glyphs[area]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5311 struct glyph *end_glyph = glyph + row->used[area]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5312 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5313 for (; glyph < end_glyph; ++glyph) |
90970
3371fc48749b
Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
90918
diff
changeset
|
5314 if (STRINGP (glyph->object) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5315 && !STRING_MARKED_P (XSTRING (glyph->object))) |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5316 mark_object (glyph->object); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5317 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5318 } |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5319 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5320 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5321 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5322 /* Mark Lisp faces in the face cache C. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5323 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5324 static void |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5325 mark_face_cache (c) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5326 struct face_cache *c; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5327 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5328 if (c) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5329 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5330 int i, j; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5331 for (i = 0; i < c->used; ++i) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5332 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5333 struct face *face = FACE_FROM_ID (c->f, i); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5334 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5335 if (face) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5336 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5337 for (j = 0; j < LFACE_VECTOR_SIZE; ++j) |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5338 mark_object (face->lface[j]); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5339 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5340 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5341 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5342 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5343 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5344 |
300 | 5345 |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
5346 /* Mark reference to a Lisp_Object. |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5347 If the object referred to has not been seen yet, recursively mark |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5348 all the references contained in it. */ |
300 | 5349 |
1168
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
5350 #define LAST_MARKED_SIZE 500 |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
5351 static Lisp_Object last_marked[LAST_MARKED_SIZE]; |
1168
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
5352 int last_marked_index; |
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
5353 |
46833
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5354 /* For debugging--call abort when we cdr down this many |
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5355 links of a list, in mark_object. In debugging, |
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5356 the call to abort will hit a breakpoint. |
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5357 Normally this is zero and the check never goes off. */ |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
5358 static int mark_object_loop_halt; |
46833
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5359 |
105986
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5360 static void |
85019
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
5361 mark_vectorlike (ptr) |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
5362 struct Lisp_Vector *ptr; |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
5363 { |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
5364 register EMACS_INT size = ptr->size; |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
5365 register int i; |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
5366 |
105986
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5367 eassert (!VECTOR_MARKED_P (ptr)); |
85019
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
5368 VECTOR_MARK (ptr); /* Else mark it */ |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
5369 if (size & PSEUDOVECTOR_FLAG) |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
5370 size &= PSEUDOVECTOR_SIZE_MASK; |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
5371 |
85019
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
5372 /* Note that this size is not the memory-footprint size, but only |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
5373 the number of Lisp_Object fields that we should trace. |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
5374 The distinction is used e.g. by Lisp_Process which places extra |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
5375 non-Lisp_Object fields at the end of the structure. */ |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
5376 for (i = 0; i < size; i++) /* and then mark its elements */ |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
5377 mark_object (ptr->contents[i]); |
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
5378 } |
46833
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5379 |
104582
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5380 /* Like mark_vectorlike but optimized for char-tables (and |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5381 sub-char-tables) assuming that the contents are mostly integers or |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5382 symbols. */ |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5383 |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5384 static void |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5385 mark_char_table (ptr) |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5386 struct Lisp_Vector *ptr; |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5387 { |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5388 register EMACS_INT size = ptr->size & PSEUDOVECTOR_SIZE_MASK; |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5389 register int i; |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5390 |
105986
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5391 eassert (!VECTOR_MARKED_P (ptr)); |
104582
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5392 VECTOR_MARK (ptr); |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5393 for (i = 0; i < size; i++) |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5394 { |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5395 Lisp_Object val = ptr->contents[i]; |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5396 |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5397 if (INTEGERP (val) || SYMBOLP (val) && XSYMBOL (val)->gcmarkbit) |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5398 continue; |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5399 if (SUB_CHAR_TABLE_P (val)) |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5400 { |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5401 if (! VECTOR_MARKED_P (XVECTOR (val))) |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5402 mark_char_table (XVECTOR (val)); |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5403 } |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5404 else |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5405 mark_object (val); |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5406 } |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5407 } |
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5408 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5409 void |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5410 mark_object (arg) |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5411 Lisp_Object arg; |
300 | 5412 { |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5413 register Lisp_Object obj = arg; |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5414 #ifdef GC_CHECK_MARKED_OBJECTS |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5415 void *po; |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5416 struct mem_node *m; |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5417 #endif |
46833
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5418 int cdr_count = 0; |
300 | 5419 |
5868
a7bd57a60cb8
(mark_object): Fetch obj from *objptr at loop, not at the gotos.
Karl Heuer <kwzh@gnu.org>
parents:
5353
diff
changeset
|
5420 loop: |
300 | 5421 |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
5422 if (PURE_POINTER_P (XPNTR (obj))) |
300 | 5423 return; |
5424 | |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5425 last_marked[last_marked_index++] = obj; |
1168
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
5426 if (last_marked_index == LAST_MARKED_SIZE) |
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
5427 last_marked_index = 0; |
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
5428 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5429 /* Perform some sanity checks on the objects marked here. Abort if |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5430 we encounter an object we know is bogus. This increases GC time |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5431 by ~80%, and requires compilation with GC_MARK_STACK != 0. */ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5432 #ifdef GC_CHECK_MARKED_OBJECTS |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5433 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5434 po = (void *) XPNTR (obj); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5435 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5436 /* Check that the object pointed to by PO is known to be a Lisp |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5437 structure allocated from the heap. */ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5438 #define CHECK_ALLOCATED() \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5439 do { \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5440 m = mem_find (po); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5441 if (m == MEM_NIL) \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5442 abort (); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5443 } while (0) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5444 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5445 /* Check that the object pointed to by PO is live, using predicate |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5446 function LIVEP. */ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5447 #define CHECK_LIVE(LIVEP) \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5448 do { \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5449 if (!LIVEP (m, po)) \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5450 abort (); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5451 } while (0) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5452 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5453 /* Check both of the above conditions. */ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5454 #define CHECK_ALLOCATED_AND_LIVE(LIVEP) \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5455 do { \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5456 CHECK_ALLOCATED (); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5457 CHECK_LIVE (LIVEP); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5458 } while (0) \ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5459 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5460 #else /* not GC_CHECK_MARKED_OBJECTS */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5461 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5462 #define CHECK_ALLOCATED() (void) 0 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5463 #define CHECK_LIVE(LIVEP) (void) 0 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5464 #define CHECK_ALLOCATED_AND_LIVE(LIVEP) (void) 0 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5465 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5466 #endif /* not GC_CHECK_MARKED_OBJECTS */ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5467 |
90970
3371fc48749b
Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
90918
diff
changeset
|
5468 switch (SWITCH_ENUM_CAST (XTYPE (obj))) |
300 | 5469 { |
5470 case Lisp_String: | |
5471 { | |
5472 register struct Lisp_String *ptr = XSTRING (obj); | |
105986
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5473 if (STRING_MARKED_P (ptr)) |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5474 break; |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5475 CHECK_ALLOCATED_AND_LIVE (live_string_p); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5476 MARK_INTERVAL_TREE (ptr->intervals); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5477 MARK_STRING (ptr); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
5478 #ifdef GC_CHECK_STRING_BYTES |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5479 /* Check that the string size recorded in the string is the |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5480 same as the one recorded in the sdata structure. */ |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5481 CHECK_STRING_BYTES (ptr); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
5482 #endif /* GC_CHECK_STRING_BYTES */ |
300 | 5483 } |
5484 break; | |
5485 | |
10009
82f3daf76995
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
10004
diff
changeset
|
5486 case Lisp_Vectorlike: |
105986
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5487 if (VECTOR_MARKED_P (XVECTOR (obj))) |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5488 break; |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5489 #ifdef GC_CHECK_MARKED_OBJECTS |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5490 m = mem_find (po); |
90970
3371fc48749b
Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
90918
diff
changeset
|
5491 if (m == MEM_NIL && !SUBRP (obj) |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5492 && po != &buffer_defaults |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5493 && po != &buffer_local_symbols) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5494 abort (); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5495 #endif /* GC_CHECK_MARKED_OBJECTS */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5496 |
90970
3371fc48749b
Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
90918
diff
changeset
|
5497 if (BUFFERP (obj)) |
10340
ef58c7a5a4d6
(mark_object, mark_buffer): Don't mark buffer twice.
Karl Heuer <kwzh@gnu.org>
parents:
10320
diff
changeset
|
5498 { |
105986
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5499 #ifdef GC_CHECK_MARKED_OBJECTS |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5500 if (po != &buffer_defaults && po != &buffer_local_symbols) |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5501 { |
105986
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5502 struct buffer *b; |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5503 for (b = all_buffers; b && b != po; b = b->next) |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5504 ; |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5505 if (b == NULL) |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5506 abort (); |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5507 } |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5508 #endif /* GC_CHECK_MARKED_OBJECTS */ |
105986
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5509 mark_buffer (obj); |
10340
ef58c7a5a4d6
(mark_object, mark_buffer): Don't mark buffer twice.
Karl Heuer <kwzh@gnu.org>
parents:
10320
diff
changeset
|
5510 } |
90970
3371fc48749b
Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
90918
diff
changeset
|
5511 else if (SUBRP (obj)) |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5512 break; |
90970
3371fc48749b
Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
90918
diff
changeset
|
5513 else if (COMPILEDP (obj)) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5514 /* We could treat this just like a vector, but it is better to |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5515 save the COMPILED_CONSTANTS element for last and avoid |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5516 recursion there. */ |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5517 { |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5518 register struct Lisp_Vector *ptr = XVECTOR (obj); |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5519 register EMACS_INT size = ptr->size; |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5520 register int i; |
300 | 5521 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5522 CHECK_LIVE (live_vector_p); |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5523 VECTOR_MARK (ptr); /* Else mark it */ |
10009
82f3daf76995
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
10004
diff
changeset
|
5524 size &= PSEUDOVECTOR_SIZE_MASK; |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5525 for (i = 0; i < size; i++) /* and then mark its elements */ |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5526 { |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5527 if (i != COMPILED_CONSTANTS) |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5528 mark_object (ptr->contents[i]); |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5529 } |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5530 obj = ptr->contents[COMPILED_CONSTANTS]; |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5531 goto loop; |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5532 } |
90970
3371fc48749b
Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
90918
diff
changeset
|
5533 else if (FRAMEP (obj)) |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5534 { |
32360
d8b668a486d7
(mark_object): Remove all workarounds installed on
Andreas Schwab <schwab@suse.de>
parents:
32099
diff
changeset
|
5535 register struct frame *ptr = XFRAME (obj); |
105986
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5536 mark_vectorlike (XVECTOR (obj)); |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5537 mark_face_cache (ptr->face_cache); |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5538 } |
90970
3371fc48749b
Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
90918
diff
changeset
|
5539 else if (WINDOWP (obj)) |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5540 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5541 register struct Lisp_Vector *ptr = XVECTOR (obj); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5542 struct window *w = XWINDOW (obj); |
105986
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5543 mark_vectorlike (ptr); |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5544 /* Mark glyphs for leaf windows. Marking window matrices is |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5545 sufficient because frame matrices use the same glyph |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5546 memory. */ |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5547 if (NILP (w->hchild) |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5548 && NILP (w->vchild) |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5549 && w->current_matrix) |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5550 { |
105986
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5551 mark_glyph_matrix (w->current_matrix); |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5552 mark_glyph_matrix (w->desired_matrix); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5553 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5554 } |
90970
3371fc48749b
Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
90918
diff
changeset
|
5555 else if (HASH_TABLE_P (obj)) |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5556 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5557 struct Lisp_Hash_Table *h = XHASH_TABLE (obj); |
105986
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5558 mark_vectorlike ((struct Lisp_Vector *)h); |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5559 /* If hash table is not weak, mark all keys and values. |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5560 For weak tables, mark only the vector. */ |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5561 if (NILP (h->weak)) |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5562 mark_object (h->key_and_value); |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5563 else |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5564 VECTOR_MARK (XVECTOR (h->key_and_value)); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5565 } |
104582
7d47cb148b29
(mark_char_table): New function.
Kenichi Handa <handa@m17n.org>
parents:
104313
diff
changeset
|
5566 else if (CHAR_TABLE_P (obj)) |
105986
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5567 mark_char_table (XVECTOR (obj)); |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5568 else |
85019
21a145f18ed2
(allocate_pseudovector): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84978
diff
changeset
|
5569 mark_vectorlike (XVECTOR (obj)); |
300 | 5570 break; |
5571 | |
5572 case Lisp_Symbol: | |
5573 { | |
32360
d8b668a486d7
(mark_object): Remove all workarounds installed on
Andreas Schwab <schwab@suse.de>
parents:
32099
diff
changeset
|
5574 register struct Lisp_Symbol *ptr = XSYMBOL (obj); |
300 | 5575 struct Lisp_Symbol *ptrx; |
5576 | |
105986
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5577 if (ptr->gcmarkbit) |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5578 break; |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5579 CHECK_ALLOCATED_AND_LIVE (live_symbol_p); |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5580 ptr->gcmarkbit = 1; |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5581 mark_object (ptr->value); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5582 mark_object (ptr->function); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5583 mark_object (ptr->plist); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5584 |
45392
f3d7ab65641f
* alloc.c (Fmake_symbol): Set symbol xname field instead of name.
Ken Raeburn <raeburn@raeburn.org>
parents:
44890
diff
changeset
|
5585 if (!PURE_POINTER_P (XSTRING (ptr->xname))) |
f3d7ab65641f
* alloc.c (Fmake_symbol): Set symbol xname field instead of name.
Ken Raeburn <raeburn@raeburn.org>
parents:
44890
diff
changeset
|
5586 MARK_STRING (XSTRING (ptr->xname)); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
5587 MARK_INTERVAL_TREE (STRING_INTERVALS (ptr->xname)); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5588 |
20768 | 5589 /* Note that we do not mark the obarray of the symbol. |
5590 It is safe not to do so because nothing accesses that | |
5591 slot except to check whether it is nil. */ | |
300 | 5592 ptr = ptr->next; |
5593 if (ptr) | |
5594 { | |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
5595 ptrx = ptr; /* Use of ptrx avoids compiler bug on Sun */ |
300 | 5596 XSETSYMBOL (obj, ptrx); |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5597 goto loop; |
300 | 5598 } |
5599 } | |
5600 break; | |
5601 | |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
5602 case Lisp_Misc: |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5603 CHECK_ALLOCATED_AND_LIVE (live_misc_p); |
85328
d0d527210b0c
* lisp.h (enum Lisp_Misc_Type): Del Lisp_Misc_Some_Buffer_Local_Value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85023
diff
changeset
|
5604 if (XMISCANY (obj)->gcmarkbit) |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5605 break; |
85328
d0d527210b0c
* lisp.h (enum Lisp_Misc_Type): Del Lisp_Misc_Some_Buffer_Local_Value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85023
diff
changeset
|
5606 XMISCANY (obj)->gcmarkbit = 1; |
56202
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5607 |
11243
054ecfce1820
(Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents:
11048
diff
changeset
|
5608 switch (XMISCTYPE (obj)) |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
5609 { |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5610 case Lisp_Misc_Buffer_Local_Value: |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5611 { |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5612 register struct Lisp_Buffer_Local_Value *ptr |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5613 = XBUFFER_LOCAL_VALUE (obj); |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5614 /* If the cdr is nil, avoid recursion for the car. */ |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5615 if (EQ (ptr->cdr, Qnil)) |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5616 { |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5617 obj = ptr->realvalue; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5618 goto loop; |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5619 } |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5620 mark_object (ptr->realvalue); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5621 mark_object (ptr->buffer); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5622 mark_object (ptr->frame); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5623 obj = ptr->cdr; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5624 goto loop; |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5625 } |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5626 |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5627 case Lisp_Misc_Marker: |
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5628 /* DO NOT mark thru the marker's chain. |
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5629 The buffer's markers chain does not preserve markers from gc; |
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5630 instead, markers are removed from the chain when freed by gc. */ |
56202
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5631 break; |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5632 |
9463
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
5633 case Lisp_Misc_Intfwd: |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
5634 case Lisp_Misc_Boolfwd: |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
5635 case Lisp_Misc_Objfwd: |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
5636 case Lisp_Misc_Buffer_Objfwd: |
11018
2d9bdf1ba3d1
(mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents:
10936
diff
changeset
|
5637 case Lisp_Misc_Kboard_Objfwd: |
9463
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
5638 /* Don't bother with Lisp_Buffer_Objfwd, |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
5639 since all markable slots in current buffer marked anyway. */ |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
5640 /* Don't need to do Lisp_Objfwd, since the places they point |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
5641 are protected with staticpro. */ |
56202
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5642 break; |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5643 |
52166
25f780eb3fd8
(mark_object): Handle Lisp_Misc_Save_Value.
Andreas Schwab <schwab@suse.de>
parents:
51985
diff
changeset
|
5644 case Lisp_Misc_Save_Value: |
56401
1529ab7bab88
(mark_object): Only look at Lisp_Misc_Save_Value if GC_MARK_STACK.
Kim F. Storm <storm@cua.dk>
parents:
56239
diff
changeset
|
5645 #if GC_MARK_STACK |
56202
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5646 { |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5647 register struct Lisp_Save_Value *ptr = XSAVE_VALUE (obj); |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5648 /* If DOGC is set, POINTER is the address of a memory |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5649 area containing INTEGER potential Lisp_Objects. */ |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5650 if (ptr->dogc) |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5651 { |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5652 Lisp_Object *p = (Lisp_Object *) ptr->pointer; |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5653 int nelt; |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5654 for (nelt = ptr->integer; nelt > 0; nelt--, p++) |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5655 mark_maybe_object (*p); |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5656 } |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5657 } |
56401
1529ab7bab88
(mark_object): Only look at Lisp_Misc_Save_Value if GC_MARK_STACK.
Kim F. Storm <storm@cua.dk>
parents:
56239
diff
changeset
|
5658 #endif |
9463
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
5659 break; |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
5660 |
9926
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
5661 case Lisp_Misc_Overlay: |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
5662 { |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
5663 struct Lisp_Overlay *ptr = XOVERLAY (obj); |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5664 mark_object (ptr->start); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5665 mark_object (ptr->end); |
51843
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5666 mark_object (ptr->plist); |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5667 if (ptr->next) |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5668 { |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5669 XSETMISC (obj, ptr->next); |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5670 goto loop; |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5671 } |
9926
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
5672 } |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
5673 break; |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
5674 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
5675 default: |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
5676 abort (); |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
5677 } |
300 | 5678 break; |
5679 | |
5680 case Lisp_Cons: | |
5681 { | |
5682 register struct Lisp_Cons *ptr = XCONS (obj); | |
105986
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5683 if (CONS_MARKED_P (ptr)) |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5684 break; |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5685 CHECK_ALLOCATED_AND_LIVE (live_cons_p); |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5686 CONS_MARK (ptr); |
1295
a9241dc503ab
(mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents:
1168
diff
changeset
|
5687 /* If the cdr is nil, avoid recursion for the car. */ |
66889
e485868e3caf
(free_float): Make free list chaining aliasing-safe.
Andreas Schwab <schwab@suse.de>
parents:
66777
diff
changeset
|
5688 if (EQ (ptr->u.cdr, Qnil)) |
1295
a9241dc503ab
(mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents:
1168
diff
changeset
|
5689 { |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5690 obj = ptr->car; |
46833
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5691 cdr_count = 0; |
1295
a9241dc503ab
(mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents:
1168
diff
changeset
|
5692 goto loop; |
a9241dc503ab
(mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents:
1168
diff
changeset
|
5693 } |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5694 mark_object (ptr->car); |
66889
e485868e3caf
(free_float): Make free list chaining aliasing-safe.
Andreas Schwab <schwab@suse.de>
parents:
66777
diff
changeset
|
5695 obj = ptr->u.cdr; |
46833
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5696 cdr_count++; |
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5697 if (cdr_count == mark_object_loop_halt) |
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5698 abort (); |
300 | 5699 goto loop; |
5700 } | |
5701 | |
5702 case Lisp_Float: | |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5703 CHECK_ALLOCATED_AND_LIVE (live_float_p); |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
5704 FLOAT_MARK (XFLOAT (obj)); |
300 | 5705 break; |
5706 | |
105885
8103235103a7
Let integers use up 2 tags to give them one extra bit and double their range.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105881
diff
changeset
|
5707 case_Lisp_Int: |
300 | 5708 break; |
5709 | |
5710 default: | |
5711 abort (); | |
5712 } | |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5713 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5714 #undef CHECK_LIVE |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5715 #undef CHECK_ALLOCATED |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5716 #undef CHECK_ALLOCATED_AND_LIVE |
300 | 5717 } |
5718 | |
5719 /* Mark the pointers in a buffer structure. */ | |
5720 | |
5721 static void | |
5722 mark_buffer (buf) | |
5723 Lisp_Object buf; | |
5724 { | |
5725 register struct buffer *buffer = XBUFFER (buf); | |
51843
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5726 register Lisp_Object *ptr, tmp; |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5727 Lisp_Object base_buffer; |
300 | 5728 |
105986
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5729 eassert (!VECTOR_MARKED_P (buffer)); |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5730 VECTOR_MARK (buffer); |
300 | 5731 |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5732 MARK_INTERVAL_TREE (BUF_INTERVALS (buffer)); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5733 |
55816
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5734 /* For now, we just don't mark the undo_list. It's done later in |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5735 a special way just before the sweep phase, and after stripping |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5736 some of its elements that are not needed any more. */ |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5737 |
51843
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5738 if (buffer->overlays_before) |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5739 { |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5740 XSETMISC (tmp, buffer->overlays_before); |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5741 mark_object (tmp); |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5742 } |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5743 if (buffer->overlays_after) |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5744 { |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5745 XSETMISC (tmp, buffer->overlays_after); |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5746 mark_object (tmp); |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5747 } |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5748 |
91780
d097bc79fdfb
(mark_buffer): Comment fix to clarify the status of Lisp fields.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91367
diff
changeset
|
5749 /* buffer-local Lisp variables start at `undo_list', |
d097bc79fdfb
(mark_buffer): Comment fix to clarify the status of Lisp fields.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91367
diff
changeset
|
5750 tho only the ones from `name' on are GC'd normally. */ |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5751 for (ptr = &buffer->name; |
300 | 5752 (char *)ptr < (char *)buffer + sizeof (struct buffer); |
5753 ptr++) | |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5754 mark_object (*ptr); |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5755 |
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5756 /* If this is an indirect buffer, mark its base buffer. */ |
51686
17c015f1f795
(mark_buffer): Fix missed buffer->name in last patch.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51683
diff
changeset
|
5757 if (buffer->base_buffer && !VECTOR_MARKED_P (buffer->base_buffer)) |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5758 { |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5759 XSETBUFFER (base_buffer, buffer->base_buffer); |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5760 mark_buffer (base_buffer); |
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5761 } |
300 | 5762 } |
10649
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
5763 |
84693
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
5764 /* Mark the Lisp pointers in the terminal objects. |
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
5765 Called by the Fgarbage_collector. */ |
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
5766 |
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
5767 static void |
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
5768 mark_terminals (void) |
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
5769 { |
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
5770 struct terminal *t; |
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
5771 for (t = terminal_list; t; t = t->next_terminal) |
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
5772 { |
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
5773 eassert (t->name != NULL); |
105986
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5774 if (!VECTOR_MARKED_P (t)) |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5775 { |
92109
4d9fc08769fa
Consolidate the image_cache to the terminal struct.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91780
diff
changeset
|
5776 #ifdef HAVE_WINDOW_SYSTEM |
105986
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5777 mark_image_cache (t->image_cache); |
92109
4d9fc08769fa
Consolidate the image_cache to the terminal struct.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91780
diff
changeset
|
5778 #endif /* HAVE_WINDOW_SYSTEM */ |
105986
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5779 mark_vectorlike ((struct Lisp_Vector *)t); |
850debe3a245
(mark_object): Don't reprocess marked strings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105958
diff
changeset
|
5780 } |
84693
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
5781 } |
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
5782 } |
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
5783 |
7ee574475f20
(enum mem_type): New member for `terminal' objects.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84602
diff
changeset
|
5784 |
10649
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
5785 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5786 /* Value is non-zero if OBJ will survive the current GC because it's |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5787 either marked or does not need to be marked to survive. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5788 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5789 int |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5790 survives_gc_p (obj) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5791 Lisp_Object obj; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5792 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5793 int survives_p; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5794 |
90970
3371fc48749b
Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
90918
diff
changeset
|
5795 switch (XTYPE (obj)) |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5796 { |
105885
8103235103a7
Let integers use up 2 tags to give them one extra bit and double their range.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105881
diff
changeset
|
5797 case_Lisp_Int: |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5798 survives_p = 1; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5799 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5800 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5801 case Lisp_Symbol: |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5802 survives_p = XSYMBOL (obj)->gcmarkbit; |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5803 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5804 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5805 case Lisp_Misc: |
85328
d0d527210b0c
* lisp.h (enum Lisp_Misc_Type): Del Lisp_Misc_Some_Buffer_Local_Value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85023
diff
changeset
|
5806 survives_p = XMISCANY (obj)->gcmarkbit; |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5807 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5808 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5809 case Lisp_String: |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5810 survives_p = STRING_MARKED_P (XSTRING (obj)); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5811 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5812 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5813 case Lisp_Vectorlike: |
90970
3371fc48749b
Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
90918
diff
changeset
|
5814 survives_p = SUBRP (obj) || VECTOR_MARKED_P (XVECTOR (obj)); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5815 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5816 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5817 case Lisp_Cons: |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5818 survives_p = CONS_MARKED_P (XCONS (obj)); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5819 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5820 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5821 case Lisp_Float: |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
5822 survives_p = FLOAT_MARKED_P (XFLOAT (obj)); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5823 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5824 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5825 default: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5826 abort (); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5827 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5828 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5829 return survives_p || PURE_POINTER_P ((void *) XPNTR (obj)); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5830 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5831 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5832 |
300 | 5833 |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
5834 /* Sweep: find all structures not marked, and free them. */ |
300 | 5835 |
5836 static void | |
5837 gc_sweep () | |
5838 { | |
55816
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5839 /* Remove or mark entries in weak hash tables. |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5840 This must be done before any object is unmarked. */ |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5841 sweep_weak_hash_tables (); |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5842 |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5843 sweep_strings (); |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5844 #ifdef GC_CHECK_STRING_BYTES |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5845 if (!noninteractive) |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5846 check_string_bytes (1); |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5847 #endif |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5848 |
300 | 5849 /* Put all unmarked conses on free list */ |
5850 { | |
5851 register struct cons_block *cblk; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5852 struct cons_block **cprev = &cons_block; |
300 | 5853 register int lim = cons_block_index; |
5854 register int num_free = 0, num_used = 0; | |
5855 | |
5856 cons_free_list = 0; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5857 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5858 for (cblk = cons_block; cblk; cblk = *cprev) |
300 | 5859 { |
84816
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5860 register int i = 0; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5861 int this_free = 0; |
84816
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5862 int ilim = (lim + BITS_PER_INT - 1) / BITS_PER_INT; |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5863 |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5864 /* Scan the mark bits an int at a time. */ |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5865 for (i = 0; i <= ilim; i++) |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5866 { |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5867 if (cblk->gcmarkbits[i] == -1) |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5868 { |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5869 /* Fast path - all cons cells for this int are marked. */ |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5870 cblk->gcmarkbits[i] = 0; |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5871 num_used += BITS_PER_INT; |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5872 } |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5873 else |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5874 { |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5875 /* Some cons cells for this int are not marked. |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5876 Find which ones, and free them. */ |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5877 int start, pos, stop; |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5878 |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5879 start = i * BITS_PER_INT; |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5880 stop = lim - start; |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5881 if (stop > BITS_PER_INT) |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5882 stop = BITS_PER_INT; |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5883 stop += start; |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5884 |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5885 for (pos = start; pos < stop; pos++) |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5886 { |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5887 if (!CONS_MARKED_P (&cblk->conses[pos])) |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5888 { |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5889 this_free++; |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5890 cblk->conses[pos].u.chain = cons_free_list; |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5891 cons_free_list = &cblk->conses[pos]; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5892 #if GC_MARK_STACK |
84816
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5893 cons_free_list->car = Vdead; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5894 #endif |
84816
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5895 } |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5896 else |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5897 { |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5898 num_used++; |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5899 CONS_UNMARK (&cblk->conses[pos]); |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5900 } |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5901 } |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5902 } |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5903 } |
4d1c866492b0
(gc_sweep): Check cons cell mark bits word by word
Richard M. Stallman <rms@gnu.org>
parents:
84693
diff
changeset
|
5904 |
300 | 5905 lim = CONS_BLOCK_SIZE; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5906 /* If this block contains only free conses and we have already |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5907 seen more than two blocks worth of free conses then deallocate |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5908 this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5909 if (this_free == CONS_BLOCK_SIZE && num_free > CONS_BLOCK_SIZE) |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5910 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5911 *cprev = cblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5912 /* Unhook from the free list. */ |
66889
e485868e3caf
(free_float): Make free list chaining aliasing-safe.
Andreas Schwab <schwab@suse.de>
parents:
66777
diff
changeset
|
5913 cons_free_list = cblk->conses[0].u.chain; |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5914 lisp_align_free (cblk); |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5915 n_cons_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5916 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5917 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5918 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5919 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5920 cprev = &cblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5921 } |
300 | 5922 } |
5923 total_conses = num_used; | |
5924 total_free_conses = num_free; | |
5925 } | |
5926 | |
5927 /* Put all unmarked floats on free list */ | |
5928 { | |
5929 register struct float_block *fblk; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5930 struct float_block **fprev = &float_block; |
300 | 5931 register int lim = float_block_index; |
5932 register int num_free = 0, num_used = 0; | |
5933 | |
5934 float_free_list = 0; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5935 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5936 for (fblk = float_block; fblk; fblk = *fprev) |
300 | 5937 { |
5938 register int i; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5939 int this_free = 0; |
300 | 5940 for (i = 0; i < lim; i++) |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
5941 if (!FLOAT_MARKED_P (&fblk->floats[i])) |
300 | 5942 { |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5943 this_free++; |
66889
e485868e3caf
(free_float): Make free list chaining aliasing-safe.
Andreas Schwab <schwab@suse.de>
parents:
66777
diff
changeset
|
5944 fblk->floats[i].u.chain = float_free_list; |
300 | 5945 float_free_list = &fblk->floats[i]; |
5946 } | |
5947 else | |
5948 { | |
5949 num_used++; | |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
5950 FLOAT_UNMARK (&fblk->floats[i]); |
300 | 5951 } |
5952 lim = FLOAT_BLOCK_SIZE; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5953 /* If this block contains only free floats and we have already |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5954 seen more than two blocks worth of free floats then deallocate |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5955 this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5956 if (this_free == FLOAT_BLOCK_SIZE && num_free > FLOAT_BLOCK_SIZE) |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5957 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5958 *fprev = fblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5959 /* Unhook from the free list. */ |
66889
e485868e3caf
(free_float): Make free list chaining aliasing-safe.
Andreas Schwab <schwab@suse.de>
parents:
66777
diff
changeset
|
5960 float_free_list = fblk->floats[0].u.chain; |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
5961 lisp_align_free (fblk); |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5962 n_float_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5963 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5964 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5965 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5966 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5967 fprev = &fblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5968 } |
300 | 5969 } |
5970 total_floats = num_used; | |
5971 total_free_floats = num_free; | |
5972 } | |
5973 | |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5974 /* Put all unmarked intervals on free list */ |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5975 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5976 register struct interval_block *iblk; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5977 struct interval_block **iprev = &interval_block; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5978 register int lim = interval_block_index; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5979 register int num_free = 0, num_used = 0; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5980 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5981 interval_free_list = 0; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5982 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5983 for (iblk = interval_block; iblk; iblk = *iprev) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5984 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5985 register int i; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5986 int this_free = 0; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5987 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5988 for (i = 0; i < lim; i++) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5989 { |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5990 if (!iblk->intervals[i].gcmarkbit) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5991 { |
28269
fd13be8ae190
Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents:
28220
diff
changeset
|
5992 SET_INTERVAL_PARENT (&iblk->intervals[i], interval_free_list); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5993 interval_free_list = &iblk->intervals[i]; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5994 this_free++; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5995 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5996 else |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5997 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5998 num_used++; |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5999 iblk->intervals[i].gcmarkbit = 0; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
6000 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
6001 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
6002 lim = INTERVAL_BLOCK_SIZE; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6003 /* If this block contains only free intervals and we have already |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6004 seen more than two blocks worth of free intervals then |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6005 deallocate this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
6006 if (this_free == INTERVAL_BLOCK_SIZE && num_free > INTERVAL_BLOCK_SIZE) |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6007 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6008 *iprev = iblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6009 /* Unhook from the free list. */ |
28269
fd13be8ae190
Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents:
28220
diff
changeset
|
6010 interval_free_list = INTERVAL_PARENT (&iblk->intervals[0]); |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
6011 lisp_free (iblk); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
6012 n_interval_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6013 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6014 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
6015 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
6016 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
6017 iprev = &iblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
6018 } |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
6019 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
6020 total_intervals = num_used; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
6021 total_free_intervals = num_free; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
6022 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
6023 |
300 | 6024 /* Put all unmarked symbols on free list */ |
6025 { | |
6026 register struct symbol_block *sblk; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6027 struct symbol_block **sprev = &symbol_block; |
300 | 6028 register int lim = symbol_block_index; |
6029 register int num_free = 0, num_used = 0; | |
6030 | |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
6031 symbol_free_list = NULL; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
6032 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6033 for (sblk = symbol_block; sblk; sblk = *sprev) |
300 | 6034 { |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6035 int this_free = 0; |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
6036 struct Lisp_Symbol *sym = sblk->symbols; |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
6037 struct Lisp_Symbol *end = sym + lim; |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
6038 |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
6039 for (; sym < end; ++sym) |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
6040 { |
34325
a65d8c29442a
(gc_sweep): Add comment.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34308
diff
changeset
|
6041 /* Check if the symbol was created during loadup. In such a case |
a65d8c29442a
(gc_sweep): Add comment.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34308
diff
changeset
|
6042 it might be pointed to by pure bytecode which we don't trace, |
a65d8c29442a
(gc_sweep): Add comment.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34308
diff
changeset
|
6043 so we conservatively assume that it is live. */ |
45392
f3d7ab65641f
* alloc.c (Fmake_symbol): Set symbol xname field instead of name.
Ken Raeburn <raeburn@raeburn.org>
parents:
44890
diff
changeset
|
6044 int pure_p = PURE_POINTER_P (XSTRING (sym->xname)); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
6045 |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
6046 if (!sym->gcmarkbit && !pure_p) |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
6047 { |
66889
e485868e3caf
(free_float): Make free list chaining aliasing-safe.
Andreas Schwab <schwab@suse.de>
parents:
66777
diff
changeset
|
6048 sym->next = symbol_free_list; |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
6049 symbol_free_list = sym; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
6050 #if GC_MARK_STACK |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
6051 symbol_free_list->function = Vdead; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
6052 #endif |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
6053 ++this_free; |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
6054 } |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
6055 else |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
6056 { |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
6057 ++num_used; |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
6058 if (!pure_p) |
45392
f3d7ab65641f
* alloc.c (Fmake_symbol): Set symbol xname field instead of name.
Ken Raeburn <raeburn@raeburn.org>
parents:
44890
diff
changeset
|
6059 UNMARK_STRING (XSTRING (sym->xname)); |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
6060 sym->gcmarkbit = 0; |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
6061 } |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
6062 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
6063 |
300 | 6064 lim = SYMBOL_BLOCK_SIZE; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6065 /* If this block contains only free symbols and we have already |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6066 seen more than two blocks worth of free symbols then deallocate |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6067 this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
6068 if (this_free == SYMBOL_BLOCK_SIZE && num_free > SYMBOL_BLOCK_SIZE) |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6069 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6070 *sprev = sblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6071 /* Unhook from the free list. */ |
66889
e485868e3caf
(free_float): Make free list chaining aliasing-safe.
Andreas Schwab <schwab@suse.de>
parents:
66777
diff
changeset
|
6072 symbol_free_list = sblk->symbols[0].next; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
6073 lisp_free (sblk); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
6074 n_symbol_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6075 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6076 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
6077 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
6078 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
6079 sprev = &sblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
6080 } |
300 | 6081 } |
6082 total_symbols = num_used; | |
6083 total_free_symbols = num_free; | |
6084 } | |
6085 | |
21143
ce12eac1ee45
(gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents:
21084
diff
changeset
|
6086 /* Put all unmarked misc's on free list. |
ce12eac1ee45
(gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents:
21084
diff
changeset
|
6087 For a marker, first unchain it from the buffer it points into. */ |
300 | 6088 { |
6089 register struct marker_block *mblk; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6090 struct marker_block **mprev = &marker_block; |
300 | 6091 register int lim = marker_block_index; |
6092 register int num_free = 0, num_used = 0; | |
6093 | |
6094 marker_free_list = 0; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
6095 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6096 for (mblk = marker_block; mblk; mblk = *mprev) |
300 | 6097 { |
6098 register int i; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6099 int this_free = 0; |
11403
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
6100 |
300 | 6101 for (i = 0; i < lim; i++) |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
6102 { |
85344
99492f857499
(free_misc): Use XMISCTYPE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85329
diff
changeset
|
6103 if (!mblk->markers[i].u_any.gcmarkbit) |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
6104 { |
85344
99492f857499
(free_misc): Use XMISCTYPE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85329
diff
changeset
|
6105 if (mblk->markers[i].u_any.type == Lisp_Misc_Marker) |
51668
0f333fd92a1d
(survives_gc_p): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51658
diff
changeset
|
6106 unchain_marker (&mblk->markers[i].u_marker); |
11403
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
6107 /* Set the type of the freed object to Lisp_Misc_Free. |
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
6108 We could leave the type alone, since nobody checks it, |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
6109 but this might catch bugs faster. */ |
11243
054ecfce1820
(Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents:
11048
diff
changeset
|
6110 mblk->markers[i].u_marker.type = Lisp_Misc_Free; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
6111 mblk->markers[i].u_free.chain = marker_free_list; |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
6112 marker_free_list = &mblk->markers[i]; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6113 this_free++; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
6114 } |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
6115 else |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
6116 { |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
6117 num_used++; |
85344
99492f857499
(free_misc): Use XMISCTYPE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85329
diff
changeset
|
6118 mblk->markers[i].u_any.gcmarkbit = 0; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
6119 } |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
6120 } |
300 | 6121 lim = MARKER_BLOCK_SIZE; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6122 /* If this block contains only free markers and we have already |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6123 seen more than two blocks worth of free markers then deallocate |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6124 this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
6125 if (this_free == MARKER_BLOCK_SIZE && num_free > MARKER_BLOCK_SIZE) |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6126 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6127 *mprev = mblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6128 /* Unhook from the free list. */ |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6129 marker_free_list = mblk->markers[0].u_free.chain; |
55816
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
6130 lisp_free (mblk); |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
6131 n_marker_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6132 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
6133 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
6134 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
6135 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
6136 mprev = &mblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
6137 } |
300 | 6138 } |
6139 | |
6140 total_markers = num_used; | |
6141 total_free_markers = num_free; | |
6142 } | |
6143 | |
6144 /* Free all unmarked buffers */ | |
6145 { | |
6146 register struct buffer *buffer = all_buffers, *prev = 0, *next; | |
6147 | |
6148 while (buffer) | |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
6149 if (!VECTOR_MARKED_P (buffer)) |
300 | 6150 { |
6151 if (prev) | |
6152 prev->next = buffer->next; | |
6153 else | |
6154 all_buffers = buffer->next; | |
6155 next = buffer->next; | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
6156 lisp_free (buffer); |
300 | 6157 buffer = next; |
6158 } | |
6159 else | |
6160 { | |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
6161 VECTOR_UNMARK (buffer); |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
6162 UNMARK_BALANCE_INTERVALS (BUF_INTERVALS (buffer)); |
300 | 6163 prev = buffer, buffer = buffer->next; |
6164 } | |
6165 } | |
6166 | |
6167 /* Free all unmarked vectors */ | |
6168 { | |
6169 register struct Lisp_Vector *vector = all_vectors, *prev = 0, *next; | |
6170 total_vector_size = 0; | |
6171 | |
6172 while (vector) | |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
6173 if (!VECTOR_MARKED_P (vector)) |
300 | 6174 { |
6175 if (prev) | |
6176 prev->next = vector->next; | |
6177 else | |
6178 all_vectors = vector->next; | |
6179 next = vector->next; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
6180 lisp_free (vector); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
6181 n_vectors--; |
300 | 6182 vector = next; |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
6183 |
300 | 6184 } |
6185 else | |
6186 { | |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
6187 VECTOR_UNMARK (vector); |
11403
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
6188 if (vector->size & PSEUDOVECTOR_FLAG) |
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
6189 total_vector_size += (PSEUDOVECTOR_SIZE_MASK & vector->size); |
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
6190 else |
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
6191 total_vector_size += vector->size; |
300 | 6192 prev = vector, vector = vector->next; |
6193 } | |
6194 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
6195 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
6196 #ifdef GC_CHECK_STRING_BYTES |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
6197 if (!noninteractive) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
6198 check_string_bytes (1); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
6199 #endif |
300 | 6200 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
6201 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
6202 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
6203 |
300 | 6204 |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
6205 /* Debugging aids. */ |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
6206 |
5353
6389ed5b45ac
(Fmemory_limit): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents:
4956
diff
changeset
|
6207 DEFUN ("memory-limit", Fmemory_limit, Smemory_limit, 0, 0, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
6208 doc: /* Return the address of the last byte Emacs has allocated, divided by 1024. |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6209 This may be helpful in debugging Emacs's memory usage. |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6210 We divide the value by 1024 to make sure it fits in a Lisp integer. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6211 () |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
6212 { |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
6213 Lisp_Object end; |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
6214 |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
6215 XSETINT (end, (EMACS_INT) sbrk (0) / 1024); |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
6216 |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
6217 return end; |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
6218 } |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
6219 |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
6220 DEFUN ("memory-use-counts", Fmemory_use_counts, Smemory_use_counts, 0, 0, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
6221 doc: /* Return a list of counters that measure how much consing there has been. |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6222 Each of these counters increments for a certain kind of object. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6223 The counters wrap around from the largest positive integer to zero. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6224 Garbage collection does not decrease them. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6225 The elements of the value are as follows: |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6226 (CONSES FLOATS VECTOR-CELLS SYMBOLS STRING-CHARS MISCS INTERVALS STRINGS) |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6227 All are in units of 1 = one object consed |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6228 except for VECTOR-CELLS and STRING-CHARS, which count the total length of |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6229 objects consed. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6230 MISCS include overlays, markers, and some internal types. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6231 Frames, windows, buffers, and subprocesses count as vectors |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6232 (but the contents of a buffer's text do not count here). */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6233 () |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
6234 { |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
6235 Lisp_Object consed[8]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
6236 |
39633
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
6237 consed[0] = make_number (min (MOST_POSITIVE_FIXNUM, cons_cells_consed)); |
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
6238 consed[1] = make_number (min (MOST_POSITIVE_FIXNUM, floats_consed)); |
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
6239 consed[2] = make_number (min (MOST_POSITIVE_FIXNUM, vector_cells_consed)); |
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
6240 consed[3] = make_number (min (MOST_POSITIVE_FIXNUM, symbols_consed)); |
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
6241 consed[4] = make_number (min (MOST_POSITIVE_FIXNUM, string_chars_consed)); |
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
6242 consed[5] = make_number (min (MOST_POSITIVE_FIXNUM, misc_objects_consed)); |
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
6243 consed[6] = make_number (min (MOST_POSITIVE_FIXNUM, intervals_consed)); |
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
6244 consed[7] = make_number (min (MOST_POSITIVE_FIXNUM, strings_consed)); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
6245 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
6246 return Flist (8, consed); |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
6247 } |
28406
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
6248 |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
6249 int suppress_checking; |
85674
01258ecfc38e
(spare_memory, stack_copy, stack_copy_size, ignore_warnings, Vdead,
Juanma Barranquero <lekktu@gmail.com>
parents:
85344
diff
changeset
|
6250 |
28406
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
6251 void |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
6252 die (msg, file, line) |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
6253 const char *msg; |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
6254 const char *file; |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
6255 int line; |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
6256 { |
85328
d0d527210b0c
* lisp.h (enum Lisp_Misc_Type): Del Lisp_Misc_Some_Buffer_Local_Value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85023
diff
changeset
|
6257 fprintf (stderr, "\r\n%s:%d: Emacs fatal error: %s\r\n", |
28406
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
6258 file, line, msg); |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
6259 abort (); |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
6260 } |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
6261 |
300 | 6262 /* Initialization */ |
6263 | |
21514 | 6264 void |
300 | 6265 init_alloc_once () |
6266 { | |
6267 /* Used to do Vpurify_flag = Qt here, but Qt isn't set up yet! */ | |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
6268 purebeg = PUREBEG; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
6269 pure_size = PURESIZE; |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
6270 pure_bytes_used = 0; |
72027
107f9a044a0a
(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
71967
diff
changeset
|
6271 pure_bytes_used_lisp = pure_bytes_used_non_lisp = 0; |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
6272 pure_bytes_used_before_overflow = 0; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
6273 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
6274 /* Initialize the list of free aligned blocks. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
6275 free_ablock = NULL; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
6276 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
6277 #if GC_MARK_STACK || defined GC_MALLOC_CHECK |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
6278 mem_init (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
6279 Vdead = make_pure_string ("DEAD", 4, 4, 0); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
6280 #endif |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
6281 |
300 | 6282 all_vectors = 0; |
6283 ignore_warnings = 1; | |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
6284 #ifdef DOUG_LEA_MALLOC |
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
6285 mallopt (M_TRIM_THRESHOLD, 128*1024); /* trim threshold */ |
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
6286 mallopt (M_MMAP_THRESHOLD, 64*1024); /* mmap threshold */ |
23973
2eb9e2f5aa33
(MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
23958
diff
changeset
|
6287 mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); /* max. number of mmap'ed areas */ |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
6288 #endif |
300 | 6289 init_strings (); |
6290 init_cons (); | |
6291 init_symbol (); | |
6292 init_marker (); | |
6293 init_float (); | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
6294 init_intervals (); |
94993
b0b4e9fbfb37
(init_alloc_once): Call init_weak_hash_tables.
Chong Yidong <cyd@stupidchicken.com>
parents:
94963
diff
changeset
|
6295 init_weak_hash_tables (); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
6296 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
6297 #ifdef REL_ALLOC |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
6298 malloc_hysteresis = 32; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
6299 #else |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
6300 malloc_hysteresis = 0; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
6301 #endif |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
6302 |
66530
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
6303 refill_memory_reserve (); |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
6304 |
300 | 6305 ignore_warnings = 0; |
6306 gcprolist = 0; | |
26364
7b0217d9259c
(Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents:
26164
diff
changeset
|
6307 byte_stack_list = 0; |
300 | 6308 staticidx = 0; |
6309 consing_since_gc = 0; | |
12605
c5798bb57fdd
(init_alloc_once): Set gc_cons_threshold from Lisp obj size.
Richard M. Stallman <rms@gnu.org>
parents:
12529
diff
changeset
|
6310 gc_cons_threshold = 100000 * sizeof (Lisp_Object); |
64611
47f158dcf216
(gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents:
64273
diff
changeset
|
6311 gc_relative_threshold = 0; |
47f158dcf216
(gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents:
64273
diff
changeset
|
6312 |
300 | 6313 #ifdef VIRT_ADDR_VARIES |
6314 malloc_sbrk_unused = 1<<22; /* A large number */ | |
6315 malloc_sbrk_used = 100000; /* as reasonable as any number */ | |
6316 #endif /* VIRT_ADDR_VARIES */ | |
6317 } | |
6318 | |
21514 | 6319 void |
300 | 6320 init_alloc () |
6321 { | |
6322 gcprolist = 0; | |
26364
7b0217d9259c
(Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents:
26164
diff
changeset
|
6323 byte_stack_list = 0; |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
6324 #if GC_MARK_STACK |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
6325 #if !defined GC_SAVE_REGISTERS_ON_STACK && !defined GC_SETJMP_WORKS |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
6326 setjmp_tested_p = longjmps_done = 0; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
6327 #endif |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
6328 #endif |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
6329 Vgc_elapsed = make_float (0.0); |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
6330 gcs_done = 0; |
300 | 6331 } |
6332 | |
6333 void | |
6334 syms_of_alloc () | |
6335 { | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6336 DEFVAR_INT ("gc-cons-threshold", &gc_cons_threshold, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
6337 doc: /* *Number of bytes of consing between garbage collections. |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6338 Garbage collection can happen automatically once this many bytes have been |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6339 allocated since the last garbage collection. All data types count. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6340 |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6341 Garbage collection happens automatically only when `eval' is called. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6342 |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6343 By binding this temporarily to a large number, you can effectively |
64267
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
6344 prevent garbage collection during a part of the program. |
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
6345 See also `gc-cons-percentage'. */); |
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
6346 |
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
6347 DEFVAR_LISP ("gc-cons-percentage", &Vgc_cons_percentage, |
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
6348 doc: /* *Portion of the heap used for allocation. |
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
6349 Garbage collection can happen automatically once this portion of the heap |
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
6350 has been allocated since the last garbage collection. |
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
6351 If this portion is smaller than `gc-cons-threshold', this is ignored. */); |
5c7cbbd6dbb4
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64084
diff
changeset
|
6352 Vgc_cons_percentage = make_float (0.1); |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6353 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6354 DEFVAR_INT ("pure-bytes-used", &pure_bytes_used, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
6355 doc: /* Number of bytes of sharable Lisp data allocated so far. */); |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6356 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6357 DEFVAR_INT ("cons-cells-consed", &cons_cells_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
6358 doc: /* Number of cons cells that have been consed so far. */); |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6359 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6360 DEFVAR_INT ("floats-consed", &floats_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
6361 doc: /* Number of floats that have been consed so far. */); |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6362 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6363 DEFVAR_INT ("vector-cells-consed", &vector_cells_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
6364 doc: /* Number of vector cells that have been consed so far. */); |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6365 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6366 DEFVAR_INT ("symbols-consed", &symbols_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
6367 doc: /* Number of symbols that have been consed so far. */); |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6368 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6369 DEFVAR_INT ("string-chars-consed", &string_chars_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
6370 doc: /* Number of string characters that have been consed so far. */); |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6371 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6372 DEFVAR_INT ("misc-objects-consed", &misc_objects_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
6373 doc: /* Number of miscellaneous objects that have been consed so far. */); |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6374 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6375 DEFVAR_INT ("intervals-consed", &intervals_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
6376 doc: /* Number of intervals that have been consed so far. */); |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6377 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6378 DEFVAR_INT ("strings-consed", &strings_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
6379 doc: /* Number of strings that have been consed so far. */); |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6380 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6381 DEFVAR_LISP ("purify-flag", &Vpurify_flag, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
6382 doc: /* Non-nil means loading Lisp code in order to dump an executable. |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6383 This means that certain objects should be allocated in shared (pure) space. */); |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6384 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6385 DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
6386 doc: /* Non-nil means display messages at start and end of garbage collection. */); |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
6387 garbage_collection_messages = 0; |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
6388 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6389 DEFVAR_LISP ("post-gc-hook", &Vpost_gc_hook, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
6390 doc: /* Hook run after garbage collection has finished. */); |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
6391 Vpost_gc_hook = Qnil; |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105871
diff
changeset
|
6392 Qpost_gc_hook = intern_c_string ("post-gc-hook"); |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
6393 staticpro (&Qpost_gc_hook); |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
6394 |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
6395 DEFVAR_LISP ("memory-signal-data", &Vmemory_signal_data, |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
6396 doc: /* Precomputed `signal' argument for memory-full error. */); |
6116
64417bbbb128
(memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents:
5874
diff
changeset
|
6397 /* We build this in advance because if we wait until we need it, we might |
64417bbbb128
(memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents:
5874
diff
changeset
|
6398 not be able to allocate the memory to hold it. */ |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
6399 Vmemory_signal_data |
105958
341a779db1d0
* frame.c (make_initial_frame):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105885
diff
changeset
|
6400 = pure_cons (Qerror, |
341a779db1d0
* frame.c (make_initial_frame):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105885
diff
changeset
|
6401 pure_cons (make_pure_c_string ("Memory exhausted--use M-x save-some-buffers then exit and restart Emacs"), Qnil)); |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
6402 |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
6403 DEFVAR_LISP ("memory-full", &Vmemory_full, |
66530
88aab29bf2b2
(syms_of_alloc) <memory-full>: Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
66499
diff
changeset
|
6404 doc: /* Non-nil means Emacs cannot get much more Lisp memory. */); |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
6405 Vmemory_full = Qnil; |
6116
64417bbbb128
(memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents:
5874
diff
changeset
|
6406 |
11374
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
6407 staticpro (&Qgc_cons_threshold); |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105871
diff
changeset
|
6408 Qgc_cons_threshold = intern_c_string ("gc-cons-threshold"); |
11374
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
6409 |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
6410 staticpro (&Qchar_table_extra_slots); |
105877
21bdda3ded62
* xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105871
diff
changeset
|
6411 Qchar_table_extra_slots = intern_c_string ("char-table-extra-slots"); |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
6412 |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
6413 DEFVAR_LISP ("gc-elapsed", &Vgc_elapsed, |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
6414 doc: /* Accumulated time elapsed in garbage collections. |
51974
111cc76606c6
(syms_of_alloc): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
51938
diff
changeset
|
6415 The time is in seconds as a floating point value. */); |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
6416 DEFVAR_INT ("gcs-done", &gcs_done, |
51974
111cc76606c6
(syms_of_alloc): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
51938
diff
changeset
|
6417 doc: /* Accumulated number of garbage collections done. */); |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
6418 |
300 | 6419 defsubr (&Scons); |
6420 defsubr (&Slist); | |
6421 defsubr (&Svector); | |
6422 defsubr (&Smake_byte_code); | |
6423 defsubr (&Smake_list); | |
6424 defsubr (&Smake_vector); | |
6425 defsubr (&Smake_string); | |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
6426 defsubr (&Smake_bool_vector); |
300 | 6427 defsubr (&Smake_symbol); |
6428 defsubr (&Smake_marker); | |
6429 defsubr (&Spurecopy); | |
6430 defsubr (&Sgarbage_collect); | |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
6431 defsubr (&Smemory_limit); |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
6432 defsubr (&Smemory_use_counts); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
6433 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
6434 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
6435 defsubr (&Sgc_status); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
6436 #endif |
300 | 6437 } |
52401 | 6438 |
6439 /* arch-tag: 6695ca10-e3c5-4c2c-8bc3-ed26a7dda857 | |
6440 (do not change this comment) */ |