Mercurial > emacs
annotate src/alloc.c @ 31701:1106e8c3d500
*** empty log message ***
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Tue, 19 Sep 2000 00:13:47 +0000 |
parents | 717e7e2ca4fd |
children | 43566b0aec59 |
rev | line source |
---|---|
300 | 1 /* Storage allocation and gc for GNU Emacs Lisp interpreter. |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2 Copyright (C) 1985, 86, 88, 93, 94, 95, 97, 98, 1999, 2000 |
20708 | 3 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> |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25762
diff
changeset
|
24 |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
25 /* 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
|
26 |
3003
5a73d384f45e
* syssignal.h: Don't #include <signal.h>
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
27 #include <signal.h> |
300 | 28 |
26164
d39ec0a27081
more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents:
26088
diff
changeset
|
29 /* 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
|
30 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
|
31 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
|
32 |
26164
d39ec0a27081
more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents:
26088
diff
changeset
|
33 #undef HIDE_LISP_IMPLEMENTATION |
300 | 34 #include "lisp.h" |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
35 #include "intervals.h" |
356 | 36 #include "puresize.h" |
300 | 37 #include "buffer.h" |
38 #include "window.h" | |
31102
6a0caa788013
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30914
diff
changeset
|
39 #include "keyboard.h" |
764 | 40 #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
|
41 #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
|
42 #include "charset.h" |
638 | 43 #include "syssignal.h" |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
44 #include <setjmp.h> |
638 | 45 |
30784
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
46 #ifdef HAVE_UNISTD_H |
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
47 #include <unistd.h> |
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
48 #else |
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
49 extern POINTER_TYPE *sbrk (); |
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
50 #endif |
12096 | 51 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
52 #ifdef DOUG_LEA_MALLOC |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
53 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
54 #include <malloc.h> |
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
55 #define __malloc_size_t int |
23973
2eb9e2f5aa33
(MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
23958
diff
changeset
|
56 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
57 /* 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
|
58 value that explicitly means "no limit". */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
59 |
23973
2eb9e2f5aa33
(MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
23958
diff
changeset
|
60 #define MMAP_MAX_AREAS 100000000 |
2eb9e2f5aa33
(MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
23958
diff
changeset
|
61 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
62 #else /* not DOUG_LEA_MALLOC */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
63 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
64 /* 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
|
65 |
28374
7a3e8a76057b
Include stdio.h. Test STDC_HEADERS, not __STDC__.
Dave Love <fx@gnu.org>
parents:
28365
diff
changeset
|
66 #if defined (STDC_HEADERS) |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
67 #include <stddef.h> |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
68 #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
|
69 #else |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
70 #define __malloc_size_t unsigned int |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
71 #endif |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
72 extern __malloc_size_t _bytes_used; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
73 extern int __malloc_extra_blocks; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
74 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
75 #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
|
76 |
300 | 77 #define max(A,B) ((A) > (B) ? (A) : (B)) |
11727
53ccd2d608ee
(gc_cons_threshold): Change back to int.
Richard M. Stallman <rms@gnu.org>
parents:
11679
diff
changeset
|
78 #define min(A,B) ((A) < (B) ? (A) : (B)) |
300 | 79 |
80 /* Macro to verify that storage intended for Lisp objects is not | |
81 out of range to fit in the space for a pointer. | |
82 ADDRESS is the start of the block, and SIZE | |
83 is the amount of space within which objects can start. */ | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
84 |
300 | 85 #define VALIDATE_LISP_STORAGE(address, size) \ |
86 do \ | |
87 { \ | |
88 Lisp_Object val; \ | |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
89 XSETCONS (val, (char *) address + size); \ |
300 | 90 if ((char *) XCONS (val) != (char *) address + size) \ |
91 { \ | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
92 xfree (address); \ |
300 | 93 memory_full (); \ |
94 } \ | |
95 } while (0) | |
96 | |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
97 /* 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
|
98 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
99 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
|
100 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
101 /* 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
|
102 to a struct Lisp_String. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
103 |
28469
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
104 #define MARK_STRING(S) ((S)->size |= MARKBIT) |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
105 #define UNMARK_STRING(S) ((S)->size &= ~MARKBIT) |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
106 #define STRING_MARKED_P(S) ((S)->size & MARKBIT) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
107 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
108 /* 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
|
109 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
|
110 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
|
111 strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
112 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
113 #define GC_STRING_BYTES(S) (STRING_BYTES (S) & ~MARKBIT) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
114 #define GC_STRING_CHARS(S) ((S)->size & ~MARKBIT) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
115 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
116 /* 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
|
117 |
300 | 118 int consing_since_gc; |
119 | |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
120 /* 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
|
121 |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
122 int cons_cells_consed; |
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
123 int floats_consed; |
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
124 int vector_cells_consed; |
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
125 int symbols_consed; |
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
126 int string_chars_consed; |
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
127 int misc_objects_consed; |
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
128 int intervals_consed; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
129 int strings_consed; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
130 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
131 /* 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
|
132 |
11727
53ccd2d608ee
(gc_cons_threshold): Change back to int.
Richard M. Stallman <rms@gnu.org>
parents:
11679
diff
changeset
|
133 int gc_cons_threshold; |
300 | 134 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
135 /* Nonzero during GC. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
136 |
300 | 137 int gc_in_progress; |
138 | |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
139 /* 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
|
140 |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
141 int garbage_collection_messages; |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
142 |
300 | 143 #ifndef VIRT_ADDR_VARIES |
144 extern | |
145 #endif /* VIRT_ADDR_VARIES */ | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
146 int malloc_sbrk_used; |
300 | 147 |
148 #ifndef VIRT_ADDR_VARIES | |
149 extern | |
150 #endif /* VIRT_ADDR_VARIES */ | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
151 int malloc_sbrk_unused; |
300 | 152 |
764 | 153 /* Two limits controlling how much undo information to keep. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
154 |
764 | 155 int undo_limit; |
156 int undo_strong_limit; | |
300 | 157 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
158 /* 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
|
159 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
160 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
|
161 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
|
162 static int total_free_floats, total_floats; |
19332
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
163 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
164 /* 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
|
165 out of memory. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
166 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
167 static char *spare_memory; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
168 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
169 /* 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
|
170 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
171 #define SPARE_MEMORY (1 << 14) |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
172 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
173 /* 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
|
174 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
175 static int malloc_hysteresis; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
176 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
177 /* 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
|
178 |
300 | 179 Lisp_Object Vpurify_flag; |
180 | |
181 #ifndef HAVE_SHM | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
182 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
183 /* Force it into data space! */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
184 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
185 EMACS_INT pure[PURESIZE / sizeof (EMACS_INT)] = {0,}; |
300 | 186 #define PUREBEG (char *) pure |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
187 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
188 #else /* not HAVE_SHM */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
189 |
300 | 190 #define pure PURE_SEG_BITS /* Use shared memory segment */ |
191 #define PUREBEG (char *)PURE_SEG_BITS | |
356 | 192 |
193 /* This variable is used only by the XPNTR macro when HAVE_SHM is | |
194 defined. If we used the PURESIZE macro directly there, that would | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
195 make most of Emacs dependent on puresize.h, which we don't want - |
356 | 196 you should be able to change that without too much recompilation. |
197 So map_in_data initializes pure_size, and the dependencies work | |
198 out. */ | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
199 |
8817
48ff00bebef6
(pure, pure_size): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
200 EMACS_INT pure_size; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
201 |
300 | 202 #endif /* not HAVE_SHM */ |
203 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
204 /* 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
|
205 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
206 #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
|
207 (((PNTR_COMPARISON_TYPE) (P) \ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
208 < (PNTR_COMPARISON_TYPE) ((char *) pure + PURESIZE)) \ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
209 && ((PNTR_COMPARISON_TYPE) (P) \ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
210 >= (PNTR_COMPARISON_TYPE) pure)) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
211 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
212 /* 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
|
213 |
300 | 214 int pureptr; |
215 | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
216 /* 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
|
217 displayed. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
218 |
300 | 219 char *pending_malloc_warning; |
220 | |
6116
64417bbbb128
(memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents:
5874
diff
changeset
|
221 /* 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
|
222 |
6133
752d4237f869
(memory_signal_data): No longer static.
Richard M. Stallman <rms@gnu.org>
parents:
6116
diff
changeset
|
223 Lisp_Object memory_signal_data; |
6116
64417bbbb128
(memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents:
5874
diff
changeset
|
224 |
300 | 225 /* Maximum amount of C stack to save when a GC happens. */ |
226 | |
227 #ifndef MAX_SAVE_STACK | |
228 #define MAX_SAVE_STACK 16000 | |
229 #endif | |
230 | |
231 /* Buffer in which we save a copy of the C stack at each GC. */ | |
232 | |
233 char *stack_copy; | |
234 int stack_copy_size; | |
235 | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
236 /* 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
|
237 Currently not used. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
238 |
300 | 239 int ignore_warnings; |
1318 | 240 |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
241 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
|
242 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
243 static void mark_buffer P_ ((Lisp_Object)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
244 static void mark_kboards P_ ((void)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
245 static void gc_sweep P_ ((void)); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
246 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
|
247 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
|
248 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
249 #ifdef HAVE_WINDOW_SYSTEM |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
250 static void mark_image P_ ((struct image *)); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
251 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
|
252 #endif /* HAVE_WINDOW_SYSTEM */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
253 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
254 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
|
255 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
|
256 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
|
257 static void sweep_strings P_ ((void)); |
20495 | 258 |
259 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
|
260 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
261 /* 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
|
262 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
|
263 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
|
264 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
265 enum mem_type |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
266 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
267 MEM_TYPE_NON_LISP, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
268 MEM_TYPE_BUFFER, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
269 MEM_TYPE_CONS, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
270 MEM_TYPE_STRING, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
271 MEM_TYPE_MISC, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
272 MEM_TYPE_SYMBOL, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
273 MEM_TYPE_FLOAT, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
274 MEM_TYPE_VECTOR |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
275 }; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
276 |
27746
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
277 #if GC_MARK_STACK |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
278 |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
279 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
280 #include <stdio.h> /* For fprintf. */ |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
281 #endif |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
282 |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
283 /* 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
|
284 on free lists recognizable in O(1). */ |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
285 |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
286 Lisp_Object Vdead; |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
287 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
288 struct mem_node; |
30914
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
289 static POINTER_TYPE *lisp_malloc P_ ((size_t, enum mem_type)); |
30784
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
290 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
|
291 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
|
292 static void init_stack P_ ((Lisp_Object *)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
293 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
|
294 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
|
295 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
|
296 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
|
297 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
|
298 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
|
299 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
|
300 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
|
301 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
|
302 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
|
303 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
|
304 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
|
305 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
|
306 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
|
307 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
|
308 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
|
309 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
|
310 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
311 #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
|
312 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
|
313 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
314 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
315 #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
|
316 |
300 | 317 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
318 /************************************************************************ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
319 Malloc |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
320 ************************************************************************/ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
321 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
322 /* Write STR to Vstandard_output plus some advice on how to free some |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
323 memory. Called when memory gets low. */ |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
324 |
300 | 325 Lisp_Object |
326 malloc_warning_1 (str) | |
327 Lisp_Object str; | |
328 { | |
329 Fprinc (str, Vstandard_output); | |
330 write_string ("\nKilling some buffers may delay running out of memory.\n", -1); | |
331 write_string ("However, certainly by the time you receive the 95% warning,\n", -1); | |
332 write_string ("you should clean up, kill this Emacs, and start a new one.", -1); | |
333 return Qnil; | |
334 } | |
335 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
336 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
337 /* Function malloc calls this if it finds we are near exhausting |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
338 storage. */ |
20375
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
339 |
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
340 void |
300 | 341 malloc_warning (str) |
342 char *str; | |
343 { | |
344 pending_malloc_warning = str; | |
345 } | |
346 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
347 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
348 /* Display a malloc warning in buffer *Danger*. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
349 |
20375
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
350 void |
300 | 351 display_malloc_warning () |
352 { | |
353 register Lisp_Object val; | |
354 | |
355 val = build_string (pending_malloc_warning); | |
356 pending_malloc_warning = 0; | |
357 internal_with_output_to_temp_buffer (" *Danger*", malloc_warning_1, val); | |
358 } | |
359 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
360 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
361 #ifdef DOUG_LEA_MALLOC |
17831
9238a2254a23
(BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents:
17348
diff
changeset
|
362 # 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
|
363 #else |
17831
9238a2254a23
(BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents:
17348
diff
changeset
|
364 # 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
|
365 #endif |
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
366 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
367 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
368 /* 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
|
369 |
20375
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
370 void |
300 | 371 memory_full () |
372 { | |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
373 #ifndef SYSTEM_MALLOC |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
374 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
|
375 #endif |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
376 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
377 /* 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
|
378 if (spare_memory) |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
379 { |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
380 free (spare_memory); |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
381 spare_memory = 0; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
382 } |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
383 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
384 /* 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
|
385 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
|
386 while (1) |
18621
53b95f307c75
(memory_full): Pass Qnil to Fsignal for ERROR_SYMBOL.
Richard M. Stallman <rms@gnu.org>
parents:
18104
diff
changeset
|
387 Fsignal (Qnil, memory_signal_data); |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
388 } |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
389 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
390 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
391 /* 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
|
392 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
393 void |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
394 buffer_memory_full () |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
395 { |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
396 /* 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
|
397 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
|
398 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
|
399 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
|
400 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
|
401 malloc. */ |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
402 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
403 #ifndef REL_ALLOC |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
404 memory_full (); |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
405 #endif |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
406 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
407 /* 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
|
408 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
|
409 while (1) |
64417bbbb128
(memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents:
5874
diff
changeset
|
410 Fsignal (Qerror, memory_signal_data); |
300 | 411 } |
412 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
413 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
414 /* Like malloc but check for no memory and block interrupt input.. */ |
300 | 415 |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
416 POINTER_TYPE * |
300 | 417 xmalloc (size) |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
418 size_t size; |
300 | 419 { |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
420 register POINTER_TYPE *val; |
300 | 421 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
422 BLOCK_INPUT; |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
423 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
|
424 UNBLOCK_INPUT; |
300 | 425 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
426 if (!val && size) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
427 memory_full (); |
300 | 428 return val; |
429 } | |
430 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
431 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
432 /* 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
|
433 |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
434 POINTER_TYPE * |
300 | 435 xrealloc (block, size) |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
436 POINTER_TYPE *block; |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
437 size_t size; |
300 | 438 { |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
439 register POINTER_TYPE *val; |
300 | 440 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
441 BLOCK_INPUT; |
590 | 442 /* We must call malloc explicitly when BLOCK is 0, since some |
443 reallocs don't do this. */ | |
444 if (! block) | |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
445 val = (POINTER_TYPE *) malloc (size); |
600
a8d78999e46d
*** empty log message ***
Noah Friedman <friedman@splode.com>
parents:
590
diff
changeset
|
446 else |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
447 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
|
448 UNBLOCK_INPUT; |
300 | 449 |
450 if (!val && size) memory_full (); | |
451 return val; | |
452 } | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
453 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
454 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
455 /* Like free but block interrupt input.. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
456 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
457 void |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
458 xfree (block) |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
459 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
|
460 { |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
461 BLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
462 free (block); |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
463 UNBLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
464 } |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
465 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
466 |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
467 /* Like strdup, but uses xmalloc. */ |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
468 |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
469 char * |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
470 xstrdup (s) |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
471 char *s; |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
472 { |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
473 size_t len = strlen (s) + 1; |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
474 char *p = (char *) xmalloc (len); |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
475 bcopy (s, p, len); |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
476 return p; |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
477 } |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
478 |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
479 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
480 /* 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
|
481 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
|
482 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
|
483 |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
484 static POINTER_TYPE * |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
485 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
|
486 size_t nbytes; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
487 enum mem_type type; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
488 { |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
489 register void *val; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
490 |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
491 BLOCK_INPUT; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
492 val = (void *) malloc (nbytes); |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
493 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
494 #if GC_MARK_STACK |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
495 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
|
496 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
|
497 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
498 |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
499 UNBLOCK_INPUT; |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
500 if (!val && nbytes) |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
501 memory_full (); |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
502 return val; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
503 } |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
504 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
505 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
506 /* Return a new buffer structure allocated from the heap with |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
507 a call to lisp_malloc. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
508 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
509 struct buffer * |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
510 allocate_buffer () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
511 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
512 return (struct buffer *) lisp_malloc (sizeof (struct buffer), |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
513 MEM_TYPE_BUFFER); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
514 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
515 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
516 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
517 /* 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
|
518 call to lisp_malloc. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
519 |
30784
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
520 static void |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
521 lisp_free (block) |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
522 POINTER_TYPE *block; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
523 { |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
524 BLOCK_INPUT; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
525 free (block); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
526 #if GC_MARK_STACK |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
527 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
|
528 #endif |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
529 UNBLOCK_INPUT; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
530 } |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
531 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
532 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
533 /* 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
|
534 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
535 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
|
536 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
|
537 elsewhere in the code should be inside a BLOCK_INPUT/UNBLOCK_INPUT |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
538 pairs; unfortunately, we have no idea what C library functions |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
539 might call malloc, so we can't really protect them unless you're |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
540 using GNU malloc. Fortunately, most of the major operating can use |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
541 GNU malloc. */ |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
542 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
543 #ifndef SYSTEM_MALLOC |
30914
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
544 #ifndef DOUG_LEA_MALLOC |
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
545 extern void * (*__malloc_hook) P_ ((size_t)); |
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
546 extern void * (*__realloc_hook) P_ ((void *, size_t)); |
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
547 extern void (*__free_hook) P_ ((void *)); |
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
548 /* 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
|
549 #endif /* DOUG_LEA_MALLOC */ |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
550 static void * (*old_malloc_hook) (); |
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
551 static void * (*old_realloc_hook) (); |
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
552 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
|
553 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
554 /* 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
|
555 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
556 static void |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
557 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
|
558 void *ptr; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
559 { |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
560 BLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
561 __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
|
562 free (ptr); |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
563 /* 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
|
564 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
|
565 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
|
566 if (spare_memory == 0 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
567 /* 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
|
568 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
|
569 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
|
570 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
|
571 && (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
|
572 > 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
|
573 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
|
574 |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
575 __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
|
576 UNBLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
577 } |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
578 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
579 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
580 /* 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
|
581 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
|
582 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
|
583 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
584 This is called when a relocatable block is freed in ralloc.c. */ |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
585 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
586 void |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
587 refill_memory_reserve () |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
588 { |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
589 if (spare_memory == 0) |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
590 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
|
591 } |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
592 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
593 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
594 /* 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
|
595 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
596 static void * |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
597 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
|
598 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
|
599 { |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
600 void *value; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
601 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
602 BLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
603 __malloc_hook = old_malloc_hook; |
17831
9238a2254a23
(BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents:
17348
diff
changeset
|
604 #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
|
605 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
|
606 #else |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
607 __malloc_extra_blocks = malloc_hysteresis; |
17831
9238a2254a23
(BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents:
17348
diff
changeset
|
608 #endif |
3581
152fd924c7bb
* alloc.c (emacs_blocked_malloc, emacs_blocked_realloc): Cast the
Jim Blandy <jimb@redhat.com>
parents:
3536
diff
changeset
|
609 value = (void *) malloc (size); |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
610 __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
|
611 UNBLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
612 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
613 return value; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
614 } |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
615 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
616 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
617 /* 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
|
618 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
619 static void * |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
620 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
|
621 void *ptr; |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
622 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
|
623 { |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
624 void *value; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
625 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
626 BLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
627 __realloc_hook = old_realloc_hook; |
3581
152fd924c7bb
* alloc.c (emacs_blocked_malloc, emacs_blocked_realloc): Cast the
Jim Blandy <jimb@redhat.com>
parents:
3536
diff
changeset
|
628 value = (void *) realloc (ptr, size); |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
629 __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
|
630 UNBLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
631 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
632 return value; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
633 } |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
634 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
635 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
636 /* 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
|
637 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
638 void |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
639 uninterrupt_malloc () |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
640 { |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
641 if (__free_hook != emacs_blocked_free) |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
642 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
|
643 __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
|
644 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
645 if (__malloc_hook != emacs_blocked_malloc) |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
646 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
|
647 __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
|
648 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
649 if (__realloc_hook != emacs_blocked_realloc) |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
650 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
|
651 __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
|
652 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
653 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
654 #endif /* not SYSTEM_MALLOC */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
655 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
656 |
300 | 657 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
658 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
659 Interval Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
660 ***********************************************************************/ |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
661 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
662 /* 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
|
663 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
|
664 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
665 #define INTERVAL_BLOCK_SIZE \ |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
666 ((1020 - sizeof (struct interval_block *)) / sizeof (struct interval)) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
667 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
668 /* 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
|
669 structure. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
670 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
671 struct interval_block |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
672 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
673 struct interval_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
674 struct interval intervals[INTERVAL_BLOCK_SIZE]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
675 }; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
676 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
677 /* 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
|
678 blocks. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
679 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
680 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
|
681 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
682 /* 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
|
683 structure. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
684 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
685 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
|
686 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
687 /* 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
|
688 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
689 static int total_free_intervals, total_intervals; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
690 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
691 /* List of free intervals. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
692 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
693 INTERVAL interval_free_list; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
694 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
695 /* 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
|
696 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
697 int n_interval_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
698 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
699 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
700 /* Initialize interval allocation. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
701 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
702 static void |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
703 init_intervals () |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
704 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
705 interval_block |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
706 = (struct interval_block *) lisp_malloc (sizeof *interval_block, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
707 MEM_TYPE_NON_LISP); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
708 interval_block->next = 0; |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
709 bzero ((char *) interval_block->intervals, sizeof interval_block->intervals); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
710 interval_block_index = 0; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
711 interval_free_list = 0; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
712 n_interval_blocks = 1; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
713 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
714 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
715 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
716 /* Return a new interval. */ |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
717 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
718 INTERVAL |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
719 make_interval () |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
720 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
721 INTERVAL val; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
722 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
723 if (interval_free_list) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
724 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
725 val = interval_free_list; |
28269
fd13be8ae190
Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents:
28220
diff
changeset
|
726 interval_free_list = INTERVAL_PARENT (interval_free_list); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
727 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
728 else |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
729 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
730 if (interval_block_index == INTERVAL_BLOCK_SIZE) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
731 { |
12529 | 732 register struct interval_block *newi; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
733 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
734 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
|
735 MEM_TYPE_NON_LISP); |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
736 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
737 VALIDATE_LISP_STORAGE (newi, sizeof *newi); |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
738 newi->next = interval_block; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
739 interval_block = newi; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
740 interval_block_index = 0; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
741 n_interval_blocks++; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
742 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
743 val = &interval_block->intervals[interval_block_index++]; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
744 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
745 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
|
746 intervals_consed++; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
747 RESET_INTERVAL (val); |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
748 return val; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
749 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
750 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
751 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
752 /* Mark Lisp objects in interval I. */ |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
753 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
754 static void |
1957
54c8c66cd9ac
(mark_interval): Add ignored arg.
Richard M. Stallman <rms@gnu.org>
parents:
1939
diff
changeset
|
755 mark_interval (i, dummy) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
756 register INTERVAL i; |
1957
54c8c66cd9ac
(mark_interval): Add ignored arg.
Richard M. Stallman <rms@gnu.org>
parents:
1939
diff
changeset
|
757 Lisp_Object dummy; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
758 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
759 if (XMARKBIT (i->plist)) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
760 abort (); |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
761 mark_object (&i->plist); |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
762 XMARK (i->plist); |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
763 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
764 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
765 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
766 /* 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
|
767 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
|
768 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
769 static void |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
770 mark_interval_tree (tree) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
771 register INTERVAL tree; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
772 { |
4139
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
773 /* 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
|
774 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
|
775 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
|
776 |
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
777 /* XMARK expands to an assignment; the LHS of an assignment can't be |
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
778 a cast. */ |
28406
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
779 XMARK (tree->up.obj); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
780 |
1957
54c8c66cd9ac
(mark_interval): Add ignored arg.
Richard M. Stallman <rms@gnu.org>
parents:
1939
diff
changeset
|
781 traverse_intervals (tree, 1, 0, mark_interval, Qnil); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
782 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
783 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
784 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
785 /* 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
|
786 |
4139
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
787 #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
|
788 do { \ |
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
789 if (!NULL_INTERVAL_P (i) \ |
28406
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
790 && ! XMARKBIT (i->up.obj)) \ |
4139
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
791 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
|
792 } while (0) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
793 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
794 |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
795 /* The oddity in the call to XUNMARK is necessary because XUNMARK |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
796 expands to an assignment to its argument, and most C compilers |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
797 don't support casts on the left operand of `='. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
798 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
799 #define UNMARK_BALANCE_INTERVALS(i) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
800 do { \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
801 if (! NULL_INTERVAL_P (i)) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
802 { \ |
28406
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
803 XUNMARK ((i)->up.obj); \ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
804 (i) = balance_intervals (i); \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
805 } \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
806 } while (0) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
807 |
28469
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
808 |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
809 /* 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
|
810 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
|
811 #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
|
812 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
|
813 make_number (n) |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
814 int n; |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
815 { |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
816 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
|
817 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
|
818 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
|
819 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
|
820 } |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
821 #endif |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
822 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
823 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
824 String Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
825 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
826 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
827 /* 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
|
828 string_block is allocated, all the Lisp_Strings it contains are |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
829 added to a free-list stiing_free_list. When a new Lisp_String is |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
830 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
|
831 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
|
832 we keep. |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
833 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
834 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
|
835 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
|
836 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
|
837 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
838 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
|
839 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
|
840 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
|
841 its sdata structure. |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
842 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
843 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
|
844 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
|
845 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
|
846 `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
|
847 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
|
848 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
|
849 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
850 /* 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
|
851 is 8192 minus malloc overhead. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
852 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
853 #define SBLOCK_SIZE 8188 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
854 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
855 /* 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
|
856 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
|
857 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
858 #define LARGE_STRING_BYTES 1024 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
859 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
860 /* 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
|
861 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
|
862 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
863 struct sdata |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
864 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
865 /* 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
|
866 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
|
867 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
|
868 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
|
869 (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
|
870 contents. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
871 struct Lisp_String *string; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
872 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
873 union |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
874 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
875 /* When STRING in non-null. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
876 unsigned char data[1]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
877 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
878 /* When STRING is null. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
879 EMACS_INT nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
880 } u; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
881 }; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
882 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
883 /* 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
|
884 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
|
885 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
|
886 as large as needed. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
887 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
888 struct sblock |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
889 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
890 /* Next in list. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
891 struct sblock *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
892 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
893 /* 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
|
894 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
|
895 struct sdata *next_free; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
896 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
897 /* Start of data. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
898 struct sdata first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
899 }; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
900 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
901 /* 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
|
902 1024 minus malloc overhead. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
903 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
904 #define STRINGS_IN_STRING_BLOCK \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
905 ((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
|
906 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
907 /* 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
|
908 are allocated. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
909 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
910 struct string_block |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
911 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
912 struct string_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
913 struct Lisp_String strings[STRINGS_IN_STRING_BLOCK]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
914 }; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
915 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
916 /* 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
|
917 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
|
918 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
|
919 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
920 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
|
921 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
922 /* List of sblocks for large strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
923 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
924 static struct sblock *large_sblocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
925 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
926 /* 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
|
927 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
928 static struct string_block *string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
929 static int n_string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
930 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
931 /* Free-list of Lisp_Strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
932 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
933 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
|
934 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
935 /* 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
|
936 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
937 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
|
938 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
939 /* 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
|
940 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
941 static int total_string_size; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
942 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
943 /* 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
|
944 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
|
945 free-list. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
946 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
947 #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
|
948 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
949 /* 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
|
950 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
|
951 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
|
952 structure starts at a constant offset in front of that. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
953 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
954 #define SDATA_OF_STRING(S) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
955 ((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
|
956 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
957 /* 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
|
958 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
|
959 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
|
960 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
961 #define SDATA_SIZE(NBYTES) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
962 ((sizeof (struct Lisp_String *) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
963 + (NBYTES) + 1 \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
964 + sizeof (EMACS_INT) - 1) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
965 & ~(sizeof (EMACS_INT) - 1)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
966 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
967 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
968 /* 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
|
969 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
970 void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
971 init_strings () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
972 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
973 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
|
974 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
|
975 string_blocks = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
976 n_string_blocks = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
977 string_free_list = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
978 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
979 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
980 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
981 /* Return a new Lisp_String. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
982 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
983 static struct Lisp_String * |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
984 allocate_string () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
985 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
986 struct Lisp_String *s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
987 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
988 /* 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
|
989 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
|
990 if (string_free_list == NULL) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
991 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
992 struct string_block *b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
993 int i; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
994 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
995 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
|
996 VALIDATE_LISP_STORAGE (b, sizeof *b); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
997 bzero (b, sizeof *b); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
998 b->next = string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
999 string_blocks = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1000 ++n_string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1001 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1002 for (i = STRINGS_IN_STRING_BLOCK - 1; i >= 0; --i) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1003 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1004 s = b->strings + i; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1005 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
|
1006 string_free_list = s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1007 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1008 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1009 total_free_strings += STRINGS_IN_STRING_BLOCK; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1010 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1011 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1012 /* 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
|
1013 s = string_free_list; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1014 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
|
1015 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1016 /* 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
|
1017 bzero (s, sizeof *s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1018 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1019 --total_free_strings; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1020 ++total_strings; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1021 ++strings_consed; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1022 consing_since_gc += sizeof *s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1023 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1024 return s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1025 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1026 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1027 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1028 /* 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
|
1029 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
|
1030 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
|
1031 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
|
1032 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
|
1033 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1034 void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1035 allocate_string_data (s, nchars, nbytes) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1036 struct Lisp_String *s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1037 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1038 { |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1039 struct sdata *data, *old_data; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1040 struct sblock *b; |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1041 int needed, old_nbytes; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1042 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1043 /* 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
|
1044 of string data. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1045 needed = SDATA_SIZE (nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1046 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1047 if (nbytes > LARGE_STRING_BYTES) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1048 { |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
1049 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
|
1050 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1051 #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
|
1052 /* 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
|
1053 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
|
1054 a dumped Emacs. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1055 mallopt (M_MMAP_MAX, 0); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1056 #endif |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1057 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1058 b = (struct sblock *) lisp_malloc (size, MEM_TYPE_NON_LISP); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1059 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1060 #ifdef DOUG_LEA_MALLOC |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1061 /* Back to a reasonable maximum of mmap'ed areas. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1062 mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1063 #endif |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1064 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1065 b->next_free = &b->first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1066 b->first_data.string = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1067 b->next = large_sblocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1068 large_sblocks = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1069 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1070 else if (current_sblock == NULL |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1071 || (((char *) current_sblock + SBLOCK_SIZE |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1072 - (char *) current_sblock->next_free) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1073 < needed)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1074 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1075 /* 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
|
1076 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
|
1077 b->next_free = &b->first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1078 b->first_data.string = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1079 b->next = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1080 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1081 if (current_sblock) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1082 current_sblock->next = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1083 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1084 oldest_sblock = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1085 current_sblock = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1086 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1087 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1088 b = current_sblock; |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1089 |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1090 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
|
1091 old_nbytes = GC_STRING_BYTES (s); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1092 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1093 data = b->next_free; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1094 data->string = s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1095 s->data = data->u.data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1096 s->size = nchars; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1097 s->size_byte = nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1098 s->data[nbytes] = '\0'; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1099 b->next_free = (struct sdata *) ((char *) data + needed); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1100 |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1101 /* 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
|
1102 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
|
1103 in it. */ |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1104 if (old_data) |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1105 { |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1106 old_data->u.nbytes = old_nbytes; |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1107 old_data->string = NULL; |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1108 } |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1109 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1110 consing_since_gc += needed; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1111 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1112 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1113 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1114 /* Sweep and compact strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1115 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1116 static void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1117 sweep_strings () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1118 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1119 struct string_block *b, *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1120 struct string_block *live_blocks = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1121 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1122 string_free_list = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1123 total_strings = total_free_strings = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1124 total_string_size = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1125 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1126 /* 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
|
1127 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
|
1128 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1129 int i, nfree = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1130 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
|
1131 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1132 next = b->next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1133 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1134 for (i = 0; i < STRINGS_IN_STRING_BLOCK; ++i) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1135 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1136 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
|
1137 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1138 if (s->data) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1139 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1140 /* 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
|
1141 if (STRING_MARKED_P (s)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1142 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1143 /* 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
|
1144 UNMARK_STRING (s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1145 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1146 if (!NULL_INTERVAL_P (s->intervals)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1147 UNMARK_BALANCE_INTERVALS (s->intervals); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1148 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1149 ++total_strings; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1150 total_string_size += STRING_BYTES (s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1151 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1152 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1153 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1154 /* 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
|
1155 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
|
1156 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1157 /* 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
|
1158 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
|
1159 back-pointer so that we know it's free. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1160 data->u.nbytes = GC_STRING_BYTES (s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1161 data->string = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1162 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1163 /* 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
|
1164 know it's free. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1165 s->data = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1166 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1167 /* 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
|
1168 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
|
1169 string_free_list = s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1170 ++nfree; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1171 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1172 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1173 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1174 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1175 /* 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
|
1176 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
|
1177 string_free_list = s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1178 ++nfree; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1179 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1180 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1181 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1182 /* 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
|
1183 the first two of them. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1184 if (nfree == STRINGS_IN_STRING_BLOCK |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1185 && total_free_strings > STRINGS_IN_STRING_BLOCK) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1186 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1187 lisp_free (b); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1188 --n_string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1189 string_free_list = free_list_before; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1190 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1191 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1192 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1193 total_free_strings += nfree; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1194 b->next = live_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1195 live_blocks = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1196 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1197 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1198 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1199 string_blocks = live_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1200 free_large_strings (); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1201 compact_small_strings (); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1202 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1203 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1204 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1205 /* Free dead large strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1206 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1207 static void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1208 free_large_strings () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1209 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1210 struct sblock *b, *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1211 struct sblock *live_blocks = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1212 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1213 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
|
1214 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1215 next = b->next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1216 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1217 if (b->first_data.string == NULL) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1218 lisp_free (b); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1219 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1220 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1221 b->next = live_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1222 live_blocks = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1223 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1224 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1225 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1226 large_sblocks = live_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1227 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1228 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1229 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1230 /* 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
|
1231 data of live strings after compaction. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1232 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1233 static void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1234 compact_small_strings () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1235 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1236 struct sblock *b, *tb, *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1237 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
|
1238 struct sdata *to_end, *from_end; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1239 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1240 /* 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
|
1241 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
|
1242 tb = oldest_sblock; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1243 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
|
1244 to = &tb->first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1245 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1246 /* 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
|
1247 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
|
1248 copying will happen this way. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1249 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
|
1250 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1251 end = b->next_free; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1252 xassert ((char *) end <= (char *) b + SBLOCK_SIZE); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1253 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1254 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
|
1255 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1256 /* 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
|
1257 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
|
1258 int nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1259 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1260 if (from->string) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1261 nbytes = GC_STRING_BYTES (from->string); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1262 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1263 nbytes = from->u.nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1264 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1265 nbytes = SDATA_SIZE (nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1266 from_end = (struct sdata *) ((char *) from + nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1267 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1268 /* 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
|
1269 if (from->string) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1270 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1271 /* If TB is full, proceed with the next sblock. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1272 to_end = (struct sdata *) ((char *) to + nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1273 if (to_end > tb_end) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1274 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1275 tb->next_free = to; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1276 tb = tb->next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1277 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
|
1278 to = &tb->first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1279 to_end = (struct sdata *) ((char *) to + nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1280 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1281 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1282 /* 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
|
1283 if (from != to) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1284 { |
30823
8ee3740aaf60
(compact_small_strings): Use safe_bcopy, add an
Gerd Moellmann <gerd@gnu.org>
parents:
30784
diff
changeset
|
1285 xassert (tb != b || to <= from); |
8ee3740aaf60
(compact_small_strings): Use safe_bcopy, add an
Gerd Moellmann <gerd@gnu.org>
parents:
30784
diff
changeset
|
1286 safe_bcopy ((char *) from, (char *) to, nbytes); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1287 to->string->data = to->u.data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1288 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1289 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1290 /* 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
|
1291 to = to_end; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1292 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1293 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1294 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1295 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1296 /* 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
|
1297 we can free them. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1298 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
|
1299 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1300 next = b->next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1301 lisp_free (b); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1302 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1303 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1304 tb->next_free = to; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1305 tb->next = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1306 current_sblock = tb; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1307 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1308 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1309 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1310 DEFUN ("make-string", Fmake_string, Smake_string, 2, 2, 0, |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1311 "Return a newly created string of length LENGTH, with each element being INIT.\n\ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1312 Both LENGTH and INIT must be numbers.") |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1313 (length, init) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1314 Lisp_Object length, init; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1315 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1316 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1317 register unsigned char *p, *end; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1318 int c, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1319 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1320 CHECK_NATNUM (length, 0); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1321 CHECK_NUMBER (init, 1); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1322 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1323 c = XINT (init); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1324 if (SINGLE_BYTE_CHAR_P (c)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1325 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1326 nbytes = XINT (length); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1327 val = make_uninit_string (nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1328 p = XSTRING (val)->data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1329 end = p + XSTRING (val)->size; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1330 while (p != end) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1331 *p++ = c; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1332 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1333 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1334 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1335 unsigned char str[4]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1336 int len = CHAR_STRING (c, str); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1337 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1338 nbytes = len * XINT (length); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1339 val = make_uninit_multibyte_string (XINT (length), nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1340 p = XSTRING (val)->data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1341 end = p + nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1342 while (p != end) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1343 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1344 bcopy (str, p, len); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1345 p += len; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1346 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1347 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1348 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1349 *p = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1350 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1351 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1352 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1353 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1354 DEFUN ("make-bool-vector", Fmake_bool_vector, Smake_bool_vector, 2, 2, 0, |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1355 "Return a new bool-vector of length LENGTH, using INIT for as each element.\n\ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1356 LENGTH must be a number. INIT matters only in whether it is t or nil.") |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1357 (length, init) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1358 Lisp_Object length, init; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1359 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1360 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1361 struct Lisp_Bool_Vector *p; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1362 int real_init, i; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1363 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
|
1364 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1365 CHECK_NATNUM (length, 0); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1366 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1367 bits_per_value = sizeof (EMACS_INT) * BITS_PER_CHAR; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1368 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1369 length_in_elts = (XFASTINT (length) + bits_per_value - 1) / bits_per_value; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1370 length_in_chars = ((XFASTINT (length) + BITS_PER_CHAR - 1) / BITS_PER_CHAR); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1371 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1372 /* 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
|
1373 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
|
1374 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
|
1375 p = XBOOL_VECTOR (val); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1376 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1377 /* 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
|
1378 p->vector_size = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1379 XSETBOOL_VECTOR (val, p); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1380 p->size = XFASTINT (length); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1381 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1382 real_init = (NILP (init) ? 0 : -1); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1383 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
|
1384 p->data[i] = real_init; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1385 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1386 /* Clear the extraneous bits in the last byte. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1387 if (XINT (length) != length_in_chars * BITS_PER_CHAR) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1388 XBOOL_VECTOR (val)->data[length_in_chars - 1] |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1389 &= (1 << (XINT (length) % BITS_PER_CHAR)) - 1; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1390 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1391 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1392 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1393 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1394 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1395 /* 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
|
1396 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
|
1397 multibyte, depending on the contents. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1398 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1399 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1400 make_string (contents, nbytes) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1401 char *contents; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1402 int nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1403 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1404 register Lisp_Object val; |
28997
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
1405 int nchars, multibyte_nbytes; |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
1406 |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
1407 parse_str_as_multibyte (contents, nbytes, &nchars, &multibyte_nbytes); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1408 val = make_uninit_multibyte_string (nchars, nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1409 bcopy (contents, XSTRING (val)->data, nbytes); |
28997
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
1410 if (nbytes == nchars || nbytes != multibyte_nbytes) |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
1411 /* 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
|
1412 multibyte sequence. We must make unibyte string. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1413 SET_STRING_BYTES (XSTRING (val), -1); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1414 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1415 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1416 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1417 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1418 /* 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
|
1419 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1420 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1421 make_unibyte_string (contents, length) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1422 char *contents; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1423 int length; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1424 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1425 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1426 val = make_uninit_string (length); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1427 bcopy (contents, XSTRING (val)->data, length); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1428 SET_STRING_BYTES (XSTRING (val), -1); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1429 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1430 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1431 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1432 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1433 /* 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
|
1434 bytes at CONTENTS. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1435 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1436 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1437 make_multibyte_string (contents, nchars, nbytes) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1438 char *contents; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1439 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1440 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1441 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1442 val = make_uninit_multibyte_string (nchars, nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1443 bcopy (contents, XSTRING (val)->data, nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1444 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1445 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1446 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1447 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1448 /* 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
|
1449 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
|
1450 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1451 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1452 make_string_from_bytes (contents, nchars, nbytes) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1453 char *contents; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1454 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1455 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1456 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1457 val = make_uninit_multibyte_string (nchars, nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1458 bcopy (contents, XSTRING (val)->data, nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1459 if (STRING_BYTES (XSTRING (val)) == XSTRING (val)->size) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1460 SET_STRING_BYTES (XSTRING (val), -1); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1461 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1462 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1463 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1464 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1465 /* 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
|
1466 CONTENTS. The argument MULTIBYTE controls whether to label the |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1467 string as multibyte. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1468 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1469 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1470 make_specified_string (contents, nchars, nbytes, multibyte) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1471 char *contents; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1472 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1473 int multibyte; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1474 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1475 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1476 val = make_uninit_multibyte_string (nchars, nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1477 bcopy (contents, XSTRING (val)->data, nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1478 if (!multibyte) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1479 SET_STRING_BYTES (XSTRING (val), -1); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1480 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1481 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1482 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1483 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1484 /* 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
|
1485 data warrants. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1486 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1487 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1488 build_string (str) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1489 char *str; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1490 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1491 return make_string (str, strlen (str)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1492 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1493 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1494 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1495 /* 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
|
1496 occupying LENGTH bytes. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1497 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1498 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1499 make_uninit_string (length) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1500 int length; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1501 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1502 Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1503 val = make_uninit_multibyte_string (length, length); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1504 SET_STRING_BYTES (XSTRING (val), -1); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1505 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1506 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1507 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1508 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1509 /* 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
|
1510 which occupy NBYTES bytes. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1511 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1512 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1513 make_uninit_multibyte_string (nchars, nbytes) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1514 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1515 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1516 Lisp_Object string; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1517 struct Lisp_String *s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1518 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1519 if (nchars < 0) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1520 abort (); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1521 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1522 s = allocate_string (); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1523 allocate_string_data (s, nchars, nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1524 XSETSTRING (string, s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1525 string_chars_consed += nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1526 return string; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1527 } |
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 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1530 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1531 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1532 Float Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1533 ***********************************************************************/ |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
1534 |
300 | 1535 /* 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
|
1536 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
|
1537 by GC are put on a free list to be reallocated before allocating |
300 | 1538 any new float cells from the latest float_block. |
1539 | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1540 Each float_block is just under 1020 bytes long, since malloc really |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1541 allocates in units of powers of two and uses 4 bytes for its own |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1542 overhead. */ |
300 | 1543 |
1544 #define FLOAT_BLOCK_SIZE \ | |
1545 ((1020 - sizeof (struct float_block *)) / sizeof (struct Lisp_Float)) | |
1546 | |
1547 struct float_block | |
27142
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 struct float_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1550 struct Lisp_Float floats[FLOAT_BLOCK_SIZE]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1551 }; |
300 | 1552 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1553 /* Current float_block. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1554 |
300 | 1555 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
|
1556 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1557 /* 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
|
1558 |
300 | 1559 int float_block_index; |
1560 | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1561 /* 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
|
1562 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1563 int n_float_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1564 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1565 /* 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
|
1566 |
300 | 1567 struct Lisp_Float *float_free_list; |
1568 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1569 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1570 /* Initialze float allocation. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1571 |
300 | 1572 void |
1573 init_float () | |
1574 { | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1575 float_block = (struct float_block *) lisp_malloc (sizeof *float_block, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1576 MEM_TYPE_FLOAT); |
300 | 1577 float_block->next = 0; |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
1578 bzero ((char *) float_block->floats, sizeof float_block->floats); |
300 | 1579 float_block_index = 0; |
1580 float_free_list = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1581 n_float_blocks = 1; |
300 | 1582 } |
1583 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1584 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1585 /* 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
|
1586 |
21514 | 1587 void |
300 | 1588 free_float (ptr) |
1589 struct Lisp_Float *ptr; | |
1590 { | |
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
|
1591 *(struct Lisp_Float **)&ptr->data = float_free_list; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1592 #if GC_MARK_STACK |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1593 ptr->type = Vdead; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1594 #endif |
300 | 1595 float_free_list = ptr; |
1596 } | |
1597 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1598 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1599 /* 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
|
1600 |
300 | 1601 Lisp_Object |
1602 make_float (float_value) | |
1603 double float_value; | |
1604 { | |
1605 register Lisp_Object val; | |
1606 | |
1607 if (float_free_list) | |
1608 { | |
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
|
1609 /* 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
|
1610 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
|
1611 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
|
1612 float_free_list = *(struct Lisp_Float **)&float_free_list->data; |
300 | 1613 } |
1614 else | |
1615 { | |
1616 if (float_block_index == FLOAT_BLOCK_SIZE) | |
1617 { | |
12529 | 1618 register struct float_block *new; |
1619 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1620 new = (struct float_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
|
1621 MEM_TYPE_FLOAT); |
300 | 1622 VALIDATE_LISP_STORAGE (new, sizeof *new); |
1623 new->next = float_block; | |
1624 float_block = new; | |
1625 float_block_index = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1626 n_float_blocks++; |
300 | 1627 } |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
1628 XSETFLOAT (val, &float_block->floats[float_block_index++]); |
300 | 1629 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1630 |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
1631 XFLOAT_DATA (val) = float_value; |
9295
17d393a8eed6
(free_float, make_float, free_cons, Flist, Fvector, Fmake_byte_code,
Karl Heuer <kwzh@gnu.org>
parents:
9261
diff
changeset
|
1632 XSETFASTINT (XFLOAT (val)->type, 0); /* bug chasing -wsr */ |
300 | 1633 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
|
1634 floats_consed++; |
300 | 1635 return val; |
1636 } | |
1637 | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1638 |
300 | 1639 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1640 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1641 Cons Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1642 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1643 |
300 | 1644 /* We store cons cells inside of cons_blocks, allocating a new |
1645 cons_block with malloc whenever necessary. Cons cells reclaimed by | |
1646 GC are put on a free list to be reallocated before allocating | |
1647 any new cons cells from the latest cons_block. | |
1648 | |
1649 Each cons_block is just under 1020 bytes long, | |
1650 since malloc really allocates in units of powers of two | |
1651 and uses 4 bytes for its own overhead. */ | |
1652 | |
1653 #define CONS_BLOCK_SIZE \ | |
1654 ((1020 - sizeof (struct cons_block *)) / sizeof (struct Lisp_Cons)) | |
1655 | |
1656 struct cons_block | |
27142
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 struct cons_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1659 struct Lisp_Cons conses[CONS_BLOCK_SIZE]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1660 }; |
300 | 1661 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1662 /* Current cons_block. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1663 |
300 | 1664 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
|
1665 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1666 /* 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
|
1667 |
300 | 1668 int cons_block_index; |
1669 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1670 /* 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
|
1671 |
300 | 1672 struct Lisp_Cons *cons_free_list; |
1673 | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1674 /* 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
|
1675 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1676 int n_cons_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1677 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1678 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1679 /* Initialize cons allocation. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1680 |
300 | 1681 void |
1682 init_cons () | |
1683 { | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1684 cons_block = (struct cons_block *) lisp_malloc (sizeof *cons_block, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1685 MEM_TYPE_CONS); |
300 | 1686 cons_block->next = 0; |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
1687 bzero ((char *) cons_block->conses, sizeof cons_block->conses); |
300 | 1688 cons_block_index = 0; |
1689 cons_free_list = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1690 n_cons_blocks = 1; |
300 | 1691 } |
1692 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1693 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1694 /* 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
|
1695 |
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
1696 void |
300 | 1697 free_cons (ptr) |
1698 struct Lisp_Cons *ptr; | |
1699 { | |
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
|
1700 *(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
|
1701 #if GC_MARK_STACK |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1702 ptr->car = Vdead; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1703 #endif |
300 | 1704 cons_free_list = ptr; |
1705 } | |
1706 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1707 |
300 | 1708 DEFUN ("cons", Fcons, Scons, 2, 2, 0, |
1709 "Create a new cons, give it CAR and CDR as components, and return it.") | |
1710 (car, cdr) | |
1711 Lisp_Object car, cdr; | |
1712 { | |
1713 register Lisp_Object val; | |
1714 | |
1715 if (cons_free_list) | |
1716 { | |
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
|
1717 /* 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
|
1718 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
|
1719 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
|
1720 cons_free_list = *(struct Lisp_Cons **)&cons_free_list->cdr; |
300 | 1721 } |
1722 else | |
1723 { | |
1724 if (cons_block_index == CONS_BLOCK_SIZE) | |
1725 { | |
12529 | 1726 register struct cons_block *new; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1727 new = (struct cons_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
|
1728 MEM_TYPE_CONS); |
300 | 1729 VALIDATE_LISP_STORAGE (new, sizeof *new); |
1730 new->next = cons_block; | |
1731 cons_block = new; | |
1732 cons_block_index = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1733 n_cons_blocks++; |
300 | 1734 } |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
1735 XSETCONS (val, &cons_block->conses[cons_block_index++]); |
300 | 1736 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1737 |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
1738 XCAR (val) = car; |
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
1739 XCDR (val) = cdr; |
300 | 1740 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
|
1741 cons_cells_consed++; |
300 | 1742 return val; |
1743 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1744 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1745 |
20849
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1746 /* 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
|
1747 |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1748 Lisp_Object |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1749 list2 (arg1, arg2) |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1750 Lisp_Object arg1, arg2; |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1751 { |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1752 return Fcons (arg1, Fcons (arg2, Qnil)); |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1753 } |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1754 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1755 |
20849
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1756 Lisp_Object |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1757 list3 (arg1, arg2, arg3) |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1758 Lisp_Object arg1, arg2, arg3; |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1759 { |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1760 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
|
1761 } |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1762 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1763 |
20849
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1764 Lisp_Object |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1765 list4 (arg1, arg2, arg3, arg4) |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1766 Lisp_Object arg1, arg2, arg3, arg4; |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1767 { |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1768 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
|
1769 } |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1770 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1771 |
20849
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1772 Lisp_Object |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1773 list5 (arg1, arg2, arg3, arg4, arg5) |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1774 Lisp_Object arg1, arg2, arg3, arg4, arg5; |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1775 { |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1776 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
|
1777 Fcons (arg5, Qnil))))); |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
1778 } |
300 | 1779 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1780 |
300 | 1781 DEFUN ("list", Flist, Slist, 0, MANY, 0, |
1782 "Return a newly created list with specified arguments as elements.\n\ | |
1783 Any number of arguments, even zero arguments, are allowed.") | |
1784 (nargs, args) | |
1785 int nargs; | |
1786 register Lisp_Object *args; | |
1787 { | |
13610
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
1788 register Lisp_Object val; |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
1789 val = Qnil; |
300 | 1790 |
13610
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
1791 while (nargs > 0) |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
1792 { |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
1793 nargs--; |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
1794 val = Fcons (args[nargs], val); |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
1795 } |
300 | 1796 return val; |
1797 } | |
1798 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1799 |
300 | 1800 DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0, |
1801 "Return a newly created list of length LENGTH, with each element being INIT.") | |
1802 (length, init) | |
1803 register Lisp_Object length, init; | |
1804 { | |
1805 register Lisp_Object val; | |
1806 register int size; | |
1807 | |
9953
e0672d4cf470
(Fmake_list, Fmake_vector, Fmake_string): Use CHECK_NATNUM instead of its
Karl Heuer <kwzh@gnu.org>
parents:
9942
diff
changeset
|
1808 CHECK_NATNUM (length, 0); |
e0672d4cf470
(Fmake_list, Fmake_vector, Fmake_string): Use CHECK_NATNUM instead of its
Karl Heuer <kwzh@gnu.org>
parents:
9942
diff
changeset
|
1809 size = XFASTINT (length); |
300 | 1810 |
1811 val = Qnil; | |
1812 while (size-- > 0) | |
1813 val = Fcons (init, val); | |
1814 return val; | |
1815 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1816 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1817 |
300 | 1818 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1819 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1820 Vector Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1821 ***********************************************************************/ |
300 | 1822 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1823 /* 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
|
1824 |
300 | 1825 struct Lisp_Vector *all_vectors; |
1826 | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1827 /* 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
|
1828 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1829 int n_vectors; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1830 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1831 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1832 /* 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
|
1833 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
|
1834 |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
1835 struct Lisp_Vector * |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
1836 allocate_vectorlike (len) |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
1837 EMACS_INT len; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
1838 { |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
1839 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
|
1840 size_t nbytes; |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
1841 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
1842 #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
|
1843 /* 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
|
1844 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
|
1845 a dumped Emacs. */ |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
1846 mallopt (M_MMAP_MAX, 0); |
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
1847 #endif |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1848 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1849 nbytes = sizeof *p + (len - 1) * sizeof p->contents[0]; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1850 p = (struct Lisp_Vector *) lisp_malloc (nbytes, MEM_TYPE_VECTOR); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1851 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
1852 #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
|
1853 /* Back to a reasonable maximum of mmap'ed areas. */ |
23973
2eb9e2f5aa33
(MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
23958
diff
changeset
|
1854 mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
1855 #endif |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1856 |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
1857 VALIDATE_LISP_STORAGE (p, 0); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1858 consing_since_gc += nbytes; |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
1859 vector_cells_consed += len; |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
1860 |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
1861 p->next = all_vectors; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
1862 all_vectors = p; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1863 ++n_vectors; |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
1864 return p; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
1865 } |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
1866 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1867 |
300 | 1868 DEFUN ("make-vector", Fmake_vector, Smake_vector, 2, 2, 0, |
1869 "Return a newly created vector of length LENGTH, with each element being INIT.\n\ | |
1870 See also the function `vector'.") | |
1871 (length, init) | |
1872 register Lisp_Object length, init; | |
1873 { | |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
1874 Lisp_Object vector; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
1875 register EMACS_INT sizei; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
1876 register int index; |
300 | 1877 register struct Lisp_Vector *p; |
1878 | |
9953
e0672d4cf470
(Fmake_list, Fmake_vector, Fmake_string): Use CHECK_NATNUM instead of its
Karl Heuer <kwzh@gnu.org>
parents:
9942
diff
changeset
|
1879 CHECK_NATNUM (length, 0); |
e0672d4cf470
(Fmake_list, Fmake_vector, Fmake_string): Use CHECK_NATNUM instead of its
Karl Heuer <kwzh@gnu.org>
parents:
9942
diff
changeset
|
1880 sizei = XFASTINT (length); |
300 | 1881 |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
1882 p = allocate_vectorlike (sizei); |
300 | 1883 p->size = sizei; |
1884 for (index = 0; index < sizei; index++) | |
1885 p->contents[index] = init; | |
1886 | |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
1887 XSETVECTOR (vector, p); |
300 | 1888 return vector; |
1889 } | |
1890 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1891 |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
1892 DEFUN ("make-char-table", Fmake_char_table, Smake_char_table, 1, 2, 0, |
13322
336cbb88a1e3
(Fmake_char_table): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
13320
diff
changeset
|
1893 "Return a newly created char-table, with purpose PURPOSE.\n\ |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
1894 Each element is initialized to INIT, which defaults to nil.\n\ |
16479
52eaaf1cc0e3
(Fmake_char_table): Doc fix.
Erik Naggum <erik@naggum.no>
parents:
16231
diff
changeset
|
1895 PURPOSE should be a symbol which has a `char-table-extra-slots' property.\n\ |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
1896 The property's value should be an integer between 0 and 10.") |
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
1897 (purpose, init) |
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
1898 register Lisp_Object purpose, init; |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
1899 { |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
1900 Lisp_Object vector; |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
1901 Lisp_Object n; |
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
1902 CHECK_SYMBOL (purpose, 1); |
17328
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
1903 n = Fget (purpose, Qchar_table_extra_slots); |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
1904 CHECK_NUMBER (n, 0); |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
1905 if (XINT (n) < 0 || XINT (n) > 10) |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
1906 args_out_of_range (n, Qnil); |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
1907 /* 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
|
1908 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
|
1909 init); |
17328
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
1910 XCHAR_TABLE (vector)->top = Qt; |
13150
3778c95adca9
(Fmake_char_table): Initialize parent to nil.
Erik Naggum <erik@naggum.no>
parents:
13141
diff
changeset
|
1911 XCHAR_TABLE (vector)->parent = Qnil; |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
1912 XCHAR_TABLE (vector)->purpose = purpose; |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
1913 XSETCHAR_TABLE (vector, XCHAR_TABLE (vector)); |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
1914 return vector; |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
1915 } |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
1916 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1917 |
17328
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
1918 /* 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
|
1919 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
|
1920 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
|
1921 |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
1922 Lisp_Object |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
1923 make_sub_char_table (defalt) |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
1924 Lisp_Object defalt; |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
1925 { |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
1926 Lisp_Object vector |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
1927 = 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
|
1928 XCHAR_TABLE (vector)->top = Qnil; |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
1929 XCHAR_TABLE (vector)->defalt = defalt; |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
1930 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
|
1931 return vector; |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
1932 } |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
1933 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1934 |
300 | 1935 DEFUN ("vector", Fvector, Svector, 0, MANY, 0, |
1936 "Return a newly created vector with specified arguments as elements.\n\ | |
1937 Any number of arguments, even zero arguments, are allowed.") | |
1938 (nargs, args) | |
1939 register int nargs; | |
1940 Lisp_Object *args; | |
1941 { | |
1942 register Lisp_Object len, val; | |
1943 register int index; | |
1944 register struct Lisp_Vector *p; | |
1945 | |
9295
17d393a8eed6
(free_float, make_float, free_cons, Flist, Fvector, Fmake_byte_code,
Karl Heuer <kwzh@gnu.org>
parents:
9261
diff
changeset
|
1946 XSETFASTINT (len, nargs); |
300 | 1947 val = Fmake_vector (len, Qnil); |
1948 p = XVECTOR (val); | |
1949 for (index = 0; index < nargs; index++) | |
1950 p->contents[index] = args[index]; | |
1951 return val; | |
1952 } | |
1953 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1954 |
300 | 1955 DEFUN ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0, |
1956 "Create a byte-code object with specified arguments as elements.\n\ | |
1957 The arguments should be the arglist, bytecode-string, constant vector,\n\ | |
1958 stack size, (optional) doc string, and (optional) interactive spec.\n\ | |
1959 The first four arguments are required; at most six have any\n\ | |
1960 significance.") | |
1961 (nargs, args) | |
1962 register int nargs; | |
1963 Lisp_Object *args; | |
1964 { | |
1965 register Lisp_Object len, val; | |
1966 register int index; | |
1967 register struct Lisp_Vector *p; | |
1968 | |
9295
17d393a8eed6
(free_float, make_float, free_cons, Flist, Fvector, Fmake_byte_code,
Karl Heuer <kwzh@gnu.org>
parents:
9261
diff
changeset
|
1969 XSETFASTINT (len, nargs); |
485 | 1970 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
|
1971 val = make_pure_vector ((EMACS_INT) nargs); |
300 | 1972 else |
1973 val = Fmake_vector (len, Qnil); | |
28997
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
1974 |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
1975 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
|
1976 /* 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
|
1977 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
|
1978 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
|
1979 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
|
1980 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
|
1981 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
|
1982 |
300 | 1983 p = XVECTOR (val); |
1984 for (index = 0; index < nargs; index++) | |
1985 { | |
485 | 1986 if (!NILP (Vpurify_flag)) |
300 | 1987 args[index] = Fpurecopy (args[index]); |
1988 p->contents[index] = args[index]; | |
1989 } | |
18104
b2a669ef69b1
(Fmake_byte_code): Set val from p, not from val.
Richard M. Stallman <rms@gnu.org>
parents:
18010
diff
changeset
|
1990 XSETCOMPILED (val, p); |
300 | 1991 return val; |
1992 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1993 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1994 |
300 | 1995 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1996 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1997 Symbol Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1998 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1999 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2000 /* 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
|
2001 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
|
2002 own overhead. */ |
300 | 2003 |
2004 #define SYMBOL_BLOCK_SIZE \ | |
2005 ((1020 - sizeof (struct symbol_block *)) / sizeof (struct Lisp_Symbol)) | |
2006 | |
2007 struct symbol_block | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2008 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2009 struct symbol_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2010 struct Lisp_Symbol symbols[SYMBOL_BLOCK_SIZE]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2011 }; |
300 | 2012 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2013 /* 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
|
2014 structure in it. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2015 |
300 | 2016 struct symbol_block *symbol_block; |
2017 int symbol_block_index; | |
2018 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2019 /* List of free symbols. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2020 |
300 | 2021 struct Lisp_Symbol *symbol_free_list; |
2022 | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2023 /* 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
|
2024 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2025 int n_symbol_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2026 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2027 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2028 /* Initialize symbol allocation. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2029 |
300 | 2030 void |
2031 init_symbol () | |
2032 { | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2033 symbol_block = (struct symbol_block *) lisp_malloc (sizeof *symbol_block, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2034 MEM_TYPE_SYMBOL); |
300 | 2035 symbol_block->next = 0; |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
2036 bzero ((char *) symbol_block->symbols, sizeof symbol_block->symbols); |
300 | 2037 symbol_block_index = 0; |
2038 symbol_free_list = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2039 n_symbol_blocks = 1; |
300 | 2040 } |
2041 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2042 |
300 | 2043 DEFUN ("make-symbol", Fmake_symbol, Smake_symbol, 1, 1, 0, |
2044 "Return a newly allocated uninterned symbol whose name is NAME.\n\ | |
2045 Its value and function definition are void, and its property list is nil.") | |
14093
338f645e6b9a
(Fmake_symbol): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2046 (name) |
338f645e6b9a
(Fmake_symbol): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2047 Lisp_Object name; |
300 | 2048 { |
2049 register Lisp_Object val; | |
2050 register struct Lisp_Symbol *p; | |
2051 | |
14093
338f645e6b9a
(Fmake_symbol): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2052 CHECK_STRING (name, 0); |
300 | 2053 |
2054 if (symbol_free_list) | |
2055 { | |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
2056 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
|
2057 symbol_free_list = *(struct Lisp_Symbol **)&symbol_free_list->value; |
300 | 2058 } |
2059 else | |
2060 { | |
2061 if (symbol_block_index == SYMBOL_BLOCK_SIZE) | |
2062 { | |
12529 | 2063 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
|
2064 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
|
2065 MEM_TYPE_SYMBOL); |
300 | 2066 VALIDATE_LISP_STORAGE (new, sizeof *new); |
2067 new->next = symbol_block; | |
2068 symbol_block = new; | |
2069 symbol_block_index = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2070 n_symbol_blocks++; |
300 | 2071 } |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
2072 XSETSYMBOL (val, &symbol_block->symbols[symbol_block_index++]); |
300 | 2073 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2074 |
300 | 2075 p = XSYMBOL (val); |
14095
d612434249db
(Fmake_symbol): Harmonize arguments with documentation (correctly).
Erik Naggum <erik@naggum.no>
parents:
14093
diff
changeset
|
2076 p->name = XSTRING (name); |
16223
bab3f12493b6
(Fmake_symbol): Initialize `obarray' field.
Erik Naggum <erik@naggum.no>
parents:
16101
diff
changeset
|
2077 p->obarray = Qnil; |
300 | 2078 p->plist = Qnil; |
2079 p->value = Qunbound; | |
2080 p->function = Qunbound; | |
2081 p->next = 0; | |
2082 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
|
2083 symbols_consed++; |
300 | 2084 return val; |
2085 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2086 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2087 |
300 | 2088 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2089 /*********************************************************************** |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2090 Marker (Misc) Allocation |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2091 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2092 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2093 /* Allocation of markers and other objects that share that structure. |
300 | 2094 Works like allocation of conses. */ |
2095 | |
2096 #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
|
2097 ((1020 - sizeof (struct marker_block *)) / sizeof (union Lisp_Misc)) |
300 | 2098 |
2099 struct marker_block | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2100 { |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2101 struct marker_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2102 union Lisp_Misc markers[MARKER_BLOCK_SIZE]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2103 }; |
300 | 2104 |
2105 struct marker_block *marker_block; | |
2106 int marker_block_index; | |
2107 | |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2108 union Lisp_Misc *marker_free_list; |
300 | 2109 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2110 /* 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
|
2111 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2112 int n_marker_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2113 |
300 | 2114 void |
2115 init_marker () | |
2116 { | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2117 marker_block = (struct marker_block *) lisp_malloc (sizeof *marker_block, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2118 MEM_TYPE_MISC); |
300 | 2119 marker_block->next = 0; |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
2120 bzero ((char *) marker_block->markers, sizeof marker_block->markers); |
300 | 2121 marker_block_index = 0; |
2122 marker_free_list = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2123 n_marker_blocks = 1; |
300 | 2124 } |
2125 | |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2126 /* 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
|
2127 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2128 Lisp_Object |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2129 allocate_misc () |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2130 { |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2131 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
|
2132 |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2133 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
|
2134 { |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2135 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
|
2136 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
|
2137 } |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2138 else |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2139 { |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2140 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
|
2141 { |
12529 | 2142 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
|
2143 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
|
2144 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
|
2145 VALIDATE_LISP_STORAGE (new, sizeof *new); |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2146 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
|
2147 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
|
2148 marker_block_index = 0; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2149 n_marker_blocks++; |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2150 } |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2151 XSETMISC (val, &marker_block->markers[marker_block_index++]); |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2152 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2153 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2154 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
|
2155 misc_objects_consed++; |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2156 return val; |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2157 } |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2158 |
300 | 2159 DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0, |
2160 "Return a newly allocated marker which does not point at any place.") | |
2161 () | |
2162 { | |
2163 register Lisp_Object val; | |
2164 register struct Lisp_Marker *p; | |
638 | 2165 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2166 val = allocate_misc (); |
11243
054ecfce1820
(Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents:
11048
diff
changeset
|
2167 XMISCTYPE (val) = Lisp_Misc_Marker; |
300 | 2168 p = XMARKER (val); |
2169 p->buffer = 0; | |
20565
aa9b7c5f0f62
(Fmake_marker): Initialize marker's bytepos and charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20495
diff
changeset
|
2170 p->bytepos = 0; |
aa9b7c5f0f62
(Fmake_marker): Initialize marker's bytepos and charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20495
diff
changeset
|
2171 p->charpos = 0; |
300 | 2172 p->chain = Qnil; |
13008
f042ef632b22
(Fmake_marker): Initialize insertion_type to 0.
Richard M. Stallman <rms@gnu.org>
parents:
12748
diff
changeset
|
2173 p->insertion_type = 0; |
300 | 2174 return val; |
2175 } | |
19332
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2176 |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2177 /* 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
|
2178 |
20375
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
2179 void |
19332
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2180 free_marker (marker) |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2181 Lisp_Object marker; |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2182 { |
19621
74151390752c
(free_marker): Call unchain_marker.
Richard M. Stallman <rms@gnu.org>
parents:
19332
diff
changeset
|
2183 unchain_marker (marker); |
74151390752c
(free_marker): Call unchain_marker.
Richard M. Stallman <rms@gnu.org>
parents:
19332
diff
changeset
|
2184 |
19332
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2185 XMISC (marker)->u_marker.type = Lisp_Misc_Free; |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2186 XMISC (marker)->u_free.chain = marker_free_list; |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2187 marker_free_list = XMISC (marker); |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2188 |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2189 total_free_markers++; |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2190 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2191 |
21258
693573ac0944
(make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
2192 |
300 | 2193 /* 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
|
2194 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
|
2195 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
|
2196 |
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
2197 Any number of arguments, even zero arguments, are allowed. */ |
300 | 2198 |
2199 Lisp_Object | |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
2200 make_event_array (nargs, args) |
300 | 2201 register int nargs; |
2202 Lisp_Object *args; | |
2203 { | |
2204 int i; | |
2205 | |
2206 for (i = 0; i < nargs; i++) | |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
2207 /* 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
|
2208 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
|
2209 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
|
2210 if (!INTEGERP (args[i]) |
3536
58d5ee6ec253
(make_event_array): Ignore bits above CHAR_META.
Richard M. Stallman <rms@gnu.org>
parents:
3181
diff
changeset
|
2211 || (XUINT (args[i]) & ~(-CHAR_META)) >= 0200) |
300 | 2212 return Fvector (nargs, args); |
2213 | |
2214 /* Since the loop exited, we know that all the things in it are | |
2215 characters, so we can make a string. */ | |
2216 { | |
6492
8372dce85f8a
(make_event_array): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6227
diff
changeset
|
2217 Lisp_Object result; |
300 | 2218 |
18104
b2a669ef69b1
(Fmake_byte_code): Set val from p, not from val.
Richard M. Stallman <rms@gnu.org>
parents:
18010
diff
changeset
|
2219 result = Fmake_string (make_number (nargs), make_number (0)); |
300 | 2220 for (i = 0; i < nargs; i++) |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
2221 { |
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
2222 XSTRING (result)->data[i] = XINT (args[i]); |
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
2223 /* 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
|
2224 if (XINT (args[i]) & CHAR_META) |
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
2225 XSTRING (result)->data[i] |= 0x80; |
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
2226 } |
300 | 2227 |
2228 return result; | |
2229 } | |
2230 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2231 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2232 |
300 | 2233 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2234 /************************************************************************ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2235 C Stack Marking |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2236 ************************************************************************/ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2237 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2238 #if GC_MARK_STACK |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2239 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2240 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2241 /* Base address of stack. Set in main. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2242 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2243 Lisp_Object *stack_base; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2244 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2245 /* A node in the red-black tree describing allocated memory containing |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2246 Lisp data. Each such block is recorded with its start and end |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2247 address when it is allocated, and removed from the tree when it |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2248 is freed. |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2249 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2250 A red-black tree is a balanced binary tree with the following |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2251 properties: |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2252 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2253 1. Every node is either red or black. |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2254 2. Every leaf is black. |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2255 3. If a node is red, then both of its children are black. |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2256 4. Every simple path from a node to a descendant leaf contains |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2257 the same number of black nodes. |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2258 5. The root is always black. |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2259 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2260 When nodes are inserted into the tree, or deleted from the tree, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2261 the tree is "fixed" so that these properties are always true. |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2262 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2263 A red-black tree with N internal nodes has height at most 2 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2264 log(N+1). Searches, insertions and deletions are done in O(log N). |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2265 Please see a text book about data structures for a detailed |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2266 description of red-black trees. Any book worth its salt should |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2267 describe them. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2268 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2269 struct mem_node |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2270 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2271 struct mem_node *left, *right, *parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2272 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2273 /* Start and end of allocated region. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2274 void *start, *end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2275 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2276 /* Node color. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2277 enum {MEM_BLACK, MEM_RED} color; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2278 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2279 /* Memory type. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2280 enum mem_type type; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2281 }; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2282 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2283 /* Root of the tree describing allocated Lisp memory. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2284 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2285 static struct mem_node *mem_root; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2286 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2287 /* Sentinel node of the tree. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2288 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2289 static struct mem_node mem_z; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2290 #define MEM_NIL &mem_z |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2291 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2292 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2293 /* 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
|
2294 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2295 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2296 mem_init () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2297 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2298 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
|
2299 mem_z.parent = NULL; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2300 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
|
2301 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
|
2302 mem_root = MEM_NIL; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2303 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2304 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2305 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2306 /* 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
|
2307 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
|
2308 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2309 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
|
2310 mem_find (start) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2311 void *start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2312 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2313 struct mem_node *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2314 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2315 /* 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
|
2316 mem_z.start = start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2317 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
|
2318 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2319 p = mem_root; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2320 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
|
2321 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
|
2322 return p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2323 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2324 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2325 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2326 /* 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
|
2327 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
|
2328 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
|
2329 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2330 static struct mem_node * |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2331 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
|
2332 void *start, *end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2333 enum mem_type type; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2334 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2335 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
|
2336 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2337 /* 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
|
2338 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
|
2339 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
|
2340 c = mem_root; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2341 parent = NULL; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2342 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2343 #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
|
2344 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2345 while (c != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2346 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2347 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
|
2348 abort (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2349 parent = c; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2350 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
|
2351 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2352 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2353 #else /* 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
|
2354 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2355 while (c != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2356 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2357 parent = c; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2358 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
|
2359 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2360 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2361 #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
|
2362 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2363 /* Create a new node. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2364 x = (struct mem_node *) xmalloc (sizeof *x); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2365 x->start = start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2366 x->end = end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2367 x->type = type; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2368 x->parent = parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2369 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
|
2370 x->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2371 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2372 /* 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
|
2373 if (parent) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2374 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2375 if (start < parent->start) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2376 parent->left = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2377 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2378 parent->right = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2379 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2380 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2381 mem_root = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2382 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2383 /* 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
|
2384 mem_insert_fixup (x); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2385 return x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2386 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2387 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2388 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2389 /* 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
|
2390 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
|
2391 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2392 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2393 mem_insert_fixup (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2394 struct mem_node *x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2395 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2396 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
|
2397 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2398 /* 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
|
2399 red-black tree property #3. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2400 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2401 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
|
2402 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2403 /* 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
|
2404 "uncle". */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2405 struct mem_node *y = x->parent->parent->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2406 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2407 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
|
2408 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2409 /* 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
|
2410 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
|
2411 with the grandparent. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2412 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
|
2413 y->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2414 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
|
2415 x = x->parent->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2416 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2417 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2418 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2419 /* 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
|
2420 red, uncle is black. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2421 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
|
2422 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2423 x = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2424 mem_rotate_left (x); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2425 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2426 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2427 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
|
2428 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
|
2429 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
|
2430 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2431 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2432 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2433 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2434 /* 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
|
2435 struct mem_node *y = x->parent->parent->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2436 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2437 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
|
2438 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2439 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
|
2440 y->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2441 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
|
2442 x = x->parent->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2443 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2444 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2445 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2446 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
|
2447 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2448 x = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2449 mem_rotate_right (x); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2450 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2451 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2452 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
|
2453 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
|
2454 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
|
2455 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2456 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2457 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2458 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2459 /* 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
|
2460 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
|
2461 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
|
2462 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2463 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2464 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2465 /* (x) (y) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2466 / \ / \ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2467 a (y) ===> (x) c |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2468 / \ / \ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2469 b c a b */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2470 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2471 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2472 mem_rotate_left (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2473 struct mem_node *x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2474 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2475 struct mem_node *y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2476 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2477 /* 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
|
2478 y = x->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2479 x->right = y->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2480 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
|
2481 y->left->parent = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2482 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2483 /* 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
|
2484 if (y != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2485 y->parent = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2486 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2487 /* 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
|
2488 if (x->parent) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2489 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2490 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
|
2491 x->parent->left = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2492 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2493 x->parent->right = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2494 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2495 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2496 mem_root = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2497 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2498 /* 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
|
2499 y->left = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2500 if (x != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2501 x->parent = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2502 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2503 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2504 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2505 /* (x) (Y) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2506 / \ / \ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2507 (y) c ===> a (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2508 / \ / \ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2509 a b b c */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2510 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2511 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2512 mem_rotate_right (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2513 struct mem_node *x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2514 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2515 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
|
2516 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2517 x->left = y->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2518 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
|
2519 y->right->parent = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2520 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2521 if (y != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2522 y->parent = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2523 if (x->parent) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2524 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2525 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
|
2526 x->parent->right = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2527 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2528 x->parent->left = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2529 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2530 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2531 mem_root = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2532 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2533 y->right = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2534 if (x != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2535 x->parent = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2536 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2537 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2538 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2539 /* 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
|
2540 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2541 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2542 mem_delete (z) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2543 struct mem_node *z; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2544 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2545 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
|
2546 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2547 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
|
2548 return; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2549 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2550 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
|
2551 y = z; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2552 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2553 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2554 y = z->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2555 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
|
2556 y = y->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2557 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2558 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2559 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
|
2560 x = y->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2561 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2562 x = y->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2563 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2564 x->parent = y->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2565 if (y->parent) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2566 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2567 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
|
2568 y->parent->left = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2569 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2570 y->parent->right = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2571 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2572 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2573 mem_root = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2574 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2575 if (y != z) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2576 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2577 z->start = y->start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2578 z->end = y->end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2579 z->type = y->type; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2580 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2581 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2582 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
|
2583 mem_delete_fixup (x); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2584 xfree (y); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2585 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2586 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2587 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2588 /* 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
|
2589 deletion. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2590 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2591 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2592 mem_delete_fixup (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2593 struct mem_node *x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2594 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2595 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
|
2596 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2597 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
|
2598 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2599 struct mem_node *w = x->parent->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2600 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2601 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
|
2602 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2603 w->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2604 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
|
2605 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
|
2606 w = x->parent->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2607 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2608 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2609 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
|
2610 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2611 w->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2612 x = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2613 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2614 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2615 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2616 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
|
2617 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2618 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
|
2619 w->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2620 mem_rotate_right (w); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2621 w = x->parent->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2622 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2623 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
|
2624 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
|
2625 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
|
2626 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
|
2627 x = mem_root; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2628 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2629 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2630 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2631 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2632 struct mem_node *w = x->parent->left; |
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 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
|
2635 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2636 w->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2637 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
|
2638 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
|
2639 w = x->parent->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2640 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2641 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2642 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
|
2643 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2644 w->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2645 x = x->parent; |
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 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2648 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2649 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
|
2650 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2651 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
|
2652 w->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2653 mem_rotate_left (w); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2654 w = x->parent->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2655 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2656 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2657 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
|
2658 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
|
2659 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
|
2660 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
|
2661 x = mem_root; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2662 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2663 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2664 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2665 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2666 x->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2667 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2668 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2669 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2670 /* 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
|
2671 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
|
2672 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2673 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2674 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
|
2675 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2676 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2677 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2678 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
|
2679 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2680 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
|
2681 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
|
2682 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2683 /* 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
|
2684 must not be on the free-list. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2685 return (offset % sizeof b->strings[0] == 0 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2686 && ((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
|
2687 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2688 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2689 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2690 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2691 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2692 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2693 /* 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
|
2694 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
|
2695 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2696 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2697 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
|
2698 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2699 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2700 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2701 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
|
2702 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2703 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
|
2704 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
|
2705 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2706 /* 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
|
2707 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
|
2708 and not be on the free-list. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2709 return (offset % sizeof b->conses[0] == 0 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2710 && (b != cons_block |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2711 || 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
|
2712 && !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
|
2713 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2714 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2715 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2716 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2717 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2718 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2719 /* 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
|
2720 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
|
2721 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2722 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2723 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
|
2724 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2725 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2726 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2727 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
|
2728 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2729 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
|
2730 int offset = (char *) p - (char *) &b->symbols[0]; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2731 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2732 /* 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
|
2733 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
|
2734 and not be on the free-list. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2735 return (offset % sizeof b->symbols[0] == 0 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2736 && (b != symbol_block |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2737 || 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
|
2738 && !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
|
2739 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2740 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2741 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2742 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2743 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2744 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2745 /* 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
|
2746 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
|
2747 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2748 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2749 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
|
2750 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2751 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2752 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2753 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
|
2754 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2755 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
|
2756 int offset = (char *) p - (char *) &b->floats[0]; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2757 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2758 /* P must point to the start of a Lisp_Float, not be |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2759 one of the unused cells 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
|
2760 and not be on the free-list. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2761 return (offset % sizeof b->floats[0] == 0 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2762 && (b != float_block |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2763 || offset / sizeof b->floats[0] < float_block_index) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2764 && !EQ (((struct Lisp_Float *) p)->type, Vdead)); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2765 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2766 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2767 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2768 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2769 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2770 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2771 /* 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
|
2772 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
|
2773 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2774 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2775 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
|
2776 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2777 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2778 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2779 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
|
2780 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2781 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
|
2782 int offset = (char *) p - (char *) &b->markers[0]; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2783 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2784 /* 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
|
2785 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
|
2786 and not be on the free-list. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2787 return (offset % sizeof b->markers[0] == 0 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2788 && (b != marker_block |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2789 || 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
|
2790 && ((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
|
2791 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2792 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2793 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2794 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2795 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2796 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2797 /* 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
|
2798 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
|
2799 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2800 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2801 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
|
2802 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2803 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2804 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2805 return m->type == MEM_TYPE_VECTOR && p == m->start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2806 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2807 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2808 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2809 /* Value is non-zero of P is a pointer to a live buffer. M is a |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2810 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
|
2811 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2812 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2813 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
|
2814 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2815 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2816 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2817 /* 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
|
2818 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
|
2819 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
|
2820 && p == m->start |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2821 && !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
|
2822 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2823 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2824 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2825 #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
|
2826 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2827 /* 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
|
2828 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
|
2829 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2830 #define MAX_ZOMBIES 10 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2831 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
|
2832 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2833 /* Number of zombie objects. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2834 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2835 static int nzombies; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2836 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2837 /* Number of garbage collections. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2838 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2839 static int ngcs; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2840 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2841 /* 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
|
2842 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2843 static double avg_zombies; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2844 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2845 /* 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
|
2846 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2847 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
|
2848 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2849 /* 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
|
2850 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2851 static double avg_live; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2852 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2853 DEFUN ("gc-status", Fgc_status, Sgc_status, 0, 0, "", |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2854 "Show information about live and zombie objects.") |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2855 () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2856 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2857 Lisp_Object args[7]; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2858 args[0] = build_string ("%d GCs, avg live/zombies = %.2f/%.2f (%f%%), max %d/%d"); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2859 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
|
2860 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
|
2861 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
|
2862 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
|
2863 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
|
2864 args[6] = make_number (max_zombies); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2865 return Fmessage (7, args); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2866 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2867 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2868 #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
|
2869 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2870 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2871 /* 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
|
2872 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2873 static INLINE void |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2874 mark_maybe_object (obj) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2875 Lisp_Object obj; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2876 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2877 void *po = (void *) XPNTR (obj); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2878 struct mem_node *m = mem_find (po); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2879 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2880 if (m != MEM_NIL) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2881 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2882 int mark_p = 0; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2883 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2884 switch (XGCTYPE (obj)) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2885 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2886 case Lisp_String: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2887 mark_p = (live_string_p (m, po) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2888 && !STRING_MARKED_P ((struct Lisp_String *) po)); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2889 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2890 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2891 case Lisp_Cons: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2892 mark_p = (live_cons_p (m, po) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2893 && !XMARKBIT (XCONS (obj)->car)); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2894 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2895 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2896 case Lisp_Symbol: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2897 mark_p = (live_symbol_p (m, po) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2898 && !XMARKBIT (XSYMBOL (obj)->plist)); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2899 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2900 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2901 case Lisp_Float: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2902 mark_p = (live_float_p (m, po) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2903 && !XMARKBIT (XFLOAT (obj)->type)); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2904 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2905 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2906 case Lisp_Vectorlike: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2907 /* 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
|
2908 buffer because checking that dereferences the pointer |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2909 PO which might point anywhere. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2910 if (live_vector_p (m, po)) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2911 mark_p = (!GC_SUBRP (obj) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2912 && !(XVECTOR (obj)->size & ARRAY_MARK_FLAG)); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2913 else if (live_buffer_p (m, po)) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2914 mark_p = GC_BUFFERP (obj) && !XMARKBIT (XBUFFER (obj)->name); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2915 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2916 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2917 case Lisp_Misc: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2918 if (live_misc_p (m, po)) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2919 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2920 switch (XMISCTYPE (obj)) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2921 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2922 case Lisp_Misc_Marker: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2923 mark_p = !XMARKBIT (XMARKER (obj)->chain); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2924 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2925 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2926 case Lisp_Misc_Buffer_Local_Value: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2927 case Lisp_Misc_Some_Buffer_Local_Value: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2928 mark_p = !XMARKBIT (XBUFFER_LOCAL_VALUE (obj)->realvalue); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2929 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2930 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2931 case Lisp_Misc_Overlay: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2932 mark_p = !XMARKBIT (XOVERLAY (obj)->plist); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2933 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2934 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2935 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2936 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2937 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2938 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2939 if (mark_p) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2940 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2941 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2942 if (nzombies < MAX_ZOMBIES) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2943 zombies[nzombies] = *p; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2944 ++nzombies; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2945 #endif |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2946 mark_object (&obj); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2947 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2948 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2949 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2950 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2951 /* Mark Lisp objects in the address range START..END. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2952 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2953 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2954 mark_memory (start, end) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2955 void *start, *end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2956 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2957 Lisp_Object *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2958 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2959 #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
|
2960 nzombies = 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2961 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2962 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2963 /* 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
|
2964 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
|
2965 if (end < start) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2966 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2967 void *tem = start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2968 start = end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2969 end = tem; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2970 } |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2971 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2972 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
|
2973 mark_maybe_object (*p); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2974 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2975 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2976 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2977 #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
|
2978 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2979 static int setjmp_tested_p, longjmps_done; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2980 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2981 #define SETJMP_WILL_LIKELY_WORK "\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2982 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2983 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
|
2984 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
|
2985 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
|
2986 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2987 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
|
2988 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
|
2989 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
|
2990 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2991 Please mail the result to <gerd@gnu.org>.\n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2992 " |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2993 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2994 #define SETJMP_WILL_NOT_WORK "\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2995 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
2996 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
|
2997 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
|
2998 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
|
2999 solution for your system.\n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3000 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3001 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
|
3002 try to find a way to make it work on your system.\n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3003 Please mail the result to <gerd@gnu.org>.\n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3004 " |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3005 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3006 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3007 /* 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
|
3008 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
|
3009 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
|
3010 conservative stack marking. Only the sources or a disassembly |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3011 can prove that. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3012 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3013 static void |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3014 test_setjmp () |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3015 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3016 char buf[10]; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3017 register int x; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3018 jmp_buf jbuf; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3019 int result = 0; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3020 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3021 /* Arrange for X to be put in a register. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3022 sprintf (buf, "1"); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3023 x = strlen (buf); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3024 x = 2 * x - 1; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3025 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3026 setjmp (jbuf); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3027 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
|
3028 { |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3029 /* 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
|
3030 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3031 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
|
3032 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
|
3033 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
|
3034 isn't sure. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3035 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3036 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
|
3037 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
|
3038 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3039 if (x == 1) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3040 fprintf (stderr, SETJMP_WILL_LIKELY_WORK); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3041 else |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3042 { |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3043 fprintf (stderr, SETJMP_WILL_NOT_WORK); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3044 exit (1); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3045 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3046 } |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3047 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3048 ++longjmps_done; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3049 x = 2; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3050 if (longjmps_done == 1) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3051 longjmp (jbuf, 1); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3052 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3053 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3054 #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
|
3055 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3056 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3057 #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
|
3058 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3059 /* 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
|
3060 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3061 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3062 check_gcpros () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3063 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3064 struct gcpro *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3065 int i; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3066 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3067 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
|
3068 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
|
3069 if (!survives_gc_p (p->var[i])) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3070 abort (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3071 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3072 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3073 #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
|
3074 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3075 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3076 dump_zombies () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3077 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3078 int i; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3079 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3080 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
|
3081 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
|
3082 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3083 fprintf (stderr, " %d = ", i); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3084 debug_print (zombies[i]); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3085 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3086 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3087 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3088 #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
|
3089 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3090 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3091 /* Mark live Lisp objects on the C stack. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3092 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3093 There are several system-dependent problems to consider when |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3094 porting this to new architectures: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3095 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3096 Processor Registers |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3097 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3098 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
|
3099 variables or are used to pass parameters. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3100 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3101 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
|
3102 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
|
3103 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
|
3104 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3105 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
|
3106 implementation assumes that calling setjmp saves registers we need |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3107 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
|
3108 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
|
3109 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
|
3110 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3111 Stack Layout |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3112 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3113 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
|
3114 For example, the stack might look like this |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3115 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3116 +----------------+ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3117 | Lisp_Object | size = 4 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3118 +----------------+ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3119 | something else | size = 2 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3120 +----------------+ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3121 | Lisp_Object | size = 4 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3122 +----------------+ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3123 | ... | |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3124 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3125 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
|
3126 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
|
3127 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
|
3128 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
|
3129 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
|
3130 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
|
3131 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
|
3132 from the stack start. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3133 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3134 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
|
3135 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
|
3136 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3137 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3138 mark_stack () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3139 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3140 jmp_buf j; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3141 int stack_grows_down_p = (char *) &j > (char *) stack_base; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3142 void *end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3143 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3144 /* 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
|
3145 the process is contained in the stack. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3146 #ifdef sparc |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3147 asm ("ta 3"); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3148 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3149 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3150 /* 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
|
3151 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
|
3152 pass parameters. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3153 #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
|
3154 GC_SAVE_REGISTERS_ON_STACK (end); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3155 #else /* not GC_SAVE_REGISTERS_ON_STACK */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3156 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3157 #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
|
3158 setjmp will definitely work, test it |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3159 and print a message with the result |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3160 of the test. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3161 if (!setjmp_tested_p) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3162 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3163 setjmp_tested_p = 1; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3164 test_setjmp (); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3165 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3166 #endif /* GC_SETJMP_WORKS */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3167 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3168 setjmp (j); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3169 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
|
3170 #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
|
3171 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3172 /* 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
|
3173 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
|
3174 over the stack segments. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3175 #if GC_LISP_OBJECT_ALIGNMENT == 1 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3176 mark_memory (stack_base, end); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3177 mark_memory ((char *) stack_base + 1, end); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3178 mark_memory ((char *) stack_base + 2, end); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3179 mark_memory ((char *) stack_base + 3, end); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3180 #elif GC_LISP_OBJECT_ALIGNMENT == 2 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3181 mark_memory (stack_base, end); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3182 mark_memory ((char *) stack_base + 2, end); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3183 #else |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3184 mark_memory (stack_base, end); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3185 #endif |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3186 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3187 #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
|
3188 check_gcpros (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3189 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3190 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3191 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3192 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3193 #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
|
3194 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3195 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3196 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3197 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3198 Pure Storage Management |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3199 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3200 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3201 /* 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
|
3202 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
|
3203 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
|
3204 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3205 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
|
3206 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
|
3207 string; then the string is not protected from gc. */ |
300 | 3208 |
3209 Lisp_Object | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3210 make_pure_string (data, nchars, nbytes, multibyte) |
300 | 3211 char *data; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3212 int nchars, nbytes; |
21258
693573ac0944
(make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
3213 int multibyte; |
300 | 3214 { |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3215 Lisp_Object string; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3216 struct Lisp_String *s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3217 int string_size, data_size; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3218 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3219 #define PAD(SZ) (((SZ) + sizeof (EMACS_INT) - 1) & ~(sizeof (EMACS_INT) - 1)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3220 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3221 string_size = PAD (sizeof (struct Lisp_String)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3222 data_size = PAD (nbytes + 1); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3223 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3224 #undef PAD |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3225 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3226 if (pureptr + string_size + data_size > PURESIZE) |
300 | 3227 error ("Pure Lisp storage exhausted"); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3228 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3229 s = (struct Lisp_String *) (PUREBEG + pureptr); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3230 pureptr += string_size; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3231 s->data = (unsigned char *) (PUREBEG + pureptr); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3232 pureptr += data_size; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3233 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3234 s->size = nchars; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3235 s->size_byte = multibyte ? nbytes : -1; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3236 bcopy (data, s->data, nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3237 s->data[nbytes] = '\0'; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3238 s->intervals = NULL_INTERVAL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3239 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3240 XSETSTRING (string, s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3241 return string; |
300 | 3242 } |
3243 | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3244 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3245 /* 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
|
3246 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
|
3247 |
300 | 3248 Lisp_Object |
3249 pure_cons (car, cdr) | |
3250 Lisp_Object car, cdr; | |
3251 { | |
3252 register Lisp_Object new; | |
3253 | |
3254 if (pureptr + sizeof (struct Lisp_Cons) > PURESIZE) | |
3255 error ("Pure Lisp storage exhausted"); | |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
3256 XSETCONS (new, PUREBEG + pureptr); |
300 | 3257 pureptr += sizeof (struct Lisp_Cons); |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
3258 XCAR (new) = Fpurecopy (car); |
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
3259 XCDR (new) = Fpurecopy (cdr); |
300 | 3260 return new; |
3261 } | |
3262 | |
3263 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3264 /* 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
|
3265 |
300 | 3266 Lisp_Object |
3267 make_pure_float (num) | |
3268 double num; | |
3269 { | |
3270 register Lisp_Object new; | |
3271 | |
1939
def7b9c64935
* alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents:
1936
diff
changeset
|
3272 /* Make sure that PUREBEG + pureptr is aligned on at least a sizeof |
def7b9c64935
* alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents:
1936
diff
changeset
|
3273 (double) boundary. Some architectures (like the sparc) require |
def7b9c64935
* alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents:
1936
diff
changeset
|
3274 this, and I suspect that floats are rare enough that it's no |
def7b9c64935
* alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents:
1936
diff
changeset
|
3275 tragedy for those that do. */ |
def7b9c64935
* alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents:
1936
diff
changeset
|
3276 { |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
3277 size_t alignment; |
1939
def7b9c64935
* alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents:
1936
diff
changeset
|
3278 char *p = PUREBEG + pureptr; |
def7b9c64935
* alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents:
1936
diff
changeset
|
3279 |
1936
82bbf90208d4
* alloc.c (make_pure_float): Align pureptr according to __alignof,
Jim Blandy <jimb@redhat.com>
parents:
1908
diff
changeset
|
3280 #ifdef __GNUC__ |
82bbf90208d4
* alloc.c (make_pure_float): Align pureptr according to __alignof,
Jim Blandy <jimb@redhat.com>
parents:
1908
diff
changeset
|
3281 #if __GNUC__ >= 2 |
1939
def7b9c64935
* alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents:
1936
diff
changeset
|
3282 alignment = __alignof (struct Lisp_Float); |
1936
82bbf90208d4
* alloc.c (make_pure_float): Align pureptr according to __alignof,
Jim Blandy <jimb@redhat.com>
parents:
1908
diff
changeset
|
3283 #else |
1939
def7b9c64935
* alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents:
1936
diff
changeset
|
3284 alignment = sizeof (struct Lisp_Float); |
1936
82bbf90208d4
* alloc.c (make_pure_float): Align pureptr according to __alignof,
Jim Blandy <jimb@redhat.com>
parents:
1908
diff
changeset
|
3285 #endif |
82bbf90208d4
* alloc.c (make_pure_float): Align pureptr according to __alignof,
Jim Blandy <jimb@redhat.com>
parents:
1908
diff
changeset
|
3286 #else |
1939
def7b9c64935
* alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents:
1936
diff
changeset
|
3287 alignment = sizeof (struct Lisp_Float); |
1936
82bbf90208d4
* alloc.c (make_pure_float): Align pureptr according to __alignof,
Jim Blandy <jimb@redhat.com>
parents:
1908
diff
changeset
|
3288 #endif |
1939
def7b9c64935
* alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents:
1936
diff
changeset
|
3289 p = (char *) (((unsigned long) p + alignment - 1) & - alignment); |
def7b9c64935
* alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents:
1936
diff
changeset
|
3290 pureptr = p - PUREBEG; |
def7b9c64935
* alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents:
1936
diff
changeset
|
3291 } |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
3292 |
300 | 3293 if (pureptr + sizeof (struct Lisp_Float) > PURESIZE) |
3294 error ("Pure Lisp storage exhausted"); | |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
3295 XSETFLOAT (new, PUREBEG + pureptr); |
300 | 3296 pureptr += sizeof (struct Lisp_Float); |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
3297 XFLOAT_DATA (new) = num; |
9295
17d393a8eed6
(free_float, make_float, free_cons, Flist, Fvector, Fmake_byte_code,
Karl Heuer <kwzh@gnu.org>
parents:
9261
diff
changeset
|
3298 XSETFASTINT (XFLOAT (new)->type, 0); /* bug chasing -wsr */ |
300 | 3299 return new; |
3300 } | |
3301 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3302 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3303 /* 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
|
3304 pure space. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3305 |
300 | 3306 Lisp_Object |
3307 make_pure_vector (len) | |
8817
48ff00bebef6
(pure, pure_size): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
3308 EMACS_INT len; |
300 | 3309 { |
3310 register Lisp_Object new; | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3311 register EMACS_INT size = (sizeof (struct Lisp_Vector) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3312 + (len - 1) * sizeof (Lisp_Object)); |
300 | 3313 |
3314 if (pureptr + size > PURESIZE) | |
3315 error ("Pure Lisp storage exhausted"); | |
3316 | |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
3317 XSETVECTOR (new, PUREBEG + pureptr); |
300 | 3318 pureptr += size; |
3319 XVECTOR (new)->size = len; | |
3320 return new; | |
3321 } | |
3322 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3323 |
300 | 3324 DEFUN ("purecopy", Fpurecopy, Spurecopy, 1, 1, 0, |
3325 "Make a copy of OBJECT in pure storage.\n\ | |
3326 Recursively copies contents of vectors and cons cells.\n\ | |
27348 | 3327 Does not copy symbols. Copies strings without text properties.") |
300 | 3328 (obj) |
3329 register Lisp_Object obj; | |
3330 { | |
485 | 3331 if (NILP (Vpurify_flag)) |
300 | 3332 return obj; |
3333 | |
3334 if ((PNTR_COMPARISON_TYPE) XPNTR (obj) < (PNTR_COMPARISON_TYPE) ((char *) pure + PURESIZE) | |
3335 && (PNTR_COMPARISON_TYPE) XPNTR (obj) >= (PNTR_COMPARISON_TYPE) pure) | |
3336 return obj; | |
3337 | |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
3338 if (CONSP (obj)) |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
3339 return pure_cons (XCAR (obj), XCDR (obj)); |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
3340 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
|
3341 return make_pure_float (XFLOAT_DATA (obj)); |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
3342 else if (STRINGP (obj)) |
20587
eaf988c7e291
(make_pure_string): New arg length_byte.
Richard M. Stallman <rms@gnu.org>
parents:
20565
diff
changeset
|
3343 return make_pure_string (XSTRING (obj)->data, XSTRING (obj)->size, |
21258
693573ac0944
(make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
3344 STRING_BYTES (XSTRING (obj)), |
693573ac0944
(make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
3345 STRING_MULTIBYTE (obj)); |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
3346 else if (COMPILEDP (obj) || VECTORP (obj)) |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
3347 { |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
3348 register struct Lisp_Vector *vec; |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
3349 register int i, size; |
300 | 3350 |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
3351 size = XVECTOR (obj)->size; |
10427
5faba1b094d5
(Fpurecopy): Mask size field when copying pseudovector.
Karl Heuer <kwzh@gnu.org>
parents:
10414
diff
changeset
|
3352 if (size & PSEUDOVECTOR_FLAG) |
5faba1b094d5
(Fpurecopy): Mask size field when copying pseudovector.
Karl Heuer <kwzh@gnu.org>
parents:
10414
diff
changeset
|
3353 size &= PSEUDOVECTOR_SIZE_MASK; |
16100
ccd19852de65
(Fpurecopy): Cast arg to make_pure_vector.
Richard M. Stallman <rms@gnu.org>
parents:
16051
diff
changeset
|
3354 vec = XVECTOR (make_pure_vector ((EMACS_INT) size)); |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
3355 for (i = 0; i < size; i++) |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
3356 vec->contents[i] = Fpurecopy (XVECTOR (obj)->contents[i]); |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
3357 if (COMPILEDP (obj)) |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
3358 XSETCOMPILED (obj, vec); |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
3359 else |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
3360 XSETVECTOR (obj, vec); |
300 | 3361 return obj; |
3362 } | |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
3363 else if (MARKERP (obj)) |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
3364 error ("Attempt to copy a marker to pure storage"); |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
3365 else |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
3366 return obj; |
300 | 3367 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3368 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3369 |
300 | 3370 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3371 /*********************************************************************** |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3372 Protection from GC |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3373 ***********************************************************************/ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3374 |
300 | 3375 /* Recording what needs to be marked for gc. */ |
3376 | |
3377 struct gcpro *gcprolist; | |
3378 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3379 /* Addresses of staticpro'd variables. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3380 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3381 #define NSTATICS 1024 |
300 | 3382 Lisp_Object *staticvec[NSTATICS] = {0}; |
3383 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3384 /* Index of next unused slot in staticvec. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3385 |
300 | 3386 int staticidx = 0; |
3387 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3388 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3389 /* 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
|
3390 VARADDRESS. */ |
300 | 3391 |
3392 void | |
3393 staticpro (varaddress) | |
3394 Lisp_Object *varaddress; | |
3395 { | |
3396 staticvec[staticidx++] = varaddress; | |
3397 if (staticidx >= NSTATICS) | |
3398 abort (); | |
3399 } | |
3400 | |
3401 struct catchtag | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3402 { |
300 | 3403 Lisp_Object tag; |
3404 Lisp_Object val; | |
3405 struct catchtag *next; | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3406 }; |
300 | 3407 |
3408 struct backtrace | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3409 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3410 struct backtrace *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3411 Lisp_Object *function; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3412 Lisp_Object *args; /* Points to vector of args. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3413 int nargs; /* Length of vector. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3414 /* If nargs is UNEVALLED, args points to slot holding list of |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3415 unevalled args. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3416 char evalargs; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3417 }; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3418 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3419 |
300 | 3420 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3421 /*********************************************************************** |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3422 Protection from GC |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3423 ***********************************************************************/ |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
3424 |
11374
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
3425 /* Temporarily prevent garbage collection. */ |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
3426 |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
3427 int |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
3428 inhibit_garbage_collection () |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
3429 { |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
3430 int count = specpdl_ptr - specpdl; |
11679
1ced2d67d411
(gc_cons_threshold): Make this an EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
11593
diff
changeset
|
3431 Lisp_Object number; |
13363
941c37982f37
(BITS_PER_SHORT, BITS_PER_INT, BITS_PER_LONG):
Karl Heuer <kwzh@gnu.org>
parents:
13322
diff
changeset
|
3432 int nbits = min (VALBITS, BITS_PER_INT); |
11374
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
3433 |
11727
53ccd2d608ee
(gc_cons_threshold): Change back to int.
Richard M. Stallman <rms@gnu.org>
parents:
11679
diff
changeset
|
3434 XSETINT (number, ((EMACS_INT) 1 << (nbits - 1)) - 1); |
11679
1ced2d67d411
(gc_cons_threshold): Make this an EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
11593
diff
changeset
|
3435 |
1ced2d67d411
(gc_cons_threshold): Make this an EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
11593
diff
changeset
|
3436 specbind (Qgc_cons_threshold, number); |
11374
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
3437 |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
3438 return count; |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
3439 } |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
3440 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3441 |
300 | 3442 DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "", |
3443 "Reclaim storage for Lisp objects no longer needed.\n\ | |
3444 Returns info on amount of space in use:\n\ | |
3445 ((USED-CONSES . FREE-CONSES) (USED-SYMS . FREE-SYMS)\n\ | |
3446 (USED-MARKERS . FREE-MARKERS) USED-STRING-CHARS USED-VECTOR-SLOTS\n\ | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3447 (USED-FLOATS . FREE-FLOATS) (USED-INTERVALS . FREE-INTERVALS\n\ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3448 (USED-STRINGS . FREE-STRINGS))\n\ |
300 | 3449 Garbage collection happens automatically if you cons more than\n\ |
3450 `gc-cons-threshold' bytes of Lisp data since previous garbage collection.") | |
3451 () | |
3452 { | |
3453 register struct gcpro *tail; | |
3454 register struct specbinding *bind; | |
3455 struct catchtag *catch; | |
3456 struct handler *handler; | |
3457 register struct backtrace *backlist; | |
3458 char stack_top_variable; | |
3459 register int i; | |
25343
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
3460 int message_p; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3461 Lisp_Object total[7]; |
300 | 3462 |
11892
6be0b7a0ac44
(Fgarbage_collect): Clear consing_since_gc first thing.
Karl Heuer <kwzh@gnu.org>
parents:
11727
diff
changeset
|
3463 /* 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
|
3464 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
|
3465 consing_since_gc = 0; |
6be0b7a0ac44
(Fgarbage_collect): Clear consing_since_gc first thing.
Karl Heuer <kwzh@gnu.org>
parents:
11727
diff
changeset
|
3466 |
25343
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
3467 /* 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
|
3468 message_p = push_message (); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3469 |
300 | 3470 /* Save a copy of the contents of the stack, for debugging. */ |
3471 #if MAX_SAVE_STACK > 0 | |
485 | 3472 if (NILP (Vpurify_flag)) |
300 | 3473 { |
3474 i = &stack_top_variable - stack_bottom; | |
3475 if (i < 0) i = -i; | |
3476 if (i < MAX_SAVE_STACK) | |
3477 { | |
3478 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
|
3479 stack_copy = (char *) xmalloc (stack_copy_size = i); |
300 | 3480 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
|
3481 stack_copy = (char *) xrealloc (stack_copy, (stack_copy_size = i)); |
300 | 3482 if (stack_copy) |
3483 { | |
8817
48ff00bebef6
(pure, pure_size): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
3484 if ((EMACS_INT) (&stack_top_variable - stack_bottom) > 0) |
300 | 3485 bcopy (stack_bottom, stack_copy, i); |
3486 else | |
3487 bcopy (&stack_top_variable, stack_copy, i); | |
3488 } | |
3489 } | |
3490 } | |
3491 #endif /* MAX_SAVE_STACK > 0 */ | |
3492 | |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
3493 if (garbage_collection_messages) |
10395
c121703d35c7
(Fgarbage_collect): Don't log the GC message.
Karl Heuer <kwzh@gnu.org>
parents:
10389
diff
changeset
|
3494 message1_nolog ("Garbage collecting..."); |
300 | 3495 |
23534
6f9c70db3a58
(Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents:
22382
diff
changeset
|
3496 BLOCK_INPUT; |
6f9c70db3a58
(Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents:
22382
diff
changeset
|
3497 |
22220
a0cd311af6e3
(Fgarbage_collect): Call shrink_regexp_cache.
Richard M. Stallman <rms@gnu.org>
parents:
21948
diff
changeset
|
3498 shrink_regexp_cache (); |
a0cd311af6e3
(Fgarbage_collect): Call shrink_regexp_cache.
Richard M. Stallman <rms@gnu.org>
parents:
21948
diff
changeset
|
3499 |
21680
c744d468bfb6
(Fgarbage_collect): Don't truncate command-history here.
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
3500 /* Don't keep undo information around forever. */ |
300 | 3501 { |
3502 register struct buffer *nextb = all_buffers; | |
3503 | |
3504 while (nextb) | |
3505 { | |
648 | 3506 /* If a buffer's undo list is Qt, that means that undo is |
3507 turned off in that buffer. Calling truncate_undo_list on | |
3508 Qt tends to return NULL, which effectively turns undo back on. | |
3509 So don't call truncate_undo_list if undo_list is Qt. */ | |
3510 if (! EQ (nextb->undo_list, Qt)) | |
3511 nextb->undo_list | |
764 | 3512 = truncate_undo_list (nextb->undo_list, undo_limit, |
3513 undo_strong_limit); | |
300 | 3514 nextb = nextb->next; |
3515 } | |
3516 } | |
3517 | |
3518 gc_in_progress = 1; | |
3519 | |
16231 | 3520 /* clear_marks (); */ |
300 | 3521 |
3522 /* Mark all the special slots that serve as the roots of accessibility. | |
3523 | |
3524 Usually the special slots to mark are contained in particular structures. | |
3525 Then we know no slot is marked twice because the structures don't overlap. | |
3526 In some cases, the structures point to the slots to be marked. | |
3527 For these, we use MARKBIT to avoid double marking of the slot. */ | |
3528 | |
3529 for (i = 0; i < staticidx; i++) | |
3530 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
|
3531 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3532 #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
|
3533 || 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
|
3534 mark_stack (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3535 #else |
300 | 3536 for (tail = gcprolist; tail; tail = tail->next) |
3537 for (i = 0; i < tail->nvars; i++) | |
3538 if (!XMARKBIT (tail->var[i])) | |
3539 { | |
3540 mark_object (&tail->var[i]); | |
3541 XMARK (tail->var[i]); | |
3542 } | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3543 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3544 |
26364
7b0217d9259c
(Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents:
26164
diff
changeset
|
3545 mark_byte_stack (); |
300 | 3546 for (bind = specpdl; bind != specpdl_ptr; bind++) |
3547 { | |
3548 mark_object (&bind->symbol); | |
3549 mark_object (&bind->old_value); | |
3550 } | |
3551 for (catch = catchlist; catch; catch = catch->next) | |
3552 { | |
3553 mark_object (&catch->tag); | |
3554 mark_object (&catch->val); | |
3555 } | |
3556 for (handler = handlerlist; handler; handler = handler->next) | |
3557 { | |
3558 mark_object (&handler->handler); | |
3559 mark_object (&handler->var); | |
3560 } | |
3561 for (backlist = backtrace_list; backlist; backlist = backlist->next) | |
3562 { | |
3563 if (!XMARKBIT (*backlist->function)) | |
3564 { | |
3565 mark_object (backlist->function); | |
3566 XMARK (*backlist->function); | |
3567 } | |
3568 if (backlist->nargs == UNEVALLED || backlist->nargs == MANY) | |
3569 i = 0; | |
3570 else | |
3571 i = backlist->nargs - 1; | |
3572 for (; i >= 0; i--) | |
3573 if (!XMARKBIT (backlist->args[i])) | |
3574 { | |
3575 mark_object (&backlist->args[i]); | |
3576 XMARK (backlist->args[i]); | |
3577 } | |
3578 } | |
11018
2d9bdf1ba3d1
(mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents:
10936
diff
changeset
|
3579 mark_kboards (); |
300 | 3580 |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3581 /* Look thru every buffer's undo list |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3582 for elements that update markers that were not marked, |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3583 and delete them. */ |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3584 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3585 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
|
3586 |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3587 while (nextb) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3588 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3589 /* If a buffer's undo list is Qt, that means that undo is |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3590 turned off in that buffer. Calling truncate_undo_list on |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3591 Qt tends to return NULL, which effectively turns undo back on. |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3592 So don't call truncate_undo_list if undo_list is Qt. */ |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3593 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
|
3594 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3595 Lisp_Object tail, prev; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3596 tail = nextb->undo_list; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3597 prev = Qnil; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3598 while (CONSP (tail)) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3599 { |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
3600 if (GC_CONSP (XCAR (tail)) |
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
3601 && GC_MARKERP (XCAR (XCAR (tail))) |
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
3602 && ! XMARKBIT (XMARKER (XCAR (XCAR (tail)))->chain)) |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3603 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3604 if (NILP (prev)) |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
3605 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
|
3606 else |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
3607 tail = XCDR (prev) = XCDR (tail); |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3608 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3609 else |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3610 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3611 prev = tail; |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
3612 tail = XCDR (tail); |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3613 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3614 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3615 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3616 |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3617 nextb = nextb->next; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3618 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3619 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
3620 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3621 #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
|
3622 mark_stack (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3623 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3624 |
300 | 3625 gc_sweep (); |
3626 | |
3627 /* Clear the mark bits that we set in certain root slots. */ | |
3628 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3629 #if (GC_MARK_STACK == GC_USE_GCPROS_AS_BEFORE \ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3630 || GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES) |
300 | 3631 for (tail = gcprolist; tail; tail = tail->next) |
3632 for (i = 0; i < tail->nvars; i++) | |
3633 XUNMARK (tail->var[i]); | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3634 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3635 |
26378
cbf297593a79
(Fgarbage_collect): Call unmark_byte_stack.
Gerd Moellmann <gerd@gnu.org>
parents:
26372
diff
changeset
|
3636 unmark_byte_stack (); |
300 | 3637 for (backlist = backtrace_list; backlist; backlist = backlist->next) |
3638 { | |
3639 XUNMARK (*backlist->function); | |
3640 if (backlist->nargs == UNEVALLED || backlist->nargs == MANY) | |
3641 i = 0; | |
3642 else | |
3643 i = backlist->nargs - 1; | |
3644 for (; i >= 0; i--) | |
3645 XUNMARK (backlist->args[i]); | |
3646 } | |
3647 XUNMARK (buffer_defaults.name); | |
3648 XUNMARK (buffer_local_symbols.name); | |
3649 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3650 #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
|
3651 dump_zombies (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3652 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3653 |
23534
6f9c70db3a58
(Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents:
22382
diff
changeset
|
3654 UNBLOCK_INPUT; |
6f9c70db3a58
(Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents:
22382
diff
changeset
|
3655 |
16231 | 3656 /* clear_marks (); */ |
300 | 3657 gc_in_progress = 0; |
3658 | |
3659 consing_since_gc = 0; | |
3660 if (gc_cons_threshold < 10000) | |
3661 gc_cons_threshold = 10000; | |
3662 | |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
3663 if (garbage_collection_messages) |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
3664 { |
25343
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
3665 if (message_p || minibuf_level > 0) |
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
3666 restore_message (); |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
3667 else |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
3668 message1_nolog ("Garbage collecting...done"); |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
3669 } |
300 | 3670 |
25343
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
3671 pop_message (); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3672 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3673 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
|
3674 make_number (total_free_conses)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3675 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
|
3676 make_number (total_free_symbols)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3677 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
|
3678 make_number (total_free_markers)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3679 total[3] = Fcons (make_number (total_string_size), |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3680 make_number (total_vector_size)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3681 total[4] = Fcons (make_number (total_floats), |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3682 make_number (total_free_floats)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3683 total[5] = Fcons (make_number (total_intervals), |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3684 make_number (total_free_intervals)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3685 total[6] = Fcons (make_number (total_strings), |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3686 make_number (total_free_strings)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3687 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3688 #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
|
3689 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3690 /* 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
|
3691 double nlive = 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3692 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3693 for (i = 0; i < 7; ++i) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3694 nlive += XFASTINT (XCAR (total[i])); |
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 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
|
3697 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
|
3698 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
|
3699 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
|
3700 ++ngcs; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3701 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3702 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3703 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3704 return Flist (7, total); |
300 | 3705 } |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3706 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3707 |
25367
823e14641544
(mark_glyph_matrix): Mark strings only.
Gerd Moellmann <gerd@gnu.org>
parents:
25343
diff
changeset
|
3708 /* 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
|
3709 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
|
3710 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3711 static void |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3712 mark_glyph_matrix (matrix) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3713 struct glyph_matrix *matrix; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3714 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3715 struct glyph_row *row = matrix->rows; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3716 struct glyph_row *end = row + matrix->nrows; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3717 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3718 for (; row < end; ++row) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3719 if (row->enabled_p) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3720 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3721 int area; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3722 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
|
3723 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3724 struct glyph *glyph = row->glyphs[area]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3725 struct glyph *end_glyph = glyph + row->used[area]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3726 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3727 for (; glyph < end_glyph; ++glyph) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3728 if (GC_STRINGP (glyph->object) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3729 && !STRING_MARKED_P (XSTRING (glyph->object))) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3730 mark_object (&glyph->object); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3731 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3732 } |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3733 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3734 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3735 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3736 /* 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
|
3737 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3738 static void |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3739 mark_face_cache (c) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3740 struct face_cache *c; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3741 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3742 if (c) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3743 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3744 int i, j; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3745 for (i = 0; i < c->used; ++i) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3746 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3747 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
|
3748 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3749 if (face) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3750 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3751 for (j = 0; j < LFACE_VECTOR_SIZE; ++j) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3752 mark_object (&face->lface[j]); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3753 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3754 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3755 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3756 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3757 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3758 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3759 #ifdef HAVE_WINDOW_SYSTEM |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3760 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3761 /* Mark Lisp objects in image IMG. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3762 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3763 static void |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3764 mark_image (img) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3765 struct image *img; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3766 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3767 mark_object (&img->spec); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3768 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3769 if (!NILP (img->data.lisp_val)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3770 mark_object (&img->data.lisp_val); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3771 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3772 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3773 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3774 /* 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
|
3775 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
|
3776 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3777 static void |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3778 mark_image_cache (f) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3779 struct frame *f; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3780 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3781 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
|
3782 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3783 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3784 #endif /* HAVE_X_WINDOWS */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3785 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3786 |
300 | 3787 |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
3788 /* 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
|
3789 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
|
3790 all the references contained in it. */ |
300 | 3791 |
1168
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
3792 #define LAST_MARKED_SIZE 500 |
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
3793 Lisp_Object *last_marked[LAST_MARKED_SIZE]; |
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
3794 int last_marked_index; |
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
3795 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3796 void |
13553
fb12156faaf5
(mark_object): Don't overwrite original argument value.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
3797 mark_object (argptr) |
fb12156faaf5
(mark_object): Don't overwrite original argument value.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
3798 Lisp_Object *argptr; |
300 | 3799 { |
13553
fb12156faaf5
(mark_object): Don't overwrite original argument value.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
3800 Lisp_Object *objptr = argptr; |
300 | 3801 register Lisp_Object obj; |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3802 #ifdef GC_CHECK_MARKED_OBJECTS |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3803 void *po; |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3804 struct mem_node *m; |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3805 #endif |
300 | 3806 |
5868
a7bd57a60cb8
(mark_object): Fetch obj from *objptr at loop, not at the gotos.
Karl Heuer <kwzh@gnu.org>
parents:
5353
diff
changeset
|
3807 loop: |
300 | 3808 obj = *objptr; |
5868
a7bd57a60cb8
(mark_object): Fetch obj from *objptr at loop, not at the gotos.
Karl Heuer <kwzh@gnu.org>
parents:
5353
diff
changeset
|
3809 loop2: |
300 | 3810 XUNMARK (obj); |
3811 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3812 if (PURE_POINTER_P ((PNTR_COMPARISON_TYPE) XPNTR (obj))) |
300 | 3813 return; |
3814 | |
1168
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
3815 last_marked[last_marked_index++] = objptr; |
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
3816 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
|
3817 last_marked_index = 0; |
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
3818 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3819 /* 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
|
3820 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
|
3821 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
|
3822 #ifdef GC_CHECK_MARKED_OBJECTS |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3823 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3824 po = (void *) XPNTR (obj); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3825 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3826 /* 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
|
3827 structure allocated from the heap. */ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3828 #define CHECK_ALLOCATED() \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3829 do { \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3830 m = mem_find (po); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3831 if (m == MEM_NIL) \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3832 abort (); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3833 } while (0) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3834 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3835 /* 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
|
3836 function LIVEP. */ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3837 #define CHECK_LIVE(LIVEP) \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3838 do { \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3839 if (!LIVEP (m, po)) \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3840 abort (); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3841 } while (0) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3842 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3843 /* 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
|
3844 #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
|
3845 do { \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3846 CHECK_ALLOCATED (); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3847 CHECK_LIVE (LIVEP); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3848 } while (0) \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3849 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3850 #else /* not GC_CHECK_MARKED_OBJECTS */ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3851 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3852 #define CHECK_ALLOCATED() (void) 0 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3853 #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
|
3854 #define CHECK_ALLOCATED_AND_LIVE(LIVEP) (void) 0 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3855 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3856 #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
|
3857 |
10457
2ab3bd0288a9
Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents:
10427
diff
changeset
|
3858 switch (SWITCH_ENUM_CAST (XGCTYPE (obj))) |
300 | 3859 { |
3860 case Lisp_String: | |
3861 { | |
3862 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
|
3863 CHECK_ALLOCATED_AND_LIVE (live_string_p); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
3864 MARK_INTERVAL_TREE (ptr->intervals); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3865 MARK_STRING (ptr); |
300 | 3866 } |
3867 break; | |
3868 | |
10009
82f3daf76995
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
10004
diff
changeset
|
3869 case Lisp_Vectorlike: |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3870 #ifdef GC_CHECK_MARKED_OBJECTS |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3871 m = mem_find (po); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3872 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
|
3873 && po != &buffer_defaults |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3874 && po != &buffer_local_symbols) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3875 abort (); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3876 #endif /* GC_CHECK_MARKED_OBJECTS */ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3877 |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
3878 if (GC_BUFFERP (obj)) |
10340
ef58c7a5a4d6
(mark_object, mark_buffer): Don't mark buffer twice.
Karl Heuer <kwzh@gnu.org>
parents:
10320
diff
changeset
|
3879 { |
ef58c7a5a4d6
(mark_object, mark_buffer): Don't mark buffer twice.
Karl Heuer <kwzh@gnu.org>
parents:
10320
diff
changeset
|
3880 if (!XMARKBIT (XBUFFER (obj)->name)) |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3881 { |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3882 #ifdef GC_CHECK_MARKED_OBJECTS |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3883 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
|
3884 { |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3885 struct buffer *b; |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3886 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
|
3887 ; |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3888 if (b == NULL) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3889 abort (); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3890 } |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3891 #endif /* GC_CHECK_MARKED_OBJECTS */ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3892 mark_buffer (obj); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3893 } |
10340
ef58c7a5a4d6
(mark_object, mark_buffer): Don't mark buffer twice.
Karl Heuer <kwzh@gnu.org>
parents:
10320
diff
changeset
|
3894 } |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
3895 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
|
3896 break; |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3897 else if (GC_COMPILEDP (obj)) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3898 /* 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
|
3899 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
|
3900 recursion there. */ |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3901 { |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3902 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
|
3903 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
|
3904 /* See comment above under Lisp_Vector. */ |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3905 struct Lisp_Vector *volatile ptr1 = ptr; |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3906 register int i; |
300 | 3907 |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3908 if (size & ARRAY_MARK_FLAG) |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3909 break; /* Already marked */ |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3910 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3911 CHECK_LIVE (live_vector_p); |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3912 ptr->size |= ARRAY_MARK_FLAG; /* Else mark it */ |
10009
82f3daf76995
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
10004
diff
changeset
|
3913 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
|
3914 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
|
3915 { |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3916 if (i != COMPILED_CONSTANTS) |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3917 mark_object (&ptr1->contents[i]); |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3918 } |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3919 /* This cast should be unnecessary, but some Mips compiler complains |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3920 (MIPS-ABI + SysVR4, DC/OSx, etc). */ |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3921 objptr = (Lisp_Object *) &ptr1->contents[COMPILED_CONSTANTS]; |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3922 goto loop; |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3923 } |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3924 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
|
3925 { |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3926 /* See comment above under Lisp_Vector for why this is volatile. */ |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3927 register struct frame *volatile ptr = XFRAME (obj); |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3928 register EMACS_INT size = ptr->size; |
1295
a9241dc503ab
(mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents:
1168
diff
changeset
|
3929 |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3930 if (size & ARRAY_MARK_FLAG) break; /* Already marked */ |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3931 ptr->size |= ARRAY_MARK_FLAG; /* 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
|
3932 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3933 CHECK_LIVE (live_vector_p); |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3934 mark_object (&ptr->name); |
12273
377cbbd8a2ad
(mark_object): Mark icon_name field.
Richard M. Stallman <rms@gnu.org>
parents:
12175
diff
changeset
|
3935 mark_object (&ptr->icon_name); |
14216
5970a52070bb
(mark_object): Mark frame title field.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
3936 mark_object (&ptr->title); |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3937 mark_object (&ptr->focus_frame); |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3938 mark_object (&ptr->selected_window); |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3939 mark_object (&ptr->minibuffer_window); |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3940 mark_object (&ptr->param_alist); |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3941 mark_object (&ptr->scroll_bars); |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3942 mark_object (&ptr->condemned_scroll_bars); |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3943 mark_object (&ptr->menu_bar_items); |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3944 mark_object (&ptr->face_alist); |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3945 mark_object (&ptr->menu_bar_vector); |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
3946 mark_object (&ptr->buffer_predicate); |
17217
571d0c136e48
(mark_object): Mark the buffer_list field.
Richard M. Stallman <rms@gnu.org>
parents:
17021
diff
changeset
|
3947 mark_object (&ptr->buffer_list); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3948 mark_object (&ptr->menu_bar_window); |
25544
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25452
diff
changeset
|
3949 mark_object (&ptr->tool_bar_window); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3950 mark_face_cache (ptr->face_cache); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3951 #ifdef HAVE_WINDOW_SYSTEM |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3952 mark_image_cache (ptr); |
25544
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25452
diff
changeset
|
3953 mark_object (&ptr->desired_tool_bar_items); |
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25452
diff
changeset
|
3954 mark_object (&ptr->current_tool_bar_items); |
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25452
diff
changeset
|
3955 mark_object (&ptr->desired_tool_bar_string); |
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25452
diff
changeset
|
3956 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
|
3957 #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
|
3958 } |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
3959 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
|
3960 { |
5cd52d4838f8
(mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents:
14959
diff
changeset
|
3961 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
|
3962 |
5cd52d4838f8
(mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents:
14959
diff
changeset
|
3963 if (ptr->size & ARRAY_MARK_FLAG) |
5cd52d4838f8
(mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents:
14959
diff
changeset
|
3964 break; /* Already marked */ |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3965 CHECK_LIVE (live_vector_p); |
15379
5cd52d4838f8
(mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents:
14959
diff
changeset
|
3966 ptr->size |= ARRAY_MARK_FLAG; /* Else mark it */ |
5cd52d4838f8
(mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents:
14959
diff
changeset
|
3967 } |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3968 else if (GC_WINDOWP (obj)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3969 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3970 register struct Lisp_Vector *ptr = XVECTOR (obj); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3971 struct window *w = XWINDOW (obj); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3972 register EMACS_INT size = ptr->size; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3973 /* The reason we use ptr1 is to avoid an apparent hardware bug |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3974 that happens occasionally on the FSF's HP 300s. |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3975 The bug is that a2 gets clobbered by recursive calls to mark_object. |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3976 The clobberage seems to happen during function entry, |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3977 perhaps in the moveml instruction. |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3978 Yes, this is a crock, but we have to do it. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3979 struct Lisp_Vector *volatile ptr1 = ptr; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3980 register int i; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3981 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3982 /* Stop if already marked. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3983 if (size & ARRAY_MARK_FLAG) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3984 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3985 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3986 /* Mark it. */ |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
3987 CHECK_LIVE (live_vector_p); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3988 ptr->size |= ARRAY_MARK_FLAG; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3989 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3990 /* 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
|
3991 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
|
3992 for (i = 0; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3993 (char *) &ptr1->contents[i] < (char *) &w->current_matrix; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3994 i++) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3995 mark_object (&ptr1->contents[i]); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3996 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
3997 /* 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
|
3998 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
|
3999 memory. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4000 if (NILP (w->hchild) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4001 && NILP (w->vchild) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4002 && w->current_matrix) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4003 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4004 mark_glyph_matrix (w->current_matrix); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4005 mark_glyph_matrix (w->desired_matrix); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4006 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4007 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4008 else if (GC_HASH_TABLE_P (obj)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4009 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4010 struct Lisp_Hash_Table *h = XHASH_TABLE (obj); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4011 EMACS_INT size = h->size; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4012 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4013 /* Stop if already marked. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4014 if (size & ARRAY_MARK_FLAG) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4015 break; |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4016 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4017 /* Mark it. */ |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4018 CHECK_LIVE (live_vector_p); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4019 h->size |= ARRAY_MARK_FLAG; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4020 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4021 /* Mark contents. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4022 mark_object (&h->test); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4023 mark_object (&h->weak); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4024 mark_object (&h->rehash_size); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4025 mark_object (&h->rehash_threshold); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4026 mark_object (&h->hash); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4027 mark_object (&h->next); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4028 mark_object (&h->index); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4029 mark_object (&h->user_hash_function); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4030 mark_object (&h->user_cmp_function); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4031 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4032 /* 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
|
4033 For weak tables, mark only the vector. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4034 if (GC_NILP (h->weak)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4035 mark_object (&h->key_and_value); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4036 else |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4037 XVECTOR (h->key_and_value)->size |= ARRAY_MARK_FLAG; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4038 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4039 } |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4040 else |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4041 { |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4042 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
|
4043 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
|
4044 /* The reason we use ptr1 is to avoid an apparent hardware bug |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4045 that happens occasionally on the FSF's HP 300s. |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4046 The bug is that a2 gets clobbered by recursive calls to mark_object. |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4047 The clobberage seems to happen during function entry, |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4048 perhaps in the moveml instruction. |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4049 Yes, this is a crock, but we have to do it. */ |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4050 struct Lisp_Vector *volatile ptr1 = ptr; |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4051 register int i; |
300 | 4052 |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4053 if (size & ARRAY_MARK_FLAG) break; /* Already marked */ |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4054 CHECK_LIVE (live_vector_p); |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4055 ptr->size |= ARRAY_MARK_FLAG; /* Else mark it */ |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4056 if (size & PSEUDOVECTOR_FLAG) |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4057 size &= PSEUDOVECTOR_SIZE_MASK; |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4058 |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4059 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
|
4060 mark_object (&ptr1->contents[i]); |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4061 } |
300 | 4062 break; |
4063 | |
4064 case Lisp_Symbol: | |
4065 { | |
4494
15b073a6c860
(mark_object): Declare ptr volatile, or don't use it
Richard M. Stallman <rms@gnu.org>
parents:
4212
diff
changeset
|
4066 /* See comment above under Lisp_Vector for why this is volatile. */ |
15b073a6c860
(mark_object): Declare ptr volatile, or don't use it
Richard M. Stallman <rms@gnu.org>
parents:
4212
diff
changeset
|
4067 register struct Lisp_Symbol *volatile ptr = XSYMBOL (obj); |
300 | 4068 struct Lisp_Symbol *ptrx; |
4069 | |
4070 if (XMARKBIT (ptr->plist)) break; | |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4071 CHECK_ALLOCATED_AND_LIVE (live_symbol_p); |
300 | 4072 XMARK (ptr->plist); |
4073 mark_object ((Lisp_Object *) &ptr->value); | |
4074 mark_object (&ptr->function); | |
4075 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
|
4076 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4077 if (!PURE_POINTER_P (ptr->name)) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4078 MARK_STRING (ptr->name); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4079 MARK_INTERVAL_TREE (ptr->name->intervals); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4080 |
20768 | 4081 /* Note that we do not mark the obarray of the symbol. |
4082 It is safe not to do so because nothing accesses that | |
4083 slot except to check whether it is nil. */ | |
300 | 4084 ptr = ptr->next; |
4085 if (ptr) | |
4086 { | |
5868
a7bd57a60cb8
(mark_object): Fetch obj from *objptr at loop, not at the gotos.
Karl Heuer <kwzh@gnu.org>
parents:
5353
diff
changeset
|
4087 /* For the benefit of the last_marked log. */ |
a7bd57a60cb8
(mark_object): Fetch obj from *objptr at loop, not at the gotos.
Karl Heuer <kwzh@gnu.org>
parents:
5353
diff
changeset
|
4088 objptr = (Lisp_Object *)&XSYMBOL (obj)->next; |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
4089 ptrx = ptr; /* Use of ptrx avoids compiler bug on Sun */ |
300 | 4090 XSETSYMBOL (obj, ptrx); |
5868
a7bd57a60cb8
(mark_object): Fetch obj from *objptr at loop, not at the gotos.
Karl Heuer <kwzh@gnu.org>
parents:
5353
diff
changeset
|
4091 /* We can't goto loop here because *objptr doesn't contain an |
a7bd57a60cb8
(mark_object): Fetch obj from *objptr at loop, not at the gotos.
Karl Heuer <kwzh@gnu.org>
parents:
5353
diff
changeset
|
4092 actual Lisp_Object with valid datatype field. */ |
a7bd57a60cb8
(mark_object): Fetch obj from *objptr at loop, not at the gotos.
Karl Heuer <kwzh@gnu.org>
parents:
5353
diff
changeset
|
4093 goto loop2; |
300 | 4094 } |
4095 } | |
4096 break; | |
4097 | |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
4098 case Lisp_Misc: |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4099 CHECK_ALLOCATED_AND_LIVE (live_misc_p); |
11243
054ecfce1820
(Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents:
11048
diff
changeset
|
4100 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
|
4101 { |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
4102 case Lisp_Misc_Marker: |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
4103 XMARK (XMARKER (obj)->chain); |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
4104 /* DO NOT mark thru the marker's chain. |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
4105 The buffer's markers chain does not preserve markers from gc; |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
4106 instead, markers are removed from the chain when freed by gc. */ |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
4107 break; |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
4108 |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4109 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
|
4110 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
|
4111 { |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4112 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
|
4113 = XBUFFER_LOCAL_VALUE (obj); |
21143
ce12eac1ee45
(gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents:
21084
diff
changeset
|
4114 if (XMARKBIT (ptr->realvalue)) break; |
ce12eac1ee45
(gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents:
21084
diff
changeset
|
4115 XMARK (ptr->realvalue); |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4116 /* 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
|
4117 if (EQ (ptr->cdr, Qnil)) |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4118 { |
21143
ce12eac1ee45
(gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents:
21084
diff
changeset
|
4119 objptr = &ptr->realvalue; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4120 goto loop; |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4121 } |
21143
ce12eac1ee45
(gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents:
21084
diff
changeset
|
4122 mark_object (&ptr->realvalue); |
ce12eac1ee45
(gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents:
21084
diff
changeset
|
4123 mark_object (&ptr->buffer); |
ce12eac1ee45
(gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents:
21084
diff
changeset
|
4124 mark_object (&ptr->frame); |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4125 /* See comment above under Lisp_Vector for why not use ptr here. */ |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4126 objptr = &XBUFFER_LOCAL_VALUE (obj)->cdr; |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4127 goto loop; |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4128 } |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4129 |
9463
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4130 case Lisp_Misc_Intfwd: |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4131 case Lisp_Misc_Boolfwd: |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4132 case Lisp_Misc_Objfwd: |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4133 case Lisp_Misc_Buffer_Objfwd: |
11018
2d9bdf1ba3d1
(mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents:
10936
diff
changeset
|
4134 case Lisp_Misc_Kboard_Objfwd: |
9463
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4135 /* Don't bother with Lisp_Buffer_Objfwd, |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4136 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
|
4137 /* 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
|
4138 are protected with staticpro. */ |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4139 break; |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4140 |
9926
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4141 case Lisp_Misc_Overlay: |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4142 { |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4143 struct Lisp_Overlay *ptr = XOVERLAY (obj); |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4144 if (!XMARKBIT (ptr->plist)) |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4145 { |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4146 XMARK (ptr->plist); |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4147 mark_object (&ptr->start); |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4148 mark_object (&ptr->end); |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4149 objptr = &ptr->plist; |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4150 goto loop; |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4151 } |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4152 } |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4153 break; |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4154 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
4155 default: |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
4156 abort (); |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
4157 } |
300 | 4158 break; |
4159 | |
4160 case Lisp_Cons: | |
4161 { | |
4162 register struct Lisp_Cons *ptr = XCONS (obj); | |
4163 if (XMARKBIT (ptr->car)) break; | |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4164 CHECK_ALLOCATED_AND_LIVE (live_cons_p); |
300 | 4165 XMARK (ptr->car); |
1295
a9241dc503ab
(mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents:
1168
diff
changeset
|
4166 /* 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
|
4167 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
|
4168 { |
a9241dc503ab
(mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents:
1168
diff
changeset
|
4169 objptr = &ptr->car; |
a9241dc503ab
(mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents:
1168
diff
changeset
|
4170 goto loop; |
a9241dc503ab
(mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents:
1168
diff
changeset
|
4171 } |
300 | 4172 mark_object (&ptr->car); |
4494
15b073a6c860
(mark_object): Declare ptr volatile, or don't use it
Richard M. Stallman <rms@gnu.org>
parents:
4212
diff
changeset
|
4173 /* See comment above under Lisp_Vector for why not use ptr here. */ |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4174 objptr = &XCDR (obj); |
300 | 4175 goto loop; |
4176 } | |
4177 | |
4178 case Lisp_Float: | |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4179 CHECK_ALLOCATED_AND_LIVE (live_float_p); |
300 | 4180 XMARK (XFLOAT (obj)->type); |
4181 break; | |
4182 | |
4183 case Lisp_Int: | |
4184 break; | |
4185 | |
4186 default: | |
4187 abort (); | |
4188 } | |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4189 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4190 #undef CHECK_LIVE |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4191 #undef CHECK_ALLOCATED |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4192 #undef CHECK_ALLOCATED_AND_LIVE |
300 | 4193 } |
4194 | |
4195 /* Mark the pointers in a buffer structure. */ | |
4196 | |
4197 static void | |
4198 mark_buffer (buf) | |
4199 Lisp_Object buf; | |
4200 { | |
4201 register struct buffer *buffer = XBUFFER (buf); | |
4202 register Lisp_Object *ptr; | |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
4203 Lisp_Object base_buffer; |
300 | 4204 |
4205 /* This is the buffer's markbit */ | |
4206 mark_object (&buffer->name); | |
4207 XMARK (buffer->name); | |
4208 | |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
4209 MARK_INTERVAL_TREE (BUF_INTERVALS (buffer)); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4210 |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4211 if (CONSP (buffer->undo_list)) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4212 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4213 Lisp_Object tail; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4214 tail = buffer->undo_list; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4215 |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4216 while (CONSP (tail)) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4217 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4218 register struct Lisp_Cons *ptr = XCONS (tail); |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4219 |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4220 if (XMARKBIT (ptr->car)) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4221 break; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4222 XMARK (ptr->car); |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4223 if (GC_CONSP (ptr->car) |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4224 && ! XMARKBIT (XCAR (ptr->car)) |
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4225 && GC_MARKERP (XCAR (ptr->car))) |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4226 { |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4227 XMARK (XCAR (ptr->car)); |
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4228 mark_object (&XCDR (ptr->car)); |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4229 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4230 else |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4231 mark_object (&ptr->car); |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4232 |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4233 if (CONSP (ptr->cdr)) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4234 tail = ptr->cdr; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4235 else |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4236 break; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4237 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4238 |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4239 mark_object (&XCDR (tail)); |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4240 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4241 else |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4242 mark_object (&buffer->undo_list); |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4243 |
300 | 4244 for (ptr = &buffer->name + 1; |
4245 (char *)ptr < (char *)buffer + sizeof (struct buffer); | |
4246 ptr++) | |
4247 mark_object (ptr); | |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
4248 |
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
4249 /* If this is an indirect buffer, mark its base buffer. */ |
10340
ef58c7a5a4d6
(mark_object, mark_buffer): Don't mark buffer twice.
Karl Heuer <kwzh@gnu.org>
parents:
10320
diff
changeset
|
4250 if (buffer->base_buffer && !XMARKBIT (buffer->base_buffer->name)) |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
4251 { |
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
4252 XSETBUFFER (base_buffer, buffer->base_buffer); |
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
4253 mark_buffer (base_buffer); |
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
4254 } |
300 | 4255 } |
10649
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
4256 |
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
4257 |
11018
2d9bdf1ba3d1
(mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents:
10936
diff
changeset
|
4258 /* Mark the pointers in the kboard objects. */ |
10649
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
4259 |
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
4260 static void |
11018
2d9bdf1ba3d1
(mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents:
10936
diff
changeset
|
4261 mark_kboards () |
10649
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
4262 { |
11018
2d9bdf1ba3d1
(mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents:
10936
diff
changeset
|
4263 KBOARD *kb; |
11593
f5385353aae3
(mark_kboards): Mark the kbd macro and Vsystem_key_alist.
Karl Heuer <kwzh@gnu.org>
parents:
11430
diff
changeset
|
4264 Lisp_Object *p; |
11018
2d9bdf1ba3d1
(mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents:
10936
diff
changeset
|
4265 for (kb = all_kboards; kb; kb = kb->next_kboard) |
10649
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
4266 { |
11593
f5385353aae3
(mark_kboards): Mark the kbd macro and Vsystem_key_alist.
Karl Heuer <kwzh@gnu.org>
parents:
11430
diff
changeset
|
4267 if (kb->kbd_macro_buffer) |
f5385353aae3
(mark_kboards): Mark the kbd macro and Vsystem_key_alist.
Karl Heuer <kwzh@gnu.org>
parents:
11430
diff
changeset
|
4268 for (p = kb->kbd_macro_buffer; p < kb->kbd_macro_ptr; p++) |
f5385353aae3
(mark_kboards): Mark the kbd macro and Vsystem_key_alist.
Karl Heuer <kwzh@gnu.org>
parents:
11430
diff
changeset
|
4269 mark_object (p); |
22381
50e1804145be
(mark_kboards): Mark all the Lisp_Object fields.
Richard M. Stallman <rms@gnu.org>
parents:
22220
diff
changeset
|
4270 mark_object (&kb->Voverriding_terminal_local_map); |
50e1804145be
(mark_kboards): Mark all the Lisp_Object fields.
Richard M. Stallman <rms@gnu.org>
parents:
22220
diff
changeset
|
4271 mark_object (&kb->Vlast_command); |
50e1804145be
(mark_kboards): Mark all the Lisp_Object fields.
Richard M. Stallman <rms@gnu.org>
parents:
22220
diff
changeset
|
4272 mark_object (&kb->Vreal_last_command); |
12120
1fc112b5fdc4
(mark_kboards): Mark Vprefix_arg instead of
Karl Heuer <kwzh@gnu.org>
parents:
12096
diff
changeset
|
4273 mark_object (&kb->Vprefix_arg); |
22382
f7d2bdefcff7
(mark_kboards): Mark Vlast_prefix_arg too.
Richard M. Stallman <rms@gnu.org>
parents:
22381
diff
changeset
|
4274 mark_object (&kb->Vlast_prefix_arg); |
11018
2d9bdf1ba3d1
(mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents:
10936
diff
changeset
|
4275 mark_object (&kb->kbd_queue); |
22381
50e1804145be
(mark_kboards): Mark all the Lisp_Object fields.
Richard M. Stallman <rms@gnu.org>
parents:
22220
diff
changeset
|
4276 mark_object (&kb->defining_kbd_macro); |
11018
2d9bdf1ba3d1
(mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents:
10936
diff
changeset
|
4277 mark_object (&kb->Vlast_kbd_macro); |
11593
f5385353aae3
(mark_kboards): Mark the kbd macro and Vsystem_key_alist.
Karl Heuer <kwzh@gnu.org>
parents:
11430
diff
changeset
|
4278 mark_object (&kb->Vsystem_key_alist); |
12175
4e36e9e99082
(mark_kboards): Mark system_key_syms member.
Karl Heuer <kwzh@gnu.org>
parents:
12120
diff
changeset
|
4279 mark_object (&kb->system_key_syms); |
22381
50e1804145be
(mark_kboards): Mark all the Lisp_Object fields.
Richard M. Stallman <rms@gnu.org>
parents:
22220
diff
changeset
|
4280 mark_object (&kb->Vdefault_minibuffer_frame); |
10649
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
4281 } |
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
4282 } |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4283 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4284 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4285 /* 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
|
4286 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
|
4287 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4288 int |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4289 survives_gc_p (obj) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4290 Lisp_Object obj; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4291 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4292 int survives_p; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4293 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4294 switch (XGCTYPE (obj)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4295 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4296 case Lisp_Int: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4297 survives_p = 1; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4298 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4299 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4300 case Lisp_Symbol: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4301 survives_p = XMARKBIT (XSYMBOL (obj)->plist); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4302 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4303 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4304 case Lisp_Misc: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4305 switch (XMISCTYPE (obj)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4306 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4307 case Lisp_Misc_Marker: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4308 survives_p = XMARKBIT (obj); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4309 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4310 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4311 case Lisp_Misc_Buffer_Local_Value: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4312 case Lisp_Misc_Some_Buffer_Local_Value: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4313 survives_p = XMARKBIT (XBUFFER_LOCAL_VALUE (obj)->realvalue); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4314 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4315 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4316 case Lisp_Misc_Intfwd: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4317 case Lisp_Misc_Boolfwd: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4318 case Lisp_Misc_Objfwd: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4319 case Lisp_Misc_Buffer_Objfwd: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4320 case Lisp_Misc_Kboard_Objfwd: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4321 survives_p = 1; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4322 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4323 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4324 case Lisp_Misc_Overlay: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4325 survives_p = XMARKBIT (XOVERLAY (obj)->plist); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4326 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4327 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4328 default: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4329 abort (); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4330 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4331 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4332 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4333 case Lisp_String: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4334 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4335 struct Lisp_String *s = XSTRING (obj); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4336 survives_p = STRING_MARKED_P (s); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4337 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4338 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4339 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4340 case Lisp_Vectorlike: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4341 if (GC_BUFFERP (obj)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4342 survives_p = XMARKBIT (XBUFFER (obj)->name); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4343 else if (GC_SUBRP (obj)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4344 survives_p = 1; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4345 else |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4346 survives_p = XVECTOR (obj)->size & ARRAY_MARK_FLAG; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4347 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4348 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4349 case Lisp_Cons: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4350 survives_p = XMARKBIT (XCAR (obj)); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4351 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4352 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4353 case Lisp_Float: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4354 survives_p = XMARKBIT (XFLOAT (obj)->type); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4355 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4356 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4357 default: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4358 abort (); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4359 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4360 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4361 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
|
4362 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4363 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4364 |
300 | 4365 |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
4366 /* Sweep: find all structures not marked, and free them. */ |
300 | 4367 |
4368 static void | |
4369 gc_sweep () | |
4370 { | |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4371 /* Remove or mark entries in weak hash tables. |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4372 This must be done before any object is unmarked. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4373 sweep_weak_hash_tables (); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4374 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4375 sweep_strings (); |
300 | 4376 |
4377 /* Put all unmarked conses on free list */ | |
4378 { | |
4379 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
|
4380 struct cons_block **cprev = &cons_block; |
300 | 4381 register int lim = cons_block_index; |
4382 register int num_free = 0, num_used = 0; | |
4383 | |
4384 cons_free_list = 0; | |
4385 | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4386 for (cblk = cons_block; cblk; cblk = *cprev) |
300 | 4387 { |
4388 register int i; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4389 int this_free = 0; |
300 | 4390 for (i = 0; i < lim; i++) |
4391 if (!XMARKBIT (cblk->conses[i].car)) | |
4392 { | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4393 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
|
4394 *(struct Lisp_Cons **)&cblk->conses[i].cdr = cons_free_list; |
300 | 4395 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
|
4396 #if GC_MARK_STACK |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4397 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
|
4398 #endif |
300 | 4399 } |
4400 else | |
4401 { | |
4402 num_used++; | |
4403 XUNMARK (cblk->conses[i].car); | |
4404 } | |
4405 lim = CONS_BLOCK_SIZE; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4406 /* 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
|
4407 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
|
4408 this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4409 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
|
4410 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4411 *cprev = cblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4412 /* Unhook from the free list. */ |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4413 cons_free_list = *(struct Lisp_Cons **) &cblk->conses[0].cdr; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
4414 lisp_free (cblk); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
4415 n_cons_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4416 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4417 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4418 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4419 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4420 cprev = &cblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4421 } |
300 | 4422 } |
4423 total_conses = num_used; | |
4424 total_free_conses = num_free; | |
4425 } | |
4426 | |
4427 /* Put all unmarked floats on free list */ | |
4428 { | |
4429 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
|
4430 struct float_block **fprev = &float_block; |
300 | 4431 register int lim = float_block_index; |
4432 register int num_free = 0, num_used = 0; | |
4433 | |
4434 float_free_list = 0; | |
4435 | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4436 for (fblk = float_block; fblk; fblk = *fprev) |
300 | 4437 { |
4438 register int i; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4439 int this_free = 0; |
300 | 4440 for (i = 0; i < lim; i++) |
4441 if (!XMARKBIT (fblk->floats[i].type)) | |
4442 { | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4443 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
|
4444 *(struct Lisp_Float **)&fblk->floats[i].data = float_free_list; |
300 | 4445 float_free_list = &fblk->floats[i]; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4446 #if GC_MARK_STACK |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4447 float_free_list->type = Vdead; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4448 #endif |
300 | 4449 } |
4450 else | |
4451 { | |
4452 num_used++; | |
4453 XUNMARK (fblk->floats[i].type); | |
4454 } | |
4455 lim = FLOAT_BLOCK_SIZE; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4456 /* 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
|
4457 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
|
4458 this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4459 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
|
4460 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4461 *fprev = fblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4462 /* Unhook from the free list. */ |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4463 float_free_list = *(struct Lisp_Float **) &fblk->floats[0].data; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
4464 lisp_free (fblk); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
4465 n_float_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4466 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4467 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4468 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4469 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4470 fprev = &fblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4471 } |
300 | 4472 } |
4473 total_floats = num_used; | |
4474 total_free_floats = num_free; | |
4475 } | |
4476 | |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4477 /* Put all unmarked intervals on free list */ |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4478 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4479 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
|
4480 struct interval_block **iprev = &interval_block; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4481 register int lim = interval_block_index; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4482 register int num_free = 0, num_used = 0; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4483 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4484 interval_free_list = 0; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4485 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4486 for (iblk = interval_block; iblk; iblk = *iprev) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4487 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4488 register int i; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4489 int this_free = 0; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4490 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4491 for (i = 0; i < lim; i++) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4492 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4493 if (! XMARKBIT (iblk->intervals[i].plist)) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4494 { |
28269
fd13be8ae190
Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents:
28220
diff
changeset
|
4495 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
|
4496 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
|
4497 this_free++; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4498 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4499 else |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4500 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4501 num_used++; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4502 XUNMARK (iblk->intervals[i].plist); |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4503 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4504 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4505 lim = INTERVAL_BLOCK_SIZE; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4506 /* 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
|
4507 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
|
4508 deallocate this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4509 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
|
4510 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4511 *iprev = iblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4512 /* Unhook from the free list. */ |
28269
fd13be8ae190
Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents:
28220
diff
changeset
|
4513 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
|
4514 lisp_free (iblk); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
4515 n_interval_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4516 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4517 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4518 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4519 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4520 iprev = &iblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4521 } |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4522 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4523 total_intervals = num_used; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4524 total_free_intervals = num_free; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4525 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4526 |
300 | 4527 /* Put all unmarked symbols on free list */ |
4528 { | |
4529 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
|
4530 struct symbol_block **sprev = &symbol_block; |
300 | 4531 register int lim = symbol_block_index; |
4532 register int num_free = 0, num_used = 0; | |
4533 | |
4534 symbol_free_list = 0; | |
4535 | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4536 for (sblk = symbol_block; sblk; sblk = *sprev) |
300 | 4537 { |
4538 register int i; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4539 int this_free = 0; |
300 | 4540 for (i = 0; i < lim; i++) |
4541 if (!XMARKBIT (sblk->symbols[i].plist)) | |
4542 { | |
9942
c189487b08dd
(free_float): Don't assume XFASTINT accesses the raw bits.
Karl Heuer <kwzh@gnu.org>
parents:
9926
diff
changeset
|
4543 *(struct Lisp_Symbol **)&sblk->symbols[i].value = symbol_free_list; |
300 | 4544 symbol_free_list = &sblk->symbols[i]; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4545 #if GC_MARK_STACK |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4546 symbol_free_list->function = Vdead; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4547 #endif |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4548 this_free++; |
300 | 4549 } |
4550 else | |
4551 { | |
4552 num_used++; | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4553 if (!PURE_POINTER_P (sblk->symbols[i].name)) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4554 UNMARK_STRING (sblk->symbols[i].name); |
300 | 4555 XUNMARK (sblk->symbols[i].plist); |
4556 } | |
4557 lim = SYMBOL_BLOCK_SIZE; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4558 /* 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
|
4559 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
|
4560 this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4561 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
|
4562 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4563 *sprev = sblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4564 /* Unhook from the free list. */ |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4565 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
|
4566 lisp_free (sblk); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
4567 n_symbol_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4568 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4569 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4570 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4571 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4572 sprev = &sblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4573 } |
300 | 4574 } |
4575 total_symbols = num_used; | |
4576 total_free_symbols = num_free; | |
4577 } | |
4578 | |
21143
ce12eac1ee45
(gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents:
21084
diff
changeset
|
4579 /* 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
|
4580 For a marker, first unchain it from the buffer it points into. */ |
300 | 4581 { |
4582 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
|
4583 struct marker_block **mprev = &marker_block; |
300 | 4584 register int lim = marker_block_index; |
4585 register int num_free = 0, num_used = 0; | |
4586 | |
4587 marker_free_list = 0; | |
4588 | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4589 for (mblk = marker_block; mblk; mblk = *mprev) |
300 | 4590 { |
4591 register int i; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4592 int this_free = 0; |
11679
1ced2d67d411
(gc_cons_threshold): Make this an EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
11593
diff
changeset
|
4593 EMACS_INT already_free = -1; |
11403
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
4594 |
300 | 4595 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
|
4596 { |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4597 Lisp_Object *markword; |
11243
054ecfce1820
(Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents:
11048
diff
changeset
|
4598 switch (mblk->markers[i].u_marker.type) |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4599 { |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4600 case Lisp_Misc_Marker: |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4601 markword = &mblk->markers[i].u_marker.chain; |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4602 break; |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4603 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
|
4604 case Lisp_Misc_Some_Buffer_Local_Value: |
21143
ce12eac1ee45
(gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents:
21084
diff
changeset
|
4605 markword = &mblk->markers[i].u_buffer_local_value.realvalue; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4606 break; |
9926
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4607 case Lisp_Misc_Overlay: |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4608 markword = &mblk->markers[i].u_overlay.plist; |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4609 break; |
11403
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
4610 case Lisp_Misc_Free: |
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
4611 /* If the object was already free, keep it |
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
4612 on the free list. */ |
18621
53b95f307c75
(memory_full): Pass Qnil to Fsignal for ERROR_SYMBOL.
Richard M. Stallman <rms@gnu.org>
parents:
18104
diff
changeset
|
4613 markword = (Lisp_Object *) &already_free; |
11403
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
4614 break; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4615 default: |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4616 markword = 0; |
9926
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4617 break; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4618 } |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4619 if (markword && !XMARKBIT (*markword)) |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4620 { |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4621 Lisp_Object tem; |
11243
054ecfce1820
(Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents:
11048
diff
changeset
|
4622 if (mblk->markers[i].u_marker.type == Lisp_Misc_Marker) |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4623 { |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4624 /* tem1 avoids Sun compiler bug */ |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4625 struct Lisp_Marker *tem1 = &mblk->markers[i].u_marker; |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4626 XSETMARKER (tem, tem1); |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4627 unchain_marker (tem); |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4628 } |
11403
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
4629 /* 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
|
4630 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
|
4631 but this might catch bugs faster. */ |
11243
054ecfce1820
(Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents:
11048
diff
changeset
|
4632 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
|
4633 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
|
4634 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
|
4635 this_free++; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4636 } |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4637 else |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4638 { |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4639 num_used++; |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4640 if (markword) |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4641 XUNMARK (*markword); |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4642 } |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4643 } |
300 | 4644 lim = MARKER_BLOCK_SIZE; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4645 /* 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
|
4646 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
|
4647 this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4648 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
|
4649 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4650 *mprev = mblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4651 /* Unhook from the free list. */ |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4652 marker_free_list = mblk->markers[0].u_free.chain; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
4653 lisp_free (mblk); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
4654 n_marker_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4655 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
4656 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4657 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4658 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4659 mprev = &mblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
4660 } |
300 | 4661 } |
4662 | |
4663 total_markers = num_used; | |
4664 total_free_markers = num_free; | |
4665 } | |
4666 | |
4667 /* Free all unmarked buffers */ | |
4668 { | |
4669 register struct buffer *buffer = all_buffers, *prev = 0, *next; | |
4670 | |
4671 while (buffer) | |
4672 if (!XMARKBIT (buffer->name)) | |
4673 { | |
4674 if (prev) | |
4675 prev->next = buffer->next; | |
4676 else | |
4677 all_buffers = buffer->next; | |
4678 next = buffer->next; | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4679 lisp_free (buffer); |
300 | 4680 buffer = next; |
4681 } | |
4682 else | |
4683 { | |
4684 XUNMARK (buffer->name); | |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
4685 UNMARK_BALANCE_INTERVALS (BUF_INTERVALS (buffer)); |
300 | 4686 prev = buffer, buffer = buffer->next; |
4687 } | |
4688 } | |
4689 | |
4690 /* Free all unmarked vectors */ | |
4691 { | |
4692 register struct Lisp_Vector *vector = all_vectors, *prev = 0, *next; | |
4693 total_vector_size = 0; | |
4694 | |
4695 while (vector) | |
4696 if (!(vector->size & ARRAY_MARK_FLAG)) | |
4697 { | |
4698 if (prev) | |
4699 prev->next = vector->next; | |
4700 else | |
4701 all_vectors = vector->next; | |
4702 next = vector->next; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
4703 lisp_free (vector); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
4704 n_vectors--; |
300 | 4705 vector = next; |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4706 |
300 | 4707 } |
4708 else | |
4709 { | |
4710 vector->size &= ~ARRAY_MARK_FLAG; | |
11403
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
4711 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
|
4712 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
|
4713 else |
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
4714 total_vector_size += vector->size; |
300 | 4715 prev = vector, vector = vector->next; |
4716 } | |
4717 } | |
4718 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4719 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4720 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4721 |
300 | 4722 |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
4723 /* Debugging aids. */ |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
4724 |
5353
6389ed5b45ac
(Fmemory_limit): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents:
4956
diff
changeset
|
4725 DEFUN ("memory-limit", Fmemory_limit, Smemory_limit, 0, 0, 0, |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
4726 "Return the address of the last byte Emacs has allocated, divided by 1024.\n\ |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
4727 This may be helpful in debugging Emacs's memory usage.\n\ |
1893
b047e77f3be4
(Fmemory_limit): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
1784
diff
changeset
|
4728 We divide the value by 1024 to make sure it fits in a Lisp integer.") |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
4729 () |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
4730 { |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
4731 Lisp_Object end; |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
4732 |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
4733 XSETINT (end, (EMACS_INT) sbrk (0) / 1024); |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
4734 |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
4735 return end; |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
4736 } |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
4737 |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
4738 DEFUN ("memory-use-counts", Fmemory_use_counts, Smemory_use_counts, 0, 0, 0, |
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
4739 "Return a list of counters that measure how much consing there has been.\n\ |
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
4740 Each of these counters increments for a certain kind of object.\n\ |
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
4741 The counters wrap around from the largest positive integer to zero.\n\ |
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
4742 Garbage collection does not decrease them.\n\ |
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
4743 The elements of the value are as follows:\n\ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4744 (CONSES FLOATS VECTOR-CELLS SYMBOLS STRING-CHARS MISCS INTERVALS STRINGS)\n\ |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
4745 All are in units of 1 = one object consed\n\ |
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
4746 except for VECTOR-CELLS and STRING-CHARS, which count the total length of\n\ |
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
4747 objects consed.\n\ |
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
4748 MISCS include overlays, markers, and some internal types.\n\ |
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
4749 Frames, windows, buffers, and subprocesses count as vectors\n\ |
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
4750 (but the contents of a buffer's text do not count here).") |
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
4751 () |
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
4752 { |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4753 Lisp_Object consed[8]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4754 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4755 XSETINT (consed[0], |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
4756 cons_cells_consed & ~(((EMACS_INT) 1) << (VALBITS - 1))); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4757 XSETINT (consed[1], |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
4758 floats_consed & ~(((EMACS_INT) 1) << (VALBITS - 1))); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4759 XSETINT (consed[2], |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
4760 vector_cells_consed & ~(((EMACS_INT) 1) << (VALBITS - 1))); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4761 XSETINT (consed[3], |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
4762 symbols_consed & ~(((EMACS_INT) 1) << (VALBITS - 1))); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4763 XSETINT (consed[4], |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
4764 string_chars_consed & ~(((EMACS_INT) 1) << (VALBITS - 1))); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4765 XSETINT (consed[5], |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
4766 misc_objects_consed & ~(((EMACS_INT) 1) << (VALBITS - 1))); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4767 XSETINT (consed[6], |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
4768 intervals_consed & ~(((EMACS_INT) 1) << (VALBITS - 1))); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4769 XSETINT (consed[7], |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4770 strings_consed & ~(((EMACS_INT) 1) << (VALBITS - 1))); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4771 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4772 return Flist (8, consed); |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
4773 } |
28406
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
4774 |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
4775 int suppress_checking; |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
4776 void |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
4777 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
|
4778 const char *msg; |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
4779 const char *file; |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
4780 int line; |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
4781 { |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
4782 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
|
4783 file, line, msg); |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
4784 abort (); |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
4785 } |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
4786 |
300 | 4787 /* Initialization */ |
4788 | |
21514 | 4789 void |
300 | 4790 init_alloc_once () |
4791 { | |
4792 /* Used to do Vpurify_flag = Qt here, but Qt isn't set up yet! */ | |
4793 pureptr = 0; | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4794 #if GC_MARK_STACK |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4795 mem_init (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4796 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
|
4797 #endif |
356 | 4798 #ifdef HAVE_SHM |
4799 pure_size = PURESIZE; | |
4800 #endif | |
300 | 4801 all_vectors = 0; |
4802 ignore_warnings = 1; | |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
4803 #ifdef DOUG_LEA_MALLOC |
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
4804 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
|
4805 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
|
4806 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
|
4807 #endif |
300 | 4808 init_strings (); |
4809 init_cons (); | |
4810 init_symbol (); | |
4811 init_marker (); | |
4812 init_float (); | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4813 init_intervals (); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4814 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
4815 #ifdef REL_ALLOC |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
4816 malloc_hysteresis = 32; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
4817 #else |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
4818 malloc_hysteresis = 0; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
4819 #endif |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
4820 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
4821 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
|
4822 |
300 | 4823 ignore_warnings = 0; |
4824 gcprolist = 0; | |
26364
7b0217d9259c
(Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents:
26164
diff
changeset
|
4825 byte_stack_list = 0; |
300 | 4826 staticidx = 0; |
4827 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
|
4828 gc_cons_threshold = 100000 * sizeof (Lisp_Object); |
300 | 4829 #ifdef VIRT_ADDR_VARIES |
4830 malloc_sbrk_unused = 1<<22; /* A large number */ | |
4831 malloc_sbrk_used = 100000; /* as reasonable as any number */ | |
4832 #endif /* VIRT_ADDR_VARIES */ | |
4833 } | |
4834 | |
21514 | 4835 void |
300 | 4836 init_alloc () |
4837 { | |
4838 gcprolist = 0; | |
26364
7b0217d9259c
(Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents:
26164
diff
changeset
|
4839 byte_stack_list = 0; |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4840 #if GC_MARK_STACK |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4841 #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
|
4842 setjmp_tested_p = longjmps_done = 0; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4843 #endif |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4844 #endif |
300 | 4845 } |
4846 | |
4847 void | |
4848 syms_of_alloc () | |
4849 { | |
4850 DEFVAR_INT ("gc-cons-threshold", &gc_cons_threshold, | |
4851 "*Number of bytes of consing between garbage collections.\n\ | |
4852 Garbage collection can happen automatically once this many bytes have been\n\ | |
4853 allocated since the last garbage collection. All data types count.\n\n\ | |
4854 Garbage collection happens automatically only when `eval' is called.\n\n\ | |
4855 By binding this temporarily to a large number, you can effectively\n\ | |
4856 prevent garbage collection during a part of the program."); | |
4857 | |
4858 DEFVAR_INT ("pure-bytes-used", &pureptr, | |
4859 "Number of bytes of sharable Lisp data allocated so far."); | |
4860 | |
15960
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4861 DEFVAR_INT ("cons-cells-consed", &cons_cells_consed, |
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4862 "Number of cons cells that have been consed so far."); |
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4863 |
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4864 DEFVAR_INT ("floats-consed", &floats_consed, |
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4865 "Number of floats that have been consed so far."); |
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4866 |
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4867 DEFVAR_INT ("vector-cells-consed", &vector_cells_consed, |
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4868 "Number of vector cells that have been consed so far."); |
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4869 |
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4870 DEFVAR_INT ("symbols-consed", &symbols_consed, |
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4871 "Number of symbols that have been consed so far."); |
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4872 |
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4873 DEFVAR_INT ("string-chars-consed", &string_chars_consed, |
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4874 "Number of string characters that have been consed so far."); |
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4875 |
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4876 DEFVAR_INT ("misc-objects-consed", &misc_objects_consed, |
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4877 "Number of miscellaneous objects that have been consed so far."); |
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4878 |
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4879 DEFVAR_INT ("intervals-consed", &intervals_consed, |
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4880 "Number of intervals that have been consed so far."); |
12c61b25b7b6
(syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents:
15379
diff
changeset
|
4881 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4882 DEFVAR_INT ("strings-consed", &strings_consed, |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4883 "Number of strings that have been consed so far."); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4884 |
300 | 4885 DEFVAR_LISP ("purify-flag", &Vpurify_flag, |
4886 "Non-nil means loading Lisp code in order to dump an executable.\n\ | |
4887 This means that certain objects should be allocated in shared (pure) space."); | |
4888 | |
764 | 4889 DEFVAR_INT ("undo-limit", &undo_limit, |
300 | 4890 "Keep no more undo information once it exceeds this size.\n\ |
764 | 4891 This limit is applied when garbage collection happens.\n\ |
300 | 4892 The size is counted as the number of bytes occupied,\n\ |
4893 which includes both saved text and other data."); | |
764 | 4894 undo_limit = 20000; |
300 | 4895 |
764 | 4896 DEFVAR_INT ("undo-strong-limit", &undo_strong_limit, |
300 | 4897 "Don't keep more than this much size of undo information.\n\ |
4898 A command which pushes past this size is itself forgotten.\n\ | |
764 | 4899 This limit is applied when garbage collection happens.\n\ |
300 | 4900 The size is counted as the number of bytes occupied,\n\ |
4901 which includes both saved text and other data."); | |
764 | 4902 undo_strong_limit = 30000; |
300 | 4903 |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4904 DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages, |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4905 "Non-nil means display messages at start and end of garbage collection."); |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4906 garbage_collection_messages = 0; |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4907 |
6116
64417bbbb128
(memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents:
5874
diff
changeset
|
4908 /* 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
|
4909 not be able to allocate the memory to hold it. */ |
6133
752d4237f869
(memory_signal_data): No longer static.
Richard M. Stallman <rms@gnu.org>
parents:
6116
diff
changeset
|
4910 memory_signal_data |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
4911 = Fcons (Qerror, Fcons (build_string ("Memory exhausted--use M-x save-some-buffers RET"), Qnil)); |
6116
64417bbbb128
(memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents:
5874
diff
changeset
|
4912 staticpro (&memory_signal_data); |
64417bbbb128
(memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents:
5874
diff
changeset
|
4913 |
11374
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4914 staticpro (&Qgc_cons_threshold); |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4915 Qgc_cons_threshold = intern ("gc-cons-threshold"); |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4916 |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
4917 staticpro (&Qchar_table_extra_slots); |
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
4918 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
|
4919 |
300 | 4920 defsubr (&Scons); |
4921 defsubr (&Slist); | |
4922 defsubr (&Svector); | |
4923 defsubr (&Smake_byte_code); | |
4924 defsubr (&Smake_list); | |
4925 defsubr (&Smake_vector); | |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
4926 defsubr (&Smake_char_table); |
300 | 4927 defsubr (&Smake_string); |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
4928 defsubr (&Smake_bool_vector); |
300 | 4929 defsubr (&Smake_symbol); |
4930 defsubr (&Smake_marker); | |
4931 defsubr (&Spurecopy); | |
4932 defsubr (&Sgarbage_collect); | |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
4933 defsubr (&Smemory_limit); |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
4934 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
|
4935 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4936 #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
|
4937 defsubr (&Sgc_status); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4938 #endif |
300 | 4939 } |