Mercurial > emacs
annotate src/alloc.c @ 61303:b56d5250fbc3
(math-read-replacement-list): Add subscripts.
(math-read-subscripts): New variable.
(math-read-preprocess-string): Process subscripts.
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Tue, 05 Apr 2005 03:50:26 +0000 |
parents | d24c6e8f9add |
children | 832617c86aa7 360860a0006f 02f1dbc4a199 |
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, |
60143
84ff5b7a4139
(BLOCK_BYTES): Harmless typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59657
diff
changeset
|
3 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. |
300 | 4 |
5 This file is part of GNU Emacs. | |
6 | |
7 GNU Emacs is free software; you can redistribute it and/or modify | |
8 it under the terms of the GNU General Public License as published by | |
1784
11f62e53acff
Make scrollbar structures into lisp objects, so that they can be
Jim Blandy <jimb@redhat.com>
parents:
1562
diff
changeset
|
9 the Free Software Foundation; either version 2, or (at your option) |
300 | 10 any later version. |
11 | |
12 GNU Emacs is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with GNU Emacs; see the file COPYING. If not, write to | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14095
diff
changeset
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14095
diff
changeset
|
20 Boston, MA 02111-1307, USA. */ |
300 | 21 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25762
diff
changeset
|
22 #include <config.h> |
28374
7a3e8a76057b
Include stdio.h. Test STDC_HEADERS, not __STDC__.
Dave Love <fx@gnu.org>
parents:
28365
diff
changeset
|
23 #include <stdio.h> |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
24 #include <limits.h> /* For CHAR_BIT. */ |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25762
diff
changeset
|
25 |
47185
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
26 #ifdef ALLOC_DEBUG |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
27 #undef INLINE |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
28 #endif |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
29 |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
30 /* Note that this declares bzero on OSF/1. How dumb. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
31 |
3003
5a73d384f45e
* syssignal.h: Don't #include <signal.h>
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
32 #include <signal.h> |
300 | 33 |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
34 #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
|
35 #include <pthread.h> |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
36 #endif |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
37 |
26164
d39ec0a27081
more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents:
26088
diff
changeset
|
38 /* 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
|
39 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
|
40 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
|
41 |
26164
d39ec0a27081
more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents:
26088
diff
changeset
|
42 #undef HIDE_LISP_IMPLEMENTATION |
300 | 43 #include "lisp.h" |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
44 #include "process.h" |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
45 #include "intervals.h" |
356 | 46 #include "puresize.h" |
300 | 47 #include "buffer.h" |
48 #include "window.h" | |
31102
6a0caa788013
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30914
diff
changeset
|
49 #include "keyboard.h" |
764 | 50 #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
|
51 #include "blockinput.h" |
21084
371ed7bdfd2b
(Fmake_string): Handle the case INIT is a multibyte character correctly.
Richard M. Stallman <rms@gnu.org>
parents:
20849
diff
changeset
|
52 #include "charset.h" |
638 | 53 #include "syssignal.h" |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
54 #include <setjmp.h> |
638 | 55 |
52547
623355edbb1d
(GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents:
52475
diff
changeset
|
56 /* 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
|
57 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
|
58 |
623355edbb1d
(GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents:
52475
diff
changeset
|
59 #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
|
60 #undef GC_MALLOC_CHECK |
623355edbb1d
(GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents:
52475
diff
changeset
|
61 #endif |
623355edbb1d
(GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents:
52475
diff
changeset
|
62 |
30784
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
63 #ifdef HAVE_UNISTD_H |
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
64 #include <unistd.h> |
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
65 #else |
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
66 extern POINTER_TYPE *sbrk (); |
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
67 #endif |
12096 | 68 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
69 #ifdef DOUG_LEA_MALLOC |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
70 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
71 #include <malloc.h> |
31892
2f3d88ac2b38
(__malloc_size_t) [DOUG_LEA_MALLOC]: Don't redefine it.
Dave Love <fx@gnu.org>
parents:
31889
diff
changeset
|
72 /* 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
|
73 #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
|
74 #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
|
75 #endif |
23973
2eb9e2f5aa33
(MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
23958
diff
changeset
|
76 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
77 /* 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
|
78 value that explicitly means "no limit". */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
79 |
23973
2eb9e2f5aa33
(MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
23958
diff
changeset
|
80 #define MMAP_MAX_AREAS 100000000 |
2eb9e2f5aa33
(MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
23958
diff
changeset
|
81 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
82 #else /* not DOUG_LEA_MALLOC */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
83 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
84 /* 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
|
85 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
86 #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
|
87 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
|
88 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
|
89 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
90 #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
|
91 |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
92 #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
|
93 |
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
|
94 /* 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
|
95 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
|
96 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
|
97 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
|
98 |
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
|
99 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 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
|
105 |
59359
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
106 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
|
107 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
|
108 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
|
109 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
|
110 |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
111 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
|
112 |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
113 #define BLOCK_INPUT_ALLOC \ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
114 do \ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
115 { \ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
116 pthread_mutex_lock (&alloc_mutex); \ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
117 if (pthread_self () == main_thread) \ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
118 BLOCK_INPUT; \ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
119 } \ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
120 while (0) |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
121 #define UNBLOCK_INPUT_ALLOC \ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
122 do \ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
123 { \ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
124 if (pthread_self () == main_thread) \ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
125 UNBLOCK_INPUT; \ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
126 pthread_mutex_unlock (&alloc_mutex); \ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
127 } \ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
128 while (0) |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
129 |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
130 #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
|
131 |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
132 #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
|
133 #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
|
134 |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
135 #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
|
136 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
137 /* 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
|
138 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
139 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
|
140 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
141 /* 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
|
142 to a struct Lisp_String. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
143 |
51985
b52e88c3d6d0
(MARK_STRING, UNMARK_STRING, STRING_MARKED_P)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51974
diff
changeset
|
144 #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
|
145 #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
|
146 #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
|
147 |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
148 #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
|
149 #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
|
150 #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
|
151 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
152 /* 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
|
153 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
|
154 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
|
155 strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
156 |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
157 #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
|
158 #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
|
159 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
160 /* 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
|
161 |
300 | 162 int consing_since_gc; |
163 | |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
164 /* 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
|
165 |
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
|
166 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
|
167 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
|
168 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
|
169 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
|
170 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
|
171 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
|
172 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
|
173 EMACS_INT strings_consed; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
174 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
175 /* Number of bytes of consing since GC before another GC should be done. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
176 |
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
|
177 EMACS_INT gc_cons_threshold; |
300 | 178 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
179 /* Nonzero during GC. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
180 |
300 | 181 int gc_in_progress; |
182 | |
50745
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
183 /* Nonzero means abort if try to GC. |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
184 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
|
185 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
|
186 |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
187 int abort_on_gc; |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
188 |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
189 /* 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
|
190 |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
191 int garbage_collection_messages; |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
192 |
300 | 193 #ifndef VIRT_ADDR_VARIES |
194 extern | |
195 #endif /* VIRT_ADDR_VARIES */ | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
196 int malloc_sbrk_used; |
300 | 197 |
198 #ifndef VIRT_ADDR_VARIES | |
199 extern | |
200 #endif /* VIRT_ADDR_VARIES */ | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
201 int malloc_sbrk_unused; |
300 | 202 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
203 /* 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
|
204 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
205 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
|
206 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
|
207 static int total_free_floats, total_floats; |
19332
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
208 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
209 /* Points to memory space allocated as "spare", to be freed if we run |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
210 out of memory. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
211 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
212 static char *spare_memory; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
213 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
214 /* Amount of spare memory to keep in reserve. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
215 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
216 #define SPARE_MEMORY (1 << 14) |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
217 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
218 /* 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
|
219 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
220 static int malloc_hysteresis; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
221 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
222 /* 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
|
223 |
300 | 224 Lisp_Object Vpurify_flag; |
225 | |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
226 /* 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
|
227 |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
228 Lisp_Object Vmemory_full; |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
229 |
300 | 230 #ifndef HAVE_SHM |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
231 |
57137 | 232 /* Initialize it to a nonzero value to force it into data space |
233 (rather than bss space). That way unexec will remap it into text | |
234 space (pure), on some systems. We have not implemented the | |
235 remapping on more recent systems because this is less important | |
236 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
|
237 |
cb3976b5e59f
(pure, staticvec): Initialize these arrays to nonzero, so that they're
Paul Eggert <eggert@twinsun.com>
parents:
51907
diff
changeset
|
238 EMACS_INT pure[PURESIZE / sizeof (EMACS_INT)] = {1,}; |
300 | 239 #define PUREBEG (char *) pure |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
240 |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
241 #else /* HAVE_SHM */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
242 |
300 | 243 #define pure PURE_SEG_BITS /* Use shared memory segment */ |
244 #define PUREBEG (char *)PURE_SEG_BITS | |
356 | 245 |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
246 #endif /* HAVE_SHM */ |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
247 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
248 /* 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
|
249 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
250 static char *purebeg; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
251 static size_t pure_size; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
252 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
253 /* 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
|
254 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
|
255 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
256 static size_t pure_bytes_used_before_overflow; |
300 | 257 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
258 /* 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
|
259 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
260 #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
|
261 (((PNTR_COMPARISON_TYPE) (P) \ |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
262 < (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
|
263 && ((PNTR_COMPARISON_TYPE) (P) \ |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
264 >= (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
|
265 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
266 /* Index in pure at which next pure object will be allocated.. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
267 |
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
|
268 EMACS_INT pure_bytes_used; |
300 | 269 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
270 /* 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
|
271 displayed. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
272 |
300 | 273 char *pending_malloc_warning; |
274 | |
6116
64417bbbb128
(memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents:
5874
diff
changeset
|
275 /* 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
|
276 |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
277 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
|
278 |
300 | 279 /* Maximum amount of C stack to save when a GC happens. */ |
280 | |
281 #ifndef MAX_SAVE_STACK | |
282 #define MAX_SAVE_STACK 16000 | |
283 #endif | |
284 | |
285 /* Buffer in which we save a copy of the C stack at each GC. */ | |
286 | |
287 char *stack_copy; | |
288 int stack_copy_size; | |
289 | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
290 /* 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
|
291 Currently not used. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
292 |
300 | 293 int ignore_warnings; |
1318 | 294 |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
295 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
|
296 |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
297 /* Hook run after GC has finished. */ |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
298 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
299 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
|
300 |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
301 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
|
302 EMACS_INT gcs_done; /* accumulated GCs */ |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
303 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
304 static void mark_buffer P_ ((Lisp_Object)); |
51578
42f25a716cb8
(mark_kboards): Move to keyboard.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51318
diff
changeset
|
305 extern void mark_kboards P_ ((void)); |
55798
a1bb695e9a0c
(struct backtrace): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55767
diff
changeset
|
306 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
|
307 static void gc_sweep P_ ((void)); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
308 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
|
309 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
|
310 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
311 #ifdef HAVE_WINDOW_SYSTEM |
59400
eeb8b96d077d
(mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents:
59359
diff
changeset
|
312 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
|
313 static void mark_image P_ ((struct image *)); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
314 static void mark_image_cache P_ ((struct frame *)); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
315 #endif /* HAVE_WINDOW_SYSTEM */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
316 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
317 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
|
318 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
|
319 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
|
320 static void sweep_strings P_ ((void)); |
20495 | 321 |
322 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
|
323 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
324 /* 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
|
325 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
|
326 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
|
327 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
328 enum mem_type |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
329 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
330 MEM_TYPE_NON_LISP, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
331 MEM_TYPE_BUFFER, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
332 MEM_TYPE_CONS, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
333 MEM_TYPE_STRING, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
334 MEM_TYPE_MISC, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
335 MEM_TYPE_SYMBOL, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
336 MEM_TYPE_FLOAT, |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
337 /* Keep the following vector-like types together, with |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
338 MEM_TYPE_WINDOW being the last, and MEM_TYPE_VECTOR the |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
339 first. Or change the code of live_vector_p, for instance. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
340 MEM_TYPE_VECTOR, |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
341 MEM_TYPE_PROCESS, |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
342 MEM_TYPE_HASH_TABLE, |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
343 MEM_TYPE_FRAME, |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
344 MEM_TYPE_WINDOW |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
345 }; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
346 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
347 #if GC_MARK_STACK || defined GC_MALLOC_CHECK |
27746
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
348 |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
349 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
350 #include <stdio.h> /* For fprintf. */ |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
351 #endif |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
352 |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
353 /* 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
|
354 on free lists recognizable in O(1). */ |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
355 |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
356 Lisp_Object Vdead; |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
357 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
358 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
359 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
360 enum mem_type allocated_mem_type; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
361 int dont_register_blocks; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
362 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
363 #endif /* GC_MALLOC_CHECK */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
364 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
365 /* 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
|
366 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
|
367 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
|
368 is freed. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
369 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
370 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
|
371 properties: |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
372 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
373 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
|
374 2. Every leaf is black. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
375 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
|
376 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
|
377 the same number of black nodes. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
378 5. The root is always black. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
379 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
380 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
|
381 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
|
382 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
383 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
|
384 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
|
385 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
|
386 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
|
387 describe them. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
388 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
389 struct mem_node |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
390 { |
48907 | 391 /* Children of this node. These pointers are never NULL. When there |
392 is no child, the value is MEM_NIL, which points to a dummy node. */ | |
393 struct mem_node *left, *right; | |
394 | |
395 /* The parent of this node. In the root node, this is NULL. */ | |
396 struct mem_node *parent; | |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
397 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
398 /* Start and end of allocated region. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
399 void *start, *end; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
400 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
401 /* Node color. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
402 enum {MEM_BLACK, MEM_RED} color; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
403 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
404 /* Memory type. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
405 enum mem_type type; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
406 }; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
407 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
408 /* Base address of stack. Set in main. */ |
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 Lisp_Object *stack_base; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
411 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
412 /* 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
|
413 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
414 static struct mem_node *mem_root; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
415 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
416 /* Lowest and highest known address in the heap. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
417 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
418 static void *min_heap_address, *max_heap_address; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
419 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
420 /* Sentinel node of the tree. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
421 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
422 static struct mem_node mem_z; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
423 #define MEM_NIL &mem_z |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
424 |
30914
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
425 static POINTER_TYPE *lisp_malloc P_ ((size_t, enum mem_type)); |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
426 static struct Lisp_Vector *allocate_vectorlike P_ ((EMACS_INT, enum mem_type)); |
30784
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
427 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
|
428 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
|
429 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
|
430 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
|
431 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
|
432 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
|
433 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
|
434 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
|
435 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
|
436 static void mark_maybe_object P_ ((Lisp_Object)); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
437 static void mark_memory P_ ((void *, void *)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
438 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
|
439 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
|
440 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
|
441 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
|
442 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
|
443 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
|
444 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
|
445 static INLINE struct mem_node *mem_find P_ ((void *)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
446 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
447 #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
|
448 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
|
449 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
450 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
451 #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
|
452 |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
453 /* Recording what needs to be marked for gc. */ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
454 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
455 struct gcpro *gcprolist; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
456 |
51908
cb3976b5e59f
(pure, staticvec): Initialize these arrays to nonzero, so that they're
Paul Eggert <eggert@twinsun.com>
parents:
51907
diff
changeset
|
457 /* 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
|
458 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
|
459 |
43313
32f59a921eb9
(NSTATICS): Increase to 1280.
Andreas Schwab <schwab@suse.de>
parents:
43302
diff
changeset
|
460 #define NSTATICS 1280 |
51908
cb3976b5e59f
(pure, staticvec): Initialize these arrays to nonzero, so that they're
Paul Eggert <eggert@twinsun.com>
parents:
51907
diff
changeset
|
461 Lisp_Object *staticvec[NSTATICS] = {&Vpurify_flag}; |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
462 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
463 /* Index of next unused slot in staticvec. */ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
464 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
465 int staticidx = 0; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
466 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
467 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
|
468 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
469 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
470 /* 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
|
471 ALIGNMENT must be a power of 2. */ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
472 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
473 #define ALIGN(ptr, ALIGNMENT) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
474 ((POINTER_TYPE *) ((((EMACS_UINT)(ptr)) + (ALIGNMENT) - 1) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
475 & ~((ALIGNMENT) - 1))) |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
476 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
477 |
300 | 478 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
479 /************************************************************************ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
480 Malloc |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
481 ************************************************************************/ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
482 |
47185
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
483 /* 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
|
484 |
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
485 void |
300 | 486 malloc_warning (str) |
487 char *str; | |
488 { | |
489 pending_malloc_warning = str; | |
490 } | |
491 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
492 |
47185
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
493 /* 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
|
494 |
20375
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
495 void |
300 | 496 display_malloc_warning () |
497 { | |
47185
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
498 call3 (intern ("display-warning"), |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
499 intern ("alloc"), |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
500 build_string (pending_malloc_warning), |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
501 intern ("emergency")); |
300 | 502 pending_malloc_warning = 0; |
503 } | |
504 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
505 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
506 #ifdef DOUG_LEA_MALLOC |
17831
9238a2254a23
(BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents:
17348
diff
changeset
|
507 # define BYTES_USED (mallinfo ().arena) |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
508 #else |
17831
9238a2254a23
(BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents:
17348
diff
changeset
|
509 # 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
|
510 #endif |
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
511 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
512 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
513 /* Called if malloc returns zero. */ |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
514 |
20375
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
515 void |
300 | 516 memory_full () |
517 { | |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
518 Vmemory_full = Qt; |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
519 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
520 #ifndef SYSTEM_MALLOC |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
521 bytes_used_when_full = BYTES_USED; |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
522 #endif |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
523 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
524 /* The first time we get here, free the spare memory. */ |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
525 if (spare_memory) |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
526 { |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
527 free (spare_memory); |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
528 spare_memory = 0; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
529 } |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
530 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
531 /* 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
|
532 get infinite recursion trying to build the string. */ |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
533 while (1) |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
534 Fsignal (Qnil, Vmemory_signal_data); |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
535 } |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
536 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
537 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
538 /* 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
|
539 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
540 void |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
541 buffer_memory_full () |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
542 { |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
543 /* 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
|
544 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
|
545 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
|
546 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
|
547 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
|
548 malloc. */ |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
549 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
550 #ifndef REL_ALLOC |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
551 memory_full (); |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
552 #endif |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
553 |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
554 Vmemory_full = Qt; |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
555 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
556 /* 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
|
557 get infinite recursion trying to build the string. */ |
6116
64417bbbb128
(memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents:
5874
diff
changeset
|
558 while (1) |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
559 Fsignal (Qnil, Vmemory_signal_data); |
300 | 560 } |
561 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
562 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
563 #ifdef XMALLOC_OVERRUN_CHECK |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
564 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
565 /* 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
|
566 and a 16 byte trailer around each block. |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
567 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
568 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
|
569 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
|
570 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
571 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
|
572 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
|
573 functions may bypass the malloc hooks. |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
574 */ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
575 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
576 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
577 #define XMALLOC_OVERRUN_CHECK_SIZE 16 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
578 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
579 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
|
580 { 0x9a, 0x9b, 0xae, 0xaf, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
581 0xbf, 0xbe, 0xce, 0xcf, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
582 0xea, 0xeb, 0xec, 0xed }; |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
583 |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
584 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
|
585 { 0xaa, 0xab, 0xac, 0xad, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
586 0xba, 0xbb, 0xbc, 0xbd, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
587 0xca, 0xcb, 0xcc, 0xcd, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
588 0xda, 0xdb, 0xdc, 0xdd }; |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
589 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
590 /* 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
|
591 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
592 #define XMALLOC_PUT_SIZE(ptr, size) \ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
593 (ptr[-1] = (size & 0xff), \ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
594 ptr[-2] = ((size >> 8) & 0xff), \ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
595 ptr[-3] = ((size >> 16) & 0xff), \ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
596 ptr[-4] = ((size >> 24) & 0xff)) |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
597 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
598 #define XMALLOC_GET_SIZE(ptr) \ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
599 (size_t)((unsigned)(ptr[-1]) | \ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
600 ((unsigned)(ptr[-2]) << 8) | \ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
601 ((unsigned)(ptr[-3]) << 16) | \ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
602 ((unsigned)(ptr[-4]) << 24)) |
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 |
59083
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
605 /* 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
|
606 xmalloc() |
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
607 overrun_check_malloc() |
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
608 -> malloc -> (via hook)_-> emacs_blocked_malloc |
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
609 -> overrun_check_malloc |
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
610 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
|
611 malloc returns 10000. |
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
612 add overhead, return 10016. |
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
613 <- (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
|
614 add overhead again, return 10032 |
59083
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
615 xmalloc returns 10032. |
59082
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
616 |
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
617 (time passes). |
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
618 |
59083
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
619 xfree(10032) |
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
620 overrun_check_free(10032) |
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
621 decrease overhed |
4295cf593352
Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59082
diff
changeset
|
622 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
|
623 |
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
624 static int check_depth; |
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
625 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
626 /* 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
|
627 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
628 POINTER_TYPE * |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
629 overrun_check_malloc (size) |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
630 size_t size; |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
631 { |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
632 register unsigned char *val; |
59082
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
633 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
|
634 |
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
635 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
|
636 if (val && check_depth == 1) |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
637 { |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
638 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
|
639 val += XMALLOC_OVERRUN_CHECK_SIZE; |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
640 XMALLOC_PUT_SIZE(val, size); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
641 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
|
642 } |
59082
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
643 --check_depth; |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
644 return (POINTER_TYPE *)val; |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
645 } |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
646 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
647 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
648 /* 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
|
649 with header and trailer. */ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
650 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
651 POINTER_TYPE * |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
652 overrun_check_realloc (block, size) |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
653 POINTER_TYPE *block; |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
654 size_t size; |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
655 { |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
656 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
|
657 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
|
658 |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
659 if (val |
59082
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
660 && check_depth == 1 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
661 && bcmp (xmalloc_overrun_check_header, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
662 val - XMALLOC_OVERRUN_CHECK_SIZE, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
663 XMALLOC_OVERRUN_CHECK_SIZE - 4) == 0) |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
664 { |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
665 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
|
666 if (bcmp (xmalloc_overrun_check_trailer, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
667 val + osize, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
668 XMALLOC_OVERRUN_CHECK_SIZE)) |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
669 abort (); |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
670 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
|
671 val -= XMALLOC_OVERRUN_CHECK_SIZE; |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
672 bzero (val, XMALLOC_OVERRUN_CHECK_SIZE); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
673 } |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
674 |
59082
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
675 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
|
676 |
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
677 if (val && check_depth == 1) |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
678 { |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
679 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
|
680 val += XMALLOC_OVERRUN_CHECK_SIZE; |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
681 XMALLOC_PUT_SIZE(val, size); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
682 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
|
683 } |
59082
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
684 --check_depth; |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
685 return (POINTER_TYPE *)val; |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
686 } |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
687 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
688 /* Like free, but checks block for overrun. */ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
689 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
690 void |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
691 overrun_check_free (block) |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
692 POINTER_TYPE *block; |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
693 { |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
694 unsigned char *val = (unsigned char *)block; |
58631
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 if (val |
59082
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
698 && check_depth == 1 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
699 && bcmp (xmalloc_overrun_check_header, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
700 val - XMALLOC_OVERRUN_CHECK_SIZE, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
701 XMALLOC_OVERRUN_CHECK_SIZE - 4) == 0) |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
702 { |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
703 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
|
704 if (bcmp (xmalloc_overrun_check_trailer, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
705 val + osize, |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
706 XMALLOC_OVERRUN_CHECK_SIZE)) |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
707 abort (); |
59400
eeb8b96d077d
(mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents:
59359
diff
changeset
|
708 #ifdef XMALLOC_CLEAR_FREE_MEMORY |
eeb8b96d077d
(mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents:
59359
diff
changeset
|
709 val -= XMALLOC_OVERRUN_CHECK_SIZE; |
eeb8b96d077d
(mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents:
59359
diff
changeset
|
710 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
|
711 #else |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
712 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
|
713 val -= XMALLOC_OVERRUN_CHECK_SIZE; |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
714 bzero (val, XMALLOC_OVERRUN_CHECK_SIZE); |
59400
eeb8b96d077d
(mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents:
59359
diff
changeset
|
715 #endif |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
716 } |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
717 |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
718 free (val); |
59082
f487226310e0
* alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59047
diff
changeset
|
719 --check_depth; |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
720 } |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
721 |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
722 #undef malloc |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
723 #undef realloc |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
724 #undef free |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
725 #define malloc overrun_check_malloc |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
726 #define realloc overrun_check_realloc |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
727 #define free overrun_check_free |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
728 #endif |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
729 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
730 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
731 /* 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
|
732 |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
733 POINTER_TYPE * |
300 | 734 xmalloc (size) |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
735 size_t size; |
300 | 736 { |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
737 register POINTER_TYPE *val; |
300 | 738 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
739 BLOCK_INPUT; |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
740 val = (POINTER_TYPE *) malloc (size); |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
741 UNBLOCK_INPUT; |
300 | 742 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
743 if (!val && size) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
744 memory_full (); |
300 | 745 return val; |
746 } | |
747 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
748 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
749 /* 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
|
750 |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
751 POINTER_TYPE * |
300 | 752 xrealloc (block, size) |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
753 POINTER_TYPE *block; |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
754 size_t size; |
300 | 755 { |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
756 register POINTER_TYPE *val; |
300 | 757 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
758 BLOCK_INPUT; |
590 | 759 /* We must call malloc explicitly when BLOCK is 0, since some |
760 reallocs don't do this. */ | |
761 if (! block) | |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
762 val = (POINTER_TYPE *) malloc (size); |
600
a8d78999e46d
*** empty log message ***
Noah Friedman <friedman@splode.com>
parents:
590
diff
changeset
|
763 else |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
764 val = (POINTER_TYPE *) realloc (block, size); |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
765 UNBLOCK_INPUT; |
300 | 766 |
767 if (!val && size) memory_full (); | |
768 return val; | |
769 } | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
770 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
771 |
52276
5623f26dff58
(lisp_align_malloc): Change type of `aligned'.
Dave Love <fx@gnu.org>
parents:
52256
diff
changeset
|
772 /* 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
|
773 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
774 void |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
775 xfree (block) |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
776 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
|
777 { |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
778 BLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
779 free (block); |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
780 UNBLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
781 } |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
782 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
783 |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
784 /* Like strdup, but uses xmalloc. */ |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
785 |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
786 char * |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
787 xstrdup (s) |
46459
0a9cbcbdbe45
(xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents:
46418
diff
changeset
|
788 const char *s; |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
789 { |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
790 size_t len = strlen (s) + 1; |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
791 char *p = (char *) xmalloc (len); |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
792 bcopy (s, p, len); |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
793 return p; |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
794 } |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
795 |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
796 |
56187
e3720731abbb
(safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents:
55838
diff
changeset
|
797 /* Unwind for SAFE_ALLOCA */ |
e3720731abbb
(safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents:
55838
diff
changeset
|
798 |
e3720731abbb
(safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents:
55838
diff
changeset
|
799 Lisp_Object |
e3720731abbb
(safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents:
55838
diff
changeset
|
800 safe_alloca_unwind (arg) |
e3720731abbb
(safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents:
55838
diff
changeset
|
801 Lisp_Object arg; |
e3720731abbb
(safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents:
55838
diff
changeset
|
802 { |
56202
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
803 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
|
804 |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
805 p->dogc = 0; |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
806 xfree (p->pointer); |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
807 p->pointer = 0; |
56239
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
808 free_misc (arg); |
56187
e3720731abbb
(safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents:
55838
diff
changeset
|
809 return Qnil; |
e3720731abbb
(safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents:
55838
diff
changeset
|
810 } |
e3720731abbb
(safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents:
55838
diff
changeset
|
811 |
e3720731abbb
(safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents:
55838
diff
changeset
|
812 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
813 /* 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
|
814 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
|
815 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
|
816 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
817 #ifndef USE_LSB_TAG |
50468
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
818 static void *lisp_malloc_loser; |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
819 #endif |
50468
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
820 |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
821 static POINTER_TYPE * |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
822 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
|
823 size_t nbytes; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
824 enum mem_type type; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
825 { |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
826 register void *val; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
827 |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
828 BLOCK_INPUT; |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
829 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
830 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
831 allocated_mem_type = type; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
832 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
833 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
834 val = (void *) malloc (nbytes); |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
835 |
53650
5558449888ec
(lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53582
diff
changeset
|
836 #ifndef USE_LSB_TAG |
50468
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
837 /* 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
|
838 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
|
839 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
|
840 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
|
841 { |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
842 Lisp_Object tem; |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
843 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
|
844 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
|
845 { |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
846 lisp_malloc_loser = val; |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
847 free (val); |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
848 val = 0; |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
849 } |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
850 } |
53650
5558449888ec
(lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53582
diff
changeset
|
851 #endif |
50468
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
852 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
853 #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
|
854 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
|
855 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
|
856 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
857 |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
858 UNBLOCK_INPUT; |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
859 if (!val && nbytes) |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
860 memory_full (); |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
861 return val; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
862 } |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
863 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
864 /* 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
|
865 call to lisp_malloc. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
866 |
30784
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
867 static void |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
868 lisp_free (block) |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
869 POINTER_TYPE *block; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
870 { |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
871 BLOCK_INPUT; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
872 free (block); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
873 #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
|
874 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
|
875 #endif |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
876 UNBLOCK_INPUT; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
877 } |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
878 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
879 /* 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
|
880 /* 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
|
881 /* 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
|
882 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
883 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
884 /* 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
|
885 #define BLOCK_ALIGN (1 << 10) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
886 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
887 /* 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
|
888 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
|
889 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
|
890 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
|
891 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
|
892 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
|
893 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
|
894 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
|
895 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
|
896 nothing else. */ |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
897 #define BLOCK_PADDING 0 |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
898 #define BLOCK_BYTES \ |
60143
84ff5b7a4139
(BLOCK_BYTES): Harmless typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59657
diff
changeset
|
899 (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
|
900 |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
901 /* Internal data structures and constants. */ |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
902 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
903 #define ABLOCKS_SIZE 16 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
904 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
905 /* An aligned block of memory. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
906 struct ablock |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
907 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
908 union |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
909 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
910 char payload[BLOCK_BYTES]; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
911 struct ablock *next_free; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
912 } x; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
913 /* `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
|
914 /* 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
|
915 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
|
916 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
|
917 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
|
918 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
|
919 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
|
920 (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
|
921 real base). */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
922 struct ablocks *abase; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
923 /* 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
|
924 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
|
925 #if BLOCK_PADDING |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
926 char padding[BLOCK_PADDING]; |
51758
ff38ea4b40ed
(struct ablock): Only include padding when there is some.
Jason Rumney <jasonr@gnu.org>
parents:
51723
diff
changeset
|
927 #endif |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
928 }; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
929 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
930 /* A bunch of consecutive aligned blocks. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
931 struct ablocks |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
932 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
933 struct ablock blocks[ABLOCKS_SIZE]; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
934 }; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
935 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
936 /* 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
|
937 #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
|
938 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
939 #define ABLOCK_ABASE(block) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
940 (((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
|
941 ? (struct ablocks *)(block) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
942 : (block)->abase) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
943 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
944 /* Virtual `busy' field. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
945 #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
|
946 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
947 /* Pointer to the (not necessarily aligned) malloc block. */ |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
948 #ifdef HAVE_POSIX_MEMALIGN |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
949 #define ABLOCKS_BASE(abase) (abase) |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
950 #else |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
951 #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
|
952 (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
|
953 #endif |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
954 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
955 /* The list of free ablock. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
956 static struct ablock *free_ablock; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
957 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
958 /* Allocate an aligned block of nbytes. |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
959 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
|
960 smaller or equal to BLOCK_BYTES. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
961 static POINTER_TYPE * |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
962 lisp_align_malloc (nbytes, type) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
963 size_t nbytes; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
964 enum mem_type type; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
965 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
966 void *base, *val; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
967 struct ablocks *abase; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
968 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
969 eassert (nbytes <= BLOCK_BYTES); |
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 BLOCK_INPUT; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
972 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
973 #ifdef GC_MALLOC_CHECK |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
974 allocated_mem_type = type; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
975 #endif |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
976 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
977 if (!free_ablock) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
978 { |
52276
5623f26dff58
(lisp_align_malloc): Change type of `aligned'.
Dave Love <fx@gnu.org>
parents:
52256
diff
changeset
|
979 int i; |
5623f26dff58
(lisp_align_malloc): Change type of `aligned'.
Dave Love <fx@gnu.org>
parents:
52256
diff
changeset
|
980 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
|
981 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
982 #ifdef DOUG_LEA_MALLOC |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
983 /* 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
|
984 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
|
985 a dumped Emacs. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
986 mallopt (M_MMAP_MAX, 0); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
987 #endif |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
988 |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
989 #ifdef HAVE_POSIX_MEMALIGN |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
990 { |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
991 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
|
992 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
|
993 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
|
994 abase = base; |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
995 } |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
996 #else |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
997 base = malloc (ABLOCKS_BYTES); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
998 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
|
999 #endif |
a05a653f63af
(lisp_align_malloc): Check for base == 0 regardless of HAVE_POSIX_MEMALIGN.
Richard M. Stallman <rms@gnu.org>
parents:
55816
diff
changeset
|
1000 |
52837
1bbf3f566879
(lisp_align_malloc): If BASE is 0, call memory_full.
Richard M. Stallman <rms@gnu.org>
parents:
52547
diff
changeset
|
1001 if (base == 0) |
1bbf3f566879
(lisp_align_malloc): If BASE is 0, call memory_full.
Richard M. Stallman <rms@gnu.org>
parents:
52547
diff
changeset
|
1002 { |
1bbf3f566879
(lisp_align_malloc): If BASE is 0, call memory_full.
Richard M. Stallman <rms@gnu.org>
parents:
52547
diff
changeset
|
1003 UNBLOCK_INPUT; |
1bbf3f566879
(lisp_align_malloc): If BASE is 0, call memory_full.
Richard M. Stallman <rms@gnu.org>
parents:
52547
diff
changeset
|
1004 memory_full (); |
1bbf3f566879
(lisp_align_malloc): If BASE is 0, call memory_full.
Richard M. Stallman <rms@gnu.org>
parents:
52547
diff
changeset
|
1005 } |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1006 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1007 aligned = (base == abase); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1008 if (!aligned) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1009 ((void**)abase)[-1] = base; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1010 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1011 #ifdef DOUG_LEA_MALLOC |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1012 /* 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
|
1013 mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1014 #endif |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1015 |
53650
5558449888ec
(lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53582
diff
changeset
|
1016 #ifndef USE_LSB_TAG |
52256
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1017 /* 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
|
1018 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
|
1019 running out of memory. */ |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1020 if (type != MEM_TYPE_NON_LISP) |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1021 { |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1022 Lisp_Object tem; |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1023 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
|
1024 XSETCONS (tem, end); |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1025 if ((char *) XCONS (tem) != end) |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1026 { |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1027 lisp_malloc_loser = base; |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1028 free (base); |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1029 UNBLOCK_INPUT; |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1030 memory_full (); |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1031 } |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1032 } |
53650
5558449888ec
(lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53582
diff
changeset
|
1033 #endif |
52256
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
1034 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1035 /* 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
|
1036 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
|
1037 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
|
1038 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1039 abase->blocks[i].abase = abase; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1040 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
|
1041 free_ablock = &abase->blocks[i]; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1042 } |
52453
62fcd311bb98
Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1043 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
|
1044 |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
1045 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
|
1046 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
|
1047 eassert (ABLOCK_ABASE (&abase->blocks[0]) == abase); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1048 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
|
1049 eassert (aligned == (long) ABLOCKS_BUSY (abase)); |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1050 } |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1051 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1052 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
|
1053 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
|
1054 val = free_ablock; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1055 free_ablock = free_ablock->x.next_free; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1056 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1057 #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
|
1058 if (val && type != MEM_TYPE_NON_LISP) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1059 mem_insert (val, (char *) val + nbytes, type); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1060 #endif |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1061 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1062 UNBLOCK_INPUT; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1063 if (!val && nbytes) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1064 memory_full (); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1065 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1066 eassert (0 == ((EMACS_UINT)val) % BLOCK_ALIGN); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1067 return val; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1068 } |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1069 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1070 static void |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1071 lisp_align_free (block) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1072 POINTER_TYPE *block; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1073 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1074 struct ablock *ablock = block; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1075 struct ablocks *abase = ABLOCK_ABASE (ablock); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1076 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1077 BLOCK_INPUT; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1078 #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
|
1079 mem_delete (mem_find (block)); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1080 #endif |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1081 /* Put on free list. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1082 ablock->x.next_free = free_ablock; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1083 free_ablock = ablock; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1084 /* Update busy count. */ |
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)); |
55634
d3542bbadad7
(mark_object): Ignore Lisp_Misc_Free objects.
Kim F. Storm <storm@cua.dk>
parents:
55159
diff
changeset
|
1086 |
52453
62fcd311bb98
Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1087 if (2 > (long) ABLOCKS_BUSY (abase)) |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1088 { /* 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
|
1089 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
|
1090 struct ablock **tem = &free_ablock; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1091 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
|
1092 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1093 while (*tem) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1094 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1095 if (*tem >= (struct ablock *) abase && *tem < atop) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1096 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1097 i++; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1098 *tem = (*tem)->x.next_free; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1099 } |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1100 else |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1101 tem = &(*tem)->x.next_free; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1102 } |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1103 eassert ((aligned & 1) == aligned); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1104 eassert (i == (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1)); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1105 free (ABLOCKS_BASE (abase)); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1106 } |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1107 UNBLOCK_INPUT; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
1108 } |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1109 |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1110 /* 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
|
1111 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
|
1112 |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1113 struct buffer * |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1114 allocate_buffer () |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1115 { |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1116 struct buffer *b |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1117 = (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
|
1118 MEM_TYPE_BUFFER); |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1119 return b; |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1120 } |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
1121 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1122 |
59359
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1123 #ifndef SYSTEM_MALLOC |
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1124 |
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1125 /* If we released our reserve (due to running out of memory), |
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1126 and we have a fair amount free once again, |
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1127 try to set aside another reserve in case we run out once more. |
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1128 |
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1129 This is called when a relocatable block is freed in ralloc.c. */ |
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1130 |
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1131 void |
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1132 refill_memory_reserve () |
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1133 { |
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1134 if (spare_memory == 0) |
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1135 spare_memory = (char *) malloc ((size_t) SPARE_MEMORY); |
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1136 } |
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1137 |
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1138 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1139 /* 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
|
1140 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1141 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
|
1142 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
|
1143 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
|
1144 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
|
1145 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
|
1146 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
|
1147 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
|
1148 |
59359
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1149 #ifndef SYNC_INPUT |
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1150 |
30914
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
1151 #ifndef DOUG_LEA_MALLOC |
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
1152 extern void * (*__malloc_hook) P_ ((size_t)); |
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
1153 extern void * (*__realloc_hook) P_ ((void *, size_t)); |
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
1154 extern void (*__free_hook) P_ ((void *)); |
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
1155 /* 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
|
1156 #endif /* DOUG_LEA_MALLOC */ |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
1157 static void * (*old_malloc_hook) (); |
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
1158 static void * (*old_realloc_hook) (); |
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
1159 static void (*old_free_hook) (); |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1160 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
1161 /* 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
|
1162 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1163 static void |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1164 emacs_blocked_free (ptr) |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1165 void *ptr; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1166 { |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1167 BLOCK_INPUT_ALLOC; |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1168 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1169 #ifdef GC_MALLOC_CHECK |
32776
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1170 if (ptr) |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1171 { |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1172 struct mem_node *m; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1173 |
32776
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1174 m = mem_find (ptr); |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1175 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
|
1176 { |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1177 fprintf (stderr, |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1178 "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
|
1179 abort (); |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1180 } |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1181 else |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1182 { |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1183 /* 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
|
1184 mem_delete (m); |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1185 } |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
1186 } |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1187 #endif /* GC_MALLOC_CHECK */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1188 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1189 __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
|
1190 free (ptr); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1191 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
1192 /* 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
|
1193 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
|
1194 try to set aside another reserve in case we run out once more. */ |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
1195 if (spare_memory == 0 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
1196 /* 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
|
1197 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
|
1198 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
|
1199 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
|
1200 && (bytes_used_when_full |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
1201 > BYTES_USED + max (malloc_hysteresis, 4) * SPARE_MEMORY)) |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
1202 spare_memory = (char *) malloc ((size_t) SPARE_MEMORY); |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
1203 |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
1204 __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
|
1205 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
|
1206 } |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1207 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1208 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
1209 /* 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
|
1210 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1211 static void * |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1212 emacs_blocked_malloc (size) |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
1213 size_t size; |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1214 { |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1215 void *value; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1216 |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1217 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
|
1218 __malloc_hook = old_malloc_hook; |
17831
9238a2254a23
(BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents:
17348
diff
changeset
|
1219 #ifdef DOUG_LEA_MALLOC |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
1220 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
|
1221 #else |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
1222 __malloc_extra_blocks = malloc_hysteresis; |
17831
9238a2254a23
(BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents:
17348
diff
changeset
|
1223 #endif |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1224 |
3581
152fd924c7bb
* alloc.c (emacs_blocked_malloc, emacs_blocked_realloc): Cast the
Jim Blandy <jimb@redhat.com>
parents:
3536
diff
changeset
|
1225 value = (void *) malloc (size); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1226 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1227 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1228 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1229 struct mem_node *m = mem_find (value); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1230 if (m != MEM_NIL) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1231 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1232 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
|
1233 value); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1234 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
|
1235 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
|
1236 m->type); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1237 abort (); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1238 } |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1239 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1240 if (!dont_register_blocks) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1241 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1242 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
|
1243 allocated_mem_type = MEM_TYPE_NON_LISP; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1244 } |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1245 } |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1246 #endif /* GC_MALLOC_CHECK */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1247 |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
1248 __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
|
1249 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
|
1250 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1251 /* 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
|
1252 return value; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1253 } |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1254 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1255 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1256 /* 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
|
1257 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1258 static void * |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1259 emacs_blocked_realloc (ptr, size) |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1260 void *ptr; |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
1261 size_t size; |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1262 { |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1263 void *value; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1264 |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1265 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
|
1266 __realloc_hook = old_realloc_hook; |
32692
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 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1269 if (ptr) |
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 struct mem_node *m = mem_find (ptr); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1272 if (m == MEM_NIL || m->start != ptr) |
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 fprintf (stderr, |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1275 "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
|
1276 ptr); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1277 abort (); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1278 } |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1279 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1280 mem_delete (m); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1281 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1282 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1283 /* fprintf (stderr, "%p -> realloc\n", ptr); */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1284 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1285 /* Prevent malloc from registering blocks. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1286 dont_register_blocks = 1; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1287 #endif /* GC_MALLOC_CHECK */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1288 |
3581
152fd924c7bb
* alloc.c (emacs_blocked_malloc, emacs_blocked_realloc): Cast the
Jim Blandy <jimb@redhat.com>
parents:
3536
diff
changeset
|
1289 value = (void *) realloc (ptr, size); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1290 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1291 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1292 dont_register_blocks = 0; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1293 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1294 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1295 struct mem_node *m = mem_find (value); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1296 if (m != MEM_NIL) |
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 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
|
1299 abort (); |
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 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1302 /* 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
|
1303 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
|
1304 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1305 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1306 /* fprintf (stderr, "%p <- realloc\n", value); */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1307 #endif /* GC_MALLOC_CHECK */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1308 |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
1309 __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
|
1310 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
|
1311 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1312 return value; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1313 } |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1314 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1315 |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1316 #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
|
1317 /* 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
|
1318 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
|
1319 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
|
1320 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
|
1321 |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1322 void |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1323 reset_malloc_hooks () |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1324 { |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1325 __free_hook = 0; |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1326 __malloc_hook = 0; |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1327 __realloc_hook = 0; |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1328 } |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1329 #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
|
1330 |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1331 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1332 /* 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
|
1333 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1334 void |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1335 uninterrupt_malloc () |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1336 { |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1337 #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
|
1338 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
|
1339 |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1340 /* 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
|
1341 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
|
1342 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
|
1343 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
|
1344 pthread_mutex_init (&alloc_mutex, &attr); |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58707
diff
changeset
|
1345 #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
|
1346 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1347 if (__free_hook != emacs_blocked_free) |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1348 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
|
1349 __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
|
1350 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1351 if (__malloc_hook != emacs_blocked_malloc) |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1352 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
|
1353 __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
|
1354 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1355 if (__realloc_hook != emacs_blocked_realloc) |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1356 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
|
1357 __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
|
1358 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1359 |
59359
1678d14c4109
(refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59314
diff
changeset
|
1360 #endif /* not SYNC_INPUT */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1361 #endif /* not SYSTEM_MALLOC */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1362 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1363 |
300 | 1364 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1365 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1366 Interval Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1367 ***********************************************************************/ |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
1368 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1369 /* 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
|
1370 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
|
1371 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1372 #define INTERVAL_BLOCK_SIZE \ |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1373 ((1020 - sizeof (struct interval_block *)) / sizeof (struct interval)) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1374 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1375 /* 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
|
1376 structure. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1377 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1378 struct interval_block |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1379 { |
53582
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
1380 /* Place `intervals' first, to preserve alignment. */ |
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
1381 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
|
1382 struct interval_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1383 }; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1384 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1385 /* 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
|
1386 blocks. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1387 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1388 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
|
1389 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1390 /* 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
|
1391 structure. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1392 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1393 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
|
1394 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1395 /* 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
|
1396 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1397 static int total_free_intervals, total_intervals; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1398 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1399 /* List of free intervals. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1400 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1401 INTERVAL interval_free_list; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1402 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1403 /* 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
|
1404 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1405 int n_interval_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1406 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1407 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1408 /* Initialize interval allocation. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1409 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1410 static void |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1411 init_intervals () |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1412 { |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
1413 interval_block = NULL; |
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
1414 interval_block_index = INTERVAL_BLOCK_SIZE; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1415 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
|
1416 n_interval_blocks = 0; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1417 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1418 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1419 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1420 /* Return a new interval. */ |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1421 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1422 INTERVAL |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1423 make_interval () |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1424 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1425 INTERVAL val; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1426 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1427 if (interval_free_list) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1428 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1429 val = interval_free_list; |
28269
fd13be8ae190
Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents:
28220
diff
changeset
|
1430 interval_free_list = INTERVAL_PARENT (interval_free_list); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1431 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1432 else |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1433 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1434 if (interval_block_index == INTERVAL_BLOCK_SIZE) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1435 { |
12529 | 1436 register struct interval_block *newi; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1437 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1438 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
|
1439 MEM_TYPE_NON_LISP); |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1440 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1441 newi->next = interval_block; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1442 interval_block = newi; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1443 interval_block_index = 0; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1444 n_interval_blocks++; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1445 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1446 val = &interval_block->intervals[interval_block_index++]; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1447 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1448 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
|
1449 intervals_consed++; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1450 RESET_INTERVAL (val); |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
1451 val->gcmarkbit = 0; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1452 return val; |
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 /* Mark Lisp objects in interval I. */ |
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 static void |
1957
54c8c66cd9ac
(mark_interval): Add ignored arg.
Richard M. Stallman <rms@gnu.org>
parents:
1939
diff
changeset
|
1459 mark_interval (i, dummy) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1460 register INTERVAL i; |
1957
54c8c66cd9ac
(mark_interval): Add ignored arg.
Richard M. Stallman <rms@gnu.org>
parents:
1939
diff
changeset
|
1461 Lisp_Object dummy; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1462 { |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
1463 eassert (!i->gcmarkbit); /* Intervals are never shared. */ |
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
1464 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
|
1465 mark_object (i->plist); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1466 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1467 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1468 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1469 /* 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
|
1470 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
|
1471 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1472 static void |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1473 mark_interval_tree (tree) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1474 register INTERVAL tree; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1475 { |
4139
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
1476 /* 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
|
1477 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
|
1478 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
|
1479 |
39859
36068b62b4c1
(mark_interval_tree): Use traverse_intervals_noorder.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39682
diff
changeset
|
1480 traverse_intervals_noorder (tree, mark_interval, Qnil); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1481 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1482 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1483 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1484 /* 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
|
1485 |
4139
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
1486 #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
|
1487 do { \ |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
1488 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
|
1489 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
|
1490 } while (0) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1491 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1492 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1493 #define UNMARK_BALANCE_INTERVALS(i) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1494 do { \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1495 if (! NULL_INTERVAL_P (i)) \ |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
1496 (i) = balance_intervals (i); \ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1497 } while (0) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1498 |
28469
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1499 |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1500 /* Number support. If NO_UNION_TYPE isn't in effect, we |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1501 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
|
1502 #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
|
1503 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
|
1504 make_number (n) |
60896
25e4a0f171b5
(make_number): The arg can be bigger than `int'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60143
diff
changeset
|
1505 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
|
1506 { |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1507 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
|
1508 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
|
1509 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
|
1510 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
|
1511 } |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1512 #endif |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1513 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1514 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1515 String Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1516 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1517 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1518 /* 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
|
1519 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
|
1520 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
|
1521 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
|
1522 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
|
1523 we keep. |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1524 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1525 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
|
1526 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
|
1527 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
|
1528 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1529 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
|
1530 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
|
1531 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
|
1532 its sdata structure. |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1533 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1534 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
|
1535 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
|
1536 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
|
1537 `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
|
1538 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
|
1539 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
|
1540 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1541 /* 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
|
1542 is 8192 minus malloc overhead. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1543 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1544 #define SBLOCK_SIZE 8188 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1545 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1546 /* 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
|
1547 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
|
1548 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1549 #define LARGE_STRING_BYTES 1024 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1550 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1551 /* 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
|
1552 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
|
1553 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1554 struct sdata |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1555 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1556 /* 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
|
1557 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
|
1558 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
|
1559 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
|
1560 (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
|
1561 contents. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1562 struct Lisp_String *string; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1563 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1564 #ifdef GC_CHECK_STRING_BYTES |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1565 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1566 EMACS_INT nbytes; |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1567 unsigned char data[1]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1568 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1569 #define SDATA_NBYTES(S) (S)->nbytes |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1570 #define SDATA_DATA(S) (S)->data |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1571 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1572 #else /* not GC_CHECK_STRING_BYTES */ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1573 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1574 union |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1575 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1576 /* When STRING in non-null. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1577 unsigned char data[1]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1578 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1579 /* When STRING is null. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1580 EMACS_INT nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1581 } u; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1582 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1583 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1584 #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
|
1585 #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
|
1586 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1587 #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
|
1588 }; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1589 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1590 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1591 /* 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
|
1592 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
|
1593 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
|
1594 as large as needed. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1595 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1596 struct sblock |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1597 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1598 /* Next in list. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1599 struct sblock *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1600 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1601 /* 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
|
1602 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
|
1603 struct sdata *next_free; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1604 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1605 /* Start of data. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1606 struct sdata first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1607 }; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1608 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1609 /* 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
|
1610 1024 minus malloc overhead. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1611 |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
1612 #define STRING_BLOCK_SIZE \ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1613 ((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
|
1614 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1615 /* 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
|
1616 are allocated. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1617 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1618 struct string_block |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1619 { |
53582
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
1620 /* Place `strings' first, to preserve alignment. */ |
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
1621 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
|
1622 struct string_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1623 }; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1624 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1625 /* 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
|
1626 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
|
1627 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
|
1628 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1629 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
|
1630 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1631 /* List of sblocks for large strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1632 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1633 static struct sblock *large_sblocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1634 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1635 /* 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
|
1636 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1637 static struct string_block *string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1638 static int n_string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1639 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1640 /* Free-list of Lisp_Strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1641 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1642 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
|
1643 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1644 /* 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
|
1645 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1646 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
|
1647 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1648 /* 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
|
1649 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1650 static int total_string_size; |
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 /* 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
|
1653 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
|
1654 free-list. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1655 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1656 #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
|
1657 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1658 /* 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
|
1659 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
|
1660 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
|
1661 structure starts at a constant offset in front of that. */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1662 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1663 #ifdef GC_CHECK_STRING_BYTES |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1664 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1665 #define SDATA_OF_STRING(S) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1666 ((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
|
1667 - sizeof (EMACS_INT))) |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1668 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1669 #else /* not GC_CHECK_STRING_BYTES */ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1670 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1671 #define SDATA_OF_STRING(S) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1672 ((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
|
1673 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1674 #endif /* not GC_CHECK_STRING_BYTES */ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1675 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1676 |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1677 #ifdef GC_CHECK_STRING_OVERRUN |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1678 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1679 /* 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
|
1680 "cookie" after each allocated string data block, and check for the |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1681 presense of this cookie during GC. */ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1682 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1683 #define GC_STRING_OVERRUN_COOKIE_SIZE 4 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1684 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
|
1685 { 0xde, 0xad, 0xbe, 0xef }; |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1686 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1687 #else |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1688 #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
|
1689 #endif |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1690 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1691 /* 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
|
1692 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
|
1693 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
|
1694 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1695 #ifdef GC_CHECK_STRING_BYTES |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1696 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1697 #define SDATA_SIZE(NBYTES) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1698 ((sizeof (struct Lisp_String *) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1699 + (NBYTES) + 1 \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1700 + sizeof (EMACS_INT) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1701 + sizeof (EMACS_INT) - 1) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1702 & ~(sizeof (EMACS_INT) - 1)) |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1703 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1704 #else /* not GC_CHECK_STRING_BYTES */ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1705 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1706 #define SDATA_SIZE(NBYTES) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1707 ((sizeof (struct Lisp_String *) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1708 + (NBYTES) + 1 \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1709 + sizeof (EMACS_INT) - 1) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1710 & ~(sizeof (EMACS_INT) - 1)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1711 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1712 #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
|
1713 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1714 /* Extra bytes to allocate for each string. */ |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1715 |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1716 #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
|
1717 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1718 /* 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
|
1719 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1720 void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1721 init_strings () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1722 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1723 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
|
1724 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
|
1725 string_blocks = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1726 n_string_blocks = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1727 string_free_list = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1728 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1729 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1730 |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1731 #ifdef GC_CHECK_STRING_BYTES |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1732 |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1733 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
|
1734 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1735 void check_string_bytes P_ ((int)); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1736 void check_sblock P_ ((struct sblock *)); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1737 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1738 #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
|
1739 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1740 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1741 /* 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
|
1742 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1743 int |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1744 string_bytes (s) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1745 struct Lisp_String *s; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1746 { |
51985
b52e88c3d6d0
(MARK_STRING, UNMARK_STRING, STRING_MARKED_P)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51974
diff
changeset
|
1747 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
|
1748 if (!PURE_POINTER_P (s) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1749 && s->data |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1750 && 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
|
1751 abort (); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1752 return nbytes; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1753 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1754 |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
1755 /* 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
|
1756 |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1757 void |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1758 check_sblock (b) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1759 struct sblock *b; |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1760 { |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1761 struct sdata *from, *end, *from_end; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1762 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1763 end = b->next_free; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1764 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1765 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
|
1766 { |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1767 /* 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
|
1768 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
|
1769 int nbytes; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1770 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1771 /* 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
|
1772 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
|
1773 if (from->string) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1774 CHECK_STRING_BYTES (from->string); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1775 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1776 if (from->string) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1777 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
|
1778 else |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1779 nbytes = SDATA_NBYTES (from); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1780 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1781 nbytes = SDATA_SIZE (nbytes); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1782 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
|
1783 } |
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 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1787 /* 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
|
1788 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
|
1789 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
|
1790 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1791 void |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1792 check_string_bytes (all_p) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1793 int all_p; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1794 { |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1795 if (all_p) |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1796 { |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1797 struct sblock *b; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1798 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1799 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
|
1800 { |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1801 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
|
1802 if (s) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1803 CHECK_STRING_BYTES (s); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1804 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1805 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1806 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
|
1807 check_sblock (b); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1808 } |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1809 else |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1810 check_sblock (current_sblock); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1811 } |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1812 |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1813 #endif /* GC_CHECK_STRING_BYTES */ |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1814 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1815 #ifdef GC_CHECK_STRING_FREE_LIST |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1816 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1817 /* 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
|
1818 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
|
1819 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1820 static void |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1821 check_string_free_list () |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1822 { |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1823 struct Lisp_String *s; |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1824 |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1825 /* 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
|
1826 s = string_free_list; |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1827 while (s != NULL) |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1828 { |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1829 if ((unsigned)s < 1024) |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1830 abort(); |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1831 s = NEXT_FREE_LISP_STRING (s); |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1832 } |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1833 } |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1834 #else |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1835 #define check_string_free_list() |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1836 #endif |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1837 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1838 /* Return a new Lisp_String. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1839 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1840 static struct Lisp_String * |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1841 allocate_string () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1842 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1843 struct Lisp_String *s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1844 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1845 /* 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
|
1846 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
|
1847 if (string_free_list == NULL) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1848 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1849 struct string_block *b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1850 int i; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1851 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1852 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
|
1853 bzero (b, sizeof *b); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1854 b->next = string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1855 string_blocks = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1856 ++n_string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1857 |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
1858 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
|
1859 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1860 s = b->strings + i; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1861 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
|
1862 string_free_list = s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1863 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1864 |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
1865 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
|
1866 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1867 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1868 check_string_free_list (); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1869 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1870 /* 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
|
1871 s = string_free_list; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1872 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
|
1873 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1874 /* 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
|
1875 bzero (s, sizeof *s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1876 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1877 --total_free_strings; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1878 ++total_strings; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1879 ++strings_consed; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1880 consing_since_gc += sizeof *s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1881 |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1882 #ifdef GC_CHECK_STRING_BYTES |
35660
b9366f467430
* alloc.c (allocate_string) [macintosh]: Call check_string_bytes
Andrew Choi <akochoi@shaw.ca>
parents:
35183
diff
changeset
|
1883 if (!noninteractive |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
44149
diff
changeset
|
1884 #ifdef MAC_OS8 |
35660
b9366f467430
* alloc.c (allocate_string) [macintosh]: Call check_string_bytes
Andrew Choi <akochoi@shaw.ca>
parents:
35183
diff
changeset
|
1885 && current_sblock |
b9366f467430
* alloc.c (allocate_string) [macintosh]: Call check_string_bytes
Andrew Choi <akochoi@shaw.ca>
parents:
35183
diff
changeset
|
1886 #endif |
b9366f467430
* alloc.c (allocate_string) [macintosh]: Call check_string_bytes
Andrew Choi <akochoi@shaw.ca>
parents:
35183
diff
changeset
|
1887 ) |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1888 { |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1889 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
|
1890 { |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1891 check_string_bytes_count = 0; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1892 check_string_bytes (1); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1893 } |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1894 else |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1895 check_string_bytes (0); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1896 } |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1897 #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
|
1898 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1899 return s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1900 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1901 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1902 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1903 /* 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
|
1904 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
|
1905 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
|
1906 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
|
1907 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
|
1908 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1909 void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1910 allocate_string_data (s, nchars, nbytes) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1911 struct Lisp_String *s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1912 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1913 { |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1914 struct sdata *data, *old_data; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1915 struct sblock *b; |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1916 int needed, old_nbytes; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1917 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1918 /* 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
|
1919 of string data. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1920 needed = SDATA_SIZE (nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1921 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1922 if (nbytes > LARGE_STRING_BYTES) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1923 { |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
1924 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
|
1925 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1926 #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
|
1927 /* 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
|
1928 because mapped region contents are not preserved in |
51318 | 1929 a dumped Emacs. |
1930 | |
1931 In case you think of allowing it in a dumped Emacs at the | |
1932 cost of not being able to re-dump, there's another reason: | |
1933 mmap'ed data typically have an address towards the top of the | |
1934 address space, which won't fit into an EMACS_INT (at least on | |
1935 32-bit systems with the current tagging scheme). --fx */ | |
61225
1e515cc6ca0c
* alloc.c (allocate_string_data): Call BLOCK_INPUT before calling
Jan Djärv <jan.h.d@swipnet.se>
parents:
60896
diff
changeset
|
1936 BLOCK_INPUT; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1937 mallopt (M_MMAP_MAX, 0); |
61225
1e515cc6ca0c
* alloc.c (allocate_string_data): Call BLOCK_INPUT before calling
Jan Djärv <jan.h.d@swipnet.se>
parents:
60896
diff
changeset
|
1938 UNBLOCK_INPUT; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1939 #endif |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1940 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1941 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
|
1942 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1943 #ifdef DOUG_LEA_MALLOC |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1944 /* Back to a reasonable maximum of mmap'ed areas. */ |
61225
1e515cc6ca0c
* alloc.c (allocate_string_data): Call BLOCK_INPUT before calling
Jan Djärv <jan.h.d@swipnet.se>
parents:
60896
diff
changeset
|
1945 BLOCK_INPUT; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1946 mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); |
61225
1e515cc6ca0c
* alloc.c (allocate_string_data): Call BLOCK_INPUT before calling
Jan Djärv <jan.h.d@swipnet.se>
parents:
60896
diff
changeset
|
1947 UNBLOCK_INPUT; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1948 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1949 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1950 b->next_free = &b->first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1951 b->first_data.string = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1952 b->next = large_sblocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1953 large_sblocks = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1954 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1955 else if (current_sblock == NULL |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1956 || (((char *) current_sblock + SBLOCK_SIZE |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1957 - (char *) current_sblock->next_free) |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1958 < (needed + GC_STRING_EXTRA))) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1959 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1960 /* 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
|
1961 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
|
1962 b->next_free = &b->first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1963 b->first_data.string = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1964 b->next = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1965 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1966 if (current_sblock) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1967 current_sblock->next = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1968 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1969 oldest_sblock = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1970 current_sblock = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1971 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1972 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1973 b = current_sblock; |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1974 |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1975 old_data = s->data ? SDATA_OF_STRING (s) : NULL; |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1976 old_nbytes = GC_STRING_BYTES (s); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1977 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1978 data = b->next_free; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1979 data->string = s; |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1980 s->data = SDATA_DATA (data); |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1981 #ifdef GC_CHECK_STRING_BYTES |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1982 SDATA_NBYTES (data) = nbytes; |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1983 #endif |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1984 s->size = nchars; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1985 s->size_byte = nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1986 s->data[nbytes] = '\0'; |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1987 #ifdef GC_CHECK_STRING_OVERRUN |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1988 bcopy (string_overrun_cookie, (char *) data + needed, |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
1989 GC_STRING_OVERRUN_COOKIE_SIZE); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1990 #endif |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
1991 b->next_free = (struct sdata *) ((char *) data + needed + GC_STRING_EXTRA); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1992 |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1993 /* 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
|
1994 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
|
1995 in it. */ |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1996 if (old_data) |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1997 { |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1998 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
|
1999 old_data->string = NULL; |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
2000 } |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
2001 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2002 consing_since_gc += needed; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2003 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2004 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2005 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2006 /* Sweep and compact strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2007 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2008 static void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2009 sweep_strings () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2010 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2011 struct string_block *b, *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2012 struct string_block *live_blocks = NULL; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2013 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2014 string_free_list = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2015 total_strings = total_free_strings = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2016 total_string_size = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2017 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2018 /* 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
|
2019 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
|
2020 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2021 int i, nfree = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2022 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
|
2023 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2024 next = b->next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2025 |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
2026 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
|
2027 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2028 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
|
2029 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2030 if (s->data) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2031 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2032 /* 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
|
2033 if (STRING_MARKED_P (s)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2034 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2035 /* 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
|
2036 UNMARK_STRING (s); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2037 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2038 if (!NULL_INTERVAL_P (s->intervals)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2039 UNMARK_BALANCE_INTERVALS (s->intervals); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2040 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2041 ++total_strings; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2042 total_string_size += STRING_BYTES (s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2043 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2044 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2045 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2046 /* 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
|
2047 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
|
2048 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2049 /* 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
|
2050 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
|
2051 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
|
2052 #ifdef GC_CHECK_STRING_BYTES |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2053 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
|
2054 abort (); |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2055 #else |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2056 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
|
2057 #endif |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2058 data->string = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2059 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2060 /* 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
|
2061 know it's free. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2062 s->data = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2063 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2064 /* 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
|
2065 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
|
2066 string_free_list = s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2067 ++nfree; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2068 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2069 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2070 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2071 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2072 /* 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
|
2073 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
|
2074 string_free_list = s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2075 ++nfree; |
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 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2078 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2079 /* 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
|
2080 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
|
2081 if (nfree == STRING_BLOCK_SIZE |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
2082 && 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
|
2083 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2084 lisp_free (b); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2085 --n_string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2086 string_free_list = free_list_before; |
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 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2089 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2090 total_free_strings += nfree; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2091 b->next = live_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2092 live_blocks = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2093 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2094 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2095 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
2096 check_string_free_list (); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2097 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2098 string_blocks = live_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2099 free_large_strings (); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2100 compact_small_strings (); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2101 |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
2102 check_string_free_list (); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2103 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2104 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2105 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2106 /* Free dead large strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2107 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2108 static void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2109 free_large_strings () |
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 struct sblock *b, *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2112 struct sblock *live_blocks = NULL; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2113 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2114 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
|
2115 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2116 next = b->next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2117 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2118 if (b->first_data.string == NULL) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2119 lisp_free (b); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2120 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2121 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2122 b->next = live_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2123 live_blocks = b; |
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 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2126 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2127 large_sblocks = live_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2128 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2129 |
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 /* 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
|
2132 data of live strings after compaction. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2133 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2134 static void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2135 compact_small_strings () |
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 struct sblock *b, *tb, *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2138 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
|
2139 struct sdata *to_end, *from_end; |
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 /* 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
|
2142 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
|
2143 tb = oldest_sblock; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2144 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
|
2145 to = &tb->first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2146 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2147 /* 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
|
2148 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
|
2149 copying will happen this way. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2150 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
|
2151 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2152 end = b->next_free; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2153 xassert ((char *) end <= (char *) b + SBLOCK_SIZE); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2154 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2155 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
|
2156 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2157 /* 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
|
2158 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
|
2159 int nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2160 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2161 #ifdef GC_CHECK_STRING_BYTES |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2162 /* 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
|
2163 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
|
2164 if (from->string |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2165 && 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
|
2166 abort (); |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2167 #endif /* GC_CHECK_STRING_BYTES */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2168 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2169 if (from->string) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2170 nbytes = GC_STRING_BYTES (from->string); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2171 else |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
2172 nbytes = SDATA_NBYTES (from); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2173 |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2174 if (nbytes > LARGE_STRING_BYTES) |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2175 abort (); |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2176 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2177 nbytes = SDATA_SIZE (nbytes); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2178 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
|
2179 |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2180 #ifdef GC_CHECK_STRING_OVERRUN |
58707
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
2181 if (bcmp (string_overrun_cookie, |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
2182 ((char *) from_end) - GC_STRING_OVERRUN_COOKIE_SIZE, |
57741ce4cd6b
Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents:
58631
diff
changeset
|
2183 GC_STRING_OVERRUN_COOKIE_SIZE)) |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2184 abort (); |
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2185 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2186 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2187 /* 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
|
2188 if (from->string) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2189 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2190 /* 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
|
2191 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
|
2192 if (to_end > tb_end) |
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 tb->next_free = to; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2195 tb = tb->next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2196 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
|
2197 to = &tb->first_data; |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2198 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
|
2199 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2200 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2201 /* 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
|
2202 if (from != to) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2203 { |
30823
8ee3740aaf60
(compact_small_strings): Use safe_bcopy, add an
Gerd Moellmann <gerd@gnu.org>
parents:
30784
diff
changeset
|
2204 xassert (tb != b || to <= from); |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2205 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
|
2206 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
|
2207 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2208 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2209 /* 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
|
2210 to = to_end; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2211 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2212 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2213 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2214 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2215 /* 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
|
2216 we can free them. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2217 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
|
2218 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2219 next = b->next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2220 lisp_free (b); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2221 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2222 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2223 tb->next_free = to; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2224 tb->next = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2225 current_sblock = tb; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2226 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2227 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2228 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2229 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
|
2230 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
|
2231 LENGTH must be an integer. |
1c3b8ce97c63
(Fmake_string): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
55720
diff
changeset
|
2232 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
|
2233 (length, init) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2234 Lisp_Object length, init; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2235 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2236 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2237 register unsigned char *p, *end; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2238 int c, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2239 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
2240 CHECK_NATNUM (length); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
2241 CHECK_NUMBER (init); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2242 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2243 c = XINT (init); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2244 if (SINGLE_BYTE_CHAR_P (c)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2245 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2246 nbytes = XINT (length); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2247 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
|
2248 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
|
2249 end = p + SCHARS (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2250 while (p != end) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2251 *p++ = c; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2252 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2253 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2254 { |
33800
7f148cfbd1f7
(Fmake_string): Use MAX_MULTIBYTE_LENGTH, instead of hard coded `4'.
Kenichi Handa <handa@m17n.org>
parents:
33764
diff
changeset
|
2255 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
|
2256 int len = CHAR_STRING (c, str); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2257 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2258 nbytes = len * XINT (length); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2259 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
|
2260 p = SDATA (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2261 end = p + nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2262 while (p != end) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2263 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2264 bcopy (str, p, len); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2265 p += len; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2266 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2267 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2268 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2269 *p = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2270 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2271 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2272 |
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 DEFUN ("make-bool-vector", Fmake_bool_vector, Smake_bool_vector, 2, 2, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
2275 doc: /* Return a new bool-vector of length LENGTH, using INIT for as each element. |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2276 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
|
2277 (length, init) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2278 Lisp_Object length, init; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2279 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2280 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2281 struct Lisp_Bool_Vector *p; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2282 int real_init, i; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2283 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
|
2284 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
2285 CHECK_NATNUM (length); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2286 |
55159
e4e9ec547c6f
(Fmake_bool_vector): Use BOOL_VECTOR_BITS_PER_CHAR instead of
Andreas Schwab <schwab@suse.de>
parents:
53705
diff
changeset
|
2287 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
|
2288 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2289 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
|
2290 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
|
2291 / BOOL_VECTOR_BITS_PER_CHAR); |
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 /* 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
|
2294 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
|
2295 val = Fmake_vector (make_number (length_in_elts + 1), Qnil); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2296 p = XBOOL_VECTOR (val); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2297 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2298 /* Get rid of any bits that would cause confusion. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2299 p->vector_size = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2300 XSETBOOL_VECTOR (val, p); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2301 p->size = XFASTINT (length); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2302 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2303 real_init = (NILP (init) ? 0 : -1); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2304 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
|
2305 p->data[i] = real_init; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2306 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2307 /* 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
|
2308 if (XINT (length) != length_in_chars * BOOL_VECTOR_BITS_PER_CHAR) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2309 XBOOL_VECTOR (val)->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
|
2310 &= (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
|
2311 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2312 return val; |
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 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2315 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2316 /* 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
|
2317 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
|
2318 multibyte, depending on the contents. */ |
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 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2321 make_string (contents, nbytes) |
46459
0a9cbcbdbe45
(xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents:
46418
diff
changeset
|
2322 const char *contents; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2323 int nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2324 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2325 register Lisp_Object val; |
28997
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
2326 int nchars, multibyte_nbytes; |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
2327 |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
2328 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
|
2329 if (nbytes == nchars || nbytes != multibyte_nbytes) |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
2330 /* 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
|
2331 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
|
2332 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
|
2333 else |
dda5cbf94928
(make_string): Fix previous change. Be sure to make
Kenichi Handa <handa@m17n.org>
parents:
32776
diff
changeset
|
2334 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
|
2335 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2336 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2337 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2338 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2339 /* 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
|
2340 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2341 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2342 make_unibyte_string (contents, length) |
46459
0a9cbcbdbe45
(xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents:
46418
diff
changeset
|
2343 const char *contents; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2344 int length; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2345 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2346 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2347 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
|
2348 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
|
2349 STRING_SET_UNIBYTE (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2350 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2351 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2352 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2353 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2354 /* 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
|
2355 bytes at CONTENTS. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2356 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2357 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2358 make_multibyte_string (contents, nchars, nbytes) |
46459
0a9cbcbdbe45
(xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents:
46418
diff
changeset
|
2359 const char *contents; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2360 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2361 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2362 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2363 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
|
2364 bcopy (contents, SDATA (val), nbytes); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2365 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2366 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2367 |
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 /* 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
|
2370 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
|
2371 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2372 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2373 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
|
2374 const char *contents; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2375 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2376 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2377 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2378 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
|
2379 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
|
2380 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
|
2381 STRING_SET_UNIBYTE (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2382 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2383 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2384 |
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 /* 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
|
2387 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
|
2388 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
|
2389 characters by itself. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2390 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2391 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2392 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
|
2393 const char *contents; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2394 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2395 int multibyte; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2396 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2397 register Lisp_Object val; |
50200
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2398 |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2399 if (nchars < 0) |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2400 { |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2401 if (multibyte) |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2402 nchars = multibyte_chars_in_text (contents, nbytes); |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2403 else |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2404 nchars = nbytes; |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2405 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2406 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
|
2407 bcopy (contents, SDATA (val), nbytes); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2408 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
|
2409 STRING_SET_UNIBYTE (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2410 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2411 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2412 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2413 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2414 /* 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
|
2415 data warrants. */ |
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 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2418 build_string (str) |
46459
0a9cbcbdbe45
(xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents:
46418
diff
changeset
|
2419 const char *str; |
27142
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 return make_string (str, strlen (str)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2422 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2423 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2424 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2425 /* 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
|
2426 occupying LENGTH bytes. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2427 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2428 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2429 make_uninit_string (length) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2430 int length; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2431 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2432 Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2433 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
|
2434 STRING_SET_UNIBYTE (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2435 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2436 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2437 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2438 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2439 /* 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
|
2440 which occupy NBYTES bytes. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2441 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2442 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2443 make_uninit_multibyte_string (nchars, nbytes) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2444 int nchars, nbytes; |
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 Lisp_Object string; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2447 struct Lisp_String *s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2448 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2449 if (nchars < 0) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2450 abort (); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2451 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2452 s = allocate_string (); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2453 allocate_string_data (s, nchars, nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2454 XSETSTRING (string, s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2455 string_chars_consed += nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2456 return string; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2457 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2458 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2459 |
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 Float Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2463 ***********************************************************************/ |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
2464 |
300 | 2465 /* 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
|
2466 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
|
2467 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
|
2468 any new float cells from the latest float_block. */ |
300 | 2469 |
53582
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
2470 #define FLOAT_BLOCK_SIZE \ |
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
2471 (((BLOCK_BYTES - sizeof (struct float_block *) \ |
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
2472 /* 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
|
2473 - (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
|
2474 / (sizeof (struct Lisp_Float) * CHAR_BIT + 1)) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2475 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2476 #define GETMARKBIT(block,n) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2477 (((block)->gcmarkbits[(n) / (sizeof(int) * CHAR_BIT)] \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2478 >> ((n) % (sizeof(int) * CHAR_BIT))) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2479 & 1) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2480 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2481 #define SETMARKBIT(block,n) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2482 (block)->gcmarkbits[(n) / (sizeof(int) * CHAR_BIT)] \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2483 |= 1 << ((n) % (sizeof(int) * CHAR_BIT)) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2484 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2485 #define UNSETMARKBIT(block,n) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2486 (block)->gcmarkbits[(n) / (sizeof(int) * CHAR_BIT)] \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2487 &= ~(1 << ((n) % (sizeof(int) * CHAR_BIT))) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2488 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2489 #define FLOAT_BLOCK(fptr) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2490 ((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
|
2491 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2492 #define FLOAT_INDEX(fptr) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2493 ((((EMACS_UINT)(fptr)) & (BLOCK_ALIGN - 1)) / sizeof (struct Lisp_Float)) |
300 | 2494 |
2495 struct float_block | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2496 { |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2497 /* 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
|
2498 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
|
2499 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
|
2500 struct float_block *next; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2501 }; |
300 | 2502 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2503 #define FLOAT_MARKED_P(fptr) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2504 GETMARKBIT (FLOAT_BLOCK (fptr), FLOAT_INDEX ((fptr))) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2505 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2506 #define FLOAT_MARK(fptr) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2507 SETMARKBIT (FLOAT_BLOCK (fptr), FLOAT_INDEX ((fptr))) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2508 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2509 #define FLOAT_UNMARK(fptr) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2510 UNSETMARKBIT (FLOAT_BLOCK (fptr), FLOAT_INDEX ((fptr))) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2511 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2512 /* Current float_block. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2513 |
300 | 2514 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
|
2515 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2516 /* 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
|
2517 |
300 | 2518 int float_block_index; |
2519 | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2520 /* 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
|
2521 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2522 int n_float_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2523 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2524 /* 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
|
2525 |
300 | 2526 struct Lisp_Float *float_free_list; |
2527 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2528 |
39297
aff361cfdccb
Fix a typo in a comment. From Pavel Janik.
Eli Zaretskii <eliz@gnu.org>
parents:
39228
diff
changeset
|
2529 /* Initialize float allocation. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2530 |
300 | 2531 void |
2532 init_float () | |
2533 { | |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2534 float_block = NULL; |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2535 float_block_index = FLOAT_BLOCK_SIZE; /* Force alloc of new float_block. */ |
300 | 2536 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
|
2537 n_float_blocks = 0; |
300 | 2538 } |
2539 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2540 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2541 /* 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
|
2542 |
21514 | 2543 void |
300 | 2544 free_float (ptr) |
2545 struct Lisp_Float *ptr; | |
2546 { | |
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
|
2547 *(struct Lisp_Float **)&ptr->data = float_free_list; |
300 | 2548 float_free_list = ptr; |
2549 } | |
2550 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2551 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2552 /* 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
|
2553 |
300 | 2554 Lisp_Object |
2555 make_float (float_value) | |
2556 double float_value; | |
2557 { | |
2558 register Lisp_Object val; | |
2559 | |
2560 if (float_free_list) | |
2561 { | |
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
|
2562 /* 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
|
2563 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
|
2564 XSETFLOAT (val, float_free_list); |
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
|
2565 float_free_list = *(struct Lisp_Float **)&float_free_list->data; |
300 | 2566 } |
2567 else | |
2568 { | |
2569 if (float_block_index == FLOAT_BLOCK_SIZE) | |
2570 { | |
12529 | 2571 register struct float_block *new; |
2572 | |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2573 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
|
2574 MEM_TYPE_FLOAT); |
300 | 2575 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
|
2576 bzero ((char *) new->gcmarkbits, sizeof new->gcmarkbits); |
300 | 2577 float_block = new; |
2578 float_block_index = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2579 n_float_blocks++; |
300 | 2580 } |
53093
e8f5463f3d5b
(make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52837
diff
changeset
|
2581 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
|
2582 float_block_index++; |
300 | 2583 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2584 |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
2585 XFLOAT_DATA (val) = float_value; |
53093
e8f5463f3d5b
(make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52837
diff
changeset
|
2586 eassert (!FLOAT_MARKED_P (XFLOAT (val))); |
300 | 2587 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
|
2588 floats_consed++; |
300 | 2589 return val; |
2590 } | |
2591 | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2592 |
300 | 2593 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2594 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2595 Cons Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2596 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2597 |
300 | 2598 /* We store cons cells inside of cons_blocks, allocating a new |
2599 cons_block with malloc whenever necessary. Cons cells reclaimed by | |
2600 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
|
2601 any new cons cells from the latest cons_block. */ |
300 | 2602 |
2603 #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
|
2604 (((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
|
2605 / (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
|
2606 |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2607 #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
|
2608 ((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
|
2609 |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2610 #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
|
2611 ((((EMACS_UINT)(fptr)) & (BLOCK_ALIGN - 1)) / sizeof (struct Lisp_Cons)) |
300 | 2612 |
2613 struct cons_block | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2614 { |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2615 /* 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
|
2616 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
|
2617 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
|
2618 struct cons_block *next; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2619 }; |
300 | 2620 |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2621 #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
|
2622 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
|
2623 |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2624 #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
|
2625 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
|
2626 |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2627 #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
|
2628 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
|
2629 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2630 /* Current cons_block. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2631 |
300 | 2632 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
|
2633 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2634 /* 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
|
2635 |
300 | 2636 int cons_block_index; |
2637 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2638 /* 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
|
2639 |
300 | 2640 struct Lisp_Cons *cons_free_list; |
2641 | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2642 /* 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
|
2643 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2644 int n_cons_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2645 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2646 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2647 /* Initialize cons allocation. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2648 |
300 | 2649 void |
2650 init_cons () | |
2651 { | |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2652 cons_block = NULL; |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2653 cons_block_index = CONS_BLOCK_SIZE; /* Force alloc of new cons_block. */ |
300 | 2654 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
|
2655 n_cons_blocks = 0; |
300 | 2656 } |
2657 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2658 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2659 /* 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
|
2660 |
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
2661 void |
300 | 2662 free_cons (ptr) |
2663 struct Lisp_Cons *ptr; | |
2664 { | |
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
|
2665 *(struct Lisp_Cons **)&ptr->cdr = cons_free_list; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2666 #if GC_MARK_STACK |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2667 ptr->car = Vdead; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2668 #endif |
300 | 2669 cons_free_list = ptr; |
2670 } | |
2671 | |
2672 DEFUN ("cons", Fcons, Scons, 2, 2, 0, | |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
2673 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
|
2674 (car, cdr) |
300 | 2675 Lisp_Object car, cdr; |
2676 { | |
2677 register Lisp_Object val; | |
2678 | |
2679 if (cons_free_list) | |
2680 { | |
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
|
2681 /* 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
|
2682 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
|
2683 XSETCONS (val, cons_free_list); |
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
|
2684 cons_free_list = *(struct Lisp_Cons **)&cons_free_list->cdr; |
300 | 2685 } |
2686 else | |
2687 { | |
2688 if (cons_block_index == CONS_BLOCK_SIZE) | |
2689 { | |
12529 | 2690 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
|
2691 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
|
2692 MEM_TYPE_CONS); |
53093
e8f5463f3d5b
(make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52837
diff
changeset
|
2693 bzero ((char *) new->gcmarkbits, sizeof new->gcmarkbits); |
300 | 2694 new->next = cons_block; |
2695 cons_block = new; | |
2696 cons_block_index = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2697 n_cons_blocks++; |
300 | 2698 } |
53093
e8f5463f3d5b
(make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52837
diff
changeset
|
2699 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
|
2700 cons_block_index++; |
300 | 2701 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2702 |
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
2703 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
|
2704 XSETCDR (val, cdr); |
53093
e8f5463f3d5b
(make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52837
diff
changeset
|
2705 eassert (!CONS_MARKED_P (XCONS (val))); |
300 | 2706 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
|
2707 cons_cells_consed++; |
300 | 2708 return val; |
2709 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2710 |
56539
9fc5aae4053e
(check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents:
56401
diff
changeset
|
2711 /* 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
|
2712 void |
9fc5aae4053e
(check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents:
56401
diff
changeset
|
2713 check_cons_list () |
9fc5aae4053e
(check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents:
56401
diff
changeset
|
2714 { |
58631
7c469d30a12d
Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents:
58593
diff
changeset
|
2715 #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
|
2716 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
|
2717 |
9fc5aae4053e
(check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents:
56401
diff
changeset
|
2718 while (tail) |
9fc5aae4053e
(check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents:
56401
diff
changeset
|
2719 tail = *(struct Lisp_Cons **)&tail->cdr; |
9fc5aae4053e
(check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents:
56401
diff
changeset
|
2720 #endif |
9fc5aae4053e
(check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents:
56401
diff
changeset
|
2721 } |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2722 |
20849
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2723 /* Make a list of 2, 3, 4 or 5 specified objects. */ |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2724 |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2725 Lisp_Object |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2726 list2 (arg1, arg2) |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2727 Lisp_Object arg1, arg2; |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2728 { |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2729 return Fcons (arg1, Fcons (arg2, Qnil)); |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2730 } |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2731 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2732 |
20849
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2733 Lisp_Object |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2734 list3 (arg1, arg2, arg3) |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2735 Lisp_Object arg1, arg2, arg3; |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2736 { |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2737 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
|
2738 } |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2739 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2740 |
20849
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2741 Lisp_Object |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2742 list4 (arg1, arg2, arg3, arg4) |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2743 Lisp_Object arg1, arg2, arg3, arg4; |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2744 { |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2745 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
|
2746 } |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2747 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2748 |
20849
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2749 Lisp_Object |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2750 list5 (arg1, arg2, arg3, arg4, arg5) |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2751 Lisp_Object arg1, arg2, arg3, arg4, arg5; |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2752 { |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2753 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
|
2754 Fcons (arg5, Qnil))))); |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2755 } |
300 | 2756 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2757 |
300 | 2758 DEFUN ("list", Flist, Slist, 0, MANY, 0, |
40977 | 2759 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
|
2760 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
|
2761 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
|
2762 (nargs, args) |
300 | 2763 int nargs; |
2764 register Lisp_Object *args; | |
2765 { | |
13610
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2766 register Lisp_Object val; |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2767 val = Qnil; |
300 | 2768 |
13610
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2769 while (nargs > 0) |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2770 { |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2771 nargs--; |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2772 val = Fcons (args[nargs], val); |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2773 } |
300 | 2774 return val; |
2775 } | |
2776 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2777 |
300 | 2778 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
|
2779 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
|
2780 (length, init) |
300 | 2781 register Lisp_Object length, init; |
2782 { | |
2783 register Lisp_Object val; | |
2784 register int size; | |
2785 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
2786 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
|
2787 size = XFASTINT (length); |
300 | 2788 |
2789 val = Qnil; | |
35762
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2790 while (size > 0) |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2791 { |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2792 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
|
2793 --size; |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2794 |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2795 if (size > 0) |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2796 { |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2797 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
|
2798 --size; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2799 |
35762
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2800 if (size > 0) |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2801 { |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2802 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
|
2803 --size; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2804 |
35762
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2805 if (size > 0) |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2806 { |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2807 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
|
2808 --size; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2809 |
35762
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2810 if (size > 0) |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2811 { |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2812 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
|
2813 --size; |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2814 } |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2815 } |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2816 } |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2817 } |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2818 |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2819 QUIT; |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2820 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2821 |
300 | 2822 return val; |
2823 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2824 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2825 |
300 | 2826 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2827 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2828 Vector Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2829 ***********************************************************************/ |
300 | 2830 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2831 /* 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
|
2832 |
300 | 2833 struct Lisp_Vector *all_vectors; |
2834 | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2835 /* 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
|
2836 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2837 int n_vectors; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2838 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2839 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2840 /* 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
|
2841 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
|
2842 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2843 static struct Lisp_Vector * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2844 allocate_vectorlike (len, type) |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2845 EMACS_INT len; |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2846 enum mem_type type; |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2847 { |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2848 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
|
2849 size_t nbytes; |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2850 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
2851 #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
|
2852 /* 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
|
2853 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
|
2854 a dumped Emacs. */ |
53555
72ce38380ab3
* alloc.c (allocate_vectorlike): Surround calls to mallopt with
Jan Djärv <jan.h.d@swipnet.se>
parents:
53093
diff
changeset
|
2855 BLOCK_INPUT; |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
2856 mallopt (M_MMAP_MAX, 0); |
53555
72ce38380ab3
* alloc.c (allocate_vectorlike): Surround calls to mallopt with
Jan Djärv <jan.h.d@swipnet.se>
parents:
53093
diff
changeset
|
2857 UNBLOCK_INPUT; |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
2858 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2859 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2860 nbytes = sizeof *p + (len - 1) * sizeof p->contents[0]; |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2861 p = (struct Lisp_Vector *) lisp_malloc (nbytes, type); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2862 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
2863 #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
|
2864 /* Back to a reasonable maximum of mmap'ed areas. */ |
53555
72ce38380ab3
* alloc.c (allocate_vectorlike): Surround calls to mallopt with
Jan Djärv <jan.h.d@swipnet.se>
parents:
53093
diff
changeset
|
2865 BLOCK_INPUT; |
23973
2eb9e2f5aa33
(MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
23958
diff
changeset
|
2866 mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); |
53555
72ce38380ab3
* alloc.c (allocate_vectorlike): Surround calls to mallopt with
Jan Djärv <jan.h.d@swipnet.se>
parents:
53093
diff
changeset
|
2867 UNBLOCK_INPUT; |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
2868 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2869 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2870 consing_since_gc += nbytes; |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
2871 vector_cells_consed += len; |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2872 |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2873 p->next = all_vectors; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2874 all_vectors = p; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2875 ++n_vectors; |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2876 return p; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2877 } |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2878 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2879 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2880 /* Allocate a vector with NSLOTS slots. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2881 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2882 struct Lisp_Vector * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2883 allocate_vector (nslots) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2884 EMACS_INT nslots; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2885 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2886 struct Lisp_Vector *v = allocate_vectorlike (nslots, MEM_TYPE_VECTOR); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2887 v->size = nslots; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2888 return v; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2889 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2890 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2891 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2892 /* Allocate other vector-like structures. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2893 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2894 struct Lisp_Hash_Table * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2895 allocate_hash_table () |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2896 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2897 EMACS_INT len = VECSIZE (struct Lisp_Hash_Table); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2898 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_HASH_TABLE); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2899 EMACS_INT i; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2900 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2901 v->size = len; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2902 for (i = 0; i < len; ++i) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2903 v->contents[i] = Qnil; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2904 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2905 return (struct Lisp_Hash_Table *) v; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2906 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2907 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2908 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2909 struct window * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2910 allocate_window () |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2911 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2912 EMACS_INT len = VECSIZE (struct window); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2913 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_WINDOW); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2914 EMACS_INT i; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2915 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2916 for (i = 0; i < len; ++i) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2917 v->contents[i] = Qnil; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2918 v->size = len; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2919 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2920 return (struct window *) v; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2921 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2922 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2923 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2924 struct frame * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2925 allocate_frame () |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2926 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2927 EMACS_INT len = VECSIZE (struct frame); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2928 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_FRAME); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2929 EMACS_INT i; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2930 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2931 for (i = 0; i < len; ++i) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2932 v->contents[i] = make_number (0); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2933 v->size = len; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2934 return (struct frame *) v; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2935 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2936 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2937 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2938 struct Lisp_Process * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2939 allocate_process () |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2940 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2941 EMACS_INT len = VECSIZE (struct Lisp_Process); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2942 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_PROCESS); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2943 EMACS_INT i; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2944 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2945 for (i = 0; i < len; ++i) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2946 v->contents[i] = Qnil; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2947 v->size = len; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2948 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2949 return (struct Lisp_Process *) v; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2950 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2951 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2952 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2953 struct Lisp_Vector * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2954 allocate_other_vector (len) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2955 EMACS_INT len; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2956 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2957 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_VECTOR); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2958 EMACS_INT i; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2959 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2960 for (i = 0; i < len; ++i) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2961 v->contents[i] = Qnil; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2962 v->size = len; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2963 |
36435
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 |
300 | 2968 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
|
2969 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
|
2970 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
|
2971 (length, init) |
300 | 2972 register Lisp_Object length, init; |
2973 { | |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2974 Lisp_Object vector; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2975 register EMACS_INT sizei; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2976 register int index; |
300 | 2977 register struct Lisp_Vector *p; |
2978 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
2979 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
|
2980 sizei = XFASTINT (length); |
300 | 2981 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2982 p = allocate_vector (sizei); |
300 | 2983 for (index = 0; index < sizei; index++) |
2984 p->contents[index] = init; | |
2985 | |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2986 XSETVECTOR (vector, p); |
300 | 2987 return vector; |
2988 } | |
2989 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2990 |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
2991 DEFUN ("make-char-table", Fmake_char_table, Smake_char_table, 1, 2, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
2992 doc: /* Return a newly created char-table, with purpose PURPOSE. |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
2993 Each element is initialized to INIT, which defaults to nil. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
2994 PURPOSE should be a symbol which has a `char-table-extra-slots' property. |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2995 The property's value should be an integer between 0 and 10. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2996 (purpose, init) |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
2997 register Lisp_Object purpose, init; |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
2998 { |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
2999 Lisp_Object vector; |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
3000 Lisp_Object n; |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
3001 CHECK_SYMBOL (purpose); |
17328
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
3002 n = Fget (purpose, Qchar_table_extra_slots); |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
3003 CHECK_NUMBER (n); |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
3004 if (XINT (n) < 0 || XINT (n) > 10) |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
3005 args_out_of_range (n, Qnil); |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
3006 /* Add 2 to the size for the defalt and parent slots. */ |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
3007 vector = Fmake_vector (make_number (CHAR_TABLE_STANDARD_SLOTS + XINT (n)), |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
3008 init); |
17328
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
3009 XCHAR_TABLE (vector)->top = Qt; |
13150
3778c95adca9
(Fmake_char_table): Initialize parent to nil.
Erik Naggum <erik@naggum.no>
parents:
13141
diff
changeset
|
3010 XCHAR_TABLE (vector)->parent = Qnil; |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
3011 XCHAR_TABLE (vector)->purpose = purpose; |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
3012 XSETCHAR_TABLE (vector, XCHAR_TABLE (vector)); |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
3013 return vector; |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
3014 } |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
3015 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3016 |
17328
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
3017 /* Return a newly created sub char table with default value DEFALT. |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
3018 Since a sub char table does not appear as a top level Emacs Lisp |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
3019 object, we don't need a Lisp interface to make it. */ |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
3020 |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
3021 Lisp_Object |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
3022 make_sub_char_table (defalt) |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
3023 Lisp_Object defalt; |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
3024 { |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
3025 Lisp_Object vector |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
3026 = Fmake_vector (make_number (SUB_CHAR_TABLE_STANDARD_SLOTS), Qnil); |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
3027 XCHAR_TABLE (vector)->top = Qnil; |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
3028 XCHAR_TABLE (vector)->defalt = defalt; |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
3029 XSETCHAR_TABLE (vector, XCHAR_TABLE (vector)); |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
3030 return vector; |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
3031 } |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
3032 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3033 |
300 | 3034 DEFUN ("vector", Fvector, Svector, 0, MANY, 0, |
40977 | 3035 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
|
3036 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
|
3037 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
|
3038 (nargs, args) |
300 | 3039 register int nargs; |
3040 Lisp_Object *args; | |
3041 { | |
3042 register Lisp_Object len, val; | |
3043 register int index; | |
3044 register struct Lisp_Vector *p; | |
3045 | |
9295
17d393a8eed6
(free_float, make_float, free_cons, Flist, Fvector, Fmake_byte_code,
Karl Heuer <kwzh@gnu.org>
parents:
9261
diff
changeset
|
3046 XSETFASTINT (len, nargs); |
300 | 3047 val = Fmake_vector (len, Qnil); |
3048 p = XVECTOR (val); | |
3049 for (index = 0; index < nargs; index++) | |
3050 p->contents[index] = args[index]; | |
3051 return val; | |
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 ("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
|
3056 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
|
3057 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
|
3058 stack size, (optional) doc string, and (optional) interactive spec. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
3059 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
|
3060 significance. |
50626
a5a77c7717cb
(Fmake_byte_code): Improve the `usage' string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50468
diff
changeset
|
3061 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
|
3062 (nargs, args) |
300 | 3063 register int nargs; |
3064 Lisp_Object *args; | |
3065 { | |
3066 register Lisp_Object len, val; | |
3067 register int index; | |
3068 register struct Lisp_Vector *p; | |
3069 | |
9295
17d393a8eed6
(free_float, make_float, free_cons, Flist, Fvector, Fmake_byte_code,
Karl Heuer <kwzh@gnu.org>
parents:
9261
diff
changeset
|
3070 XSETFASTINT (len, nargs); |
485 | 3071 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
|
3072 val = make_pure_vector ((EMACS_INT) nargs); |
300 | 3073 else |
3074 val = Fmake_vector (len, Qnil); | |
28997
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
3075 |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
3076 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
|
3077 /* 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
|
3078 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
|
3079 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
|
3080 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
|
3081 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
|
3082 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
|
3083 |
300 | 3084 p = XVECTOR (val); |
3085 for (index = 0; index < nargs; index++) | |
3086 { | |
485 | 3087 if (!NILP (Vpurify_flag)) |
300 | 3088 args[index] = Fpurecopy (args[index]); |
3089 p->contents[index] = args[index]; | |
3090 } | |
18104
b2a669ef69b1
(Fmake_byte_code): Set val from p, not from val.
Richard M. Stallman <rms@gnu.org>
parents:
18010
diff
changeset
|
3091 XSETCOMPILED (val, p); |
300 | 3092 return val; |
3093 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3094 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3095 |
300 | 3096 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3097 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3098 Symbol Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3099 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3100 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3101 /* 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
|
3102 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
|
3103 own overhead. */ |
300 | 3104 |
3105 #define SYMBOL_BLOCK_SIZE \ | |
3106 ((1020 - sizeof (struct symbol_block *)) / sizeof (struct Lisp_Symbol)) | |
3107 | |
3108 struct symbol_block | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3109 { |
53582
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
3110 /* Place `symbols' first, to preserve alignment. */ |
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
3111 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
|
3112 struct symbol_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3113 }; |
300 | 3114 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3115 /* 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
|
3116 structure in it. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3117 |
300 | 3118 struct symbol_block *symbol_block; |
3119 int symbol_block_index; | |
3120 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3121 /* List of free symbols. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3122 |
300 | 3123 struct Lisp_Symbol *symbol_free_list; |
3124 | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
3125 /* 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
|
3126 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
3127 int n_symbol_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
3128 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3129 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3130 /* Initialize symbol allocation. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3131 |
300 | 3132 void |
3133 init_symbol () | |
3134 { | |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
3135 symbol_block = NULL; |
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
3136 symbol_block_index = SYMBOL_BLOCK_SIZE; |
300 | 3137 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
|
3138 n_symbol_blocks = 0; |
300 | 3139 } |
3140 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3141 |
300 | 3142 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
|
3143 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
|
3144 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
|
3145 (name) |
14093
338f645e6b9a
(Fmake_symbol): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
3146 Lisp_Object name; |
300 | 3147 { |
3148 register Lisp_Object val; | |
3149 register struct Lisp_Symbol *p; | |
3150 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
3151 CHECK_STRING (name); |
300 | 3152 |
3153 if (symbol_free_list) | |
3154 { | |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
3155 XSETSYMBOL (val, symbol_free_list); |
9942
c189487b08dd
(free_float): Don't assume XFASTINT accesses the raw bits.
Karl Heuer <kwzh@gnu.org>
parents:
9926
diff
changeset
|
3156 symbol_free_list = *(struct Lisp_Symbol **)&symbol_free_list->value; |
300 | 3157 } |
3158 else | |
3159 { | |
3160 if (symbol_block_index == SYMBOL_BLOCK_SIZE) | |
3161 { | |
12529 | 3162 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
|
3163 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
|
3164 MEM_TYPE_SYMBOL); |
300 | 3165 new->next = symbol_block; |
3166 symbol_block = new; | |
3167 symbol_block_index = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
3168 n_symbol_blocks++; |
300 | 3169 } |
53093
e8f5463f3d5b
(make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52837
diff
changeset
|
3170 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
|
3171 symbol_block_index++; |
300 | 3172 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3173 |
300 | 3174 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
|
3175 p->xname = name; |
300 | 3176 p->plist = Qnil; |
3177 p->value = Qunbound; | |
3178 p->function = Qunbound; | |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
3179 p->next = NULL; |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
3180 p->gcmarkbit = 0; |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
3181 p->interned = SYMBOL_UNINTERNED; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
3182 p->constant = 0; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
3183 p->indirect_variable = 0; |
300 | 3184 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
|
3185 symbols_consed++; |
300 | 3186 return val; |
3187 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3188 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3189 |
300 | 3190 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3191 /*********************************************************************** |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3192 Marker (Misc) Allocation |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3193 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3194 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3195 /* Allocation of markers and other objects that share that structure. |
300 | 3196 Works like allocation of conses. */ |
3197 | |
3198 #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
|
3199 ((1020 - sizeof (struct marker_block *)) / sizeof (union Lisp_Misc)) |
300 | 3200 |
3201 struct marker_block | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
3202 { |
53582
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
3203 /* Place `markers' first, to preserve alignment. */ |
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
3204 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
|
3205 struct marker_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3206 }; |
300 | 3207 |
3208 struct marker_block *marker_block; | |
3209 int marker_block_index; | |
3210 | |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3211 union Lisp_Misc *marker_free_list; |
300 | 3212 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
3213 /* 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
|
3214 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
3215 int n_marker_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
3216 |
300 | 3217 void |
3218 init_marker () | |
3219 { | |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
3220 marker_block = NULL; |
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
3221 marker_block_index = MARKER_BLOCK_SIZE; |
300 | 3222 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
|
3223 n_marker_blocks = 0; |
300 | 3224 } |
3225 | |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3226 /* 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
|
3227 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3228 Lisp_Object |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3229 allocate_misc () |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3230 { |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3231 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
|
3232 |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3233 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
|
3234 { |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3235 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
|
3236 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
|
3237 } |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3238 else |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3239 { |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3240 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
|
3241 { |
12529 | 3242 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
|
3243 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
|
3244 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
|
3245 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
|
3246 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
|
3247 marker_block_index = 0; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
3248 n_marker_blocks++; |
56239
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3249 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
|
3250 } |
53093
e8f5463f3d5b
(make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52837
diff
changeset
|
3251 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
|
3252 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
|
3253 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3254 |
56239
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3255 --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
|
3256 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
|
3257 misc_objects_consed++; |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
3258 XMARKER (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
|
3259 return val; |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3260 } |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3261 |
56239
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3262 /* Free a Lisp_Misc object */ |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3263 |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3264 void |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3265 free_misc (misc) |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3266 Lisp_Object misc; |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3267 { |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3268 XMISC (misc)->u_marker.type = Lisp_Misc_Free; |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3269 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
|
3270 marker_free_list = XMISC (misc); |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3271 |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3272 total_free_markers++; |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3273 } |
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3274 |
49055
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3275 /* 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
|
3276 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
|
3277 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
|
3278 |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3279 Lisp_Object |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3280 make_save_value (pointer, integer) |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3281 void *pointer; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3282 int integer; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3283 { |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3284 register Lisp_Object val; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3285 register struct Lisp_Save_Value *p; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3286 |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3287 val = allocate_misc (); |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3288 XMISCTYPE (val) = Lisp_Misc_Save_Value; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3289 p = XSAVE_VALUE (val); |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3290 p->pointer = pointer; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3291 p->integer = integer; |
56202
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
3292 p->dogc = 0; |
49055
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3293 return val; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3294 } |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
3295 |
300 | 3296 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
|
3297 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
|
3298 () |
300 | 3299 { |
3300 register Lisp_Object val; | |
3301 register struct Lisp_Marker *p; | |
638 | 3302 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
3303 val = allocate_misc (); |
11243
054ecfce1820
(Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents:
11048
diff
changeset
|
3304 XMISCTYPE (val) = Lisp_Misc_Marker; |
300 | 3305 p = XMARKER (val); |
3306 p->buffer = 0; | |
20565
aa9b7c5f0f62
(Fmake_marker): Initialize marker's bytepos and charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20495
diff
changeset
|
3307 p->bytepos = 0; |
aa9b7c5f0f62
(Fmake_marker): Initialize marker's bytepos and charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20495
diff
changeset
|
3308 p->charpos = 0; |
51668
0f333fd92a1d
(survives_gc_p): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51658
diff
changeset
|
3309 p->next = NULL; |
13008
f042ef632b22
(Fmake_marker): Initialize insertion_type to 0.
Richard M. Stallman <rms@gnu.org>
parents:
12748
diff
changeset
|
3310 p->insertion_type = 0; |
300 | 3311 return val; |
3312 } | |
19332
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
3313 |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
3314 /* 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
|
3315 |
20375
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
3316 void |
19332
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
3317 free_marker (marker) |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
3318 Lisp_Object marker; |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
3319 { |
51668
0f333fd92a1d
(survives_gc_p): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51658
diff
changeset
|
3320 unchain_marker (XMARKER (marker)); |
56239
a446552d2240
(allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents:
56202
diff
changeset
|
3321 free_misc (marker); |
19332
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
3322 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3323 |
21258
693573ac0944
(make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
3324 |
300 | 3325 /* 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
|
3326 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
|
3327 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
|
3328 |
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
3329 Any number of arguments, even zero arguments, are allowed. */ |
300 | 3330 |
3331 Lisp_Object | |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
3332 make_event_array (nargs, args) |
300 | 3333 register int nargs; |
3334 Lisp_Object *args; | |
3335 { | |
3336 int i; | |
3337 | |
3338 for (i = 0; i < nargs; i++) | |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
3339 /* 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
|
3340 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
|
3341 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
|
3342 if (!INTEGERP (args[i]) |
3536
58d5ee6ec253
(make_event_array): Ignore bits above CHAR_META.
Richard M. Stallman <rms@gnu.org>
parents:
3181
diff
changeset
|
3343 || (XUINT (args[i]) & ~(-CHAR_META)) >= 0200) |
300 | 3344 return Fvector (nargs, args); |
3345 | |
3346 /* Since the loop exited, we know that all the things in it are | |
3347 characters, so we can make a string. */ | |
3348 { | |
6492
8372dce85f8a
(make_event_array): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6227
diff
changeset
|
3349 Lisp_Object result; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3350 |
18104
b2a669ef69b1
(Fmake_byte_code): Set val from p, not from val.
Richard M. Stallman <rms@gnu.org>
parents:
18010
diff
changeset
|
3351 result = Fmake_string (make_number (nargs), make_number (0)); |
300 | 3352 for (i = 0; i < nargs; i++) |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
3353 { |
46418
b12a32662433
* alloc.c (make_event_array): Use SSET for storing into a string.
Ken Raeburn <raeburn@raeburn.org>
parents:
46370
diff
changeset
|
3354 SSET (result, i, XINT (args[i])); |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
3355 /* 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
|
3356 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
|
3357 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
|
3358 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3359 |
300 | 3360 return result; |
3361 } | |
3362 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3363 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3364 |
300 | 3365 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3366 /************************************************************************ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3367 C Stack Marking |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3368 ************************************************************************/ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3369 |
32700
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
3370 #if GC_MARK_STACK || defined GC_MALLOC_CHECK |
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
3371 |
42403 | 3372 /* Conservative C stack marking requires a method to identify possibly |
3373 live Lisp objects given a pointer value. We do this by keeping | |
3374 track of blocks of Lisp data that are allocated in a red-black tree | |
3375 (see also the comment of mem_node which is the type of nodes in | |
3376 that tree). Function lisp_malloc adds information for an allocated | |
3377 block to the red-black tree with calls to mem_insert, and function | |
3378 lisp_free removes it with mem_delete. Functions live_string_p etc | |
3379 call mem_find to lookup information about a given pointer in the | |
3380 tree, and use that to determine if the pointer points to a Lisp | |
3381 object or not. */ | |
3382 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3383 /* 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
|
3384 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3385 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3386 mem_init () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3387 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3388 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
|
3389 mem_z.parent = NULL; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3390 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
|
3391 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
|
3392 mem_root = MEM_NIL; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3393 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3394 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3395 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3396 /* 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
|
3397 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
|
3398 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3399 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
|
3400 mem_find (start) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3401 void *start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3402 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3403 struct mem_node *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3404 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3405 if (start < min_heap_address || start > max_heap_address) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3406 return MEM_NIL; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3407 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3408 /* 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
|
3409 mem_z.start = start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3410 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
|
3411 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3412 p = mem_root; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3413 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
|
3414 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
|
3415 return p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3416 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3417 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3418 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3419 /* 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
|
3420 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
|
3421 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
|
3422 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3423 static struct mem_node * |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3424 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
|
3425 void *start, *end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3426 enum mem_type type; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3427 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3428 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
|
3429 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3430 if (start < min_heap_address) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3431 min_heap_address = start; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3432 if (end > max_heap_address) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3433 max_heap_address = end; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3434 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3435 /* 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
|
3436 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
|
3437 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
|
3438 c = mem_root; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3439 parent = NULL; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3440 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3441 #if GC_MARK_STACK != GC_MAKE_GCPROS_NOOPS |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3442 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3443 while (c != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3444 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3445 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
|
3446 abort (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3447 parent = c; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3448 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
|
3449 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3450 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3451 #else /* GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3452 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3453 while (c != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3454 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3455 parent = c; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3456 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
|
3457 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3458 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3459 #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
|
3460 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3461 /* Create a new node. */ |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3462 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3463 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
|
3464 if (x == NULL) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3465 abort (); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3466 #else |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3467 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
|
3468 #endif |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3469 x->start = start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3470 x->end = end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3471 x->type = type; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3472 x->parent = parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3473 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
|
3474 x->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3475 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3476 /* 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
|
3477 if (parent) |
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 if (start < parent->start) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3480 parent->left = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3481 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3482 parent->right = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3483 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3484 else |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3485 mem_root = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3486 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3487 /* 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
|
3488 mem_insert_fixup (x); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3489 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3490 return x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3491 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3492 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3493 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3494 /* 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
|
3495 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
|
3496 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3497 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3498 mem_insert_fixup (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3499 struct mem_node *x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3500 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3501 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
|
3502 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3503 /* 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
|
3504 red-black tree property #3. */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3505 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3506 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
|
3507 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3508 /* 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
|
3509 "uncle". */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3510 struct mem_node *y = x->parent->parent->right; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3511 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3512 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
|
3513 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3514 /* 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
|
3515 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
|
3516 with the grandparent. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3517 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
|
3518 y->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3519 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
|
3520 x = x->parent->parent; |
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 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3523 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3524 /* 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
|
3525 red, uncle is black. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3526 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
|
3527 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3528 x = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3529 mem_rotate_left (x); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3530 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3531 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3532 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
|
3533 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
|
3534 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
|
3535 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3536 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3537 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3538 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3539 /* 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
|
3540 struct mem_node *y = x->parent->parent->left; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3541 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3542 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
|
3543 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3544 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
|
3545 y->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3546 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
|
3547 x = x->parent->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3548 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3549 else |
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 (x == x->parent->left) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3552 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3553 x = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3554 mem_rotate_right (x); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3555 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3556 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3557 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
|
3558 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
|
3559 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
|
3560 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3561 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3562 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3563 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3564 /* 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
|
3565 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
|
3566 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
|
3567 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3568 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3569 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3570 /* (x) (y) |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3571 / \ / \ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3572 a (y) ===> (x) c |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3573 / \ / \ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3574 b c a b */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3575 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3576 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3577 mem_rotate_left (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3578 struct mem_node *x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3579 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3580 struct mem_node *y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3581 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3582 /* 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
|
3583 y = x->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3584 x->right = y->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3585 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
|
3586 y->left->parent = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3587 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3588 /* 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
|
3589 if (y != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3590 y->parent = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3591 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3592 /* 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
|
3593 if (x->parent) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3594 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3595 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
|
3596 x->parent->left = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3597 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3598 x->parent->right = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3599 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3600 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3601 mem_root = y; |
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 /* 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
|
3604 y->left = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3605 if (x != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3606 x->parent = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3607 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3608 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3609 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3610 /* (x) (Y) |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3611 / \ / \ |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3612 (y) c ===> a (x) |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3613 / \ / \ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3614 a b b c */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3615 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3616 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3617 mem_rotate_right (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3618 struct mem_node *x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3619 { |
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->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3621 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3622 x->left = y->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3623 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
|
3624 y->right->parent = x; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3625 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3626 if (y != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3627 y->parent = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3628 if (x->parent) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3629 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3630 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
|
3631 x->parent->right = y; |
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 x->parent->left = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3634 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3635 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3636 mem_root = y; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3637 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3638 y->right = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3639 if (x != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3640 x->parent = y; |
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 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3643 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3644 /* 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
|
3645 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3646 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3647 mem_delete (z) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3648 struct mem_node *z; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3649 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3650 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
|
3651 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3652 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
|
3653 return; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3654 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3655 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
|
3656 y = z; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3657 else |
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 y = z->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3660 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
|
3661 y = y->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 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3664 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
|
3665 x = y->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3666 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3667 x = y->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3668 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3669 x->parent = y->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3670 if (y->parent) |
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 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
|
3673 y->parent->left = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3674 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3675 y->parent->right = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3676 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3677 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3678 mem_root = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3679 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3680 if (y != z) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3681 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3682 z->start = y->start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3683 z->end = y->end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3684 z->type = y->type; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3685 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3686 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3687 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
|
3688 mem_delete_fixup (x); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3689 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3690 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3691 _free_internal (y); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3692 #else |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3693 xfree (y); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3694 #endif |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3695 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3696 |
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 /* 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
|
3699 deletion. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3700 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3701 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3702 mem_delete_fixup (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3703 struct mem_node *x; |
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 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
|
3706 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3707 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
|
3708 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3709 struct mem_node *w = x->parent->right; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3710 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3711 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
|
3712 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3713 w->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3714 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
|
3715 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
|
3716 w = x->parent->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3717 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3718 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3719 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
|
3720 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3721 w->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3722 x = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3723 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3724 else |
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 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
|
3727 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3728 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
|
3729 w->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3730 mem_rotate_right (w); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3731 w = x->parent->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3732 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3733 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
|
3734 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
|
3735 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
|
3736 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
|
3737 x = mem_root; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3738 } |
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 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3741 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3742 struct mem_node *w = x->parent->left; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3743 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3744 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
|
3745 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3746 w->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3747 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
|
3748 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
|
3749 w = x->parent->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3750 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3751 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3752 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
|
3753 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3754 w->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3755 x = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3756 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3757 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3758 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3759 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
|
3760 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3761 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
|
3762 w->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3763 mem_rotate_left (w); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3764 w = x->parent->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3765 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3766 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3767 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
|
3768 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
|
3769 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
|
3770 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
|
3771 x = mem_root; |
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 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3775 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3776 x->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3777 } |
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 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3780 /* 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
|
3781 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
|
3782 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3783 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3784 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
|
3785 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3786 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3787 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3788 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
|
3789 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3790 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
|
3791 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
|
3792 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3793 /* 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
|
3794 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
|
3795 return (offset >= 0 |
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3796 && offset % sizeof b->strings[0] == 0 |
53582
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
3797 && 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
|
3798 && ((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
|
3799 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3800 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3801 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3802 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3803 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3804 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3805 /* 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
|
3806 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
|
3807 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3808 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3809 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
|
3810 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3811 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3812 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3813 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
|
3814 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3815 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
|
3816 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
|
3817 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3818 /* 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
|
3819 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
|
3820 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
|
3821 return (offset >= 0 |
53582
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
3822 && 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
|
3823 && 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
|
3824 && (b != cons_block |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3825 || 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
|
3826 && !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
|
3827 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3828 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3829 return 0; |
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 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3832 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3833 /* 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
|
3834 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
|
3835 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3836 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3837 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
|
3838 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3839 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3840 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3841 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
|
3842 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3843 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
|
3844 int offset = (char *) p - (char *) &b->symbols[0]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3845 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3846 /* 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
|
3847 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
|
3848 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
|
3849 return (offset >= 0 |
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3850 && offset % sizeof b->symbols[0] == 0 |
53582
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
3851 && 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
|
3852 && (b != symbol_block |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3853 || 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
|
3854 && !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
|
3855 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3856 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3857 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3858 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3859 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3860 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3861 /* 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
|
3862 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
|
3863 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3864 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3865 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
|
3866 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3867 void *p; |
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 (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
|
3870 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3871 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
|
3872 int offset = (char *) p - (char *) &b->floats[0]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3873 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
3874 /* 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
|
3875 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
|
3876 return (offset >= 0 |
53582
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
3877 && 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
|
3878 && 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
|
3879 && (b != float_block |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
3880 || 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
|
3881 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3882 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3883 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3884 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3885 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3886 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3887 /* 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
|
3888 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
|
3889 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3890 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3891 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
|
3892 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3893 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3894 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3895 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
|
3896 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3897 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
|
3898 int offset = (char *) p - (char *) &b->markers[0]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3899 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3900 /* 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
|
3901 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
|
3902 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
|
3903 return (offset >= 0 |
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3904 && offset % sizeof b->markers[0] == 0 |
53582
b4eef5adebbf
(struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53555
diff
changeset
|
3905 && 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
|
3906 && (b != marker_block |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3907 || offset / sizeof b->markers[0] < marker_block_index) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3908 && ((union Lisp_Misc *) p)->u_marker.type != Lisp_Misc_Free); |
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 vector-like object. |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3916 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_vector_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 { |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3923 return (p == m->start |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3924 && m->type >= MEM_TYPE_VECTOR |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3925 && m->type <= MEM_TYPE_WINDOW); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3926 } |
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 |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
3929 /* 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
|
3930 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
|
3931 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3932 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3933 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
|
3934 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3935 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3936 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3937 /* 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
|
3938 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
|
3939 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
|
3940 && p == m->start |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3941 && !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
|
3942 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3943 |
32700
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
3944 #endif /* GC_MARK_STACK || defined GC_MALLOC_CHECK */ |
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
3945 |
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
3946 #if GC_MARK_STACK |
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
3947 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3948 #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
|
3949 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3950 /* 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
|
3951 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
|
3952 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3953 #define MAX_ZOMBIES 10 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3954 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
|
3955 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3956 /* Number of zombie objects. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3957 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3958 static int nzombies; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3959 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3960 /* Number of garbage collections. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3961 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3962 static int ngcs; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3963 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3964 /* 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
|
3965 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3966 static double avg_zombies; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3967 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3968 /* 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
|
3969 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3970 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
|
3971 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3972 /* 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
|
3973 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3974 static double avg_live; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3975 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3976 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
|
3977 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
|
3978 () |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3979 { |
49357 | 3980 Lisp_Object args[8], zombie_list = Qnil; |
3981 int i; | |
3982 for (i = 0; i < nzombies; i++) | |
3983 zombie_list = Fcons (zombies[i], zombie_list); | |
3984 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
|
3985 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
|
3986 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
|
3987 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
|
3988 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
|
3989 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
|
3990 args[6] = make_number (max_zombies); |
49357 | 3991 args[7] = zombie_list; |
3992 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
|
3993 } |
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 #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
|
3996 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3997 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3998 /* 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
|
3999 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4000 static INLINE void |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4001 mark_maybe_object (obj) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4002 Lisp_Object obj; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4003 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4004 void *po = (void *) XPNTR (obj); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4005 struct mem_node *m = mem_find (po); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4006 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4007 if (m != MEM_NIL) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4008 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4009 int mark_p = 0; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4010 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4011 switch (XGCTYPE (obj)) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4012 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4013 case Lisp_String: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4014 mark_p = (live_string_p (m, po) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4015 && !STRING_MARKED_P ((struct Lisp_String *) po)); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4016 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4017 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4018 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
|
4019 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
|
4020 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4021 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4022 case Lisp_Symbol: |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
4023 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
|
4024 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4025 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4026 case Lisp_Float: |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
4027 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
|
4028 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4029 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4030 case Lisp_Vectorlike: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4031 /* Note: can't check GC_BUFFERP before we know it's a |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4032 buffer because checking that dereferences the pointer |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4033 PO which might point anywhere. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4034 if (live_vector_p (m, po)) |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4035 mark_p = !GC_SUBRP (obj) && !VECTOR_MARKED_P (XVECTOR (obj)); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4036 else if (live_buffer_p (m, po)) |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4037 mark_p = GC_BUFFERP (obj) && !VECTOR_MARKED_P (XBUFFER (obj)); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4038 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4039 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4040 case Lisp_Misc: |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
4041 mark_p = (live_misc_p (m, po) && !XMARKER (obj)->gcmarkbit); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4042 break; |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
4043 |
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
4044 case Lisp_Int: |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
4045 case Lisp_Type_Limit: |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
4046 break; |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4047 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4048 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4049 if (mark_p) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4050 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4051 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4052 if (nzombies < MAX_ZOMBIES) |
49357 | 4053 zombies[nzombies] = obj; |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4054 ++nzombies; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4055 #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
|
4056 mark_object (obj); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4057 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4058 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4059 } |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4060 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4061 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4062 /* 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
|
4063 marked. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4064 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4065 static INLINE void |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4066 mark_maybe_pointer (p) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4067 void *p; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4068 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4069 struct mem_node *m; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4070 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4071 /* Quickly rule out some values which can't point to Lisp data. We |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4072 assume that Lisp data is aligned on even addresses. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4073 if ((EMACS_INT) p & 1) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4074 return; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4075 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4076 m = mem_find (p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4077 if (m != MEM_NIL) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4078 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4079 Lisp_Object obj = Qnil; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4080 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4081 switch (m->type) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4082 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4083 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
|
4084 /* Nothing to do; not a pointer to Lisp memory. */ |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4085 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4086 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4087 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
|
4088 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
|
4089 XSETVECTOR (obj, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4090 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4091 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4092 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
|
4093 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
|
4094 XSETCONS (obj, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4095 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4096 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4097 case MEM_TYPE_STRING: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4098 if (live_string_p (m, p) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4099 && !STRING_MARKED_P ((struct Lisp_String *) p)) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4100 XSETSTRING (obj, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4101 break; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4102 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4103 case MEM_TYPE_MISC: |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
4104 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
|
4105 XSETMISC (obj, p); |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4106 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4107 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4108 case MEM_TYPE_SYMBOL: |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
4109 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
|
4110 XSETSYMBOL (obj, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4111 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4112 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4113 case MEM_TYPE_FLOAT: |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
4114 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
|
4115 XSETFLOAT (obj, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4116 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4117 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4118 case MEM_TYPE_VECTOR: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4119 case MEM_TYPE_PROCESS: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4120 case MEM_TYPE_HASH_TABLE: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4121 case MEM_TYPE_FRAME: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4122 case MEM_TYPE_WINDOW: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4123 if (live_vector_p (m, p)) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4124 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4125 Lisp_Object tem; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4126 XSETVECTOR (tem, p); |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4127 if (!GC_SUBRP (tem) && !VECTOR_MARKED_P (XVECTOR (tem))) |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4128 obj = tem; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4129 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4130 break; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4131 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4132 default: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4133 abort (); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4134 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4135 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4136 if (!GC_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
|
4137 mark_object (obj); |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4138 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4139 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4140 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4141 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4142 /* Mark Lisp objects referenced from the address range START..END. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4143 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4144 static void |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4145 mark_memory (start, end) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4146 void *start, *end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4147 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4148 Lisp_Object *p; |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4149 void **pp; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4150 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4151 #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
|
4152 nzombies = 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4153 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4154 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4155 /* 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
|
4156 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
|
4157 if (end < start) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4158 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4159 void *tem = start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4160 start = end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4161 end = tem; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4162 } |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4163 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4164 /* Mark Lisp_Objects. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4165 for (p = (Lisp_Object *) start; (void *) p < end; ++p) |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4166 mark_maybe_object (*p); |
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 /* 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
|
4169 situations, the C compiler optimizes Lisp objects away, so that |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4170 only a pointer to them remains. Example: |
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 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
|
4173 () |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4174 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4175 Lisp_Object obj = build_string ("test"); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4176 struct Lisp_String *s = XSTRING (obj); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4177 Fgarbage_collect (); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4178 fprintf (stderr, "test `%s'\n", s->data); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4179 return Qnil; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4180 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4181 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4182 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
|
4183 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
|
4184 pointer `s'. */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4185 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4186 for (pp = (void **) start; (void *) pp < end; ++pp) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
4187 mark_maybe_pointer (*pp); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4188 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4189 |
48316 | 4190 /* setjmp will work with GCC unless NON_SAVING_SETJMP is defined in |
4191 the GCC system configuration. In gcc 3.2, the only systems for | |
4192 which this is so are i386-sco5 non-ELF, i386-sysv3 (maybe included | |
4193 by others?) and ns32k-pc532-min. */ | |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4194 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4195 #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
|
4196 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4197 static int setjmp_tested_p, longjmps_done; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4198 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4199 #define SETJMP_WILL_LIKELY_WORK "\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4200 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4201 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
|
4202 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
|
4203 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
|
4204 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4205 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
|
4206 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
|
4207 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
|
4208 \n\ |
43200
4082674ce69b
(SETJMP_WILL_LIKELY_WORK, SETJMP_WILL_NOT_WORK):
Kim F. Storm <storm@cua.dk>
parents:
43161
diff
changeset
|
4209 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
|
4210 " |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4211 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4212 #define SETJMP_WILL_NOT_WORK "\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4213 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4214 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
|
4215 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
|
4216 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
|
4217 solution for your system.\n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4218 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4219 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
|
4220 try to find a way to make it work on your system.\n\ |
48316 | 4221 \n\ |
4222 Note that you may get false negatives, depending on the compiler.\n\ | |
4223 In particular, you need to use -O with GCC for this test.\n\ | |
4224 \n\ | |
43200
4082674ce69b
(SETJMP_WILL_LIKELY_WORK, SETJMP_WILL_NOT_WORK):
Kim F. Storm <storm@cua.dk>
parents:
43161
diff
changeset
|
4225 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
|
4226 " |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4227 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4228 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4229 /* 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
|
4230 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
|
4231 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
|
4232 conservative stack marking. Only the sources or a disassembly |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4233 can prove that. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4234 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4235 static void |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4236 test_setjmp () |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4237 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4238 char buf[10]; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4239 register int x; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4240 jmp_buf jbuf; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4241 int result = 0; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4242 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4243 /* Arrange for X to be put in a register. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4244 sprintf (buf, "1"); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4245 x = strlen (buf); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4246 x = 2 * x - 1; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4247 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4248 setjmp (jbuf); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4249 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
|
4250 { |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4251 /* 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
|
4252 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4253 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
|
4254 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
|
4255 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
|
4256 isn't sure. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4257 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4258 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
|
4259 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
|
4260 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4261 if (x == 1) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4262 fprintf (stderr, SETJMP_WILL_LIKELY_WORK); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4263 else |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4264 { |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4265 fprintf (stderr, SETJMP_WILL_NOT_WORK); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4266 exit (1); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4267 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4268 } |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4269 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4270 ++longjmps_done; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4271 x = 2; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4272 if (longjmps_done == 1) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4273 longjmp (jbuf, 1); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4274 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4275 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4276 #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
|
4277 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4278 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4279 #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
|
4280 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4281 /* 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
|
4282 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4283 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4284 check_gcpros () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4285 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4286 struct gcpro *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4287 int i; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4288 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4289 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
|
4290 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
|
4291 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
|
4292 /* 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
|
4293 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
|
4294 abort (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4295 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4296 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4297 #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
|
4298 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4299 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4300 dump_zombies () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4301 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4302 int i; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4303 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4304 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
|
4305 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
|
4306 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4307 fprintf (stderr, " %d = ", i); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4308 debug_print (zombies[i]); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4309 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4310 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4311 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4312 #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
|
4313 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4314 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4315 /* Mark live Lisp objects on the C stack. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4316 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4317 There are several system-dependent problems to consider when |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4318 porting this to new architectures: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4319 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4320 Processor Registers |
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 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
|
4323 variables or are used to pass parameters. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4324 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4325 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
|
4326 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
|
4327 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
|
4328 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4329 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
|
4330 implementation assumes that calling setjmp saves registers we need |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4331 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
|
4332 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
|
4333 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
|
4334 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4335 Stack Layout |
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 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
|
4338 For example, the stack might look like this |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4339 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4340 +----------------+ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4341 | Lisp_Object | size = 4 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4342 +----------------+ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4343 | something else | size = 2 |
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 | Lisp_Object | size = 4 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4346 +----------------+ |
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 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4349 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
|
4350 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
|
4351 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
|
4352 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
|
4353 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
|
4354 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
|
4355 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
|
4356 from the stack start. |
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 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
|
4359 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
|
4360 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4361 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4362 mark_stack () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4363 { |
43160
630c8b6deafd
(mark_stack): Don't assume sizeof (Lisp_Object) is 4.
Andreas Schwab <schwab@suse.de>
parents:
43005
diff
changeset
|
4364 int i; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4365 jmp_buf j; |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
4366 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
|
4367 void *end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4368 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4369 /* 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
|
4370 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
|
4371 /* 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
|
4372 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
|
4373 assembler doesn't work with relevant proprietary compilers. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4374 #ifdef sparc |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4375 asm ("ta 3"); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4376 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4377 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4378 /* 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
|
4379 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
|
4380 pass parameters. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4381 #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
|
4382 GC_SAVE_REGISTERS_ON_STACK (end); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4383 #else /* not GC_SAVE_REGISTERS_ON_STACK */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4384 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4385 #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
|
4386 setjmp will definitely work, test it |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4387 and print a message with the result |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4388 of the test. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4389 if (!setjmp_tested_p) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4390 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4391 setjmp_tested_p = 1; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4392 test_setjmp (); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4393 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4394 #endif /* GC_SETJMP_WORKS */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4395 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4396 setjmp (j); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4397 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
|
4398 #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
|
4399 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4400 /* 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
|
4401 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
|
4402 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
|
4403 #ifndef GC_LISP_OBJECT_ALIGNMENT |
49414
668c96afa702
(mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents:
49357
diff
changeset
|
4404 #ifdef __GNUC__ |
668c96afa702
(mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents:
49357
diff
changeset
|
4405 #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
|
4406 #else |
43160
630c8b6deafd
(mark_stack): Don't assume sizeof (Lisp_Object) is 4.
Andreas Schwab <schwab@suse.de>
parents:
43005
diff
changeset
|
4407 #define GC_LISP_OBJECT_ALIGNMENT sizeof (Lisp_Object) |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4408 #endif |
49414
668c96afa702
(mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents:
49357
diff
changeset
|
4409 #endif |
43161
8a549ab185a2
Fix thinko in last change.
Andreas Schwab <schwab@suse.de>
parents:
43160
diff
changeset
|
4410 for (i = 0; i < sizeof (Lisp_Object); i += GC_LISP_OBJECT_ALIGNMENT) |
43160
630c8b6deafd
(mark_stack): Don't assume sizeof (Lisp_Object) is 4.
Andreas Schwab <schwab@suse.de>
parents:
43005
diff
changeset
|
4411 mark_memory ((char *) stack_base + i, end); |
58593
ff0c144203a1
(mark_stack): Call GC_MARK_SECONDARY_STACK if defined.
Andreas Schwab <schwab@suse.de>
parents:
57137
diff
changeset
|
4412 /* 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
|
4413 ia64. */ |
ff0c144203a1
(mark_stack): Call GC_MARK_SECONDARY_STACK if defined.
Andreas Schwab <schwab@suse.de>
parents:
57137
diff
changeset
|
4414 #ifdef GC_MARK_SECONDARY_STACK |
ff0c144203a1
(mark_stack): Call GC_MARK_SECONDARY_STACK if defined.
Andreas Schwab <schwab@suse.de>
parents:
57137
diff
changeset
|
4415 GC_MARK_SECONDARY_STACK (); |
ff0c144203a1
(mark_stack): Call GC_MARK_SECONDARY_STACK if defined.
Andreas Schwab <schwab@suse.de>
parents:
57137
diff
changeset
|
4416 #endif |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4417 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4418 #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
|
4419 check_gcpros (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4420 #endif |
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 |
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 #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
|
4425 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4426 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4427 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4428 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4429 Pure Storage Management |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4430 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4431 |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4432 /* 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
|
4433 pointer to it. TYPE is the Lisp type for which the memory is |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4434 allocated. TYPE < 0 means it's not used for a Lisp object. |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4435 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4436 If store_pure_type_info is set and TYPE is >= 0, the type of |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4437 the allocated object is recorded in pure_types. */ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4438 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4439 static POINTER_TYPE * |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4440 pure_alloc (size, type) |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4441 size_t size; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4442 int type; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4443 { |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4444 POINTER_TYPE *result; |
53650
5558449888ec
(lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53582
diff
changeset
|
4445 #ifdef USE_LSB_TAG |
5558449888ec
(lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53582
diff
changeset
|
4446 size_t alignment = (1 << GCTYPEBITS); |
5558449888ec
(lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53582
diff
changeset
|
4447 #else |
49159
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4448 size_t alignment = sizeof (EMACS_INT); |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4449 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4450 /* Give Lisp_Floats an extra alignment. */ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4451 if (type == Lisp_Float) |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4452 { |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4453 #if defined __GNUC__ && __GNUC__ >= 2 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4454 alignment = __alignof (struct Lisp_Float); |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4455 #else |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4456 alignment = sizeof (struct Lisp_Float); |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4457 #endif |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4458 } |
53650
5558449888ec
(lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53582
diff
changeset
|
4459 #endif |
49159
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4460 |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4461 again: |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
4462 result = ALIGN (purebeg + pure_bytes_used, alignment); |
49159
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4463 pure_bytes_used = ((char *)result - (char *)purebeg) + size; |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4464 |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4465 if (pure_bytes_used <= pure_size) |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4466 return result; |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4467 |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4468 /* Don't allocate a large amount here, |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4469 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
|
4470 might not be usable. */ |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4471 purebeg = (char *) xmalloc (10000); |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4472 pure_size = 10000; |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4473 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
|
4474 pure_bytes_used = 0; |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4475 goto again; |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4476 } |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4477 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4478 |
44149
a3e6cfa20afd
(check_pure_size): Update the comment.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44100
diff
changeset
|
4479 /* 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
|
4480 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4481 void |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4482 check_pure_size () |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4483 { |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4484 if (pure_bytes_used_before_overflow) |
44100
57e965380c39
(check_pure_size): Only output a warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43751
diff
changeset
|
4485 message ("Pure Lisp storage overflow (approx. %d bytes needed)", |
57e965380c39
(check_pure_size): Only output a warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43751
diff
changeset
|
4486 (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
|
4487 } |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4488 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4489 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4490 /* 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
|
4491 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
|
4492 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
|
4493 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4494 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
|
4495 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
|
4496 string; then the string is not protected from gc. */ |
300 | 4497 |
4498 Lisp_Object | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4499 make_pure_string (data, nchars, nbytes, multibyte) |
300 | 4500 char *data; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4501 int nchars, nbytes; |
21258
693573ac0944
(make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
4502 int multibyte; |
300 | 4503 { |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4504 Lisp_Object string; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4505 struct Lisp_String *s; |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4506 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4507 s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String); |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4508 s->data = (unsigned char *) pure_alloc (nbytes + 1, -1); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4509 s->size = nchars; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4510 s->size_byte = multibyte ? nbytes : -1; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4511 bcopy (data, s->data, nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4512 s->data[nbytes] = '\0'; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4513 s->intervals = NULL_INTERVAL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4514 XSETSTRING (string, s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4515 return string; |
300 | 4516 } |
4517 | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4518 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4519 /* 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
|
4520 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
|
4521 |
300 | 4522 Lisp_Object |
4523 pure_cons (car, cdr) | |
4524 Lisp_Object car, cdr; | |
4525 { | |
4526 register Lisp_Object new; | |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4527 struct Lisp_Cons *p; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4528 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4529 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
|
4530 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
|
4531 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
|
4532 XSETCDR (new, Fpurecopy (cdr)); |
300 | 4533 return new; |
4534 } | |
4535 | |
4536 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4537 /* 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
|
4538 |
300 | 4539 Lisp_Object |
4540 make_pure_float (num) | |
4541 double num; | |
4542 { | |
4543 register Lisp_Object new; | |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4544 struct Lisp_Float *p; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4545 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4546 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
|
4547 XSETFLOAT (new, p); |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4548 XFLOAT_DATA (new) = num; |
300 | 4549 return new; |
4550 } | |
4551 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4552 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4553 /* 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
|
4554 pure space. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4555 |
300 | 4556 Lisp_Object |
4557 make_pure_vector (len) | |
8817
48ff00bebef6
(pure, pure_size): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
4558 EMACS_INT len; |
300 | 4559 { |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4560 Lisp_Object new; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4561 struct Lisp_Vector *p; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4562 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
|
4563 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4564 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
|
4565 XSETVECTOR (new, p); |
300 | 4566 XVECTOR (new)->size = len; |
4567 return new; | |
4568 } | |
4569 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4570 |
300 | 4571 DEFUN ("purecopy", Fpurecopy, Spurecopy, 1, 1, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
4572 doc: /* Make a copy of OBJECT in pure storage. |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
4573 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
|
4574 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
|
4575 (obj) |
300 | 4576 register Lisp_Object obj; |
4577 { | |
485 | 4578 if (NILP (Vpurify_flag)) |
300 | 4579 return obj; |
4580 | |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4581 if (PURE_POINTER_P (XPNTR (obj))) |
300 | 4582 return obj; |
4583 | |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4584 if (CONSP (obj)) |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4585 return pure_cons (XCAR (obj), XCDR (obj)); |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4586 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
|
4587 return make_pure_float (XFLOAT_DATA (obj)); |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4588 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
|
4589 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
|
4590 SBYTES (obj), |
21258
693573ac0944
(make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
4591 STRING_MULTIBYTE (obj)); |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4592 else if (COMPILEDP (obj) || VECTORP (obj)) |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4593 { |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4594 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
|
4595 register int i; |
db8cbe59ee5c
(Fpurecopy): Declare size as EMACS_INT to not lose bits.
Andreas Schwab <schwab@suse.de>
parents:
53650
diff
changeset
|
4596 EMACS_INT size; |
300 | 4597 |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4598 size = XVECTOR (obj)->size; |
10427
5faba1b094d5
(Fpurecopy): Mask size field when copying pseudovector.
Karl Heuer <kwzh@gnu.org>
parents:
10414
diff
changeset
|
4599 if (size & PSEUDOVECTOR_FLAG) |
5faba1b094d5
(Fpurecopy): Mask size field when copying pseudovector.
Karl Heuer <kwzh@gnu.org>
parents:
10414
diff
changeset
|
4600 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
|
4601 vec = XVECTOR (make_pure_vector (size)); |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4602 for (i = 0; i < size; i++) |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4603 vec->contents[i] = Fpurecopy (XVECTOR (obj)->contents[i]); |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4604 if (COMPILEDP (obj)) |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4605 XSETCOMPILED (obj, vec); |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4606 else |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4607 XSETVECTOR (obj, vec); |
300 | 4608 return obj; |
4609 } | |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4610 else if (MARKERP (obj)) |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4611 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
|
4612 |
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
4613 return obj; |
300 | 4614 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4615 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4616 |
300 | 4617 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4618 /*********************************************************************** |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4619 Protection from GC |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4620 ***********************************************************************/ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4621 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4622 /* 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
|
4623 VARADDRESS. */ |
300 | 4624 |
4625 void | |
4626 staticpro (varaddress) | |
4627 Lisp_Object *varaddress; | |
4628 { | |
4629 staticvec[staticidx++] = varaddress; | |
4630 if (staticidx >= NSTATICS) | |
4631 abort (); | |
4632 } | |
4633 | |
4634 struct catchtag | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4635 { |
300 | 4636 Lisp_Object tag; |
4637 Lisp_Object val; | |
4638 struct catchtag *next; | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4639 }; |
300 | 4640 |
4641 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4642 /*********************************************************************** |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4643 Protection from GC |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4644 ***********************************************************************/ |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
4645 |
11374
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4646 /* Temporarily prevent garbage collection. */ |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4647 |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4648 int |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4649 inhibit_garbage_collection () |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4650 { |
46293
1fb8f75062c6
Use macro SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents:
46285
diff
changeset
|
4651 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
|
4652 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
|
4653 |
a555c6419185
(inhibit_garbage_collection): Don't exceed value an int can hold.
Andreas Schwab <schwab@suse.de>
parents:
41831
diff
changeset
|
4654 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
|
4655 return count; |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4656 } |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4657 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4658 |
300 | 4659 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
|
4660 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
|
4661 Garbage collection happens automatically if you cons more than |
43d663a05e2d
(Fgarbage_collect): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
51779
diff
changeset
|
4662 `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
|
4663 `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
|
4664 ((USED-CONSES . FREE-CONSES) (USED-SYMS . FREE-SYMS) |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
4665 (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
|
4666 (USED-FLOATS . FREE-FLOATS) (USED-INTERVALS . FREE-INTERVALS) |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
4667 (USED-STRINGS . FREE-STRINGS)) |
51788
43d663a05e2d
(Fgarbage_collect): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
51779
diff
changeset
|
4668 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
|
4669 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
|
4670 () |
300 | 4671 { |
4672 register struct specbinding *bind; | |
4673 struct catchtag *catch; | |
4674 struct handler *handler; | |
4675 char stack_top_variable; | |
4676 register int i; | |
25343
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
4677 int message_p; |
34270
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
4678 Lisp_Object total[8]; |
46285
3f111801efb4
Rename BINDING_STACK_SIZE to SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents:
45392
diff
changeset
|
4679 int count = SPECPDL_INDEX (); |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4680 EMACS_TIME t1, t2, t3; |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4681 |
50745
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
4682 if (abort_on_gc) |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
4683 abort (); |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
4684 |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4685 /* 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
|
4686 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
|
4687 if (pure_bytes_used_before_overflow) |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4688 return Qnil; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4689 |
61252
d24c6e8f9add
(Fgarbage_collect): Call CHECK_CONS_LIST before and after gc.
Kim F. Storm <storm@cua.dk>
parents:
61225
diff
changeset
|
4690 CHECK_CONS_LIST (); |
d24c6e8f9add
(Fgarbage_collect): Call CHECK_CONS_LIST before and after gc.
Kim F. Storm <storm@cua.dk>
parents:
61225
diff
changeset
|
4691 |
59047
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4692 /* 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
|
4693 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
|
4694 { |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4695 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
|
4696 |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4697 while (nextb) |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4698 { |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4699 /* 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
|
4700 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
|
4701 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
|
4702 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
|
4703 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
|
4704 truncate_undo_list (nextb); |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4705 |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4706 /* Shrink buffer gaps, but skip indirect and dead buffers. */ |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4707 if (nextb->base_buffer == 0 && !NILP (nextb->name)) |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4708 { |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4709 /* 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
|
4710 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
|
4711 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
|
4712 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
|
4713 |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4714 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
|
4715 { |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4716 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
|
4717 current_buffer = nextb; |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4718 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
|
4719 current_buffer = save_current; |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4720 } |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4721 } |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4722 |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4723 nextb = nextb->next; |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4724 } |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4725 } |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4726 |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4727 EMACS_GET_TIME (t1); |
0d2678a6add0
(Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents:
58986
diff
changeset
|
4728 |
11892
6be0b7a0ac44
(Fgarbage_collect): Clear consing_since_gc first thing.
Karl Heuer <kwzh@gnu.org>
parents:
11727
diff
changeset
|
4729 /* 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
|
4730 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
|
4731 consing_since_gc = 0; |
6be0b7a0ac44
(Fgarbage_collect): Clear consing_since_gc first thing.
Karl Heuer <kwzh@gnu.org>
parents:
11727
diff
changeset
|
4732 |
25343
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
4733 /* 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
|
4734 message_p = push_message (); |
47391
1afd007f814f
(Fgarbage_collect): Use pop_message_unwind.
Richard M. Stallman <rms@gnu.org>
parents:
47185
diff
changeset
|
4735 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
|
4736 |
300 | 4737 /* Save a copy of the contents of the stack, for debugging. */ |
4738 #if MAX_SAVE_STACK > 0 | |
485 | 4739 if (NILP (Vpurify_flag)) |
300 | 4740 { |
4741 i = &stack_top_variable - stack_bottom; | |
4742 if (i < 0) i = -i; | |
4743 if (i < MAX_SAVE_STACK) | |
4744 { | |
4745 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
|
4746 stack_copy = (char *) xmalloc (stack_copy_size = i); |
300 | 4747 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
|
4748 stack_copy = (char *) xrealloc (stack_copy, (stack_copy_size = i)); |
300 | 4749 if (stack_copy) |
4750 { | |
8817
48ff00bebef6
(pure, pure_size): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
4751 if ((EMACS_INT) (&stack_top_variable - stack_bottom) > 0) |
300 | 4752 bcopy (stack_bottom, stack_copy, i); |
4753 else | |
4754 bcopy (&stack_top_variable, stack_copy, i); | |
4755 } | |
4756 } | |
4757 } | |
4758 #endif /* MAX_SAVE_STACK > 0 */ | |
4759 | |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4760 if (garbage_collection_messages) |
10395
c121703d35c7
(Fgarbage_collect): Don't log the GC message.
Karl Heuer <kwzh@gnu.org>
parents:
10389
diff
changeset
|
4761 message1_nolog ("Garbage collecting..."); |
300 | 4762 |
23534
6f9c70db3a58
(Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents:
22382
diff
changeset
|
4763 BLOCK_INPUT; |
6f9c70db3a58
(Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents:
22382
diff
changeset
|
4764 |
22220
a0cd311af6e3
(Fgarbage_collect): Call shrink_regexp_cache.
Richard M. Stallman <rms@gnu.org>
parents:
21948
diff
changeset
|
4765 shrink_regexp_cache (); |
a0cd311af6e3
(Fgarbage_collect): Call shrink_regexp_cache.
Richard M. Stallman <rms@gnu.org>
parents:
21948
diff
changeset
|
4766 |
300 | 4767 gc_in_progress = 1; |
4768 | |
16231 | 4769 /* clear_marks (); */ |
300 | 4770 |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
4771 /* Mark all the special slots that serve as the roots of accessibility. */ |
300 | 4772 |
4773 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
|
4774 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
|
4775 |
57098
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
4776 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
|
4777 { |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
4778 mark_object (bind->symbol); |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
4779 mark_object (bind->old_value); |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
4780 } |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
4781 mark_kboards (); |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
4782 |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
4783 #ifdef USE_GTK |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
4784 { |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
4785 extern void xg_mark_data (); |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
4786 xg_mark_data (); |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
4787 } |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
4788 #endif |
0487c26b96ee
(Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56539
diff
changeset
|
4789 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4790 #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
|
4791 || 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
|
4792 mark_stack (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4793 #else |
51228
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
4794 { |
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
4795 register struct gcpro *tail; |
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
4796 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
|
4797 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
|
4798 mark_object (tail->var[i]); |
51228
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
4799 } |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4800 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4801 |
26364
7b0217d9259c
(Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents:
26164
diff
changeset
|
4802 mark_byte_stack (); |
300 | 4803 for (catch = catchlist; catch; catch = catch->next) |
4804 { | |
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
|
4805 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
|
4806 mark_object (catch->val); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4807 } |
300 | 4808 for (handler = handlerlist; handler; handler = handler->next) |
4809 { | |
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
|
4810 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
|
4811 mark_object (handler->var); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4812 } |
55798
a1bb695e9a0c
(struct backtrace): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55767
diff
changeset
|
4813 mark_backtrace (); |
300 | 4814 |
59400
eeb8b96d077d
(mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents:
59359
diff
changeset
|
4815 #ifdef HAVE_WINDOW_SYSTEM |
eeb8b96d077d
(mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents:
59359
diff
changeset
|
4816 mark_fringe_data (); |
eeb8b96d077d
(mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents:
59359
diff
changeset
|
4817 #endif |
eeb8b96d077d
(mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents:
59359
diff
changeset
|
4818 |
55667
57f4a242e8f4
(Fgarbage_collect): Do all the marking before flushing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55635
diff
changeset
|
4819 #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
|
4820 mark_stack (); |
57f4a242e8f4
(Fgarbage_collect): Do all the marking before flushing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55635
diff
changeset
|
4821 #endif |
57f4a242e8f4
(Fgarbage_collect): Do all the marking before flushing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55635
diff
changeset
|
4822 |
55816
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
4823 /* 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
|
4824 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
|
4825 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
|
4826 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
|
4827 and delete them. */ |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4828 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4829 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
|
4830 |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4831 while (nextb) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4832 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4833 /* 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
|
4834 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
|
4835 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
|
4836 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
|
4837 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
|
4838 { |
55816
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
4839 Lisp_Object tail, prev; |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4840 tail = nextb->undo_list; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4841 prev = Qnil; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4842 while (CONSP (tail)) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4843 { |
55816
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
4844 if (GC_CONSP (XCAR (tail)) |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
4845 && GC_MARKERP (XCAR (XCAR (tail))) |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
4846 && !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
|
4847 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4848 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
|
4849 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
|
4850 else |
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
4851 { |
55816
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
4852 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
|
4853 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
|
4854 } |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4855 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4856 else |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4857 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4858 prev = tail; |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4859 tail = XCDR (tail); |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4860 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4861 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4862 } |
55816
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
4863 /* 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
|
4864 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
|
4865 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
|
4866 |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4867 nextb = nextb->next; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4868 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4869 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4870 |
55816
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
4871 gc_sweep (); |
55767
ee3a30045908
(marker_blocks_pending_free): New var.
Kim F. Storm <storm@cua.dk>
parents:
55745
diff
changeset
|
4872 |
300 | 4873 /* Clear the mark bits that we set in certain root slots. */ |
4874 | |
26378
cbf297593a79
(Fgarbage_collect): Call unmark_byte_stack.
Gerd Moellmann <gerd@gnu.org>
parents:
26372
diff
changeset
|
4875 unmark_byte_stack (); |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4876 VECTOR_UNMARK (&buffer_defaults); |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4877 VECTOR_UNMARK (&buffer_local_symbols); |
300 | 4878 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4879 #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
|
4880 dump_zombies (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4881 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4882 |
23534
6f9c70db3a58
(Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents:
22382
diff
changeset
|
4883 UNBLOCK_INPUT; |
6f9c70db3a58
(Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents:
22382
diff
changeset
|
4884 |
61252
d24c6e8f9add
(Fgarbage_collect): Call CHECK_CONS_LIST before and after gc.
Kim F. Storm <storm@cua.dk>
parents:
61225
diff
changeset
|
4885 CHECK_CONS_LIST (); |
d24c6e8f9add
(Fgarbage_collect): Call CHECK_CONS_LIST before and after gc.
Kim F. Storm <storm@cua.dk>
parents:
61225
diff
changeset
|
4886 |
16231 | 4887 /* clear_marks (); */ |
300 | 4888 gc_in_progress = 0; |
4889 | |
4890 consing_since_gc = 0; | |
4891 if (gc_cons_threshold < 10000) | |
4892 gc_cons_threshold = 10000; | |
4893 | |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4894 if (garbage_collection_messages) |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4895 { |
25343
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
4896 if (message_p || minibuf_level > 0) |
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
4897 restore_message (); |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4898 else |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4899 message1_nolog ("Garbage collecting...done"); |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4900 } |
300 | 4901 |
35170
a9b677239421
(Fgarbage_collect): Use a record_unwind_protect to
Gerd Moellmann <gerd@gnu.org>
parents:
34325
diff
changeset
|
4902 unbind_to (count, Qnil); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4903 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4904 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
|
4905 make_number (total_free_conses)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4906 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
|
4907 make_number (total_free_symbols)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4908 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
|
4909 make_number (total_free_markers)); |
34270
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
4910 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
|
4911 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
|
4912 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
|
4913 make_number (total_free_floats)); |
34270
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
4914 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
|
4915 make_number (total_free_intervals)); |
34270
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
4916 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
|
4917 make_number (total_free_strings)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4918 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4919 #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
|
4920 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4921 /* 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
|
4922 double nlive = 0; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4923 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4924 for (i = 0; i < 7; ++i) |
49357 | 4925 if (CONSP (total[i])) |
4926 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
|
4927 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4928 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
|
4929 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
|
4930 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
|
4931 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
|
4932 ++ngcs; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4933 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4934 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4935 |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4936 if (!NILP (Vpost_gc_hook)) |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4937 { |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4938 int count = inhibit_garbage_collection (); |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4939 safe_run_hooks (Qpost_gc_hook); |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4940 unbind_to (count, Qnil); |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4941 } |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4942 |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4943 /* Accumulate statistics. */ |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4944 EMACS_GET_TIME (t2); |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4945 EMACS_SUB_TIME (t3, t2, t1); |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4946 if (FLOATP (Vgc_elapsed)) |
49911
d9ade23e09df
(Fgarbage_collect): Don't use XSETFLOAT.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49600
diff
changeset
|
4947 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
|
4948 EMACS_SECS (t3) + |
d9ade23e09df
(Fgarbage_collect): Don't use XSETFLOAT.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49600
diff
changeset
|
4949 EMACS_USECS (t3) * 1.0e-6); |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4950 gcs_done++; |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4951 |
34270
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
4952 return Flist (sizeof total / sizeof *total, total); |
300 | 4953 } |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4954 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4955 |
25367
823e14641544
(mark_glyph_matrix): Mark strings only.
Gerd Moellmann <gerd@gnu.org>
parents:
25343
diff
changeset
|
4956 /* 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
|
4957 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
|
4958 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4959 static void |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4960 mark_glyph_matrix (matrix) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4961 struct glyph_matrix *matrix; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4962 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4963 struct glyph_row *row = matrix->rows; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4964 struct glyph_row *end = row + matrix->nrows; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4965 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4966 for (; row < end; ++row) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4967 if (row->enabled_p) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4968 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4969 int area; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4970 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
|
4971 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4972 struct glyph *glyph = row->glyphs[area]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4973 struct glyph *end_glyph = glyph + row->used[area]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4974 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4975 for (; glyph < end_glyph; ++glyph) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4976 if (GC_STRINGP (glyph->object) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4977 && !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
|
4978 mark_object (glyph->object); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4979 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4980 } |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4981 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4982 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4983 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4984 /* 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
|
4985 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4986 static void |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4987 mark_face_cache (c) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4988 struct face_cache *c; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4989 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4990 if (c) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4991 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4992 int i, j; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4993 for (i = 0; i < c->used; ++i) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4994 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4995 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
|
4996 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4997 if (face) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4998 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4999 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
|
5000 mark_object (face->lface[j]); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5001 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5002 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5003 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5004 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5005 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5006 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5007 #ifdef HAVE_WINDOW_SYSTEM |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5008 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5009 /* Mark Lisp objects in image IMG. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5010 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5011 static void |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5012 mark_image (img) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5013 struct image *img; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5014 { |
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
|
5015 mark_object (img->spec); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5016 |
31892
2f3d88ac2b38
(__malloc_size_t) [DOUG_LEA_MALLOC]: Don't redefine it.
Dave Love <fx@gnu.org>
parents:
31889
diff
changeset
|
5017 if (!NILP (img->data.lisp_val)) |
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
|
5018 mark_object (img->data.lisp_val); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5019 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5020 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5021 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5022 /* Mark Lisp objects in image cache of frame F. It's done this way so |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5023 that we don't have to include xterm.h here. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5024 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5025 static void |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5026 mark_image_cache (f) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5027 struct frame *f; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5028 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5029 forall_images_in_image_cache (f, mark_image); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5030 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5031 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5032 #endif /* HAVE_X_WINDOWS */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5033 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5034 |
300 | 5035 |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
5036 /* 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
|
5037 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
|
5038 all the references contained in it. */ |
300 | 5039 |
1168
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
5040 #define LAST_MARKED_SIZE 500 |
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
|
5041 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
|
5042 int last_marked_index; |
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
5043 |
46833
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5044 /* 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
|
5045 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
|
5046 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
|
5047 Normally this is zero and the check never goes off. */ |
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5048 int mark_object_loop_halt; |
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5049 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5050 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
|
5051 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
|
5052 Lisp_Object arg; |
300 | 5053 { |
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
|
5054 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
|
5055 #ifdef GC_CHECK_MARKED_OBJECTS |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5056 void *po; |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5057 struct mem_node *m; |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5058 #endif |
46833
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5059 int cdr_count = 0; |
300 | 5060 |
5868
a7bd57a60cb8
(mark_object): Fetch obj from *objptr at loop, not at the gotos.
Karl Heuer <kwzh@gnu.org>
parents:
5353
diff
changeset
|
5061 loop: |
300 | 5062 |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
5063 if (PURE_POINTER_P (XPNTR (obj))) |
300 | 5064 return; |
5065 | |
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
|
5066 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
|
5067 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
|
5068 last_marked_index = 0; |
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
5069 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5070 /* 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
|
5071 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
|
5072 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
|
5073 #ifdef GC_CHECK_MARKED_OBJECTS |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5074 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5075 po = (void *) XPNTR (obj); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5076 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5077 /* 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
|
5078 structure allocated from the heap. */ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5079 #define CHECK_ALLOCATED() \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5080 do { \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5081 m = mem_find (po); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5082 if (m == MEM_NIL) \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5083 abort (); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5084 } while (0) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5085 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5086 /* 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
|
5087 function LIVEP. */ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5088 #define CHECK_LIVE(LIVEP) \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5089 do { \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5090 if (!LIVEP (m, po)) \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5091 abort (); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5092 } while (0) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5093 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5094 /* 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
|
5095 #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
|
5096 do { \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5097 CHECK_ALLOCATED (); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5098 CHECK_LIVE (LIVEP); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5099 } while (0) \ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5100 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5101 #else /* not GC_CHECK_MARKED_OBJECTS */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5102 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5103 #define CHECK_ALLOCATED() (void) 0 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5104 #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
|
5105 #define CHECK_ALLOCATED_AND_LIVE(LIVEP) (void) 0 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5106 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5107 #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
|
5108 |
10457
2ab3bd0288a9
Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents:
10427
diff
changeset
|
5109 switch (SWITCH_ENUM_CAST (XGCTYPE (obj))) |
300 | 5110 { |
5111 case Lisp_String: | |
5112 { | |
5113 register struct Lisp_String *ptr = XSTRING (obj); | |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5114 CHECK_ALLOCATED_AND_LIVE (live_string_p); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5115 MARK_INTERVAL_TREE (ptr->intervals); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5116 MARK_STRING (ptr); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
5117 #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
|
5118 /* 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
|
5119 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
|
5120 CHECK_STRING_BYTES (ptr); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
5121 #endif /* GC_CHECK_STRING_BYTES */ |
300 | 5122 } |
5123 break; | |
5124 | |
10009
82f3daf76995
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
10004
diff
changeset
|
5125 case Lisp_Vectorlike: |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5126 #ifdef GC_CHECK_MARKED_OBJECTS |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5127 m = mem_find (po); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5128 if (m == MEM_NIL && !GC_SUBRP (obj) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5129 && po != &buffer_defaults |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5130 && po != &buffer_local_symbols) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5131 abort (); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5132 #endif /* GC_CHECK_MARKED_OBJECTS */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5133 |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5134 if (GC_BUFFERP (obj)) |
10340
ef58c7a5a4d6
(mark_object, mark_buffer): Don't mark buffer twice.
Karl Heuer <kwzh@gnu.org>
parents:
10320
diff
changeset
|
5135 { |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5136 if (!VECTOR_MARKED_P (XBUFFER (obj))) |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5137 { |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5138 #ifdef GC_CHECK_MARKED_OBJECTS |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5139 if (po != &buffer_defaults && po != &buffer_local_symbols) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5140 { |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5141 struct buffer *b; |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5142 for (b = all_buffers; b && b != po; b = b->next) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5143 ; |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5144 if (b == NULL) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5145 abort (); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5146 } |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5147 #endif /* GC_CHECK_MARKED_OBJECTS */ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5148 mark_buffer (obj); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5149 } |
10340
ef58c7a5a4d6
(mark_object, mark_buffer): Don't mark buffer twice.
Karl Heuer <kwzh@gnu.org>
parents:
10320
diff
changeset
|
5150 } |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5151 else if (GC_SUBRP (obj)) |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5152 break; |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5153 else if (GC_COMPILEDP (obj)) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5154 /* 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
|
5155 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
|
5156 recursion there. */ |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5157 { |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5158 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
|
5159 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
|
5160 register int i; |
300 | 5161 |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5162 if (VECTOR_MARKED_P (ptr)) |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5163 break; /* Already marked */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5164 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5165 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
|
5166 VECTOR_MARK (ptr); /* Else mark it */ |
10009
82f3daf76995
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
10004
diff
changeset
|
5167 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
|
5168 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
|
5169 { |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5170 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
|
5171 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
|
5172 } |
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
|
5173 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
|
5174 goto loop; |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5175 } |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5176 else if (GC_FRAMEP (obj)) |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5177 { |
32360
d8b668a486d7
(mark_object): Remove all workarounds installed on
Andreas Schwab <schwab@suse.de>
parents:
32099
diff
changeset
|
5178 register struct frame *ptr = XFRAME (obj); |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5179 |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5180 if (VECTOR_MARKED_P (ptr)) break; /* Already marked */ |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5181 VECTOR_MARK (ptr); /* Else mark it */ |
1295
a9241dc503ab
(mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents:
1168
diff
changeset
|
5182 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5183 CHECK_LIVE (live_vector_p); |
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
|
5184 mark_object (ptr->name); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5185 mark_object (ptr->icon_name); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5186 mark_object (ptr->title); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5187 mark_object (ptr->focus_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
|
5188 mark_object (ptr->selected_window); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5189 mark_object (ptr->minibuffer_window); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5190 mark_object (ptr->param_alist); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5191 mark_object (ptr->scroll_bars); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5192 mark_object (ptr->condemned_scroll_bars); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5193 mark_object (ptr->menu_bar_items); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5194 mark_object (ptr->face_alist); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5195 mark_object (ptr->menu_bar_vector); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5196 mark_object (ptr->buffer_predicate); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5197 mark_object (ptr->buffer_list); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5198 mark_object (ptr->menu_bar_window); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5199 mark_object (ptr->tool_bar_window); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5200 mark_face_cache (ptr->face_cache); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5201 #ifdef HAVE_WINDOW_SYSTEM |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5202 mark_image_cache (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
|
5203 mark_object (ptr->tool_bar_items); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5204 mark_object (ptr->desired_tool_bar_string); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5205 mark_object (ptr->current_tool_bar_string); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5206 #endif /* HAVE_WINDOW_SYSTEM */ |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5207 } |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
5208 else if (GC_BOOL_VECTOR_P (obj)) |
15379
5cd52d4838f8
(mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents:
14959
diff
changeset
|
5209 { |
5cd52d4838f8
(mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents:
14959
diff
changeset
|
5210 register struct Lisp_Vector *ptr = XVECTOR (obj); |
5cd52d4838f8
(mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents:
14959
diff
changeset
|
5211 |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5212 if (VECTOR_MARKED_P (ptr)) |
15379
5cd52d4838f8
(mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents:
14959
diff
changeset
|
5213 break; /* Already marked */ |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5214 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
|
5215 VECTOR_MARK (ptr); /* Else mark it */ |
15379
5cd52d4838f8
(mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents:
14959
diff
changeset
|
5216 } |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5217 else if (GC_WINDOWP (obj)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5218 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5219 register struct Lisp_Vector *ptr = XVECTOR (obj); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5220 struct window *w = XWINDOW (obj); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5221 register int i; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5222 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5223 /* Stop if already marked. */ |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5224 if (VECTOR_MARKED_P (ptr)) |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5225 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5226 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5227 /* Mark it. */ |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5228 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
|
5229 VECTOR_MARK (ptr); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5230 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5231 /* There is no Lisp data above The member CURRENT_MATRIX in |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5232 struct WINDOW. Stop marking when that slot is reached. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5233 for (i = 0; |
32360
d8b668a486d7
(mark_object): Remove all workarounds installed on
Andreas Schwab <schwab@suse.de>
parents:
32099
diff
changeset
|
5234 (char *) &ptr->contents[i] < (char *) &w->current_matrix; |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5235 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
|
5236 mark_object (ptr->contents[i]); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5237 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5238 /* Mark glyphs for leaf windows. Marking window matrices is |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5239 sufficient because frame matrices use the same glyph |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5240 memory. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5241 if (NILP (w->hchild) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5242 && NILP (w->vchild) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5243 && w->current_matrix) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5244 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5245 mark_glyph_matrix (w->current_matrix); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5246 mark_glyph_matrix (w->desired_matrix); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5247 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5248 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5249 else if (GC_HASH_TABLE_P (obj)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5250 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5251 struct Lisp_Hash_Table *h = XHASH_TABLE (obj); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5252 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5253 /* Stop if already marked. */ |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5254 if (VECTOR_MARKED_P (h)) |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5255 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5256 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5257 /* Mark it. */ |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5258 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
|
5259 VECTOR_MARK (h); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5260 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5261 /* Mark contents. */ |
43005 | 5262 /* Do not mark next_free or next_weak. |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5263 Being in the next_weak chain |
43005 | 5264 should not keep the hash table alive. |
5265 No need to mark `count' since it is an integer. */ | |
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
|
5266 mark_object (h->test); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5267 mark_object (h->weak); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5268 mark_object (h->rehash_size); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5269 mark_object (h->rehash_threshold); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5270 mark_object (h->hash); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5271 mark_object (h->next); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5272 mark_object (h->index); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5273 mark_object (h->user_hash_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
|
5274 mark_object (h->user_cmp_function); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5275 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5276 /* If hash table is not weak, mark all keys and values. |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5277 For weak tables, mark only the vector. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5278 if (GC_NILP (h->weak)) |
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
|
5279 mark_object (h->key_and_value); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5280 else |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5281 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
|
5282 } |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5283 else |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5284 { |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5285 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
|
5286 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
|
5287 register int i; |
300 | 5288 |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5289 if (VECTOR_MARKED_P (ptr)) break; /* Already marked */ |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5290 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
|
5291 VECTOR_MARK (ptr); /* Else mark it */ |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5292 if (size & PSEUDOVECTOR_FLAG) |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5293 size &= PSEUDOVECTOR_SIZE_MASK; |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5294 |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
5295 for (i = 0; i < size; i++) /* and then mark its elements */ |
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
|
5296 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
|
5297 } |
300 | 5298 break; |
5299 | |
5300 case Lisp_Symbol: | |
5301 { | |
32360
d8b668a486d7
(mark_object): Remove all workarounds installed on
Andreas Schwab <schwab@suse.de>
parents:
32099
diff
changeset
|
5302 register struct Lisp_Symbol *ptr = XSYMBOL (obj); |
300 | 5303 struct Lisp_Symbol *ptrx; |
5304 | |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5305 if (ptr->gcmarkbit) break; |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5306 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
|
5307 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
|
5308 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
|
5309 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
|
5310 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
|
5311 |
45392
f3d7ab65641f
* alloc.c (Fmake_symbol): Set symbol xname field instead of name.
Ken Raeburn <raeburn@raeburn.org>
parents:
44890
diff
changeset
|
5312 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
|
5313 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
|
5314 MARK_INTERVAL_TREE (STRING_INTERVALS (ptr->xname)); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5315 |
20768 | 5316 /* Note that we do not mark the obarray of the symbol. |
5317 It is safe not to do so because nothing accesses that | |
5318 slot except to check whether it is nil. */ | |
300 | 5319 ptr = ptr->next; |
5320 if (ptr) | |
5321 { | |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
5322 ptrx = ptr; /* Use of ptrx avoids compiler bug on Sun */ |
300 | 5323 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
|
5324 goto loop; |
300 | 5325 } |
5326 } | |
5327 break; | |
5328 | |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
5329 case Lisp_Misc: |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5330 CHECK_ALLOCATED_AND_LIVE (live_misc_p); |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5331 if (XMARKER (obj)->gcmarkbit) |
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5332 break; |
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5333 XMARKER (obj)->gcmarkbit = 1; |
56202
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5334 |
11243
054ecfce1820
(Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents:
11048
diff
changeset
|
5335 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
|
5336 { |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5337 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
|
5338 case Lisp_Misc_Some_Buffer_Local_Value: |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5339 { |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5340 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
|
5341 = XBUFFER_LOCAL_VALUE (obj); |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5342 /* 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
|
5343 if (EQ (ptr->cdr, Qnil)) |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5344 { |
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
|
5345 obj = ptr->realvalue; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5346 goto loop; |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5347 } |
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
|
5348 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
|
5349 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
|
5350 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
|
5351 obj = ptr->cdr; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5352 goto loop; |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5353 } |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5354 |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5355 case Lisp_Misc_Marker: |
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5356 /* 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
|
5357 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
|
5358 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
|
5359 break; |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5360 |
9463
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
5361 case Lisp_Misc_Intfwd: |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
5362 case Lisp_Misc_Boolfwd: |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
5363 case Lisp_Misc_Objfwd: |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
5364 case Lisp_Misc_Buffer_Objfwd: |
11018
2d9bdf1ba3d1
(mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents:
10936
diff
changeset
|
5365 case Lisp_Misc_Kboard_Objfwd: |
9463
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
5366 /* Don't bother with Lisp_Buffer_Objfwd, |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
5367 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
|
5368 /* 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
|
5369 are protected with staticpro. */ |
56202
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5370 break; |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5371 |
52166
25f780eb3fd8
(mark_object): Handle Lisp_Misc_Save_Value.
Andreas Schwab <schwab@suse.de>
parents:
51985
diff
changeset
|
5372 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
|
5373 #if GC_MARK_STACK |
56202
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5374 { |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5375 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
|
5376 /* 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
|
5377 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
|
5378 if (ptr->dogc) |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5379 { |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5380 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
|
5381 int nelt; |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5382 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
|
5383 mark_maybe_object (*p); |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5384 } |
db1817b88294
(safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents:
56187
diff
changeset
|
5385 } |
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
|
5386 #endif |
9463
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
5387 break; |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
5388 |
9926
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
5389 case Lisp_Misc_Overlay: |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
5390 { |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
5391 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
|
5392 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
|
5393 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
|
5394 mark_object (ptr->plist); |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5395 if (ptr->next) |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5396 { |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5397 XSETMISC (obj, ptr->next); |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5398 goto loop; |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5399 } |
9926
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
5400 } |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
5401 break; |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
5402 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
5403 default: |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
5404 abort (); |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
5405 } |
300 | 5406 break; |
5407 | |
5408 case Lisp_Cons: | |
5409 { | |
5410 register struct Lisp_Cons *ptr = XCONS (obj); | |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5411 if (CONS_MARKED_P (ptr)) break; |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5412 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
|
5413 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
|
5414 /* If the cdr is nil, avoid recursion for the car. */ |
a9241dc503ab
(mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents:
1168
diff
changeset
|
5415 if (EQ (ptr->cdr, Qnil)) |
a9241dc503ab
(mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents:
1168
diff
changeset
|
5416 { |
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
|
5417 obj = ptr->car; |
46833
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5418 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
|
5419 goto loop; |
a9241dc503ab
(mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents:
1168
diff
changeset
|
5420 } |
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
|
5421 mark_object (ptr->car); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5422 obj = ptr->cdr; |
46833
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5423 cdr_count++; |
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5424 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
|
5425 abort (); |
300 | 5426 goto loop; |
5427 } | |
5428 | |
5429 case Lisp_Float: | |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5430 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
|
5431 FLOAT_MARK (XFLOAT (obj)); |
300 | 5432 break; |
5433 | |
5434 case Lisp_Int: | |
5435 break; | |
5436 | |
5437 default: | |
5438 abort (); | |
5439 } | |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5440 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5441 #undef CHECK_LIVE |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5442 #undef CHECK_ALLOCATED |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5443 #undef CHECK_ALLOCATED_AND_LIVE |
300 | 5444 } |
5445 | |
5446 /* Mark the pointers in a buffer structure. */ | |
5447 | |
5448 static void | |
5449 mark_buffer (buf) | |
5450 Lisp_Object buf; | |
5451 { | |
5452 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
|
5453 register Lisp_Object *ptr, tmp; |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5454 Lisp_Object base_buffer; |
300 | 5455 |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5456 VECTOR_MARK (buffer); |
300 | 5457 |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5458 MARK_INTERVAL_TREE (BUF_INTERVALS (buffer)); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5459 |
55816
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5460 /* 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
|
5461 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
|
5462 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
|
5463 |
51843
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5464 if (buffer->overlays_before) |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5465 { |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5466 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
|
5467 mark_object (tmp); |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5468 } |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5469 if (buffer->overlays_after) |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5470 { |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5471 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
|
5472 mark_object (tmp); |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5473 } |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5474 |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5475 for (ptr = &buffer->name; |
300 | 5476 (char *)ptr < (char *)buffer + sizeof (struct buffer); |
5477 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
|
5478 mark_object (*ptr); |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5479 |
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5480 /* 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
|
5481 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
|
5482 { |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5483 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
|
5484 mark_buffer (base_buffer); |
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5485 } |
300 | 5486 } |
10649
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
5487 |
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
5488 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5489 /* 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
|
5490 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
|
5491 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5492 int |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5493 survives_gc_p (obj) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5494 Lisp_Object obj; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5495 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5496 int survives_p; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5497 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5498 switch (XGCTYPE (obj)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5499 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5500 case Lisp_Int: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5501 survives_p = 1; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5502 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5503 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5504 case Lisp_Symbol: |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5505 survives_p = XSYMBOL (obj)->gcmarkbit; |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5506 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5507 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5508 case Lisp_Misc: |
51668
0f333fd92a1d
(survives_gc_p): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51658
diff
changeset
|
5509 survives_p = XMARKER (obj)->gcmarkbit; |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5510 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5511 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5512 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
|
5513 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
|
5514 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5515 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5516 case Lisp_Vectorlike: |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5517 survives_p = GC_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
|
5518 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5519 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5520 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
|
5521 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
|
5522 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5523 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5524 case Lisp_Float: |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
5525 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
|
5526 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5527 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5528 default: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5529 abort (); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5530 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5531 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5532 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
|
5533 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5534 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5535 |
300 | 5536 |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
5537 /* Sweep: find all structures not marked, and free them. */ |
300 | 5538 |
5539 static void | |
5540 gc_sweep () | |
5541 { | |
55816
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5542 /* 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
|
5543 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
|
5544 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
|
5545 |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5546 sweep_strings (); |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5547 #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
|
5548 if (!noninteractive) |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5549 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
|
5550 #endif |
a4fe04f4d9c2
Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55798
diff
changeset
|
5551 |
300 | 5552 /* Put all unmarked conses on free list */ |
5553 { | |
5554 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
|
5555 struct cons_block **cprev = &cons_block; |
300 | 5556 register int lim = cons_block_index; |
5557 register int num_free = 0, num_used = 0; | |
5558 | |
5559 cons_free_list = 0; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5560 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5561 for (cblk = cons_block; cblk; cblk = *cprev) |
300 | 5562 { |
5563 register int i; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5564 int this_free = 0; |
300 | 5565 for (i = 0; i < lim; i++) |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5566 if (!CONS_MARKED_P (&cblk->conses[i])) |
300 | 5567 { |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5568 this_free++; |
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
|
5569 *(struct Lisp_Cons **)&cblk->conses[i].cdr = cons_free_list; |
300 | 5570 cons_free_list = &cblk->conses[i]; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5571 #if GC_MARK_STACK |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5572 cons_free_list->car = Vdead; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5573 #endif |
300 | 5574 } |
5575 else | |
5576 { | |
5577 num_used++; | |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5578 CONS_UNMARK (&cblk->conses[i]); |
300 | 5579 } |
5580 lim = CONS_BLOCK_SIZE; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5581 /* 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
|
5582 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
|
5583 this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5584 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
|
5585 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5586 *cprev = cblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5587 /* Unhook from the free list. */ |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5588 cons_free_list = *(struct Lisp_Cons **) &cblk->conses[0].cdr; |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5589 lisp_align_free (cblk); |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5590 n_cons_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5591 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5592 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5593 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5594 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5595 cprev = &cblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5596 } |
300 | 5597 } |
5598 total_conses = num_used; | |
5599 total_free_conses = num_free; | |
5600 } | |
5601 | |
5602 /* Put all unmarked floats on free list */ | |
5603 { | |
5604 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
|
5605 struct float_block **fprev = &float_block; |
300 | 5606 register int lim = float_block_index; |
5607 register int num_free = 0, num_used = 0; | |
5608 | |
5609 float_free_list = 0; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5610 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5611 for (fblk = float_block; fblk; fblk = *fprev) |
300 | 5612 { |
5613 register int i; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5614 int this_free = 0; |
300 | 5615 for (i = 0; i < lim; i++) |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
5616 if (!FLOAT_MARKED_P (&fblk->floats[i])) |
300 | 5617 { |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5618 this_free++; |
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
|
5619 *(struct Lisp_Float **)&fblk->floats[i].data = float_free_list; |
300 | 5620 float_free_list = &fblk->floats[i]; |
5621 } | |
5622 else | |
5623 { | |
5624 num_used++; | |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
5625 FLOAT_UNMARK (&fblk->floats[i]); |
300 | 5626 } |
5627 lim = FLOAT_BLOCK_SIZE; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5628 /* 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
|
5629 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
|
5630 this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5631 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
|
5632 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5633 *fprev = fblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5634 /* Unhook from the free list. */ |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5635 float_free_list = *(struct Lisp_Float **) &fblk->floats[0].data; |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
5636 lisp_align_free (fblk); |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5637 n_float_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5638 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5639 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5640 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5641 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5642 fprev = &fblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5643 } |
300 | 5644 } |
5645 total_floats = num_used; | |
5646 total_free_floats = num_free; | |
5647 } | |
5648 | |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5649 /* Put all unmarked intervals on free list */ |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5650 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5651 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
|
5652 struct interval_block **iprev = &interval_block; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5653 register int lim = interval_block_index; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5654 register int num_free = 0, num_used = 0; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5655 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5656 interval_free_list = 0; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5657 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5658 for (iblk = interval_block; iblk; iblk = *iprev) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5659 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5660 register int i; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5661 int this_free = 0; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5662 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5663 for (i = 0; i < lim; i++) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5664 { |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5665 if (!iblk->intervals[i].gcmarkbit) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5666 { |
28269
fd13be8ae190
Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents:
28220
diff
changeset
|
5667 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
|
5668 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
|
5669 this_free++; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5670 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5671 else |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5672 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5673 num_used++; |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5674 iblk->intervals[i].gcmarkbit = 0; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5675 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5676 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5677 lim = INTERVAL_BLOCK_SIZE; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5678 /* 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
|
5679 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
|
5680 deallocate this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5681 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
|
5682 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5683 *iprev = iblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5684 /* Unhook from the free list. */ |
28269
fd13be8ae190
Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents:
28220
diff
changeset
|
5685 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
|
5686 lisp_free (iblk); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5687 n_interval_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5688 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5689 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5690 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5691 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5692 iprev = &iblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5693 } |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5694 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5695 total_intervals = num_used; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5696 total_free_intervals = num_free; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5697 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5698 |
300 | 5699 /* Put all unmarked symbols on free list */ |
5700 { | |
5701 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
|
5702 struct symbol_block **sprev = &symbol_block; |
300 | 5703 register int lim = symbol_block_index; |
5704 register int num_free = 0, num_used = 0; | |
5705 | |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5706 symbol_free_list = NULL; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5707 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5708 for (sblk = symbol_block; sblk; sblk = *sprev) |
300 | 5709 { |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5710 int this_free = 0; |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5711 struct Lisp_Symbol *sym = sblk->symbols; |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5712 struct Lisp_Symbol *end = sym + lim; |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5713 |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5714 for (; sym < end; ++sym) |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5715 { |
34325
a65d8c29442a
(gc_sweep): Add comment.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34308
diff
changeset
|
5716 /* 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
|
5717 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
|
5718 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
|
5719 int pure_p = PURE_POINTER_P (XSTRING (sym->xname)); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5720 |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5721 if (!sym->gcmarkbit && !pure_p) |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5722 { |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5723 *(struct Lisp_Symbol **) &sym->value = symbol_free_list; |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5724 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
|
5725 #if GC_MARK_STACK |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5726 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
|
5727 #endif |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5728 ++this_free; |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5729 } |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5730 else |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5731 { |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5732 ++num_used; |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5733 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
|
5734 UNMARK_STRING (XSTRING (sym->xname)); |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5735 sym->gcmarkbit = 0; |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5736 } |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5737 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5738 |
300 | 5739 lim = SYMBOL_BLOCK_SIZE; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5740 /* 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
|
5741 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
|
5742 this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5743 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
|
5744 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5745 *sprev = sblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5746 /* Unhook from the free list. */ |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5747 symbol_free_list = *(struct Lisp_Symbol **)&sblk->symbols[0].value; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5748 lisp_free (sblk); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5749 n_symbol_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5750 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5751 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5752 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5753 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5754 sprev = &sblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5755 } |
300 | 5756 } |
5757 total_symbols = num_used; | |
5758 total_free_symbols = num_free; | |
5759 } | |
5760 | |
21143
ce12eac1ee45
(gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents:
21084
diff
changeset
|
5761 /* 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
|
5762 For a marker, first unchain it from the buffer it points into. */ |
300 | 5763 { |
5764 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
|
5765 struct marker_block **mprev = &marker_block; |
300 | 5766 register int lim = marker_block_index; |
5767 register int num_free = 0, num_used = 0; | |
5768 | |
5769 marker_free_list = 0; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5770 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5771 for (mblk = marker_block; mblk; mblk = *mprev) |
300 | 5772 { |
5773 register int i; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5774 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
|
5775 |
300 | 5776 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
|
5777 { |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5778 if (!mblk->markers[i].u_marker.gcmarkbit) |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5779 { |
11243
054ecfce1820
(Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents:
11048
diff
changeset
|
5780 if (mblk->markers[i].u_marker.type == Lisp_Misc_Marker) |
51668
0f333fd92a1d
(survives_gc_p): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51658
diff
changeset
|
5781 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
|
5782 /* 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
|
5783 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
|
5784 but this might catch bugs faster. */ |
11243
054ecfce1820
(Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents:
11048
diff
changeset
|
5785 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
|
5786 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
|
5787 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
|
5788 this_free++; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5789 } |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5790 else |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5791 { |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5792 num_used++; |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5793 mblk->markers[i].u_marker.gcmarkbit = 0; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5794 } |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5795 } |
300 | 5796 lim = MARKER_BLOCK_SIZE; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5797 /* 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
|
5798 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
|
5799 this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5800 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
|
5801 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5802 *mprev = mblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5803 /* Unhook from the free list. */ |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5804 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
|
5805 lisp_free (mblk); |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5806 n_marker_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5807 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5808 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5809 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5810 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5811 mprev = &mblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5812 } |
300 | 5813 } |
5814 | |
5815 total_markers = num_used; | |
5816 total_free_markers = num_free; | |
5817 } | |
5818 | |
5819 /* Free all unmarked buffers */ | |
5820 { | |
5821 register struct buffer *buffer = all_buffers, *prev = 0, *next; | |
5822 | |
5823 while (buffer) | |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5824 if (!VECTOR_MARKED_P (buffer)) |
300 | 5825 { |
5826 if (prev) | |
5827 prev->next = buffer->next; | |
5828 else | |
5829 all_buffers = buffer->next; | |
5830 next = buffer->next; | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5831 lisp_free (buffer); |
300 | 5832 buffer = next; |
5833 } | |
5834 else | |
5835 { | |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5836 VECTOR_UNMARK (buffer); |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5837 UNMARK_BALANCE_INTERVALS (BUF_INTERVALS (buffer)); |
300 | 5838 prev = buffer, buffer = buffer->next; |
5839 } | |
5840 } | |
5841 | |
5842 /* Free all unmarked vectors */ | |
5843 { | |
5844 register struct Lisp_Vector *vector = all_vectors, *prev = 0, *next; | |
5845 total_vector_size = 0; | |
5846 | |
5847 while (vector) | |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5848 if (!VECTOR_MARKED_P (vector)) |
300 | 5849 { |
5850 if (prev) | |
5851 prev->next = vector->next; | |
5852 else | |
5853 all_vectors = vector->next; | |
5854 next = vector->next; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5855 lisp_free (vector); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5856 n_vectors--; |
300 | 5857 vector = next; |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5858 |
300 | 5859 } |
5860 else | |
5861 { | |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5862 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
|
5863 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
|
5864 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
|
5865 else |
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
5866 total_vector_size += vector->size; |
300 | 5867 prev = vector, vector = vector->next; |
5868 } | |
5869 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5870 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5871 #ifdef GC_CHECK_STRING_BYTES |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5872 if (!noninteractive) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5873 check_string_bytes (1); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5874 #endif |
300 | 5875 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5876 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5877 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5878 |
300 | 5879 |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5880 /* Debugging aids. */ |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5881 |
5353
6389ed5b45ac
(Fmemory_limit): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents:
4956
diff
changeset
|
5882 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
|
5883 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
|
5884 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
|
5885 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
|
5886 () |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5887 { |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5888 Lisp_Object end; |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5889 |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
5890 XSETINT (end, (EMACS_INT) sbrk (0) / 1024); |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5891 |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5892 return end; |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5893 } |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5894 |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
5895 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
|
5896 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
|
5897 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
|
5898 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
|
5899 Garbage collection does not decrease them. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5900 The elements of the value are as follows: |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5901 (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
|
5902 All are in units of 1 = one object consed |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5903 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
|
5904 objects consed. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5905 MISCS include overlays, markers, and some internal types. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5906 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
|
5907 (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
|
5908 () |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
5909 { |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5910 Lisp_Object consed[8]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5911 |
39633
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
5912 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
|
5913 consed[1] = make_number (min (MOST_POSITIVE_FIXNUM, floats_consed)); |
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
5914 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
|
5915 consed[3] = make_number (min (MOST_POSITIVE_FIXNUM, symbols_consed)); |
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
5916 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
|
5917 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
|
5918 consed[6] = make_number (min (MOST_POSITIVE_FIXNUM, intervals_consed)); |
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
5919 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
|
5920 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5921 return Flist (8, consed); |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
5922 } |
28406
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5923 |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5924 int suppress_checking; |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5925 void |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5926 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
|
5927 const char *msg; |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5928 const char *file; |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5929 int line; |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5930 { |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5931 fprintf (stderr, "\r\nEmacs fatal error: %s:%d: %s\r\n", |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5932 file, line, msg); |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5933 abort (); |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5934 } |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5935 |
300 | 5936 /* Initialization */ |
5937 | |
21514 | 5938 void |
300 | 5939 init_alloc_once () |
5940 { | |
5941 /* 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
|
5942 purebeg = PUREBEG; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5943 pure_size = PURESIZE; |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
5944 pure_bytes_used = 0; |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5945 pure_bytes_used_before_overflow = 0; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5946 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
5947 /* Initialize the list of free aligned blocks. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
5948 free_ablock = NULL; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
5949 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
5950 #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
|
5951 mem_init (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5952 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
|
5953 #endif |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5954 |
300 | 5955 all_vectors = 0; |
5956 ignore_warnings = 1; | |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
5957 #ifdef DOUG_LEA_MALLOC |
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
5958 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
|
5959 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
|
5960 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
|
5961 #endif |
300 | 5962 init_strings (); |
5963 init_cons (); | |
5964 init_symbol (); | |
5965 init_marker (); | |
5966 init_float (); | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5967 init_intervals (); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5968 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5969 #ifdef REL_ALLOC |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5970 malloc_hysteresis = 32; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5971 #else |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5972 malloc_hysteresis = 0; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5973 #endif |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5974 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5975 spare_memory = (char *) malloc (SPARE_MEMORY); |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5976 |
300 | 5977 ignore_warnings = 0; |
5978 gcprolist = 0; | |
26364
7b0217d9259c
(Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents:
26164
diff
changeset
|
5979 byte_stack_list = 0; |
300 | 5980 staticidx = 0; |
5981 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
|
5982 gc_cons_threshold = 100000 * sizeof (Lisp_Object); |
300 | 5983 #ifdef VIRT_ADDR_VARIES |
5984 malloc_sbrk_unused = 1<<22; /* A large number */ | |
5985 malloc_sbrk_used = 100000; /* as reasonable as any number */ | |
5986 #endif /* VIRT_ADDR_VARIES */ | |
5987 } | |
5988 | |
21514 | 5989 void |
300 | 5990 init_alloc () |
5991 { | |
5992 gcprolist = 0; | |
26364
7b0217d9259c
(Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents:
26164
diff
changeset
|
5993 byte_stack_list = 0; |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
5994 #if GC_MARK_STACK |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
5995 #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
|
5996 setjmp_tested_p = longjmps_done = 0; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
5997 #endif |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
5998 #endif |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5999 Vgc_elapsed = make_float (0.0); |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
6000 gcs_done = 0; |
300 | 6001 } |
6002 | |
6003 void | |
6004 syms_of_alloc () | |
6005 { | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6006 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
|
6007 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
|
6008 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
|
6009 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
|
6010 |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6011 Garbage collection happens automatically only when `eval' is called. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6012 |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6013 By binding this temporarily to a large number, you can effectively |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6014 prevent garbage collection during a part of the program. */); |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
6015 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6016 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
|
6017 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
|
6018 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6019 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
|
6020 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
|
6021 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6022 DEFVAR_INT ("floats-consed", &floats_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
6023 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
|
6024 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6025 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
|
6026 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
|
6027 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6028 DEFVAR_INT ("symbols-consed", &symbols_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
6029 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
|
6030 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6031 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
|
6032 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
|
6033 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6034 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
|
6035 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
|
6036 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6037 DEFVAR_INT ("intervals-consed", &intervals_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
6038 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
|
6039 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6040 DEFVAR_INT ("strings-consed", &strings_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
6041 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
|
6042 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6043 DEFVAR_LISP ("purify-flag", &Vpurify_flag, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
6044 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
|
6045 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
|
6046 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6047 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
|
6048 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
|
6049 garbage_collection_messages = 0; |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
6050 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
6051 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
|
6052 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
|
6053 Vpost_gc_hook = Qnil; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
6054 Qpost_gc_hook = intern ("post-gc-hook"); |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
6055 staticpro (&Qpost_gc_hook); |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
6056 |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
6057 DEFVAR_LISP ("memory-signal-data", &Vmemory_signal_data, |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
6058 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
|
6059 /* 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
|
6060 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
|
6061 Vmemory_signal_data |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
6062 = list2 (Qerror, |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
6063 build_string ("Memory exhausted--use M-x save-some-buffers then exit and restart Emacs")); |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
6064 |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
6065 DEFVAR_LISP ("memory-full", &Vmemory_full, |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
6066 doc: /* 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
|
6067 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
|
6068 |
11374
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
6069 staticpro (&Qgc_cons_threshold); |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
6070 Qgc_cons_threshold = intern ("gc-cons-threshold"); |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
6071 |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
6072 staticpro (&Qchar_table_extra_slots); |
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
6073 Qchar_table_extra_slots = intern ("char-table-extra-slots"); |
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
6074 |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
6075 DEFVAR_LISP ("gc-elapsed", &Vgc_elapsed, |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
6076 doc: /* Accumulated time elapsed in garbage collections. |
51974
111cc76606c6
(syms_of_alloc): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
51938
diff
changeset
|
6077 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
|
6078 DEFVAR_INT ("gcs-done", &gcs_done, |
51974
111cc76606c6
(syms_of_alloc): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
51938
diff
changeset
|
6079 doc: /* Accumulated number of garbage collections done. */); |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
6080 |
300 | 6081 defsubr (&Scons); |
6082 defsubr (&Slist); | |
6083 defsubr (&Svector); | |
6084 defsubr (&Smake_byte_code); | |
6085 defsubr (&Smake_list); | |
6086 defsubr (&Smake_vector); | |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
6087 defsubr (&Smake_char_table); |
300 | 6088 defsubr (&Smake_string); |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
6089 defsubr (&Smake_bool_vector); |
300 | 6090 defsubr (&Smake_symbol); |
6091 defsubr (&Smake_marker); | |
6092 defsubr (&Spurecopy); | |
6093 defsubr (&Sgarbage_collect); | |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
6094 defsubr (&Smemory_limit); |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
6095 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
|
6096 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
6097 #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
|
6098 defsubr (&Sgc_status); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
6099 #endif |
300 | 6100 } |
52401 | 6101 |
6102 /* arch-tag: 6695ca10-e3c5-4c2c-8bc3-ed26a7dda857 | |
6103 (do not change this comment) */ |