Mercurial > emacs
annotate src/alloc.c @ 51423:4b0652a2bde5
(after-find-file): Simplify msg if nonexistent directory.
(make-directory): Doc fix.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 03 Jun 2003 11:08:25 +0000 |
parents | 0b5248964d32 |
children | 42f25a716cb8 |
rev | line source |
---|---|
300 | 1 /* Storage allocation and gc for GNU Emacs Lisp interpreter. |
49139
e807249d08c1
(pure_alloc): Correct alignment for Lisp_Floats.
Andreas Schwab <schwab@suse.de>
parents:
49055
diff
changeset
|
2 Copyright (C) 1985, 86, 88, 93, 94, 95, 97, 98, 1999, 2000, 2001, 2002, 2003 |
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 |
47185
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
25 #ifdef ALLOC_DEBUG |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
26 #undef INLINE |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
27 #endif |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
28 |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
29 /* 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
|
30 |
3003
5a73d384f45e
* syssignal.h: Don't #include <signal.h>
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
31 #include <signal.h> |
300 | 32 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
33 /* GC_MALLOC_CHECK defined means perform validity checks of malloc'd |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
34 memory. Can do this only if using gmalloc.c. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
35 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
36 #if defined SYSTEM_MALLOC || defined DOUG_LEA_MALLOC |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
37 #undef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
38 #endif |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
39 |
26164
d39ec0a27081
more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents:
26088
diff
changeset
|
40 /* This file is part of the core Lisp implementation, and thus must |
d39ec0a27081
more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents:
26088
diff
changeset
|
41 deal with the real data structures. If the Lisp implementation is |
d39ec0a27081
more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents:
26088
diff
changeset
|
42 replaced, this file likely will not be used. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
43 |
26164
d39ec0a27081
more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents:
26088
diff
changeset
|
44 #undef HIDE_LISP_IMPLEMENTATION |
300 | 45 #include "lisp.h" |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
46 #include "process.h" |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
47 #include "intervals.h" |
356 | 48 #include "puresize.h" |
300 | 49 #include "buffer.h" |
50 #include "window.h" | |
31102
6a0caa788013
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30914
diff
changeset
|
51 #include "keyboard.h" |
764 | 52 #include "frame.h" |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
53 #include "blockinput.h" |
21084
371ed7bdfd2b
(Fmake_string): Handle the case INIT is a multibyte character correctly.
Richard M. Stallman <rms@gnu.org>
parents:
20849
diff
changeset
|
54 #include "charset.h" |
638 | 55 #include "syssignal.h" |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
56 #include <setjmp.h> |
638 | 57 |
30784
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
58 #ifdef HAVE_UNISTD_H |
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
59 #include <unistd.h> |
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
60 #else |
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
61 extern POINTER_TYPE *sbrk (); |
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
62 #endif |
12096 | 63 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
64 #ifdef DOUG_LEA_MALLOC |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
65 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
66 #include <malloc.h> |
31892
2f3d88ac2b38
(__malloc_size_t) [DOUG_LEA_MALLOC]: Don't redefine it.
Dave Love <fx@gnu.org>
parents:
31889
diff
changeset
|
67 /* malloc.h #defines this as size_t, at least in glibc2. */ |
2f3d88ac2b38
(__malloc_size_t) [DOUG_LEA_MALLOC]: Don't redefine it.
Dave Love <fx@gnu.org>
parents:
31889
diff
changeset
|
68 #ifndef __malloc_size_t |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
69 #define __malloc_size_t int |
31892
2f3d88ac2b38
(__malloc_size_t) [DOUG_LEA_MALLOC]: Don't redefine it.
Dave Love <fx@gnu.org>
parents:
31889
diff
changeset
|
70 #endif |
23973
2eb9e2f5aa33
(MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
23958
diff
changeset
|
71 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
72 /* 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
|
73 value that explicitly means "no limit". */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
74 |
23973
2eb9e2f5aa33
(MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
23958
diff
changeset
|
75 #define MMAP_MAX_AREAS 100000000 |
2eb9e2f5aa33
(MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
23958
diff
changeset
|
76 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
77 #else /* not DOUG_LEA_MALLOC */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
78 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
79 /* 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
|
80 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
81 #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
|
82 extern __malloc_size_t _bytes_used; |
31892
2f3d88ac2b38
(__malloc_size_t) [DOUG_LEA_MALLOC]: Don't redefine it.
Dave Love <fx@gnu.org>
parents:
31889
diff
changeset
|
83 extern __malloc_size_t __malloc_extra_blocks; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
84 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
85 #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
|
86 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
87 /* 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
|
88 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
89 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
|
90 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
91 /* 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
|
92 to a struct Lisp_String. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
93 |
28469
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
94 #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
|
95 #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
|
96 #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
|
97 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
98 /* 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
|
99 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
|
100 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
|
101 strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
102 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
103 #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
|
104 #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
|
105 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
106 /* 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
|
107 |
300 | 108 int consing_since_gc; |
109 | |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
110 /* 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
|
111 |
43713
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
112 EMACS_INT cons_cells_consed; |
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
113 EMACS_INT floats_consed; |
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
114 EMACS_INT vector_cells_consed; |
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
115 EMACS_INT symbols_consed; |
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
116 EMACS_INT string_chars_consed; |
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
117 EMACS_INT misc_objects_consed; |
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
118 EMACS_INT intervals_consed; |
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
119 EMACS_INT strings_consed; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
120 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
121 /* 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
|
122 |
43713
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
123 EMACS_INT gc_cons_threshold; |
300 | 124 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
125 /* Nonzero during GC. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
126 |
300 | 127 int gc_in_progress; |
128 | |
50745
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
129 /* Nonzero means abort if try to GC. |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
130 This is for code which is written on the assumption that |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
131 no GC will happen, so as to verify that assumption. */ |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
132 |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
133 int abort_on_gc; |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
134 |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
135 /* 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
|
136 |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
137 int garbage_collection_messages; |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
138 |
300 | 139 #ifndef VIRT_ADDR_VARIES |
140 extern | |
141 #endif /* VIRT_ADDR_VARIES */ | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
142 int malloc_sbrk_used; |
300 | 143 |
144 #ifndef VIRT_ADDR_VARIES | |
145 extern | |
146 #endif /* VIRT_ADDR_VARIES */ | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
147 int malloc_sbrk_unused; |
300 | 148 |
764 | 149 /* 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
|
150 |
43713
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
151 EMACS_INT undo_limit; |
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
152 EMACS_INT undo_strong_limit; |
300 | 153 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
154 /* 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
|
155 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
156 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
|
157 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
|
158 static int total_free_floats, total_floats; |
19332
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
159 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
160 /* 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
|
161 out of memory. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
162 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
163 static char *spare_memory; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
164 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
165 /* 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
|
166 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
167 #define SPARE_MEMORY (1 << 14) |
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 /* 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
|
170 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
171 static int malloc_hysteresis; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
172 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
173 /* 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
|
174 |
300 | 175 Lisp_Object Vpurify_flag; |
176 | |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
177 /* Non-nil means we are handling a memory-full error. */ |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
178 |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
179 Lisp_Object Vmemory_full; |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
180 |
300 | 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 |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
188 #else /* HAVE_SHM */ |
27142
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 |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
193 #endif /* HAVE_SHM */ |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
194 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
195 /* Pointer to the pure area, and its size. */ |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
196 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
197 static char *purebeg; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
198 static size_t pure_size; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
199 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
200 /* Number of bytes of pure storage used before pure storage overflowed. |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
201 If this is non-zero, this implies that an overflow occurred. */ |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
202 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
203 static size_t pure_bytes_used_before_overflow; |
300 | 204 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
205 /* 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
|
206 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
207 #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
|
208 (((PNTR_COMPARISON_TYPE) (P) \ |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
209 < (PNTR_COMPARISON_TYPE) ((char *) purebeg + pure_size)) \ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
210 && ((PNTR_COMPARISON_TYPE) (P) \ |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
211 >= (PNTR_COMPARISON_TYPE) purebeg)) |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
212 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
213 /* 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
|
214 |
43713
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43314
diff
changeset
|
215 EMACS_INT pure_bytes_used; |
300 | 216 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
217 /* 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
|
218 displayed. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
219 |
300 | 220 char *pending_malloc_warning; |
221 | |
6116
64417bbbb128
(memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents:
5874
diff
changeset
|
222 /* 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
|
223 |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
224 Lisp_Object Vmemory_signal_data; |
6116
64417bbbb128
(memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents:
5874
diff
changeset
|
225 |
300 | 226 /* Maximum amount of C stack to save when a GC happens. */ |
227 | |
228 #ifndef MAX_SAVE_STACK | |
229 #define MAX_SAVE_STACK 16000 | |
230 #endif | |
231 | |
232 /* Buffer in which we save a copy of the C stack at each GC. */ | |
233 | |
234 char *stack_copy; | |
235 int stack_copy_size; | |
236 | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
237 /* 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
|
238 Currently not used. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
239 |
300 | 240 int ignore_warnings; |
1318 | 241 |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
242 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
|
243 |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
244 /* Hook run after GC has finished. */ |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
245 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
246 Lisp_Object Vpost_gc_hook, Qpost_gc_hook; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
247 |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
248 Lisp_Object Vgc_elapsed; /* accumulated elapsed time in GC */ |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
249 EMACS_INT gcs_done; /* accumulated GCs */ |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
250 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
251 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
|
252 static void mark_kboards P_ ((void)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
253 static void gc_sweep P_ ((void)); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
254 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
|
255 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
|
256 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
257 #ifdef HAVE_WINDOW_SYSTEM |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
258 static void mark_image P_ ((struct image *)); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
259 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
|
260 #endif /* HAVE_WINDOW_SYSTEM */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
261 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
262 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
|
263 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
|
264 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
|
265 static void sweep_strings P_ ((void)); |
20495 | 266 |
267 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
|
268 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
269 /* 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
|
270 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
|
271 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
|
272 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
273 enum mem_type |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
274 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
275 MEM_TYPE_NON_LISP, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
276 MEM_TYPE_BUFFER, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
277 MEM_TYPE_CONS, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
278 MEM_TYPE_STRING, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
279 MEM_TYPE_MISC, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
280 MEM_TYPE_SYMBOL, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
281 MEM_TYPE_FLOAT, |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
282 /* Keep the following vector-like types together, with |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
283 MEM_TYPE_WINDOW being the last, and MEM_TYPE_VECTOR the |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
284 first. Or change the code of live_vector_p, for instance. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
285 MEM_TYPE_VECTOR, |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
286 MEM_TYPE_PROCESS, |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
287 MEM_TYPE_HASH_TABLE, |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
288 MEM_TYPE_FRAME, |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
289 MEM_TYPE_WINDOW |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
290 }; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
291 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
292 #if GC_MARK_STACK || defined GC_MALLOC_CHECK |
27746
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
293 |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
294 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
295 #include <stdio.h> /* For fprintf. */ |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
296 #endif |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
297 |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
298 /* 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
|
299 on free lists recognizable in O(1). */ |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
300 |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
301 Lisp_Object Vdead; |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
302 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
303 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
304 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
305 enum mem_type allocated_mem_type; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
306 int dont_register_blocks; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
307 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
308 #endif /* GC_MALLOC_CHECK */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
309 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
310 /* A node in the red-black tree describing allocated memory containing |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
311 Lisp data. Each such block is recorded with its start and end |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
312 address when it is allocated, and removed from the tree when it |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
313 is freed. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
314 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
315 A red-black tree is a balanced binary tree with the following |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
316 properties: |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
317 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
318 1. Every node is either red or black. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
319 2. Every leaf is black. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
320 3. If a node is red, then both of its children are black. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
321 4. Every simple path from a node to a descendant leaf contains |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
322 the same number of black nodes. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
323 5. The root is always black. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
324 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
325 When nodes are inserted into the tree, or deleted from the tree, |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
326 the tree is "fixed" so that these properties are always true. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
327 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
328 A red-black tree with N internal nodes has height at most 2 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
329 log(N+1). Searches, insertions and deletions are done in O(log N). |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
330 Please see a text book about data structures for a detailed |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
331 description of red-black trees. Any book worth its salt should |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
332 describe them. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
333 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
334 struct mem_node |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
335 { |
48907 | 336 /* Children of this node. These pointers are never NULL. When there |
337 is no child, the value is MEM_NIL, which points to a dummy node. */ | |
338 struct mem_node *left, *right; | |
339 | |
340 /* The parent of this node. In the root node, this is NULL. */ | |
341 struct mem_node *parent; | |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
342 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
343 /* Start and end of allocated region. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
344 void *start, *end; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
345 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
346 /* Node color. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
347 enum {MEM_BLACK, MEM_RED} color; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
348 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
349 /* Memory type. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
350 enum mem_type type; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
351 }; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
352 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
353 /* Base address of stack. Set in main. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
354 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
355 Lisp_Object *stack_base; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
356 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
357 /* Root of the tree describing allocated Lisp memory. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
358 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
359 static struct mem_node *mem_root; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
360 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
361 /* Lowest and highest known address in the heap. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
362 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
363 static void *min_heap_address, *max_heap_address; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
364 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
365 /* Sentinel node of the tree. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
366 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
367 static struct mem_node mem_z; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
368 #define MEM_NIL &mem_z |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
369 |
30914
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
370 static POINTER_TYPE *lisp_malloc P_ ((size_t, enum mem_type)); |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
371 static struct Lisp_Vector *allocate_vectorlike P_ ((EMACS_INT, enum mem_type)); |
30784
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
372 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
|
373 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
|
374 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
|
375 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
|
376 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
|
377 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
|
378 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
|
379 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
|
380 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
|
381 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
|
382 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
|
383 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
|
384 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
|
385 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
|
386 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
|
387 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
|
388 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
|
389 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
|
390 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
|
391 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
392 #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
|
393 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
|
394 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
395 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
396 #endif /* GC_MARK_STACK || GC_MALLOC_CHECK */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
397 |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
398 /* Recording what needs to be marked for gc. */ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
399 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
400 struct gcpro *gcprolist; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
401 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
402 /* Addresses of staticpro'd variables. */ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
403 |
43313
32f59a921eb9
(NSTATICS): Increase to 1280.
Andreas Schwab <schwab@suse.de>
parents:
43302
diff
changeset
|
404 #define NSTATICS 1280 |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
405 Lisp_Object *staticvec[NSTATICS] = {0}; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
406 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
407 /* Index of next unused slot in staticvec. */ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
408 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
409 int staticidx = 0; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
410 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
411 static POINTER_TYPE *pure_alloc P_ ((size_t, int)); |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
412 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
413 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
414 /* Value is SZ rounded up to the next multiple of ALIGNMENT. |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
415 ALIGNMENT must be a power of 2. */ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
416 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
417 #define ALIGN(SZ, ALIGNMENT) \ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
418 (((SZ) + (ALIGNMENT) - 1) & ~((ALIGNMENT) - 1)) |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
419 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
420 |
300 | 421 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
422 /************************************************************************ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
423 Malloc |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
424 ************************************************************************/ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
425 |
47185
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
426 /* Function malloc calls this if it finds we are near exhausting storage. */ |
20375
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
427 |
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
428 void |
300 | 429 malloc_warning (str) |
430 char *str; | |
431 { | |
432 pending_malloc_warning = str; | |
433 } | |
434 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
435 |
47185
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
436 /* Display an already-pending malloc warning. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
437 |
20375
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
438 void |
300 | 439 display_malloc_warning () |
440 { | |
47185
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
441 call3 (intern ("display-warning"), |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
442 intern ("alloc"), |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
443 build_string (pending_malloc_warning), |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
444 intern ("emergency")); |
300 | 445 pending_malloc_warning = 0; |
446 } | |
447 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
448 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
449 #ifdef DOUG_LEA_MALLOC |
17831
9238a2254a23
(BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents:
17348
diff
changeset
|
450 # 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
|
451 #else |
17831
9238a2254a23
(BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents:
17348
diff
changeset
|
452 # 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
|
453 #endif |
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
454 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
455 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
456 /* 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
|
457 |
20375
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
458 void |
300 | 459 memory_full () |
460 { | |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
461 Vmemory_full = Qt; |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
462 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
463 #ifndef SYSTEM_MALLOC |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
464 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
|
465 #endif |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
466 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
467 /* 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
|
468 if (spare_memory) |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
469 { |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
470 free (spare_memory); |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
471 spare_memory = 0; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
472 } |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
473 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
474 /* 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
|
475 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
|
476 while (1) |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
477 Fsignal (Qnil, Vmemory_signal_data); |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
478 } |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
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 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
481 /* 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
|
482 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
483 void |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
484 buffer_memory_full () |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
485 { |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
486 /* 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
|
487 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
|
488 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
|
489 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
|
490 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
|
491 malloc. */ |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
492 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
493 #ifndef REL_ALLOC |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
494 memory_full (); |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
495 #endif |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
496 |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
497 Vmemory_full = Qt; |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
498 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
499 /* 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
|
500 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
|
501 while (1) |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
502 Fsignal (Qnil, Vmemory_signal_data); |
300 | 503 } |
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 /* Like malloc but check for no memory and block interrupt input.. */ |
300 | 507 |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
508 POINTER_TYPE * |
300 | 509 xmalloc (size) |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
510 size_t size; |
300 | 511 { |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
512 register POINTER_TYPE *val; |
300 | 513 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
514 BLOCK_INPUT; |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
515 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
|
516 UNBLOCK_INPUT; |
300 | 517 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
518 if (!val && size) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
519 memory_full (); |
300 | 520 return val; |
521 } | |
522 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
523 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
524 /* 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
|
525 |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
526 POINTER_TYPE * |
300 | 527 xrealloc (block, size) |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
528 POINTER_TYPE *block; |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
529 size_t size; |
300 | 530 { |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
531 register POINTER_TYPE *val; |
300 | 532 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
533 BLOCK_INPUT; |
590 | 534 /* We must call malloc explicitly when BLOCK is 0, since some |
535 reallocs don't do this. */ | |
536 if (! block) | |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
537 val = (POINTER_TYPE *) malloc (size); |
600
a8d78999e46d
*** empty log message ***
Noah Friedman <friedman@splode.com>
parents:
590
diff
changeset
|
538 else |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
539 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
|
540 UNBLOCK_INPUT; |
300 | 541 |
542 if (!val && size) memory_full (); | |
543 return val; | |
544 } | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
545 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
546 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
547 /* 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
|
548 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
549 void |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
550 xfree (block) |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
551 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
|
552 { |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
553 BLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
554 free (block); |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
555 UNBLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
556 } |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
557 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
558 |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
559 /* Like strdup, but uses xmalloc. */ |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
560 |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
561 char * |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
562 xstrdup (s) |
46459
0a9cbcbdbe45
(xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents:
46418
diff
changeset
|
563 const char *s; |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
564 { |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
565 size_t len = strlen (s) + 1; |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
566 char *p = (char *) xmalloc (len); |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
567 bcopy (s, p, len); |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
568 return p; |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
569 } |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
570 |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
571 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
572 /* 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
|
573 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
|
574 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
|
575 |
50468
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
576 static void *lisp_malloc_loser; |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
577 |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
578 static POINTER_TYPE * |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
579 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
|
580 size_t nbytes; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
581 enum mem_type type; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
582 { |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
583 register void *val; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
584 |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
585 BLOCK_INPUT; |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
586 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
587 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
588 allocated_mem_type = type; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
589 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
590 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
591 val = (void *) malloc (nbytes); |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
592 |
50468
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
593 /* If the memory just allocated cannot be addressed thru a Lisp |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
594 object's pointer, and it needs to be, |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
595 that's equivalent to running out of memory. */ |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
596 if (val && type != MEM_TYPE_NON_LISP) |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
597 { |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
598 Lisp_Object tem; |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
599 XSETCONS (tem, (char *) val + nbytes - 1); |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
600 if ((char *) XCONS (tem) != (char *) val + nbytes - 1) |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
601 { |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
602 lisp_malloc_loser = val; |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
603 free (val); |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
604 val = 0; |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
605 } |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
606 } |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
607 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
608 #if GC_MARK_STACK && !defined GC_MALLOC_CHECK |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
609 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
|
610 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
|
611 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
612 |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
613 UNBLOCK_INPUT; |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
614 if (!val && nbytes) |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
615 memory_full (); |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
616 return val; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
617 } |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
618 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
619 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
620 /* 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
|
621 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
|
622 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
623 struct buffer * |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
624 allocate_buffer () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
625 { |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
626 struct buffer *b |
39228
fcb8e48eec89
allocate_buffer): Call VALIDATE_LISP_STORAGE.
Gerd Moellmann <gerd@gnu.org>
parents:
38696
diff
changeset
|
627 = (struct buffer *) lisp_malloc (sizeof (struct buffer), |
fcb8e48eec89
allocate_buffer): Call VALIDATE_LISP_STORAGE.
Gerd Moellmann <gerd@gnu.org>
parents:
38696
diff
changeset
|
628 MEM_TYPE_BUFFER); |
fcb8e48eec89
allocate_buffer): Call VALIDATE_LISP_STORAGE.
Gerd Moellmann <gerd@gnu.org>
parents:
38696
diff
changeset
|
629 return b; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
630 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
631 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
632 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
633 /* 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
|
634 call to lisp_malloc. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
635 |
30784
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
636 static void |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
637 lisp_free (block) |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
638 POINTER_TYPE *block; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
639 { |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
640 BLOCK_INPUT; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
641 free (block); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
642 #if GC_MARK_STACK && !defined GC_MALLOC_CHECK |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
643 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
|
644 #endif |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
645 UNBLOCK_INPUT; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
646 } |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
647 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
648 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
649 /* 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
|
650 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
651 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
|
652 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
|
653 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
|
654 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
|
655 might call malloc, so we can't really protect them unless you're |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
656 using GNU malloc. Fortunately, most of the major operating systems |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
657 can use GNU malloc. */ |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
658 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
659 #ifndef SYSTEM_MALLOC |
30914
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
660 #ifndef DOUG_LEA_MALLOC |
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
661 extern void * (*__malloc_hook) P_ ((size_t)); |
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
662 extern void * (*__realloc_hook) P_ ((void *, size_t)); |
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
663 extern void (*__free_hook) P_ ((void *)); |
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
664 /* 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
|
665 #endif /* DOUG_LEA_MALLOC */ |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
666 static void * (*old_malloc_hook) (); |
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
667 static void * (*old_realloc_hook) (); |
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
668 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
|
669 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
670 /* 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
|
671 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
672 static void |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
673 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
|
674 void *ptr; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
675 { |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
676 BLOCK_INPUT; |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
677 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
678 #ifdef GC_MALLOC_CHECK |
32776
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
679 if (ptr) |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
680 { |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
681 struct mem_node *m; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
682 |
32776
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
683 m = mem_find (ptr); |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
684 if (m == MEM_NIL || m->start != ptr) |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
685 { |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
686 fprintf (stderr, |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
687 "Freeing `%p' which wasn't allocated with malloc\n", ptr); |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
688 abort (); |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
689 } |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
690 else |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
691 { |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
692 /* fprintf (stderr, "free %p...%p (%p)\n", m->start, m->end, ptr); */ |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
693 mem_delete (m); |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
694 } |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
695 } |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
696 #endif /* GC_MALLOC_CHECK */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
697 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
698 __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
|
699 free (ptr); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
700 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
701 /* 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
|
702 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
|
703 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
|
704 if (spare_memory == 0 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
705 /* 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
|
706 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
|
707 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
|
708 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
|
709 && (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
|
710 > 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
|
711 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
|
712 |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
713 __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
|
714 UNBLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
715 } |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
716 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
717 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
718 /* 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
|
719 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
|
720 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
|
721 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
722 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
|
723 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
724 void |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
725 refill_memory_reserve () |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
726 { |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
727 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
|
728 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
|
729 } |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
730 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
731 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
732 /* 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
|
733 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
734 static void * |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
735 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
|
736 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
|
737 { |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
738 void *value; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
739 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
740 BLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
741 __malloc_hook = old_malloc_hook; |
17831
9238a2254a23
(BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents:
17348
diff
changeset
|
742 #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
|
743 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
|
744 #else |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
745 __malloc_extra_blocks = malloc_hysteresis; |
17831
9238a2254a23
(BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents:
17348
diff
changeset
|
746 #endif |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
747 |
3581
152fd924c7bb
* alloc.c (emacs_blocked_malloc, emacs_blocked_realloc): Cast the
Jim Blandy <jimb@redhat.com>
parents:
3536
diff
changeset
|
748 value = (void *) malloc (size); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
749 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
750 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
751 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
752 struct mem_node *m = mem_find (value); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
753 if (m != MEM_NIL) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
754 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
755 fprintf (stderr, "Malloc returned %p which is already in use\n", |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
756 value); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
757 fprintf (stderr, "Region in use is %p...%p, %u bytes, type %d\n", |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
758 m->start, m->end, (char *) m->end - (char *) m->start, |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
759 m->type); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
760 abort (); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
761 } |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
762 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
763 if (!dont_register_blocks) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
764 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
765 mem_insert (value, (char *) value + max (1, size), allocated_mem_type); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
766 allocated_mem_type = MEM_TYPE_NON_LISP; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
767 } |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
768 } |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
769 #endif /* GC_MALLOC_CHECK */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
770 |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
771 __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
|
772 UNBLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
773 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
774 /* fprintf (stderr, "%p malloc\n", value); */ |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
775 return value; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
776 } |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
777 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
778 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
779 /* 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
|
780 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
781 static void * |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
782 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
|
783 void *ptr; |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
784 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
|
785 { |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
786 void *value; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
787 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
788 BLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
789 __realloc_hook = old_realloc_hook; |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
790 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
791 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
792 if (ptr) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
793 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
794 struct mem_node *m = mem_find (ptr); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
795 if (m == MEM_NIL || m->start != ptr) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
796 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
797 fprintf (stderr, |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
798 "Realloc of %p which wasn't allocated with malloc\n", |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
799 ptr); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
800 abort (); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
801 } |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
802 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
803 mem_delete (m); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
804 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
805 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
806 /* fprintf (stderr, "%p -> realloc\n", ptr); */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
807 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
808 /* Prevent malloc from registering blocks. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
809 dont_register_blocks = 1; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
810 #endif /* GC_MALLOC_CHECK */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
811 |
3581
152fd924c7bb
* alloc.c (emacs_blocked_malloc, emacs_blocked_realloc): Cast the
Jim Blandy <jimb@redhat.com>
parents:
3536
diff
changeset
|
812 value = (void *) realloc (ptr, size); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
813 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
814 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
815 dont_register_blocks = 0; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
816 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
817 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
818 struct mem_node *m = mem_find (value); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
819 if (m != MEM_NIL) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
820 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
821 fprintf (stderr, "Realloc returns memory that is already in use\n"); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
822 abort (); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
823 } |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
824 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
825 /* Can't handle zero size regions in the red-black tree. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
826 mem_insert (value, (char *) value + max (size, 1), MEM_TYPE_NON_LISP); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
827 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
828 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
829 /* fprintf (stderr, "%p <- realloc\n", value); */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
830 #endif /* GC_MALLOC_CHECK */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
831 |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
832 __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
|
833 UNBLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
834 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
835 return value; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
836 } |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
837 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
838 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
839 /* 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
|
840 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
841 void |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
842 uninterrupt_malloc () |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
843 { |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
844 if (__free_hook != emacs_blocked_free) |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
845 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
|
846 __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
|
847 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
848 if (__malloc_hook != emacs_blocked_malloc) |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
849 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
|
850 __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
|
851 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
852 if (__realloc_hook != emacs_blocked_realloc) |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
853 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
|
854 __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
|
855 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
856 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
857 #endif /* not SYSTEM_MALLOC */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
858 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
859 |
300 | 860 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
861 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
862 Interval Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
863 ***********************************************************************/ |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
864 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
865 /* 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
|
866 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
|
867 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
868 #define INTERVAL_BLOCK_SIZE \ |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
869 ((1020 - sizeof (struct interval_block *)) / sizeof (struct interval)) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
870 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
871 /* 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
|
872 structure. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
873 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
874 struct interval_block |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
875 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
876 struct interval_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
877 struct interval intervals[INTERVAL_BLOCK_SIZE]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
878 }; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
879 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
880 /* 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
|
881 blocks. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
882 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
883 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
|
884 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
885 /* 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
|
886 structure. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
887 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
888 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
|
889 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
890 /* 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
|
891 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
892 static int total_free_intervals, total_intervals; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
893 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
894 /* List of free intervals. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
895 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
896 INTERVAL interval_free_list; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
897 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
898 /* 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
|
899 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
900 int n_interval_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
901 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
902 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
903 /* Initialize interval allocation. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
904 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
905 static void |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
906 init_intervals () |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
907 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
908 interval_block |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
909 = (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
|
910 MEM_TYPE_NON_LISP); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
911 interval_block->next = 0; |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
912 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
|
913 interval_block_index = 0; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
914 interval_free_list = 0; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
915 n_interval_blocks = 1; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
916 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
917 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
918 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
919 /* Return a new interval. */ |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
920 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
921 INTERVAL |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
922 make_interval () |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
923 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
924 INTERVAL val; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
925 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
926 if (interval_free_list) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
927 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
928 val = interval_free_list; |
28269
fd13be8ae190
Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents:
28220
diff
changeset
|
929 interval_free_list = INTERVAL_PARENT (interval_free_list); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
930 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
931 else |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
932 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
933 if (interval_block_index == INTERVAL_BLOCK_SIZE) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
934 { |
12529 | 935 register struct interval_block *newi; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
936 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
937 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
|
938 MEM_TYPE_NON_LISP); |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
939 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
940 newi->next = interval_block; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
941 interval_block = newi; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
942 interval_block_index = 0; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
943 n_interval_blocks++; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
944 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
945 val = &interval_block->intervals[interval_block_index++]; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
946 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
947 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
|
948 intervals_consed++; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
949 RESET_INTERVAL (val); |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
950 return val; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
951 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
952 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
953 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
954 /* Mark Lisp objects in interval I. */ |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
955 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
956 static void |
1957
54c8c66cd9ac
(mark_interval): Add ignored arg.
Richard M. Stallman <rms@gnu.org>
parents:
1939
diff
changeset
|
957 mark_interval (i, dummy) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
958 register INTERVAL i; |
1957
54c8c66cd9ac
(mark_interval): Add ignored arg.
Richard M. Stallman <rms@gnu.org>
parents:
1939
diff
changeset
|
959 Lisp_Object dummy; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
960 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
961 if (XMARKBIT (i->plist)) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
962 abort (); |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
963 mark_object (&i->plist); |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
964 XMARK (i->plist); |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
965 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
966 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
967 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
968 /* 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
|
969 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
|
970 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
971 static void |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
972 mark_interval_tree (tree) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
973 register INTERVAL tree; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
974 { |
4139
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
975 /* 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
|
976 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
|
977 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
|
978 |
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
979 /* 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
|
980 a cast. */ |
28406
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
981 XMARK (tree->up.obj); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
982 |
39859
36068b62b4c1
(mark_interval_tree): Use traverse_intervals_noorder.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39682
diff
changeset
|
983 traverse_intervals_noorder (tree, mark_interval, Qnil); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
984 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
985 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
986 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
987 /* 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
|
988 |
4139
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
989 #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
|
990 do { \ |
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
991 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
|
992 && ! 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
|
993 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
|
994 } while (0) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
995 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
996 |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
997 /* 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
|
998 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
|
999 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
|
1000 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1001 #define UNMARK_BALANCE_INTERVALS(i) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1002 do { \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1003 if (! NULL_INTERVAL_P (i)) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1004 { \ |
28406
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
1005 XUNMARK ((i)->up.obj); \ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1006 (i) = balance_intervals (i); \ |
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 } while (0) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1009 |
28469
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1010 |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1011 /* 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
|
1012 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
|
1013 #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
|
1014 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
|
1015 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
|
1016 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
|
1017 { |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1018 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
|
1019 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
|
1020 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
|
1021 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
|
1022 } |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1023 #endif |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1024 |
27142
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 String Allocation |
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 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1029 /* 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
|
1030 string_block is allocated, all the Lisp_Strings it contains are |
41831
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
1031 added to a free-list string_free_list. When a new Lisp_String is |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1032 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
|
1033 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
|
1034 we keep. |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1035 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1036 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
|
1037 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
|
1038 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
|
1039 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1040 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
|
1041 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
|
1042 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
|
1043 its sdata structure. |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1044 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1045 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
|
1046 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
|
1047 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
|
1048 `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
|
1049 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
|
1050 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
|
1051 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1052 /* 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
|
1053 is 8192 minus malloc overhead. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1054 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1055 #define SBLOCK_SIZE 8188 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1056 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1057 /* 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
|
1058 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
|
1059 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1060 #define LARGE_STRING_BYTES 1024 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1061 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1062 /* 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
|
1063 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
|
1064 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1065 struct sdata |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1066 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1067 /* 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
|
1068 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
|
1069 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
|
1070 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
|
1071 (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
|
1072 contents. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1073 struct Lisp_String *string; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1074 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1075 #ifdef GC_CHECK_STRING_BYTES |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1076 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1077 EMACS_INT nbytes; |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1078 unsigned char data[1]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1079 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1080 #define SDATA_NBYTES(S) (S)->nbytes |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1081 #define SDATA_DATA(S) (S)->data |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1082 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1083 #else /* not GC_CHECK_STRING_BYTES */ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1084 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1085 union |
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 /* When STRING in non-null. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1088 unsigned char data[1]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1089 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1090 /* When STRING is null. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1091 EMACS_INT nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1092 } u; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1093 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1094 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1095 #define SDATA_NBYTES(S) (S)->u.nbytes |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1096 #define SDATA_DATA(S) (S)->u.data |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1097 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1098 #endif /* not GC_CHECK_STRING_BYTES */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1099 }; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1100 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1101 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1102 /* 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
|
1103 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
|
1104 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
|
1105 as large as needed. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1106 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1107 struct sblock |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1108 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1109 /* Next in list. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1110 struct sblock *next; |
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 /* 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
|
1113 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
|
1114 struct sdata *next_free; |
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 /* Start of data. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1117 struct sdata first_data; |
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 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1120 /* 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
|
1121 1024 minus malloc overhead. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1122 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1123 #define STRINGS_IN_STRING_BLOCK \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1124 ((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
|
1125 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1126 /* 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
|
1127 are allocated. */ |
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 struct string_block |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1130 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1131 struct string_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1132 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
|
1133 }; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1134 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1135 /* 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
|
1136 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
|
1137 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
|
1138 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1139 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
|
1140 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1141 /* List of sblocks for large strings. */ |
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 static struct sblock *large_sblocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1144 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1145 /* 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
|
1146 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1147 static struct string_block *string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1148 static int n_string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1149 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1150 /* Free-list of Lisp_Strings. */ |
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 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
|
1153 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1154 /* 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
|
1155 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1156 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
|
1157 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1158 /* 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
|
1159 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1160 static int total_string_size; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1161 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1162 /* 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
|
1163 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
|
1164 free-list. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1165 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1166 #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
|
1167 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1168 /* 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
|
1169 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
|
1170 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
|
1171 structure starts at a constant offset in front of that. */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1172 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1173 #ifdef GC_CHECK_STRING_BYTES |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1174 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1175 #define SDATA_OF_STRING(S) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1176 ((struct sdata *) ((S)->data - sizeof (struct Lisp_String *) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1177 - sizeof (EMACS_INT))) |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1178 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1179 #else /* not GC_CHECK_STRING_BYTES */ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1180 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1181 #define SDATA_OF_STRING(S) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1182 ((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
|
1183 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1184 #endif /* not GC_CHECK_STRING_BYTES */ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1185 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1186 /* 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
|
1187 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
|
1188 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
|
1189 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1190 #ifdef GC_CHECK_STRING_BYTES |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1191 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1192 #define SDATA_SIZE(NBYTES) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1193 ((sizeof (struct Lisp_String *) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1194 + (NBYTES) + 1 \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1195 + sizeof (EMACS_INT) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1196 + sizeof (EMACS_INT) - 1) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1197 & ~(sizeof (EMACS_INT) - 1)) |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1198 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1199 #else /* not GC_CHECK_STRING_BYTES */ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1200 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1201 #define SDATA_SIZE(NBYTES) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1202 ((sizeof (struct Lisp_String *) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1203 + (NBYTES) + 1 \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1204 + sizeof (EMACS_INT) - 1) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1205 & ~(sizeof (EMACS_INT) - 1)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1206 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1207 #endif /* not GC_CHECK_STRING_BYTES */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1208 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1209 /* 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
|
1210 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1211 void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1212 init_strings () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1213 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1214 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
|
1215 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
|
1216 string_blocks = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1217 n_string_blocks = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1218 string_free_list = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1219 } |
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 |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1222 #ifdef GC_CHECK_STRING_BYTES |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1223 |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1224 static int check_string_bytes_count; |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1225 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1226 void check_string_bytes P_ ((int)); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1227 void check_sblock P_ ((struct sblock *)); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1228 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1229 #define CHECK_STRING_BYTES(S) STRING_BYTES (S) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1230 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1231 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1232 /* Like GC_STRING_BYTES, but with debugging check. */ |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1233 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1234 int |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1235 string_bytes (s) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1236 struct Lisp_String *s; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1237 { |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1238 int nbytes = (s->size_byte < 0 ? s->size : s->size_byte) & ~MARKBIT; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1239 if (!PURE_POINTER_P (s) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1240 && s->data |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1241 && nbytes != SDATA_NBYTES (SDATA_OF_STRING (s))) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1242 abort (); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1243 return nbytes; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1244 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1245 |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
1246 /* Check validity of Lisp strings' string_bytes member in B. */ |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1247 |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1248 void |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1249 check_sblock (b) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1250 struct sblock *b; |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1251 { |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1252 struct sdata *from, *end, *from_end; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1253 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1254 end = b->next_free; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1255 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1256 for (from = &b->first_data; from < end; from = from_end) |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1257 { |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1258 /* Compute the next FROM here because copying below may |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1259 overwrite data we need to compute it. */ |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1260 int nbytes; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1261 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1262 /* Check that the string size recorded in the string is the |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1263 same as the one recorded in the sdata structure. */ |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1264 if (from->string) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1265 CHECK_STRING_BYTES (from->string); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1266 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1267 if (from->string) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1268 nbytes = GC_STRING_BYTES (from->string); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1269 else |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1270 nbytes = SDATA_NBYTES (from); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1271 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1272 nbytes = SDATA_SIZE (nbytes); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1273 from_end = (struct sdata *) ((char *) from + nbytes); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1274 } |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1275 } |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1276 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1277 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1278 /* Check validity of Lisp strings' string_bytes member. ALL_P |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1279 non-zero means check all strings, otherwise check only most |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1280 recently allocated strings. Used for hunting a bug. */ |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1281 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1282 void |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1283 check_string_bytes (all_p) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1284 int all_p; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1285 { |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1286 if (all_p) |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1287 { |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1288 struct sblock *b; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1289 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1290 for (b = large_sblocks; b; b = b->next) |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1291 { |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1292 struct Lisp_String *s = b->first_data.string; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1293 if (s) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1294 CHECK_STRING_BYTES (s); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1295 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1296 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1297 for (b = oldest_sblock; b; b = b->next) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1298 check_sblock (b); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1299 } |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1300 else |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1301 check_sblock (current_sblock); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1302 } |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1303 |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1304 #endif /* GC_CHECK_STRING_BYTES */ |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1305 |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1306 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1307 /* Return a new Lisp_String. */ |
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 static struct Lisp_String * |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1310 allocate_string () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1311 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1312 struct Lisp_String *s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1313 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1314 /* 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
|
1315 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
|
1316 if (string_free_list == NULL) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1317 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1318 struct string_block *b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1319 int i; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1320 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1321 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
|
1322 bzero (b, sizeof *b); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1323 b->next = string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1324 string_blocks = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1325 ++n_string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1326 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1327 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
|
1328 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1329 s = b->strings + i; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1330 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
|
1331 string_free_list = s; |
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 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1334 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
|
1335 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1336 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1337 /* 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
|
1338 s = string_free_list; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1339 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
|
1340 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1341 /* 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
|
1342 bzero (s, sizeof *s); |
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 --total_free_strings; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1345 ++total_strings; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1346 ++strings_consed; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1347 consing_since_gc += sizeof *s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1348 |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1349 #ifdef GC_CHECK_STRING_BYTES |
35660
b9366f467430
* alloc.c (allocate_string) [macintosh]: Call check_string_bytes
Andrew Choi <akochoi@shaw.ca>
parents:
35183
diff
changeset
|
1350 if (!noninteractive |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
44149
diff
changeset
|
1351 #ifdef MAC_OS8 |
35660
b9366f467430
* alloc.c (allocate_string) [macintosh]: Call check_string_bytes
Andrew Choi <akochoi@shaw.ca>
parents:
35183
diff
changeset
|
1352 && current_sblock |
b9366f467430
* alloc.c (allocate_string) [macintosh]: Call check_string_bytes
Andrew Choi <akochoi@shaw.ca>
parents:
35183
diff
changeset
|
1353 #endif |
b9366f467430
* alloc.c (allocate_string) [macintosh]: Call check_string_bytes
Andrew Choi <akochoi@shaw.ca>
parents:
35183
diff
changeset
|
1354 ) |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1355 { |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1356 if (++check_string_bytes_count == 200) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1357 { |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1358 check_string_bytes_count = 0; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1359 check_string_bytes (1); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1360 } |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1361 else |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1362 check_string_bytes (0); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1363 } |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1364 #endif /* GC_CHECK_STRING_BYTES */ |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1365 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1366 return s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1367 } |
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 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1370 /* 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
|
1371 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
|
1372 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
|
1373 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
|
1374 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
|
1375 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1376 void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1377 allocate_string_data (s, nchars, nbytes) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1378 struct Lisp_String *s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1379 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1380 { |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1381 struct sdata *data, *old_data; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1382 struct sblock *b; |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1383 int needed, old_nbytes; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1384 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1385 /* 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
|
1386 of string data. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1387 needed = SDATA_SIZE (nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1388 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1389 if (nbytes > LARGE_STRING_BYTES) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1390 { |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
1391 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
|
1392 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1393 #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
|
1394 /* 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
|
1395 because mapped region contents are not preserved in |
51318 | 1396 a dumped Emacs. |
1397 | |
1398 In case you think of allowing it in a dumped Emacs at the | |
1399 cost of not being able to re-dump, there's another reason: | |
1400 mmap'ed data typically have an address towards the top of the | |
1401 address space, which won't fit into an EMACS_INT (at least on | |
1402 32-bit systems with the current tagging scheme). --fx */ | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1403 mallopt (M_MMAP_MAX, 0); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1404 #endif |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1405 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1406 b = (struct sblock *) lisp_malloc (size, MEM_TYPE_NON_LISP); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1407 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1408 #ifdef DOUG_LEA_MALLOC |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1409 /* 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
|
1410 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
|
1411 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1412 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1413 b->next_free = &b->first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1414 b->first_data.string = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1415 b->next = large_sblocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1416 large_sblocks = b; |
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 else if (current_sblock == NULL |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1419 || (((char *) current_sblock + SBLOCK_SIZE |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1420 - (char *) current_sblock->next_free) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1421 < needed)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1422 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1423 /* 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
|
1424 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
|
1425 b->next_free = &b->first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1426 b->first_data.string = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1427 b->next = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1428 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1429 if (current_sblock) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1430 current_sblock->next = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1431 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1432 oldest_sblock = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1433 current_sblock = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1434 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1435 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1436 b = current_sblock; |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1437 |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1438 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
|
1439 old_nbytes = GC_STRING_BYTES (s); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1440 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1441 data = b->next_free; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1442 data->string = s; |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1443 s->data = SDATA_DATA (data); |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1444 #ifdef GC_CHECK_STRING_BYTES |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1445 SDATA_NBYTES (data) = nbytes; |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1446 #endif |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1447 s->size = nchars; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1448 s->size_byte = nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1449 s->data[nbytes] = '\0'; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1450 b->next_free = (struct sdata *) ((char *) data + needed); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1451 |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1452 /* 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
|
1453 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
|
1454 in it. */ |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1455 if (old_data) |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1456 { |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1457 SDATA_NBYTES (old_data) = old_nbytes; |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1458 old_data->string = NULL; |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1459 } |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1460 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1461 consing_since_gc += needed; |
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 /* Sweep and compact strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1466 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1467 static void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1468 sweep_strings () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1469 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1470 struct string_block *b, *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1471 struct string_block *live_blocks = NULL; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1472 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1473 string_free_list = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1474 total_strings = total_free_strings = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1475 total_string_size = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1476 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1477 /* 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
|
1478 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
|
1479 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1480 int i, nfree = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1481 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
|
1482 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1483 next = b->next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1484 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1485 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
|
1486 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1487 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
|
1488 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1489 if (s->data) |
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 /* 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
|
1492 if (STRING_MARKED_P (s)) |
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 /* 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
|
1495 UNMARK_STRING (s); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1496 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1497 if (!NULL_INTERVAL_P (s->intervals)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1498 UNMARK_BALANCE_INTERVALS (s->intervals); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1499 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1500 ++total_strings; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1501 total_string_size += STRING_BYTES (s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1502 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1503 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1504 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1505 /* 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
|
1506 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
|
1507 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1508 /* 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
|
1509 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
|
1510 back-pointer so that we know it's free. */ |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1511 #ifdef GC_CHECK_STRING_BYTES |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1512 if (GC_STRING_BYTES (s) != SDATA_NBYTES (data)) |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1513 abort (); |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1514 #else |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1515 data->u.nbytes = GC_STRING_BYTES (s); |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1516 #endif |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1517 data->string = NULL; |
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 /* 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
|
1520 know it's free. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1521 s->data = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1522 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1523 /* 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
|
1524 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
|
1525 string_free_list = s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1526 ++nfree; |
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 else |
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 /* 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
|
1532 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
|
1533 string_free_list = s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1534 ++nfree; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1535 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1536 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1537 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1538 /* 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
|
1539 the first two of them. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1540 if (nfree == STRINGS_IN_STRING_BLOCK |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1541 && 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
|
1542 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1543 lisp_free (b); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1544 --n_string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1545 string_free_list = free_list_before; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1546 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1547 else |
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 total_free_strings += nfree; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1550 b->next = live_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1551 live_blocks = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1552 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1553 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1554 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1555 string_blocks = live_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1556 free_large_strings (); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1557 compact_small_strings (); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1558 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1559 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1560 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1561 /* Free dead large strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1562 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1563 static void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1564 free_large_strings () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1565 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1566 struct sblock *b, *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1567 struct sblock *live_blocks = NULL; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1568 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1569 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
|
1570 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1571 next = b->next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1572 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1573 if (b->first_data.string == NULL) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1574 lisp_free (b); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1575 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1576 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1577 b->next = live_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1578 live_blocks = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1579 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1580 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1581 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1582 large_sblocks = live_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1583 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1584 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1585 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1586 /* 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
|
1587 data of live strings after compaction. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1588 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1589 static void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1590 compact_small_strings () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1591 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1592 struct sblock *b, *tb, *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1593 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
|
1594 struct sdata *to_end, *from_end; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1595 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1596 /* 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
|
1597 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
|
1598 tb = oldest_sblock; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1599 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
|
1600 to = &tb->first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1601 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1602 /* 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
|
1603 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
|
1604 copying will happen this way. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1605 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
|
1606 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1607 end = b->next_free; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1608 xassert ((char *) end <= (char *) b + SBLOCK_SIZE); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1609 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1610 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
|
1611 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1612 /* 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
|
1613 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
|
1614 int nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1615 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1616 #ifdef GC_CHECK_STRING_BYTES |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1617 /* Check that the string size recorded in the string is the |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1618 same as the one recorded in the sdata structure. */ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1619 if (from->string |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1620 && GC_STRING_BYTES (from->string) != SDATA_NBYTES (from)) |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1621 abort (); |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1622 #endif /* GC_CHECK_STRING_BYTES */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1623 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1624 if (from->string) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1625 nbytes = GC_STRING_BYTES (from->string); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1626 else |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1627 nbytes = SDATA_NBYTES (from); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1628 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1629 nbytes = SDATA_SIZE (nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1630 from_end = (struct sdata *) ((char *) from + nbytes); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1631 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1632 /* 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
|
1633 if (from->string) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1634 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1635 /* 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
|
1636 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
|
1637 if (to_end > tb_end) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1638 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1639 tb->next_free = to; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1640 tb = tb->next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1641 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
|
1642 to = &tb->first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1643 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
|
1644 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1645 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1646 /* 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
|
1647 if (from != to) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1648 { |
30823
8ee3740aaf60
(compact_small_strings): Use safe_bcopy, add an
Gerd Moellmann <gerd@gnu.org>
parents:
30784
diff
changeset
|
1649 xassert (tb != b || to <= from); |
8ee3740aaf60
(compact_small_strings): Use safe_bcopy, add an
Gerd Moellmann <gerd@gnu.org>
parents:
30784
diff
changeset
|
1650 safe_bcopy ((char *) from, (char *) to, nbytes); |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1651 to->string->data = SDATA_DATA (to); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1652 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1653 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1654 /* 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
|
1655 to = to_end; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1656 } |
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 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1659 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1660 /* 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
|
1661 we can free them. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1662 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
|
1663 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1664 next = b->next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1665 lisp_free (b); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1666 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1667 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1668 tb->next_free = to; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1669 tb->next = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1670 current_sblock = tb; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1671 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1672 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1673 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1674 DEFUN ("make-string", Fmake_string, Smake_string, 2, 2, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
1675 doc: /* Return a newly created string of length LENGTH, with each element being INIT. |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
1676 Both LENGTH and INIT must be numbers. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
1677 (length, init) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1678 Lisp_Object length, init; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1679 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1680 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1681 register unsigned char *p, *end; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1682 int c, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1683 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
1684 CHECK_NATNUM (length); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
1685 CHECK_NUMBER (init); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1686 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1687 c = XINT (init); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1688 if (SINGLE_BYTE_CHAR_P (c)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1689 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1690 nbytes = XINT (length); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1691 val = make_uninit_string (nbytes); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
1692 p = SDATA (val); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
1693 end = p + SCHARS (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1694 while (p != end) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1695 *p++ = c; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1696 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1697 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1698 { |
33800
7f148cfbd1f7
(Fmake_string): Use MAX_MULTIBYTE_LENGTH, instead of hard coded `4'.
Kenichi Handa <handa@m17n.org>
parents:
33764
diff
changeset
|
1699 unsigned char str[MAX_MULTIBYTE_LENGTH]; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1700 int len = CHAR_STRING (c, str); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1701 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1702 nbytes = len * XINT (length); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1703 val = make_uninit_multibyte_string (XINT (length), nbytes); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
1704 p = SDATA (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1705 end = p + nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1706 while (p != end) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1707 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1708 bcopy (str, p, len); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1709 p += len; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1710 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1711 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1712 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1713 *p = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1714 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1715 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1716 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1717 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1718 DEFUN ("make-bool-vector", Fmake_bool_vector, Smake_bool_vector, 2, 2, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
1719 doc: /* Return a new bool-vector of length LENGTH, using INIT for as each element. |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
1720 LENGTH must be a number. INIT matters only in whether it is t or nil. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
1721 (length, init) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1722 Lisp_Object length, init; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1723 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1724 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1725 struct Lisp_Bool_Vector *p; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1726 int real_init, i; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1727 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
|
1728 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
1729 CHECK_NATNUM (length); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1730 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1731 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
|
1732 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1733 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
|
1734 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
|
1735 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1736 /* 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
|
1737 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
|
1738 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
|
1739 p = XBOOL_VECTOR (val); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1740 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1741 /* 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
|
1742 p->vector_size = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1743 XSETBOOL_VECTOR (val, p); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1744 p->size = XFASTINT (length); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1745 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1746 real_init = (NILP (init) ? 0 : -1); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1747 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
|
1748 p->data[i] = real_init; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1749 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1750 /* 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
|
1751 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
|
1752 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
|
1753 &= (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
|
1754 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1755 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1756 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1757 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1758 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1759 /* 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
|
1760 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
|
1761 multibyte, depending on the contents. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1762 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1763 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1764 make_string (contents, nbytes) |
46459
0a9cbcbdbe45
(xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents:
46418
diff
changeset
|
1765 const char *contents; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1766 int nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1767 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1768 register Lisp_Object val; |
28997
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
1769 int nchars, multibyte_nbytes; |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
1770 |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
1771 parse_str_as_multibyte (contents, nbytes, &nchars, &multibyte_nbytes); |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
1772 if (nbytes == nchars || nbytes != multibyte_nbytes) |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
1773 /* 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
|
1774 multibyte sequence. We must make unibyte string. */ |
33623
dda5cbf94928
(make_string): Fix previous change. Be sure to make
Kenichi Handa <handa@m17n.org>
parents:
32776
diff
changeset
|
1775 val = make_unibyte_string (contents, nbytes); |
dda5cbf94928
(make_string): Fix previous change. Be sure to make
Kenichi Handa <handa@m17n.org>
parents:
32776
diff
changeset
|
1776 else |
dda5cbf94928
(make_string): Fix previous change. Be sure to make
Kenichi Handa <handa@m17n.org>
parents:
32776
diff
changeset
|
1777 val = make_multibyte_string (contents, nchars, nbytes); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1778 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1779 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1780 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1781 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1782 /* 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
|
1783 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1784 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1785 make_unibyte_string (contents, length) |
46459
0a9cbcbdbe45
(xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents:
46418
diff
changeset
|
1786 const char *contents; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1787 int length; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1788 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1789 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1790 val = make_uninit_string (length); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
1791 bcopy (contents, SDATA (val), length); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
1792 STRING_SET_UNIBYTE (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1793 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1794 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1795 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1796 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1797 /* 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
|
1798 bytes at CONTENTS. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1799 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1800 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1801 make_multibyte_string (contents, nchars, nbytes) |
46459
0a9cbcbdbe45
(xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents:
46418
diff
changeset
|
1802 const char *contents; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1803 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1804 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1805 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1806 val = make_uninit_multibyte_string (nchars, nbytes); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
1807 bcopy (contents, SDATA (val), nbytes); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1808 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1809 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1810 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1811 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1812 /* 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
|
1813 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
|
1814 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1815 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1816 make_string_from_bytes (contents, nchars, nbytes) |
50274
a617ca0d5d85
(make_string_from_bytes): Add `const' for the arg
Kenichi Handa <handa@m17n.org>
parents:
50200
diff
changeset
|
1817 const char *contents; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1818 int nchars, nbytes; |
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 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1821 val = make_uninit_multibyte_string (nchars, nbytes); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
1822 bcopy (contents, SDATA (val), nbytes); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
1823 if (SBYTES (val) == SCHARS (val)) |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
1824 STRING_SET_UNIBYTE (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1825 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1826 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1827 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1828 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1829 /* 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
|
1830 CONTENTS. The argument MULTIBYTE controls whether to label the |
50200
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
1831 string as multibyte. If NCHARS is negative, it counts the number of |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
1832 characters by itself. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1833 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1834 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1835 make_specified_string (contents, nchars, nbytes, multibyte) |
50274
a617ca0d5d85
(make_string_from_bytes): Add `const' for the arg
Kenichi Handa <handa@m17n.org>
parents:
50200
diff
changeset
|
1836 const char *contents; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1837 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1838 int multibyte; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1839 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1840 register Lisp_Object val; |
50200
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
1841 |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
1842 if (nchars < 0) |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
1843 { |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
1844 if (multibyte) |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
1845 nchars = multibyte_chars_in_text (contents, nbytes); |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
1846 else |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
1847 nchars = nbytes; |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
1848 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1849 val = make_uninit_multibyte_string (nchars, nbytes); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
1850 bcopy (contents, SDATA (val), nbytes); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1851 if (!multibyte) |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
1852 STRING_SET_UNIBYTE (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1853 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1854 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1855 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1856 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1857 /* 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
|
1858 data warrants. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1859 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1860 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1861 build_string (str) |
46459
0a9cbcbdbe45
(xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents:
46418
diff
changeset
|
1862 const char *str; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1863 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1864 return make_string (str, strlen (str)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1865 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1866 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1867 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1868 /* 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
|
1869 occupying LENGTH bytes. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1870 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1871 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1872 make_uninit_string (length) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1873 int length; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1874 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1875 Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1876 val = make_uninit_multibyte_string (length, length); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
1877 STRING_SET_UNIBYTE (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1878 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1879 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1880 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1881 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1882 /* 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
|
1883 which occupy NBYTES bytes. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1884 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1885 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1886 make_uninit_multibyte_string (nchars, nbytes) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1887 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1888 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1889 Lisp_Object string; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1890 struct Lisp_String *s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1891 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1892 if (nchars < 0) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1893 abort (); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1894 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1895 s = allocate_string (); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1896 allocate_string_data (s, nchars, nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1897 XSETSTRING (string, s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1898 string_chars_consed += nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1899 return string; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1900 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1901 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1902 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1903 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1904 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1905 Float Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1906 ***********************************************************************/ |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
1907 |
300 | 1908 /* 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
|
1909 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
|
1910 by GC are put on a free list to be reallocated before allocating |
300 | 1911 any new float cells from the latest float_block. |
1912 | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1913 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
|
1914 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
|
1915 overhead. */ |
300 | 1916 |
1917 #define FLOAT_BLOCK_SIZE \ | |
1918 ((1020 - sizeof (struct float_block *)) / sizeof (struct Lisp_Float)) | |
1919 | |
1920 struct float_block | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1921 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1922 struct float_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1923 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
|
1924 }; |
300 | 1925 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1926 /* Current float_block. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1927 |
300 | 1928 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
|
1929 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1930 /* 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
|
1931 |
300 | 1932 int float_block_index; |
1933 | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1934 /* 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
|
1935 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1936 int n_float_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1937 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1938 /* 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
|
1939 |
300 | 1940 struct Lisp_Float *float_free_list; |
1941 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1942 |
39297
aff361cfdccb
Fix a typo in a comment. From Pavel Janik.
Eli Zaretskii <eliz@gnu.org>
parents:
39228
diff
changeset
|
1943 /* Initialize float allocation. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1944 |
300 | 1945 void |
1946 init_float () | |
1947 { | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1948 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
|
1949 MEM_TYPE_FLOAT); |
300 | 1950 float_block->next = 0; |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
1951 bzero ((char *) float_block->floats, sizeof float_block->floats); |
300 | 1952 float_block_index = 0; |
1953 float_free_list = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1954 n_float_blocks = 1; |
300 | 1955 } |
1956 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1957 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1958 /* 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
|
1959 |
21514 | 1960 void |
300 | 1961 free_float (ptr) |
1962 struct Lisp_Float *ptr; | |
1963 { | |
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
|
1964 *(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
|
1965 #if GC_MARK_STACK |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1966 ptr->type = Vdead; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1967 #endif |
300 | 1968 float_free_list = ptr; |
1969 } | |
1970 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1971 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1972 /* 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
|
1973 |
300 | 1974 Lisp_Object |
1975 make_float (float_value) | |
1976 double float_value; | |
1977 { | |
1978 register Lisp_Object val; | |
1979 | |
1980 if (float_free_list) | |
1981 { | |
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
|
1982 /* 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
|
1983 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
|
1984 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
|
1985 float_free_list = *(struct Lisp_Float **)&float_free_list->data; |
300 | 1986 } |
1987 else | |
1988 { | |
1989 if (float_block_index == FLOAT_BLOCK_SIZE) | |
1990 { | |
12529 | 1991 register struct float_block *new; |
1992 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1993 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
|
1994 MEM_TYPE_FLOAT); |
300 | 1995 new->next = float_block; |
1996 float_block = new; | |
1997 float_block_index = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1998 n_float_blocks++; |
300 | 1999 } |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
2000 XSETFLOAT (val, &float_block->floats[float_block_index++]); |
300 | 2001 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2002 |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
2003 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
|
2004 XSETFASTINT (XFLOAT (val)->type, 0); /* bug chasing -wsr */ |
300 | 2005 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
|
2006 floats_consed++; |
300 | 2007 return val; |
2008 } | |
2009 | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2010 |
300 | 2011 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2012 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2013 Cons Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2014 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2015 |
300 | 2016 /* We store cons cells inside of cons_blocks, allocating a new |
2017 cons_block with malloc whenever necessary. Cons cells reclaimed by | |
2018 GC are put on a free list to be reallocated before allocating | |
2019 any new cons cells from the latest cons_block. | |
2020 | |
2021 Each cons_block is just under 1020 bytes long, | |
2022 since malloc really allocates in units of powers of two | |
2023 and uses 4 bytes for its own overhead. */ | |
2024 | |
2025 #define CONS_BLOCK_SIZE \ | |
2026 ((1020 - sizeof (struct cons_block *)) / sizeof (struct Lisp_Cons)) | |
2027 | |
2028 struct cons_block | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2029 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2030 struct cons_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2031 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
|
2032 }; |
300 | 2033 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2034 /* Current cons_block. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2035 |
300 | 2036 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
|
2037 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2038 /* 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
|
2039 |
300 | 2040 int cons_block_index; |
2041 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2042 /* 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
|
2043 |
300 | 2044 struct Lisp_Cons *cons_free_list; |
2045 | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2046 /* 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
|
2047 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2048 int n_cons_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2049 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2050 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2051 /* Initialize cons allocation. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2052 |
300 | 2053 void |
2054 init_cons () | |
2055 { | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2056 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
|
2057 MEM_TYPE_CONS); |
300 | 2058 cons_block->next = 0; |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
2059 bzero ((char *) cons_block->conses, sizeof cons_block->conses); |
300 | 2060 cons_block_index = 0; |
2061 cons_free_list = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2062 n_cons_blocks = 1; |
300 | 2063 } |
2064 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2065 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2066 /* 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
|
2067 |
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
2068 void |
300 | 2069 free_cons (ptr) |
2070 struct Lisp_Cons *ptr; | |
2071 { | |
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
|
2072 *(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
|
2073 #if GC_MARK_STACK |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2074 ptr->car = Vdead; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2075 #endif |
300 | 2076 cons_free_list = ptr; |
2077 } | |
2078 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2079 |
300 | 2080 DEFUN ("cons", Fcons, Scons, 2, 2, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
2081 doc: /* Create a new cons, give it CAR and CDR as components, and return it. */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2082 (car, cdr) |
300 | 2083 Lisp_Object car, cdr; |
2084 { | |
2085 register Lisp_Object val; | |
2086 | |
2087 if (cons_free_list) | |
2088 { | |
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
|
2089 /* 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
|
2090 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
|
2091 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
|
2092 cons_free_list = *(struct Lisp_Cons **)&cons_free_list->cdr; |
300 | 2093 } |
2094 else | |
2095 { | |
2096 if (cons_block_index == CONS_BLOCK_SIZE) | |
2097 { | |
12529 | 2098 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
|
2099 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
|
2100 MEM_TYPE_CONS); |
300 | 2101 new->next = cons_block; |
2102 cons_block = new; | |
2103 cons_block_index = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2104 n_cons_blocks++; |
300 | 2105 } |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
2106 XSETCONS (val, &cons_block->conses[cons_block_index++]); |
300 | 2107 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2108 |
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
2109 XSETCAR (val, car); |
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
2110 XSETCDR (val, cdr); |
300 | 2111 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
|
2112 cons_cells_consed++; |
300 | 2113 return val; |
2114 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2115 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2116 |
20849
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2117 /* 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
|
2118 |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2119 Lisp_Object |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2120 list2 (arg1, arg2) |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2121 Lisp_Object arg1, arg2; |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2122 { |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2123 return Fcons (arg1, Fcons (arg2, Qnil)); |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2124 } |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2125 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2126 |
20849
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2127 Lisp_Object |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2128 list3 (arg1, arg2, arg3) |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2129 Lisp_Object arg1, arg2, arg3; |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2130 { |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2131 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
|
2132 } |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2133 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2134 |
20849
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2135 Lisp_Object |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2136 list4 (arg1, arg2, arg3, arg4) |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2137 Lisp_Object arg1, arg2, arg3, arg4; |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2138 { |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2139 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
|
2140 } |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2141 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2142 |
20849
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2143 Lisp_Object |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2144 list5 (arg1, arg2, arg3, arg4, arg5) |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2145 Lisp_Object arg1, arg2, arg3, arg4, arg5; |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2146 { |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2147 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
|
2148 Fcons (arg5, Qnil))))); |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2149 } |
300 | 2150 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2151 |
300 | 2152 DEFUN ("list", Flist, Slist, 0, MANY, 0, |
40977 | 2153 doc: /* Return a newly created list with specified arguments as elements. |
40113
66132b83e52a
(Fmake_byte_code, Fvector, Flist): Add usage: string to doc string.
Miles Bader <miles@gnu.org>
parents:
40107
diff
changeset
|
2154 Any number of arguments, even zero arguments, are allowed. |
66132b83e52a
(Fmake_byte_code, Fvector, Flist): Add usage: string to doc string.
Miles Bader <miles@gnu.org>
parents:
40107
diff
changeset
|
2155 usage: (list &rest OBJECTS) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2156 (nargs, args) |
300 | 2157 int nargs; |
2158 register Lisp_Object *args; | |
2159 { | |
13610
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2160 register Lisp_Object val; |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2161 val = Qnil; |
300 | 2162 |
13610
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2163 while (nargs > 0) |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2164 { |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2165 nargs--; |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2166 val = Fcons (args[nargs], val); |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2167 } |
300 | 2168 return val; |
2169 } | |
2170 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2171 |
300 | 2172 DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
2173 doc: /* Return a newly created list of length LENGTH, with each element being INIT. */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2174 (length, init) |
300 | 2175 register Lisp_Object length, init; |
2176 { | |
2177 register Lisp_Object val; | |
2178 register int size; | |
2179 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
2180 CHECK_NATNUM (length); |
9953
e0672d4cf470
(Fmake_list, Fmake_vector, Fmake_string): Use CHECK_NATNUM instead of its
Karl Heuer <kwzh@gnu.org>
parents:
9942
diff
changeset
|
2181 size = XFASTINT (length); |
300 | 2182 |
2183 val = Qnil; | |
35762
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2184 while (size > 0) |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2185 { |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2186 val = Fcons (init, val); |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2187 --size; |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2188 |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2189 if (size > 0) |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2190 { |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2191 val = Fcons (init, val); |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2192 --size; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2193 |
35762
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2194 if (size > 0) |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2195 { |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2196 val = Fcons (init, val); |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2197 --size; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2198 |
35762
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2199 if (size > 0) |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2200 { |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2201 val = Fcons (init, val); |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2202 --size; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2203 |
35762
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2204 if (size > 0) |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2205 { |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2206 val = Fcons (init, val); |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2207 --size; |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2208 } |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2209 } |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2210 } |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2211 } |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2212 |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2213 QUIT; |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2214 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2215 |
300 | 2216 return val; |
2217 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2218 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2219 |
300 | 2220 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2221 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2222 Vector Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2223 ***********************************************************************/ |
300 | 2224 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2225 /* 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
|
2226 |
300 | 2227 struct Lisp_Vector *all_vectors; |
2228 | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2229 /* 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
|
2230 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2231 int n_vectors; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2232 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2233 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2234 /* 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
|
2235 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
|
2236 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2237 static struct Lisp_Vector * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2238 allocate_vectorlike (len, type) |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2239 EMACS_INT len; |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2240 enum mem_type type; |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2241 { |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2242 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
|
2243 size_t nbytes; |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2244 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
2245 #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
|
2246 /* 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
|
2247 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
|
2248 a dumped Emacs. */ |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
2249 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
|
2250 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2251 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2252 nbytes = sizeof *p + (len - 1) * sizeof p->contents[0]; |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2253 p = (struct Lisp_Vector *) lisp_malloc (nbytes, type); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2254 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
2255 #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
|
2256 /* 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
|
2257 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
|
2258 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2259 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2260 consing_since_gc += nbytes; |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
2261 vector_cells_consed += len; |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2262 |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2263 p->next = all_vectors; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2264 all_vectors = p; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2265 ++n_vectors; |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2266 return p; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2267 } |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2268 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2269 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2270 /* Allocate a vector with NSLOTS slots. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2271 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2272 struct Lisp_Vector * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2273 allocate_vector (nslots) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2274 EMACS_INT nslots; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2275 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2276 struct Lisp_Vector *v = allocate_vectorlike (nslots, MEM_TYPE_VECTOR); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2277 v->size = nslots; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2278 return v; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2279 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2280 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2281 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2282 /* Allocate other vector-like structures. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2283 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2284 struct Lisp_Hash_Table * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2285 allocate_hash_table () |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2286 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2287 EMACS_INT len = VECSIZE (struct Lisp_Hash_Table); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2288 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_HASH_TABLE); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2289 EMACS_INT i; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2290 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2291 v->size = len; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2292 for (i = 0; i < len; ++i) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2293 v->contents[i] = Qnil; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2294 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2295 return (struct Lisp_Hash_Table *) v; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2296 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2297 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2298 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2299 struct window * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2300 allocate_window () |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2301 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2302 EMACS_INT len = VECSIZE (struct window); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2303 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_WINDOW); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2304 EMACS_INT i; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2305 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2306 for (i = 0; i < len; ++i) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2307 v->contents[i] = Qnil; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2308 v->size = len; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2309 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2310 return (struct window *) v; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2311 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2312 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2313 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2314 struct frame * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2315 allocate_frame () |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2316 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2317 EMACS_INT len = VECSIZE (struct frame); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2318 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_FRAME); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2319 EMACS_INT i; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2320 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2321 for (i = 0; i < len; ++i) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2322 v->contents[i] = make_number (0); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2323 v->size = len; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2324 return (struct frame *) v; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2325 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2326 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2327 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2328 struct Lisp_Process * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2329 allocate_process () |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2330 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2331 EMACS_INT len = VECSIZE (struct Lisp_Process); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2332 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_PROCESS); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2333 EMACS_INT i; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2334 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2335 for (i = 0; i < len; ++i) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2336 v->contents[i] = Qnil; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2337 v->size = len; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2338 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2339 return (struct Lisp_Process *) v; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2340 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2341 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2342 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2343 struct Lisp_Vector * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2344 allocate_other_vector (len) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2345 EMACS_INT len; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2346 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2347 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_VECTOR); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2348 EMACS_INT i; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2349 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2350 for (i = 0; i < len; ++i) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2351 v->contents[i] = Qnil; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2352 v->size = len; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2353 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2354 return v; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2355 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2356 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2357 |
300 | 2358 DEFUN ("make-vector", Fmake_vector, Smake_vector, 2, 2, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
2359 doc: /* Return a newly created vector of length LENGTH, with each element being INIT. |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2360 See also the function `vector'. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2361 (length, init) |
300 | 2362 register Lisp_Object length, init; |
2363 { | |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2364 Lisp_Object vector; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2365 register EMACS_INT sizei; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2366 register int index; |
300 | 2367 register struct Lisp_Vector *p; |
2368 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
2369 CHECK_NATNUM (length); |
9953
e0672d4cf470
(Fmake_list, Fmake_vector, Fmake_string): Use CHECK_NATNUM instead of its
Karl Heuer <kwzh@gnu.org>
parents:
9942
diff
changeset
|
2370 sizei = XFASTINT (length); |
300 | 2371 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2372 p = allocate_vector (sizei); |
300 | 2373 for (index = 0; index < sizei; index++) |
2374 p->contents[index] = init; | |
2375 | |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2376 XSETVECTOR (vector, p); |
300 | 2377 return vector; |
2378 } | |
2379 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2380 |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
2381 DEFUN ("make-char-table", Fmake_char_table, Smake_char_table, 1, 2, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
2382 doc: /* Return a newly created char-table, with purpose PURPOSE. |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
2383 Each element is initialized to INIT, which defaults to nil. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
2384 PURPOSE should be a symbol which has a `char-table-extra-slots' property. |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2385 The property's value should be an integer between 0 and 10. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2386 (purpose, init) |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
2387 register Lisp_Object purpose, init; |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
2388 { |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
2389 Lisp_Object vector; |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
2390 Lisp_Object n; |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
2391 CHECK_SYMBOL (purpose); |
17328
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2392 n = Fget (purpose, Qchar_table_extra_slots); |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
2393 CHECK_NUMBER (n); |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
2394 if (XINT (n) < 0 || XINT (n) > 10) |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
2395 args_out_of_range (n, Qnil); |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
2396 /* 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
|
2397 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
|
2398 init); |
17328
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2399 XCHAR_TABLE (vector)->top = Qt; |
13150
3778c95adca9
(Fmake_char_table): Initialize parent to nil.
Erik Naggum <erik@naggum.no>
parents:
13141
diff
changeset
|
2400 XCHAR_TABLE (vector)->parent = Qnil; |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
2401 XCHAR_TABLE (vector)->purpose = purpose; |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
2402 XSETCHAR_TABLE (vector, XCHAR_TABLE (vector)); |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
2403 return vector; |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
2404 } |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
2405 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2406 |
17328
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2407 /* 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
|
2408 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
|
2409 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
|
2410 |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2411 Lisp_Object |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2412 make_sub_char_table (defalt) |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2413 Lisp_Object defalt; |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2414 { |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2415 Lisp_Object vector |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2416 = 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
|
2417 XCHAR_TABLE (vector)->top = Qnil; |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2418 XCHAR_TABLE (vector)->defalt = defalt; |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2419 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
|
2420 return vector; |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2421 } |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2422 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2423 |
300 | 2424 DEFUN ("vector", Fvector, Svector, 0, MANY, 0, |
40977 | 2425 doc: /* Return a newly created vector with specified arguments as elements. |
40113
66132b83e52a
(Fmake_byte_code, Fvector, Flist): Add usage: string to doc string.
Miles Bader <miles@gnu.org>
parents:
40107
diff
changeset
|
2426 Any number of arguments, even zero arguments, are allowed. |
66132b83e52a
(Fmake_byte_code, Fvector, Flist): Add usage: string to doc string.
Miles Bader <miles@gnu.org>
parents:
40107
diff
changeset
|
2427 usage: (vector &rest OBJECTS) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2428 (nargs, args) |
300 | 2429 register int nargs; |
2430 Lisp_Object *args; | |
2431 { | |
2432 register Lisp_Object len, val; | |
2433 register int index; | |
2434 register struct Lisp_Vector *p; | |
2435 | |
9295
17d393a8eed6
(free_float, make_float, free_cons, Flist, Fvector, Fmake_byte_code,
Karl Heuer <kwzh@gnu.org>
parents:
9261
diff
changeset
|
2436 XSETFASTINT (len, nargs); |
300 | 2437 val = Fmake_vector (len, Qnil); |
2438 p = XVECTOR (val); | |
2439 for (index = 0; index < nargs; index++) | |
2440 p->contents[index] = args[index]; | |
2441 return val; | |
2442 } | |
2443 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2444 |
300 | 2445 DEFUN ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
2446 doc: /* Create a byte-code object with specified arguments as elements. |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
2447 The arguments should be the arglist, bytecode-string, constant vector, |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
2448 stack size, (optional) doc string, and (optional) interactive spec. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
2449 The first four arguments are required; at most six have any |
40113
66132b83e52a
(Fmake_byte_code, Fvector, Flist): Add usage: string to doc string.
Miles Bader <miles@gnu.org>
parents:
40107
diff
changeset
|
2450 significance. |
50626
a5a77c7717cb
(Fmake_byte_code): Improve the `usage' string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50468
diff
changeset
|
2451 usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INTERACTIVE-SPEC &rest ELEMENTS) */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2452 (nargs, args) |
300 | 2453 register int nargs; |
2454 Lisp_Object *args; | |
2455 { | |
2456 register Lisp_Object len, val; | |
2457 register int index; | |
2458 register struct Lisp_Vector *p; | |
2459 | |
9295
17d393a8eed6
(free_float, make_float, free_cons, Flist, Fvector, Fmake_byte_code,
Karl Heuer <kwzh@gnu.org>
parents:
9261
diff
changeset
|
2460 XSETFASTINT (len, nargs); |
485 | 2461 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
|
2462 val = make_pure_vector ((EMACS_INT) nargs); |
300 | 2463 else |
2464 val = Fmake_vector (len, Qnil); | |
28997
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
2465 |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
2466 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
|
2467 /* 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
|
2468 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
|
2469 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
|
2470 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
|
2471 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
|
2472 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
|
2473 |
300 | 2474 p = XVECTOR (val); |
2475 for (index = 0; index < nargs; index++) | |
2476 { | |
485 | 2477 if (!NILP (Vpurify_flag)) |
300 | 2478 args[index] = Fpurecopy (args[index]); |
2479 p->contents[index] = args[index]; | |
2480 } | |
18104
b2a669ef69b1
(Fmake_byte_code): Set val from p, not from val.
Richard M. Stallman <rms@gnu.org>
parents:
18010
diff
changeset
|
2481 XSETCOMPILED (val, p); |
300 | 2482 return val; |
2483 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2484 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2485 |
300 | 2486 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2487 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2488 Symbol Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2489 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2490 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2491 /* 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
|
2492 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
|
2493 own overhead. */ |
300 | 2494 |
2495 #define SYMBOL_BLOCK_SIZE \ | |
2496 ((1020 - sizeof (struct symbol_block *)) / sizeof (struct Lisp_Symbol)) | |
2497 | |
2498 struct symbol_block | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2499 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2500 struct symbol_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2501 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
|
2502 }; |
300 | 2503 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2504 /* 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
|
2505 structure in it. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2506 |
300 | 2507 struct symbol_block *symbol_block; |
2508 int symbol_block_index; | |
2509 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2510 /* List of free symbols. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2511 |
300 | 2512 struct Lisp_Symbol *symbol_free_list; |
2513 | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2514 /* 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
|
2515 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2516 int n_symbol_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2517 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2518 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2519 /* Initialize symbol allocation. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2520 |
300 | 2521 void |
2522 init_symbol () | |
2523 { | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2524 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
|
2525 MEM_TYPE_SYMBOL); |
300 | 2526 symbol_block->next = 0; |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
2527 bzero ((char *) symbol_block->symbols, sizeof symbol_block->symbols); |
300 | 2528 symbol_block_index = 0; |
2529 symbol_free_list = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2530 n_symbol_blocks = 1; |
300 | 2531 } |
2532 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2533 |
300 | 2534 DEFUN ("make-symbol", Fmake_symbol, Smake_symbol, 1, 1, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
2535 doc: /* Return a newly allocated uninterned symbol whose name is NAME. |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2536 Its value and function definition are void, and its property list is nil. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2537 (name) |
14093
338f645e6b9a
(Fmake_symbol): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2538 Lisp_Object name; |
300 | 2539 { |
2540 register Lisp_Object val; | |
2541 register struct Lisp_Symbol *p; | |
2542 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
2543 CHECK_STRING (name); |
300 | 2544 |
2545 if (symbol_free_list) | |
2546 { | |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
2547 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
|
2548 symbol_free_list = *(struct Lisp_Symbol **)&symbol_free_list->value; |
300 | 2549 } |
2550 else | |
2551 { | |
2552 if (symbol_block_index == SYMBOL_BLOCK_SIZE) | |
2553 { | |
12529 | 2554 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
|
2555 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
|
2556 MEM_TYPE_SYMBOL); |
300 | 2557 new->next = symbol_block; |
2558 symbol_block = new; | |
2559 symbol_block_index = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2560 n_symbol_blocks++; |
300 | 2561 } |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
2562 XSETSYMBOL (val, &symbol_block->symbols[symbol_block_index++]); |
300 | 2563 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2564 |
300 | 2565 p = XSYMBOL (val); |
45392
f3d7ab65641f
* alloc.c (Fmake_symbol): Set symbol xname field instead of name.
Ken Raeburn <raeburn@raeburn.org>
parents:
44890
diff
changeset
|
2566 p->xname = name; |
300 | 2567 p->plist = Qnil; |
2568 p->value = Qunbound; | |
2569 p->function = Qunbound; | |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
2570 p->next = NULL; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
2571 p->interned = SYMBOL_UNINTERNED; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
2572 p->constant = 0; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
2573 p->indirect_variable = 0; |
300 | 2574 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
|
2575 symbols_consed++; |
300 | 2576 return val; |
2577 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2578 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2579 |
300 | 2580 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2581 /*********************************************************************** |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2582 Marker (Misc) Allocation |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2583 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2584 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2585 /* Allocation of markers and other objects that share that structure. |
300 | 2586 Works like allocation of conses. */ |
2587 | |
2588 #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
|
2589 ((1020 - sizeof (struct marker_block *)) / sizeof (union Lisp_Misc)) |
300 | 2590 |
2591 struct marker_block | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2592 { |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2593 struct marker_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2594 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
|
2595 }; |
300 | 2596 |
2597 struct marker_block *marker_block; | |
2598 int marker_block_index; | |
2599 | |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2600 union Lisp_Misc *marker_free_list; |
300 | 2601 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2602 /* 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
|
2603 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2604 int n_marker_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2605 |
300 | 2606 void |
2607 init_marker () | |
2608 { | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2609 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
|
2610 MEM_TYPE_MISC); |
300 | 2611 marker_block->next = 0; |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
2612 bzero ((char *) marker_block->markers, sizeof marker_block->markers); |
300 | 2613 marker_block_index = 0; |
2614 marker_free_list = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2615 n_marker_blocks = 1; |
300 | 2616 } |
2617 | |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2618 /* 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
|
2619 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2620 Lisp_Object |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2621 allocate_misc () |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2622 { |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2623 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
|
2624 |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2625 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
|
2626 { |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2627 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
|
2628 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
|
2629 } |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2630 else |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2631 { |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2632 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
|
2633 { |
12529 | 2634 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
|
2635 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
|
2636 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
|
2637 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
|
2638 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
|
2639 marker_block_index = 0; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2640 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
|
2641 } |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2642 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
|
2643 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2644 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2645 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
|
2646 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
|
2647 return val; |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2648 } |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2649 |
49055
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2650 /* Return a Lisp_Misc_Save_Value object containing POINTER and |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2651 INTEGER. This is used to package C values to call record_unwind_protect. |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2652 The unwind function can get the C values back using XSAVE_VALUE. */ |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2653 |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2654 Lisp_Object |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2655 make_save_value (pointer, integer) |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2656 void *pointer; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2657 int integer; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2658 { |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2659 register Lisp_Object val; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2660 register struct Lisp_Save_Value *p; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2661 |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2662 val = allocate_misc (); |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2663 XMISCTYPE (val) = Lisp_Misc_Save_Value; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2664 p = XSAVE_VALUE (val); |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2665 p->pointer = pointer; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2666 p->integer = integer; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2667 return val; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2668 } |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2669 |
300 | 2670 DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
2671 doc: /* Return a newly allocated marker which does not point at any place. */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
2672 () |
300 | 2673 { |
2674 register Lisp_Object val; | |
2675 register struct Lisp_Marker *p; | |
638 | 2676 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2677 val = allocate_misc (); |
11243
054ecfce1820
(Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents:
11048
diff
changeset
|
2678 XMISCTYPE (val) = Lisp_Misc_Marker; |
300 | 2679 p = XMARKER (val); |
2680 p->buffer = 0; | |
20565
aa9b7c5f0f62
(Fmake_marker): Initialize marker's bytepos and charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20495
diff
changeset
|
2681 p->bytepos = 0; |
aa9b7c5f0f62
(Fmake_marker): Initialize marker's bytepos and charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20495
diff
changeset
|
2682 p->charpos = 0; |
300 | 2683 p->chain = Qnil; |
13008
f042ef632b22
(Fmake_marker): Initialize insertion_type to 0.
Richard M. Stallman <rms@gnu.org>
parents:
12748
diff
changeset
|
2684 p->insertion_type = 0; |
300 | 2685 return val; |
2686 } | |
19332
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2687 |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2688 /* 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
|
2689 |
20375
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
2690 void |
19332
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2691 free_marker (marker) |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2692 Lisp_Object marker; |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2693 { |
19621
74151390752c
(free_marker): Call unchain_marker.
Richard M. Stallman <rms@gnu.org>
parents:
19332
diff
changeset
|
2694 unchain_marker (marker); |
74151390752c
(free_marker): Call unchain_marker.
Richard M. Stallman <rms@gnu.org>
parents:
19332
diff
changeset
|
2695 |
19332
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2696 XMISC (marker)->u_marker.type = Lisp_Misc_Free; |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2697 XMISC (marker)->u_free.chain = marker_free_list; |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2698 marker_free_list = XMISC (marker); |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2699 |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2700 total_free_markers++; |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2701 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2702 |
21258
693573ac0944
(make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
2703 |
300 | 2704 /* 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
|
2705 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
|
2706 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
|
2707 |
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
2708 Any number of arguments, even zero arguments, are allowed. */ |
300 | 2709 |
2710 Lisp_Object | |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
2711 make_event_array (nargs, args) |
300 | 2712 register int nargs; |
2713 Lisp_Object *args; | |
2714 { | |
2715 int i; | |
2716 | |
2717 for (i = 0; i < nargs; i++) | |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
2718 /* 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
|
2719 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
|
2720 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
|
2721 if (!INTEGERP (args[i]) |
3536
58d5ee6ec253
(make_event_array): Ignore bits above CHAR_META.
Richard M. Stallman <rms@gnu.org>
parents:
3181
diff
changeset
|
2722 || (XUINT (args[i]) & ~(-CHAR_META)) >= 0200) |
300 | 2723 return Fvector (nargs, args); |
2724 | |
2725 /* Since the loop exited, we know that all the things in it are | |
2726 characters, so we can make a string. */ | |
2727 { | |
6492
8372dce85f8a
(make_event_array): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6227
diff
changeset
|
2728 Lisp_Object result; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2729 |
18104
b2a669ef69b1
(Fmake_byte_code): Set val from p, not from val.
Richard M. Stallman <rms@gnu.org>
parents:
18010
diff
changeset
|
2730 result = Fmake_string (make_number (nargs), make_number (0)); |
300 | 2731 for (i = 0; i < nargs; i++) |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
2732 { |
46418
b12a32662433
* alloc.c (make_event_array): Use SSET for storing into a string.
Ken Raeburn <raeburn@raeburn.org>
parents:
46370
diff
changeset
|
2733 SSET (result, i, XINT (args[i])); |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
2734 /* 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
|
2735 if (XINT (args[i]) & CHAR_META) |
46418
b12a32662433
* alloc.c (make_event_array): Use SSET for storing into a string.
Ken Raeburn <raeburn@raeburn.org>
parents:
46370
diff
changeset
|
2736 SSET (result, i, SREF (result, i) | 0x80); |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
2737 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2738 |
300 | 2739 return result; |
2740 } | |
2741 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2742 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2743 |
300 | 2744 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2745 /************************************************************************ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2746 C Stack Marking |
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 |
32700
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
2749 #if GC_MARK_STACK || defined GC_MALLOC_CHECK |
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
2750 |
42403 | 2751 /* Conservative C stack marking requires a method to identify possibly |
2752 live Lisp objects given a pointer value. We do this by keeping | |
2753 track of blocks of Lisp data that are allocated in a red-black tree | |
2754 (see also the comment of mem_node which is the type of nodes in | |
2755 that tree). Function lisp_malloc adds information for an allocated | |
2756 block to the red-black tree with calls to mem_insert, and function | |
2757 lisp_free removes it with mem_delete. Functions live_string_p etc | |
2758 call mem_find to lookup information about a given pointer in the | |
2759 tree, and use that to determine if the pointer points to a Lisp | |
2760 object or not. */ | |
2761 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2762 /* 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
|
2763 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2764 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2765 mem_init () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2766 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2767 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
|
2768 mem_z.parent = NULL; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2769 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
|
2770 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
|
2771 mem_root = MEM_NIL; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2772 } |
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 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2775 /* 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
|
2776 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
|
2777 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2778 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
|
2779 mem_find (start) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2780 void *start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2781 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2782 struct mem_node *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2783 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2784 if (start < min_heap_address || start > max_heap_address) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2785 return MEM_NIL; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2786 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2787 /* 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
|
2788 mem_z.start = start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2789 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
|
2790 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2791 p = mem_root; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2792 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
|
2793 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
|
2794 return p; |
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 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2798 /* 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
|
2799 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
|
2800 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
|
2801 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2802 static struct mem_node * |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2803 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
|
2804 void *start, *end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2805 enum mem_type type; |
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 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
|
2808 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2809 if (start < min_heap_address) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2810 min_heap_address = start; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2811 if (end > max_heap_address) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2812 max_heap_address = end; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2813 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2814 /* 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
|
2815 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
|
2816 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
|
2817 c = mem_root; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2818 parent = NULL; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2819 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2820 #if GC_MARK_STACK != GC_MAKE_GCPROS_NOOPS |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2821 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2822 while (c != MEM_NIL) |
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 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
|
2825 abort (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2826 parent = c; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2827 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
|
2828 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2829 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2830 #else /* GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2831 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2832 while (c != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2833 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2834 parent = c; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2835 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
|
2836 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2837 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2838 #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
|
2839 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2840 /* Create a new node. */ |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
2841 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
2842 x = (struct mem_node *) _malloc_internal (sizeof *x); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
2843 if (x == NULL) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
2844 abort (); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
2845 #else |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2846 x = (struct mem_node *) xmalloc (sizeof *x); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
2847 #endif |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2848 x->start = start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2849 x->end = end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2850 x->type = type; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2851 x->parent = parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2852 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
|
2853 x->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2854 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2855 /* 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
|
2856 if (parent) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2857 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2858 if (start < parent->start) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2859 parent->left = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2860 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2861 parent->right = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2862 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2863 else |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2864 mem_root = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2865 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2866 /* 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
|
2867 mem_insert_fixup (x); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
2868 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2869 return x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2870 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2871 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2872 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2873 /* 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
|
2874 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
|
2875 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2876 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2877 mem_insert_fixup (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2878 struct mem_node *x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2879 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2880 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
|
2881 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2882 /* 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
|
2883 red-black tree property #3. */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2884 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2885 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
|
2886 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2887 /* 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
|
2888 "uncle". */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2889 struct mem_node *y = x->parent->parent->right; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2890 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2891 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
|
2892 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2893 /* 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
|
2894 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
|
2895 with the grandparent. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2896 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
|
2897 y->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2898 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
|
2899 x = x->parent->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2900 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2901 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2902 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2903 /* 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
|
2904 red, uncle is black. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2905 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
|
2906 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2907 x = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2908 mem_rotate_left (x); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2909 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2910 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2911 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
|
2912 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
|
2913 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
|
2914 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2915 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2916 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2917 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2918 /* 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
|
2919 struct mem_node *y = x->parent->parent->left; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2920 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2921 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
|
2922 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2923 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
|
2924 y->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2925 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
|
2926 x = x->parent->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2927 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2928 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2929 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2930 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
|
2931 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2932 x = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2933 mem_rotate_right (x); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2934 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2935 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2936 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
|
2937 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
|
2938 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
|
2939 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2940 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2941 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2942 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2943 /* 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
|
2944 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
|
2945 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
|
2946 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2947 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2948 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2949 /* (x) (y) |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
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 a (y) ===> (x) c |
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 b c a b */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2954 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2955 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2956 mem_rotate_left (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2957 struct mem_node *x; |
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 struct mem_node *y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2960 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2961 /* 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
|
2962 y = x->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2963 x->right = y->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2964 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
|
2965 y->left->parent = x; |
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 /* 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
|
2968 if (y != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2969 y->parent = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2970 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2971 /* 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
|
2972 if (x->parent) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2973 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2974 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
|
2975 x->parent->left = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2976 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2977 x->parent->right = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2978 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2979 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2980 mem_root = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2981 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2982 /* 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
|
2983 y->left = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2984 if (x != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2985 x->parent = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2986 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2987 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2988 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2989 /* (x) (Y) |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2990 / \ / \ |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2991 (y) c ===> a (x) |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2992 / \ / \ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2993 a b b c */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2994 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2995 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2996 mem_rotate_right (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2997 struct mem_node *x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2998 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2999 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
|
3000 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3001 x->left = y->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3002 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
|
3003 y->right->parent = x; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3004 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3005 if (y != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3006 y->parent = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3007 if (x->parent) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3008 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3009 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
|
3010 x->parent->right = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3011 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3012 x->parent->left = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3013 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3014 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3015 mem_root = y; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3016 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3017 y->right = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3018 if (x != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3019 x->parent = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3020 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3021 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3022 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3023 /* 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
|
3024 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3025 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3026 mem_delete (z) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3027 struct mem_node *z; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3028 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3029 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
|
3030 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3031 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
|
3032 return; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3033 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3034 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
|
3035 y = z; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3036 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3037 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3038 y = z->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3039 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
|
3040 y = y->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3041 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3042 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3043 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
|
3044 x = y->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3045 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3046 x = y->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3047 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3048 x->parent = y->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3049 if (y->parent) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3050 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3051 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
|
3052 y->parent->left = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3053 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3054 y->parent->right = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3055 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3056 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3057 mem_root = x; |
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 if (y != z) |
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 z->start = y->start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3062 z->end = y->end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3063 z->type = y->type; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3064 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3065 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3066 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
|
3067 mem_delete_fixup (x); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3068 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3069 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3070 _free_internal (y); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3071 #else |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3072 xfree (y); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3073 #endif |
27738
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 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3076 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3077 /* 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
|
3078 deletion. */ |
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 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3081 mem_delete_fixup (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3082 struct mem_node *x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3083 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3084 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
|
3085 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3086 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
|
3087 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3088 struct mem_node *w = x->parent->right; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3089 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3090 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
|
3091 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3092 w->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3093 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
|
3094 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
|
3095 w = x->parent->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3096 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3097 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3098 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
|
3099 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3100 w->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3101 x = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3102 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3103 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3104 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3105 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
|
3106 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3107 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
|
3108 w->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3109 mem_rotate_right (w); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3110 w = x->parent->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3111 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3112 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
|
3113 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
|
3114 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
|
3115 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
|
3116 x = mem_root; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3117 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3118 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3119 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3120 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3121 struct mem_node *w = x->parent->left; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3122 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3123 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
|
3124 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3125 w->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3126 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
|
3127 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
|
3128 w = x->parent->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3129 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3130 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3131 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
|
3132 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3133 w->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3134 x = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3135 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3136 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3137 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3138 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
|
3139 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3140 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
|
3141 w->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3142 mem_rotate_left (w); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3143 w = x->parent->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3144 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3145 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3146 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
|
3147 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
|
3148 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
|
3149 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
|
3150 x = mem_root; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3151 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3152 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3153 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3154 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3155 x->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3156 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3157 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3158 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3159 /* 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
|
3160 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
|
3161 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3162 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3163 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
|
3164 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3165 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3166 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3167 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
|
3168 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3169 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
|
3170 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
|
3171 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3172 /* 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
|
3173 must not be on the free-list. */ |
37049
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3174 return (offset >= 0 |
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3175 && offset % sizeof b->strings[0] == 0 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3176 && ((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
|
3177 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3178 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3179 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3180 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3181 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3182 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3183 /* 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
|
3184 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
|
3185 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3186 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3187 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
|
3188 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3189 void *p; |
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 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
|
3192 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3193 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
|
3194 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
|
3195 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3196 /* 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
|
3197 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
|
3198 and not be on the free-list. */ |
37049
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3199 return (offset >= 0 |
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3200 && offset % sizeof b->conses[0] == 0 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3201 && (b != cons_block |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3202 || 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
|
3203 && !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
|
3204 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3205 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3206 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3207 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3208 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3209 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3210 /* 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
|
3211 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
|
3212 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3213 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3214 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
|
3215 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3216 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3217 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3218 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
|
3219 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3220 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
|
3221 int offset = (char *) p - (char *) &b->symbols[0]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3222 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3223 /* 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
|
3224 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
|
3225 and not be on the free-list. */ |
37049
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3226 return (offset >= 0 |
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3227 && offset % sizeof b->symbols[0] == 0 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3228 && (b != symbol_block |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3229 || 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
|
3230 && !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
|
3231 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3232 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3233 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3234 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3235 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3236 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3237 /* 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
|
3238 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
|
3239 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3240 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3241 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
|
3242 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3243 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3244 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3245 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
|
3246 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3247 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
|
3248 int offset = (char *) p - (char *) &b->floats[0]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3249 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3250 /* 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
|
3251 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
|
3252 and not be on the free-list. */ |
37049
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3253 return (offset >= 0 |
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3254 && offset % sizeof b->floats[0] == 0 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3255 && (b != float_block |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3256 || 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
|
3257 && !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
|
3258 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3259 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3260 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3261 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3262 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3263 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3264 /* 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
|
3265 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
|
3266 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3267 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3268 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
|
3269 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3270 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3271 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3272 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
|
3273 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3274 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
|
3275 int offset = (char *) p - (char *) &b->markers[0]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3276 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3277 /* 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
|
3278 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
|
3279 and not be on the free-list. */ |
37049
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3280 return (offset >= 0 |
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3281 && offset % sizeof b->markers[0] == 0 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3282 && (b != marker_block |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3283 || 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
|
3284 && ((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
|
3285 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3286 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3287 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3288 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3289 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3290 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3291 /* 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
|
3292 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
|
3293 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3294 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3295 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
|
3296 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3297 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3298 { |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3299 return (p == m->start |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3300 && m->type >= MEM_TYPE_VECTOR |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3301 && m->type <= MEM_TYPE_WINDOW); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3302 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3303 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3304 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3305 /* 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
|
3306 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
|
3307 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3308 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3309 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
|
3310 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3311 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3312 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3313 /* 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
|
3314 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
|
3315 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
|
3316 && p == m->start |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3317 && !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
|
3318 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3319 |
32700
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
3320 #endif /* GC_MARK_STACK || defined GC_MALLOC_CHECK */ |
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
3321 |
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
3322 #if GC_MARK_STACK |
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
3323 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3324 #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
|
3325 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3326 /* 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
|
3327 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
|
3328 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3329 #define MAX_ZOMBIES 10 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3330 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
|
3331 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3332 /* Number of zombie objects. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3333 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3334 static int nzombies; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3335 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3336 /* Number of garbage collections. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3337 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3338 static int ngcs; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3339 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3340 /* 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
|
3341 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3342 static double avg_zombies; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3343 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3344 /* 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
|
3345 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3346 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
|
3347 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3348 /* 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
|
3349 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3350 static double avg_live; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3351 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3352 DEFUN ("gc-status", Fgc_status, Sgc_status, 0, 0, "", |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
3353 doc: /* Show information about live and zombie objects. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
3354 () |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3355 { |
49357 | 3356 Lisp_Object args[8], zombie_list = Qnil; |
3357 int i; | |
3358 for (i = 0; i < nzombies; i++) | |
3359 zombie_list = Fcons (zombies[i], zombie_list); | |
3360 args[0] = build_string ("%d GCs, avg live/zombies = %.2f/%.2f (%f%%), max %d/%d\nzombies: %S"); | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3361 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
|
3362 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
|
3363 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
|
3364 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
|
3365 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
|
3366 args[6] = make_number (max_zombies); |
49357 | 3367 args[7] = zombie_list; |
3368 return Fmessage (8, args); | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3369 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3370 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3371 #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
|
3372 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3373 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3374 /* 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
|
3375 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3376 static INLINE void |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3377 mark_maybe_object (obj) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3378 Lisp_Object obj; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3379 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3380 void *po = (void *) XPNTR (obj); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3381 struct mem_node *m = mem_find (po); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3382 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3383 if (m != MEM_NIL) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3384 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3385 int mark_p = 0; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3386 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3387 switch (XGCTYPE (obj)) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3388 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3389 case Lisp_String: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3390 mark_p = (live_string_p (m, po) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3391 && !STRING_MARKED_P ((struct Lisp_String *) po)); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3392 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3393 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3394 case Lisp_Cons: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3395 mark_p = (live_cons_p (m, po) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3396 && !XMARKBIT (XCONS (obj)->car)); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3397 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3398 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3399 case Lisp_Symbol: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3400 mark_p = (live_symbol_p (m, po) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3401 && !XMARKBIT (XSYMBOL (obj)->plist)); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3402 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3403 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3404 case Lisp_Float: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3405 mark_p = (live_float_p (m, po) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3406 && !XMARKBIT (XFLOAT (obj)->type)); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3407 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3408 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3409 case Lisp_Vectorlike: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3410 /* 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
|
3411 buffer because checking that dereferences the pointer |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3412 PO which might point anywhere. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3413 if (live_vector_p (m, po)) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3414 mark_p = (!GC_SUBRP (obj) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3415 && !(XVECTOR (obj)->size & ARRAY_MARK_FLAG)); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3416 else if (live_buffer_p (m, po)) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3417 mark_p = GC_BUFFERP (obj) && !XMARKBIT (XBUFFER (obj)->name); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3418 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3419 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3420 case Lisp_Misc: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3421 if (live_misc_p (m, po)) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3422 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3423 switch (XMISCTYPE (obj)) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3424 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3425 case Lisp_Misc_Marker: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3426 mark_p = !XMARKBIT (XMARKER (obj)->chain); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3427 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3428 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3429 case Lisp_Misc_Buffer_Local_Value: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3430 case Lisp_Misc_Some_Buffer_Local_Value: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3431 mark_p = !XMARKBIT (XBUFFER_LOCAL_VALUE (obj)->realvalue); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3432 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3433 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3434 case Lisp_Misc_Overlay: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3435 mark_p = !XMARKBIT (XOVERLAY (obj)->plist); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3436 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3437 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3438 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3439 break; |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
3440 |
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
3441 case Lisp_Int: |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
3442 case Lisp_Type_Limit: |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
3443 break; |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3444 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3445 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3446 if (mark_p) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3447 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3448 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3449 if (nzombies < MAX_ZOMBIES) |
49357 | 3450 zombies[nzombies] = obj; |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3451 ++nzombies; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3452 #endif |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3453 mark_object (&obj); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3454 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3455 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3456 } |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3457 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3458 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3459 /* If P points to Lisp data, mark that as live if it isn't already |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3460 marked. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3461 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3462 static INLINE void |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3463 mark_maybe_pointer (p) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3464 void *p; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3465 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3466 struct mem_node *m; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3467 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3468 /* Quickly rule out some values which can't point to Lisp data. We |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3469 assume that Lisp data is aligned on even addresses. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3470 if ((EMACS_INT) p & 1) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3471 return; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3472 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3473 m = mem_find (p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3474 if (m != MEM_NIL) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3475 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3476 Lisp_Object obj = Qnil; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3477 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3478 switch (m->type) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3479 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3480 case MEM_TYPE_NON_LISP: |
36487
4df2ac60690e
(mark_maybe_pointer): Fix a typo in a comment.
Eli Zaretskii <eliz@gnu.org>
parents:
36435
diff
changeset
|
3481 /* Nothing to do; not a pointer to Lisp memory. */ |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3482 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3483 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3484 case MEM_TYPE_BUFFER: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3485 if (live_buffer_p (m, p) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3486 && !XMARKBIT (((struct buffer *) p)->name)) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3487 XSETVECTOR (obj, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3488 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3489 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3490 case MEM_TYPE_CONS: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3491 if (live_cons_p (m, p) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3492 && !XMARKBIT (((struct Lisp_Cons *) p)->car)) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3493 XSETCONS (obj, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3494 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3495 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3496 case MEM_TYPE_STRING: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3497 if (live_string_p (m, p) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3498 && !STRING_MARKED_P ((struct Lisp_String *) p)) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3499 XSETSTRING (obj, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3500 break; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3501 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3502 case MEM_TYPE_MISC: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3503 if (live_misc_p (m, p)) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3504 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3505 Lisp_Object tem; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3506 XSETMISC (tem, p); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3507 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3508 switch (XMISCTYPE (tem)) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3509 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3510 case Lisp_Misc_Marker: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3511 if (!XMARKBIT (XMARKER (tem)->chain)) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3512 obj = tem; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3513 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3514 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3515 case Lisp_Misc_Buffer_Local_Value: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3516 case Lisp_Misc_Some_Buffer_Local_Value: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3517 if (!XMARKBIT (XBUFFER_LOCAL_VALUE (tem)->realvalue)) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3518 obj = tem; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3519 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3520 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3521 case Lisp_Misc_Overlay: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3522 if (!XMARKBIT (XOVERLAY (tem)->plist)) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3523 obj = tem; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3524 break; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3525 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3526 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3527 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3528 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3529 case MEM_TYPE_SYMBOL: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3530 if (live_symbol_p (m, p) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3531 && !XMARKBIT (((struct Lisp_Symbol *) p)->plist)) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3532 XSETSYMBOL (obj, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3533 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3534 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3535 case MEM_TYPE_FLOAT: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3536 if (live_float_p (m, p) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3537 && !XMARKBIT (((struct Lisp_Float *) p)->type)) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3538 XSETFLOAT (obj, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3539 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3540 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3541 case MEM_TYPE_VECTOR: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3542 case MEM_TYPE_PROCESS: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3543 case MEM_TYPE_HASH_TABLE: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3544 case MEM_TYPE_FRAME: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3545 case MEM_TYPE_WINDOW: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3546 if (live_vector_p (m, p)) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3547 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3548 Lisp_Object tem; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3549 XSETVECTOR (tem, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3550 if (!GC_SUBRP (tem) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3551 && !(XVECTOR (tem)->size & ARRAY_MARK_FLAG)) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3552 obj = tem; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3553 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3554 break; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3555 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3556 default: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3557 abort (); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3558 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3559 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3560 if (!GC_NILP (obj)) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3561 mark_object (&obj); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3562 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3563 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3564 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3565 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3566 /* Mark Lisp objects referenced from the address range START..END. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3567 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3568 static void |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3569 mark_memory (start, end) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3570 void *start, *end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3571 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3572 Lisp_Object *p; |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3573 void **pp; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3574 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3575 #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
|
3576 nzombies = 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3577 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3578 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3579 /* 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
|
3580 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
|
3581 if (end < start) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3582 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3583 void *tem = start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3584 start = end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3585 end = tem; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3586 } |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3587 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3588 /* Mark Lisp_Objects. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3589 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
|
3590 mark_maybe_object (*p); |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3591 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3592 /* Mark Lisp data pointed to. This is necessary because, in some |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3593 situations, the C compiler optimizes Lisp objects away, so that |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3594 only a pointer to them remains. Example: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3595 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3596 DEFUN ("testme", Ftestme, Stestme, 0, 0, 0, "") |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
3597 () |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3598 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3599 Lisp_Object obj = build_string ("test"); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3600 struct Lisp_String *s = XSTRING (obj); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3601 Fgarbage_collect (); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3602 fprintf (stderr, "test `%s'\n", s->data); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3603 return Qnil; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3604 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3605 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3606 Here, `obj' isn't really used, and the compiler optimizes it |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3607 away. The only reference to the life string is through the |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3608 pointer `s'. */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3609 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3610 for (pp = (void **) start; (void *) pp < end; ++pp) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3611 mark_maybe_pointer (*pp); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3612 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3613 |
48316 | 3614 /* setjmp will work with GCC unless NON_SAVING_SETJMP is defined in |
3615 the GCC system configuration. In gcc 3.2, the only systems for | |
3616 which this is so are i386-sco5 non-ELF, i386-sysv3 (maybe included | |
3617 by others?) and ns32k-pc532-min. */ | |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3618 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3619 #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
|
3620 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3621 static int setjmp_tested_p, longjmps_done; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3622 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3623 #define SETJMP_WILL_LIKELY_WORK "\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3624 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3625 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
|
3626 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
|
3627 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
|
3628 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3629 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
|
3630 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
|
3631 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
|
3632 \n\ |
43200
4082674ce69b
(SETJMP_WILL_LIKELY_WORK, SETJMP_WILL_NOT_WORK):
Kim F. Storm <storm@cua.dk>
parents:
43161
diff
changeset
|
3633 Please mail the result to <emacs-devel@gnu.org>.\n\ |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3634 " |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3635 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3636 #define SETJMP_WILL_NOT_WORK "\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3637 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3638 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
|
3639 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
|
3640 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
|
3641 solution for your system.\n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3642 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3643 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
|
3644 try to find a way to make it work on your system.\n\ |
48316 | 3645 \n\ |
3646 Note that you may get false negatives, depending on the compiler.\n\ | |
3647 In particular, you need to use -O with GCC for this test.\n\ | |
3648 \n\ | |
43200
4082674ce69b
(SETJMP_WILL_LIKELY_WORK, SETJMP_WILL_NOT_WORK):
Kim F. Storm <storm@cua.dk>
parents:
43161
diff
changeset
|
3649 Please mail the result to <emacs-devel@gnu.org>.\n\ |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3650 " |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3651 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3652 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3653 /* 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
|
3654 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
|
3655 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
|
3656 conservative stack marking. Only the sources or a disassembly |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3657 can prove that. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3658 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3659 static void |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3660 test_setjmp () |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3661 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3662 char buf[10]; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3663 register int x; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3664 jmp_buf jbuf; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3665 int result = 0; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3666 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3667 /* Arrange for X to be put in a register. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3668 sprintf (buf, "1"); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3669 x = strlen (buf); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3670 x = 2 * x - 1; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3671 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3672 setjmp (jbuf); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3673 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
|
3674 { |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3675 /* 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
|
3676 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3677 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
|
3678 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
|
3679 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
|
3680 isn't sure. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3681 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3682 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
|
3683 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
|
3684 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3685 if (x == 1) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3686 fprintf (stderr, SETJMP_WILL_LIKELY_WORK); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3687 else |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3688 { |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3689 fprintf (stderr, SETJMP_WILL_NOT_WORK); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3690 exit (1); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3691 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3692 } |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3693 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3694 ++longjmps_done; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3695 x = 2; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3696 if (longjmps_done == 1) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3697 longjmp (jbuf, 1); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3698 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3699 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3700 #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
|
3701 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3702 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3703 #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
|
3704 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3705 /* 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
|
3706 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3707 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3708 check_gcpros () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3709 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3710 struct gcpro *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3711 int i; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3712 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3713 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
|
3714 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
|
3715 if (!survives_gc_p (p->var[i])) |
50626
a5a77c7717cb
(Fmake_byte_code): Improve the `usage' string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50468
diff
changeset
|
3716 /* FIXME: It's not necessarily a bug. It might just be that the |
a5a77c7717cb
(Fmake_byte_code): Improve the `usage' string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50468
diff
changeset
|
3717 GCPRO is unnecessary or should release the object sooner. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3718 abort (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3719 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3720 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3721 #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
|
3722 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3723 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3724 dump_zombies () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3725 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3726 int i; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3727 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3728 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
|
3729 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
|
3730 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3731 fprintf (stderr, " %d = ", i); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3732 debug_print (zombies[i]); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3733 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3734 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3735 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3736 #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
|
3737 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3738 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3739 /* Mark live Lisp objects on the C stack. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3740 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3741 There are several system-dependent problems to consider when |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3742 porting this to new architectures: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3743 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3744 Processor Registers |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3745 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3746 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
|
3747 variables or are used to pass parameters. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3748 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3749 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
|
3750 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
|
3751 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
|
3752 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3753 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
|
3754 implementation assumes that calling setjmp saves registers we need |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3755 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
|
3756 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
|
3757 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
|
3758 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3759 Stack Layout |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3760 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3761 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
|
3762 For example, the stack might look like this |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3763 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3764 +----------------+ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3765 | Lisp_Object | size = 4 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3766 +----------------+ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3767 | something else | size = 2 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3768 +----------------+ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3769 | Lisp_Object | size = 4 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3770 +----------------+ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3771 | ... | |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3772 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3773 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
|
3774 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
|
3775 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
|
3776 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
|
3777 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
|
3778 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
|
3779 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
|
3780 from the stack start. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3781 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3782 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
|
3783 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
|
3784 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3785 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3786 mark_stack () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3787 { |
43160
630c8b6deafd
(mark_stack): Don't assume sizeof (Lisp_Object) is 4.
Andreas Schwab <schwab@suse.de>
parents:
43005
diff
changeset
|
3788 int i; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3789 jmp_buf j; |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
3790 volatile int stack_grows_down_p = (char *) &j > (char *) stack_base; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3791 void *end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3792 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3793 /* 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
|
3794 the process is contained in the stack. */ |
49414
668c96afa702
(mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents:
49357
diff
changeset
|
3795 /* Fixme: Code in the Boehm GC sugests flushing (with `flushrs') is |
668c96afa702
(mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents:
49357
diff
changeset
|
3796 needed on ia64 too. See mach_dep.c, where it also says inline |
668c96afa702
(mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents:
49357
diff
changeset
|
3797 assembler doesn't work with relevant proprietary compilers. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3798 #ifdef sparc |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3799 asm ("ta 3"); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3800 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3801 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3802 /* 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
|
3803 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
|
3804 pass parameters. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3805 #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
|
3806 GC_SAVE_REGISTERS_ON_STACK (end); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3807 #else /* not GC_SAVE_REGISTERS_ON_STACK */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3808 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3809 #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
|
3810 setjmp will definitely work, test it |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3811 and print a message with the result |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3812 of the test. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3813 if (!setjmp_tested_p) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3814 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3815 setjmp_tested_p = 1; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3816 test_setjmp (); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3817 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3818 #endif /* GC_SETJMP_WORKS */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3819 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3820 setjmp (j); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3821 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
|
3822 #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
|
3823 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3824 /* 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
|
3825 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
|
3826 over the stack segments. */ |
43160
630c8b6deafd
(mark_stack): Don't assume sizeof (Lisp_Object) is 4.
Andreas Schwab <schwab@suse.de>
parents:
43005
diff
changeset
|
3827 #ifndef GC_LISP_OBJECT_ALIGNMENT |
49414
668c96afa702
(mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents:
49357
diff
changeset
|
3828 #ifdef __GNUC__ |
668c96afa702
(mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents:
49357
diff
changeset
|
3829 #define GC_LISP_OBJECT_ALIGNMENT __alignof__ (Lisp_Object) |
668c96afa702
(mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents:
49357
diff
changeset
|
3830 #else |
43160
630c8b6deafd
(mark_stack): Don't assume sizeof (Lisp_Object) is 4.
Andreas Schwab <schwab@suse.de>
parents:
43005
diff
changeset
|
3831 #define GC_LISP_OBJECT_ALIGNMENT sizeof (Lisp_Object) |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3832 #endif |
49414
668c96afa702
(mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents:
49357
diff
changeset
|
3833 #endif |
43161
8a549ab185a2
Fix thinko in last change.
Andreas Schwab <schwab@suse.de>
parents:
43160
diff
changeset
|
3834 for (i = 0; i < sizeof (Lisp_Object); i += GC_LISP_OBJECT_ALIGNMENT) |
43160
630c8b6deafd
(mark_stack): Don't assume sizeof (Lisp_Object) is 4.
Andreas Schwab <schwab@suse.de>
parents:
43005
diff
changeset
|
3835 mark_memory ((char *) stack_base + i, end); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3836 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3837 #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
|
3838 check_gcpros (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3839 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3840 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3841 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3842 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3843 #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
|
3844 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3845 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3846 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3847 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3848 Pure Storage Management |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3849 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3850 |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3851 /* Allocate room for SIZE bytes from pure Lisp storage and return a |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3852 pointer to it. TYPE is the Lisp type for which the memory is |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3853 allocated. TYPE < 0 means it's not used for a Lisp object. |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3854 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3855 If store_pure_type_info is set and TYPE is >= 0, the type of |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3856 the allocated object is recorded in pure_types. */ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3857 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3858 static POINTER_TYPE * |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3859 pure_alloc (size, type) |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3860 size_t size; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3861 int type; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3862 { |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3863 POINTER_TYPE *result; |
49159
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
3864 size_t alignment = sizeof (EMACS_INT); |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3865 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3866 /* Give Lisp_Floats an extra alignment. */ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3867 if (type == Lisp_Float) |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3868 { |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3869 #if defined __GNUC__ && __GNUC__ >= 2 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3870 alignment = __alignof (struct Lisp_Float); |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3871 #else |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3872 alignment = sizeof (struct Lisp_Float); |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3873 #endif |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3874 } |
49159
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
3875 |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
3876 again: |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
3877 result = (POINTER_TYPE *) ALIGN ((EMACS_UINT)purebeg + pure_bytes_used, alignment); |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
3878 pure_bytes_used = ((char *)result - (char *)purebeg) + size; |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
3879 |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
3880 if (pure_bytes_used <= pure_size) |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
3881 return result; |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
3882 |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
3883 /* Don't allocate a large amount here, |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
3884 because it might get mmap'd and then its address |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
3885 might not be usable. */ |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
3886 purebeg = (char *) xmalloc (10000); |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
3887 pure_size = 10000; |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
3888 pure_bytes_used_before_overflow += pure_bytes_used - size; |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
3889 pure_bytes_used = 0; |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
3890 goto again; |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3891 } |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3892 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3893 |
44149
a3e6cfa20afd
(check_pure_size): Update the comment.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44100
diff
changeset
|
3894 /* Print a warning if PURESIZE is too small. */ |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
3895 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
3896 void |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
3897 check_pure_size () |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
3898 { |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
3899 if (pure_bytes_used_before_overflow) |
44100
57e965380c39
(check_pure_size): Only output a warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43751
diff
changeset
|
3900 message ("Pure Lisp storage overflow (approx. %d bytes needed)", |
57e965380c39
(check_pure_size): Only output a warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43751
diff
changeset
|
3901 (int) (pure_bytes_used + pure_bytes_used_before_overflow)); |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
3902 } |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
3903 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
3904 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3905 /* 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
|
3906 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
|
3907 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
|
3908 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3909 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
|
3910 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
|
3911 string; then the string is not protected from gc. */ |
300 | 3912 |
3913 Lisp_Object | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3914 make_pure_string (data, nchars, nbytes, multibyte) |
300 | 3915 char *data; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3916 int nchars, nbytes; |
21258
693573ac0944
(make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
3917 int multibyte; |
300 | 3918 { |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3919 Lisp_Object string; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3920 struct Lisp_String *s; |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3921 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3922 s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String); |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3923 s->data = (unsigned char *) pure_alloc (nbytes + 1, -1); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3924 s->size = nchars; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3925 s->size_byte = multibyte ? nbytes : -1; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3926 bcopy (data, s->data, nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3927 s->data[nbytes] = '\0'; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3928 s->intervals = NULL_INTERVAL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3929 XSETSTRING (string, s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3930 return string; |
300 | 3931 } |
3932 | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
3933 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3934 /* 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
|
3935 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
|
3936 |
300 | 3937 Lisp_Object |
3938 pure_cons (car, cdr) | |
3939 Lisp_Object car, cdr; | |
3940 { | |
3941 register Lisp_Object new; | |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3942 struct Lisp_Cons *p; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3943 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3944 p = (struct Lisp_Cons *) pure_alloc (sizeof *p, Lisp_Cons); |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3945 XSETCONS (new, p); |
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
3946 XSETCAR (new, Fpurecopy (car)); |
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
3947 XSETCDR (new, Fpurecopy (cdr)); |
300 | 3948 return new; |
3949 } | |
3950 | |
3951 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3952 /* 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
|
3953 |
300 | 3954 Lisp_Object |
3955 make_pure_float (num) | |
3956 double num; | |
3957 { | |
3958 register Lisp_Object new; | |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3959 struct Lisp_Float *p; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3960 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3961 p = (struct Lisp_Float *) pure_alloc (sizeof *p, Lisp_Float); |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3962 XSETFLOAT (new, p); |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
3963 XFLOAT_DATA (new) = num; |
300 | 3964 return new; |
3965 } | |
3966 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3967 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3968 /* 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
|
3969 pure space. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3970 |
300 | 3971 Lisp_Object |
3972 make_pure_vector (len) | |
8817
48ff00bebef6
(pure, pure_size): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
3973 EMACS_INT len; |
300 | 3974 { |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3975 Lisp_Object new; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3976 struct Lisp_Vector *p; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3977 size_t size = sizeof *p + (len - 1) * sizeof (Lisp_Object); |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3978 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3979 p = (struct Lisp_Vector *) pure_alloc (size, Lisp_Vectorlike); |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3980 XSETVECTOR (new, p); |
300 | 3981 XVECTOR (new)->size = len; |
3982 return new; | |
3983 } | |
3984 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3985 |
300 | 3986 DEFUN ("purecopy", Fpurecopy, Spurecopy, 1, 1, 0, |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
3987 doc: /* Make a copy of OBJECT in pure storage. |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
3988 Recursively copies contents of vectors and cons cells. |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
3989 Does not copy symbols. Copies strings without text properties. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
3990 (obj) |
300 | 3991 register Lisp_Object obj; |
3992 { | |
485 | 3993 if (NILP (Vpurify_flag)) |
300 | 3994 return obj; |
3995 | |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
3996 if (PURE_POINTER_P (XPNTR (obj))) |
300 | 3997 return obj; |
3998 | |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
3999 if (CONSP (obj)) |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4000 return pure_cons (XCAR (obj), XCDR (obj)); |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4001 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
|
4002 return make_pure_float (XFLOAT_DATA (obj)); |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4003 else if (STRINGP (obj)) |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
4004 return make_pure_string (SDATA (obj), SCHARS (obj), |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
4005 SBYTES (obj), |
21258
693573ac0944
(make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
4006 STRING_MULTIBYTE (obj)); |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4007 else if (COMPILEDP (obj) || VECTORP (obj)) |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4008 { |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4009 register struct Lisp_Vector *vec; |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4010 register int i, size; |
300 | 4011 |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4012 size = XVECTOR (obj)->size; |
10427
5faba1b094d5
(Fpurecopy): Mask size field when copying pseudovector.
Karl Heuer <kwzh@gnu.org>
parents:
10414
diff
changeset
|
4013 if (size & PSEUDOVECTOR_FLAG) |
5faba1b094d5
(Fpurecopy): Mask size field when copying pseudovector.
Karl Heuer <kwzh@gnu.org>
parents:
10414
diff
changeset
|
4014 size &= PSEUDOVECTOR_SIZE_MASK; |
16100
ccd19852de65
(Fpurecopy): Cast arg to make_pure_vector.
Richard M. Stallman <rms@gnu.org>
parents:
16051
diff
changeset
|
4015 vec = XVECTOR (make_pure_vector ((EMACS_INT) size)); |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4016 for (i = 0; i < size; i++) |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4017 vec->contents[i] = Fpurecopy (XVECTOR (obj)->contents[i]); |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4018 if (COMPILEDP (obj)) |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4019 XSETCOMPILED (obj, vec); |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4020 else |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4021 XSETVECTOR (obj, vec); |
300 | 4022 return obj; |
4023 } | |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4024 else if (MARKERP (obj)) |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4025 error ("Attempt to copy a marker to pure storage"); |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
4026 |
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
4027 return obj; |
300 | 4028 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4029 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4030 |
300 | 4031 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4032 /*********************************************************************** |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4033 Protection from GC |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4034 ***********************************************************************/ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4035 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4036 /* 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
|
4037 VARADDRESS. */ |
300 | 4038 |
4039 void | |
4040 staticpro (varaddress) | |
4041 Lisp_Object *varaddress; | |
4042 { | |
4043 staticvec[staticidx++] = varaddress; | |
4044 if (staticidx >= NSTATICS) | |
4045 abort (); | |
4046 } | |
4047 | |
4048 struct catchtag | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4049 { |
300 | 4050 Lisp_Object tag; |
4051 Lisp_Object val; | |
4052 struct catchtag *next; | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4053 }; |
300 | 4054 |
4055 struct backtrace | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4056 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4057 struct backtrace *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4058 Lisp_Object *function; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4059 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
|
4060 int nargs; /* Length of vector. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4061 /* 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
|
4062 unevalled args. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4063 char evalargs; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4064 }; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4065 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4066 |
300 | 4067 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4068 /*********************************************************************** |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4069 Protection from GC |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4070 ***********************************************************************/ |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
4071 |
11374
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4072 /* Temporarily prevent garbage collection. */ |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4073 |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4074 int |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4075 inhibit_garbage_collection () |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4076 { |
46293
1fb8f75062c6
Use macro SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents:
46285
diff
changeset
|
4077 int count = SPECPDL_INDEX (); |
41867
a555c6419185
(inhibit_garbage_collection): Don't exceed value an int can hold.
Andreas Schwab <schwab@suse.de>
parents:
41831
diff
changeset
|
4078 int nbits = min (VALBITS, BITS_PER_INT); |
a555c6419185
(inhibit_garbage_collection): Don't exceed value an int can hold.
Andreas Schwab <schwab@suse.de>
parents:
41831
diff
changeset
|
4079 |
a555c6419185
(inhibit_garbage_collection): Don't exceed value an int can hold.
Andreas Schwab <schwab@suse.de>
parents:
41831
diff
changeset
|
4080 specbind (Qgc_cons_threshold, make_number (((EMACS_INT) 1 << (nbits - 1)) - 1)); |
11374
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4081 return count; |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4082 } |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4083 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4084 |
300 | 4085 DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "", |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
4086 doc: /* Reclaim storage for Lisp objects no longer needed. |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
4087 Returns info on amount of space in use: |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
4088 ((USED-CONSES . FREE-CONSES) (USED-SYMS . FREE-SYMS) |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
4089 (USED-MARKERS . FREE-MARKERS) USED-STRING-CHARS USED-VECTOR-SLOTS |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
4090 (USED-FLOATS . FREE-FLOATS) (USED-INTERVALS . FREE-INTERVALS) |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
4091 (USED-STRINGS . FREE-STRINGS)) |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
4092 Garbage collection happens automatically if you cons more than |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
4093 `gc-cons-threshold' bytes of Lisp data since previous garbage collection. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
4094 () |
300 | 4095 { |
4096 register struct specbinding *bind; | |
4097 struct catchtag *catch; | |
4098 struct handler *handler; | |
4099 register struct backtrace *backlist; | |
4100 char stack_top_variable; | |
4101 register int i; | |
25343
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
4102 int message_p; |
34270
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
4103 Lisp_Object total[8]; |
46285
3f111801efb4
Rename BINDING_STACK_SIZE to SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents:
45392
diff
changeset
|
4104 int count = SPECPDL_INDEX (); |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4105 EMACS_TIME t1, t2, t3; |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4106 |
50745
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
4107 if (abort_on_gc) |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
4108 abort (); |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
4109 |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4110 EMACS_GET_TIME (t1); |
300 | 4111 |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4112 /* Can't GC if pure storage overflowed because we can't determine |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4113 if something is a pure object or not. */ |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4114 if (pure_bytes_used_before_overflow) |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4115 return Qnil; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4116 |
11892
6be0b7a0ac44
(Fgarbage_collect): Clear consing_since_gc first thing.
Karl Heuer <kwzh@gnu.org>
parents:
11727
diff
changeset
|
4117 /* 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
|
4118 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
|
4119 consing_since_gc = 0; |
6be0b7a0ac44
(Fgarbage_collect): Clear consing_since_gc first thing.
Karl Heuer <kwzh@gnu.org>
parents:
11727
diff
changeset
|
4120 |
25343
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
4121 /* 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
|
4122 message_p = push_message (); |
47391
1afd007f814f
(Fgarbage_collect): Use pop_message_unwind.
Richard M. Stallman <rms@gnu.org>
parents:
47185
diff
changeset
|
4123 record_unwind_protect (pop_message_unwind, Qnil); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4124 |
300 | 4125 /* Save a copy of the contents of the stack, for debugging. */ |
4126 #if MAX_SAVE_STACK > 0 | |
485 | 4127 if (NILP (Vpurify_flag)) |
300 | 4128 { |
4129 i = &stack_top_variable - stack_bottom; | |
4130 if (i < 0) i = -i; | |
4131 if (i < MAX_SAVE_STACK) | |
4132 { | |
4133 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
|
4134 stack_copy = (char *) xmalloc (stack_copy_size = i); |
300 | 4135 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
|
4136 stack_copy = (char *) xrealloc (stack_copy, (stack_copy_size = i)); |
300 | 4137 if (stack_copy) |
4138 { | |
8817
48ff00bebef6
(pure, pure_size): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
4139 if ((EMACS_INT) (&stack_top_variable - stack_bottom) > 0) |
300 | 4140 bcopy (stack_bottom, stack_copy, i); |
4141 else | |
4142 bcopy (&stack_top_variable, stack_copy, i); | |
4143 } | |
4144 } | |
4145 } | |
4146 #endif /* MAX_SAVE_STACK > 0 */ | |
4147 | |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4148 if (garbage_collection_messages) |
10395
c121703d35c7
(Fgarbage_collect): Don't log the GC message.
Karl Heuer <kwzh@gnu.org>
parents:
10389
diff
changeset
|
4149 message1_nolog ("Garbage collecting..."); |
300 | 4150 |
23534
6f9c70db3a58
(Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents:
22382
diff
changeset
|
4151 BLOCK_INPUT; |
6f9c70db3a58
(Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents:
22382
diff
changeset
|
4152 |
22220
a0cd311af6e3
(Fgarbage_collect): Call shrink_regexp_cache.
Richard M. Stallman <rms@gnu.org>
parents:
21948
diff
changeset
|
4153 shrink_regexp_cache (); |
a0cd311af6e3
(Fgarbage_collect): Call shrink_regexp_cache.
Richard M. Stallman <rms@gnu.org>
parents:
21948
diff
changeset
|
4154 |
21680
c744d468bfb6
(Fgarbage_collect): Don't truncate command-history here.
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
4155 /* Don't keep undo information around forever. */ |
300 | 4156 { |
4157 register struct buffer *nextb = all_buffers; | |
4158 | |
4159 while (nextb) | |
4160 { | |
648 | 4161 /* If a buffer's undo list is Qt, that means that undo is |
4162 turned off in that buffer. Calling truncate_undo_list on | |
4163 Qt tends to return NULL, which effectively turns undo back on. | |
4164 So don't call truncate_undo_list if undo_list is Qt. */ | |
4165 if (! EQ (nextb->undo_list, Qt)) | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4166 nextb->undo_list |
764 | 4167 = truncate_undo_list (nextb->undo_list, undo_limit, |
4168 undo_strong_limit); | |
41831
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4169 |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4170 /* Shrink buffer gaps, but skip indirect and dead buffers. */ |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4171 if (nextb->base_buffer == 0 && !NILP (nextb->name)) |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4172 { |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4173 /* If a buffer's gap size is more than 10% of the buffer |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4174 size, or larger than 2000 bytes, then shrink it |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4175 accordingly. Keep a minimum size of 20 bytes. */ |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4176 int size = min (2000, max (20, (nextb->text->z_byte / 10))); |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4177 |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4178 if (nextb->text->gap_size > size) |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4179 { |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4180 struct buffer *save_current = current_buffer; |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4181 current_buffer = nextb; |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4182 make_gap (-(nextb->text->gap_size - size)); |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4183 current_buffer = save_current; |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4184 } |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4185 } |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4186 |
300 | 4187 nextb = nextb->next; |
4188 } | |
4189 } | |
4190 | |
4191 gc_in_progress = 1; | |
4192 | |
16231 | 4193 /* clear_marks (); */ |
300 | 4194 |
4195 /* Mark all the special slots that serve as the roots of accessibility. | |
4196 | |
4197 Usually the special slots to mark are contained in particular structures. | |
4198 Then we know no slot is marked twice because the structures don't overlap. | |
4199 In some cases, the structures point to the slots to be marked. | |
4200 For these, we use MARKBIT to avoid double marking of the slot. */ | |
4201 | |
4202 for (i = 0; i < staticidx; i++) | |
4203 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
|
4204 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4205 #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
|
4206 || 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
|
4207 mark_stack (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4208 #else |
51228
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
4209 { |
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
4210 register struct gcpro *tail; |
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
4211 for (tail = gcprolist; tail; tail = tail->next) |
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
4212 for (i = 0; i < tail->nvars; i++) |
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
4213 if (!XMARKBIT (tail->var[i])) |
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
4214 { |
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
4215 /* Explicit casting prevents compiler warning about |
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
4216 discarding the `volatile' qualifier. */ |
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
4217 mark_object ((Lisp_Object *)&tail->var[i]); |
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
4218 XMARK (tail->var[i]); |
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
4219 } |
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
4220 } |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4221 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4222 |
26364
7b0217d9259c
(Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents:
26164
diff
changeset
|
4223 mark_byte_stack (); |
300 | 4224 for (bind = specpdl; bind != specpdl_ptr; bind++) |
4225 { | |
51029
ffa1dc43c997
(Fgarbage_collect): Cast pointers into specpdl to avoid GCC warning.
Richard M. Stallman <rms@gnu.org>
parents:
50745
diff
changeset
|
4226 /* These casts avoid a warning for discarding `volatile'. */ |
ffa1dc43c997
(Fgarbage_collect): Cast pointers into specpdl to avoid GCC warning.
Richard M. Stallman <rms@gnu.org>
parents:
50745
diff
changeset
|
4227 mark_object ((Lisp_Object *) &bind->symbol); |
ffa1dc43c997
(Fgarbage_collect): Cast pointers into specpdl to avoid GCC warning.
Richard M. Stallman <rms@gnu.org>
parents:
50745
diff
changeset
|
4228 mark_object ((Lisp_Object *) &bind->old_value); |
300 | 4229 } |
4230 for (catch = catchlist; catch; catch = catch->next) | |
4231 { | |
4232 mark_object (&catch->tag); | |
4233 mark_object (&catch->val); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4234 } |
300 | 4235 for (handler = handlerlist; handler; handler = handler->next) |
4236 { | |
4237 mark_object (&handler->handler); | |
4238 mark_object (&handler->var); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4239 } |
300 | 4240 for (backlist = backtrace_list; backlist; backlist = backlist->next) |
4241 { | |
4242 if (!XMARKBIT (*backlist->function)) | |
4243 { | |
4244 mark_object (backlist->function); | |
4245 XMARK (*backlist->function); | |
4246 } | |
4247 if (backlist->nargs == UNEVALLED || backlist->nargs == MANY) | |
4248 i = 0; | |
4249 else | |
4250 i = backlist->nargs - 1; | |
4251 for (; i >= 0; i--) | |
4252 if (!XMARKBIT (backlist->args[i])) | |
4253 { | |
4254 mark_object (&backlist->args[i]); | |
4255 XMARK (backlist->args[i]); | |
4256 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4257 } |
11018
2d9bdf1ba3d1
(mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents:
10936
diff
changeset
|
4258 mark_kboards (); |
300 | 4259 |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4260 /* 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
|
4261 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
|
4262 and delete them. */ |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4263 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4264 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
|
4265 |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4266 while (nextb) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4267 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4268 /* 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
|
4269 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
|
4270 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
|
4271 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
|
4272 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
|
4273 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4274 Lisp_Object tail, prev; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4275 tail = nextb->undo_list; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4276 prev = Qnil; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4277 while (CONSP (tail)) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4278 { |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4279 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
|
4280 && 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
|
4281 && ! 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
|
4282 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4283 if (NILP (prev)) |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4284 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
|
4285 else |
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
4286 { |
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
4287 tail = XCDR (tail); |
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
4288 XSETCDR (prev, tail); |
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
4289 } |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4290 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4291 else |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4292 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4293 prev = tail; |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4294 tail = XCDR (tail); |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4295 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4296 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4297 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4298 |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4299 nextb = nextb->next; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4300 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4301 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4302 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4303 #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
|
4304 mark_stack (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4305 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4306 |
49322 | 4307 #ifdef USE_GTK |
4308 { | |
4309 extern void xg_mark_data (); | |
4310 xg_mark_data (); | |
4311 } | |
4312 #endif | |
4313 | |
300 | 4314 gc_sweep (); |
4315 | |
4316 /* Clear the mark bits that we set in certain root slots. */ | |
4317 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4318 #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
|
4319 || GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES) |
51252
beb851c49c65
(Fgarbage_collect): Fix last change.
Andreas Schwab <schwab@suse.de>
parents:
51228
diff
changeset
|
4320 { |
beb851c49c65
(Fgarbage_collect): Fix last change.
Andreas Schwab <schwab@suse.de>
parents:
51228
diff
changeset
|
4321 register struct gcpro *tail; |
beb851c49c65
(Fgarbage_collect): Fix last change.
Andreas Schwab <schwab@suse.de>
parents:
51228
diff
changeset
|
4322 |
beb851c49c65
(Fgarbage_collect): Fix last change.
Andreas Schwab <schwab@suse.de>
parents:
51228
diff
changeset
|
4323 for (tail = gcprolist; tail; tail = tail->next) |
beb851c49c65
(Fgarbage_collect): Fix last change.
Andreas Schwab <schwab@suse.de>
parents:
51228
diff
changeset
|
4324 for (i = 0; i < tail->nvars; i++) |
beb851c49c65
(Fgarbage_collect): Fix last change.
Andreas Schwab <schwab@suse.de>
parents:
51228
diff
changeset
|
4325 XUNMARK (tail->var[i]); |
beb851c49c65
(Fgarbage_collect): Fix last change.
Andreas Schwab <schwab@suse.de>
parents:
51228
diff
changeset
|
4326 } |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4327 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4328 |
26378
cbf297593a79
(Fgarbage_collect): Call unmark_byte_stack.
Gerd Moellmann <gerd@gnu.org>
parents:
26372
diff
changeset
|
4329 unmark_byte_stack (); |
300 | 4330 for (backlist = backtrace_list; backlist; backlist = backlist->next) |
4331 { | |
4332 XUNMARK (*backlist->function); | |
4333 if (backlist->nargs == UNEVALLED || backlist->nargs == MANY) | |
4334 i = 0; | |
4335 else | |
4336 i = backlist->nargs - 1; | |
4337 for (; i >= 0; i--) | |
4338 XUNMARK (backlist->args[i]); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4339 } |
300 | 4340 XUNMARK (buffer_defaults.name); |
4341 XUNMARK (buffer_local_symbols.name); | |
4342 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4343 #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
|
4344 dump_zombies (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4345 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4346 |
23534
6f9c70db3a58
(Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents:
22382
diff
changeset
|
4347 UNBLOCK_INPUT; |
6f9c70db3a58
(Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents:
22382
diff
changeset
|
4348 |
16231 | 4349 /* clear_marks (); */ |
300 | 4350 gc_in_progress = 0; |
4351 | |
4352 consing_since_gc = 0; | |
4353 if (gc_cons_threshold < 10000) | |
4354 gc_cons_threshold = 10000; | |
4355 | |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4356 if (garbage_collection_messages) |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4357 { |
25343
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
4358 if (message_p || minibuf_level > 0) |
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
4359 restore_message (); |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4360 else |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4361 message1_nolog ("Garbage collecting...done"); |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4362 } |
300 | 4363 |
35170
a9b677239421
(Fgarbage_collect): Use a record_unwind_protect to
Gerd Moellmann <gerd@gnu.org>
parents:
34325
diff
changeset
|
4364 unbind_to (count, Qnil); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4365 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4366 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
|
4367 make_number (total_free_conses)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4368 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
|
4369 make_number (total_free_symbols)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4370 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
|
4371 make_number (total_free_markers)); |
34270
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
4372 total[3] = make_number (total_string_size); |
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
4373 total[4] = make_number (total_vector_size); |
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
4374 total[5] = Fcons (make_number (total_floats), |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4375 make_number (total_free_floats)); |
34270
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
4376 total[6] = Fcons (make_number (total_intervals), |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4377 make_number (total_free_intervals)); |
34270
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
4378 total[7] = Fcons (make_number (total_strings), |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4379 make_number (total_free_strings)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4380 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4381 #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
|
4382 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4383 /* 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
|
4384 double nlive = 0; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4385 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4386 for (i = 0; i < 7; ++i) |
49357 | 4387 if (CONSP (total[i])) |
4388 nlive += XFASTINT (XCAR (total[i])); | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4389 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4390 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
|
4391 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
|
4392 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
|
4393 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
|
4394 ++ngcs; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4395 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4396 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4397 |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4398 if (!NILP (Vpost_gc_hook)) |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4399 { |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4400 int count = inhibit_garbage_collection (); |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4401 safe_run_hooks (Qpost_gc_hook); |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4402 unbind_to (count, Qnil); |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4403 } |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4404 |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4405 /* Accumulate statistics. */ |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4406 EMACS_GET_TIME (t2); |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4407 EMACS_SUB_TIME (t3, t2, t1); |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4408 if (FLOATP (Vgc_elapsed)) |
49911
d9ade23e09df
(Fgarbage_collect): Don't use XSETFLOAT.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49600
diff
changeset
|
4409 Vgc_elapsed = make_float (XFLOAT_DATA (Vgc_elapsed) + |
d9ade23e09df
(Fgarbage_collect): Don't use XSETFLOAT.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49600
diff
changeset
|
4410 EMACS_SECS (t3) + |
d9ade23e09df
(Fgarbage_collect): Don't use XSETFLOAT.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49600
diff
changeset
|
4411 EMACS_USECS (t3) * 1.0e-6); |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4412 gcs_done++; |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4413 |
34270
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
4414 return Flist (sizeof total / sizeof *total, total); |
300 | 4415 } |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4416 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4417 |
25367
823e14641544
(mark_glyph_matrix): Mark strings only.
Gerd Moellmann <gerd@gnu.org>
parents:
25343
diff
changeset
|
4418 /* 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
|
4419 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
|
4420 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4421 static void |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4422 mark_glyph_matrix (matrix) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4423 struct glyph_matrix *matrix; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4424 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4425 struct glyph_row *row = matrix->rows; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4426 struct glyph_row *end = row + matrix->nrows; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4427 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4428 for (; row < end; ++row) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4429 if (row->enabled_p) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4430 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4431 int area; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4432 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
|
4433 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4434 struct glyph *glyph = row->glyphs[area]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4435 struct glyph *end_glyph = glyph + row->used[area]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4436 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4437 for (; glyph < end_glyph; ++glyph) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4438 if (GC_STRINGP (glyph->object) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4439 && !STRING_MARKED_P (XSTRING (glyph->object))) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4440 mark_object (&glyph->object); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4441 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4442 } |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4443 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4444 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4445 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4446 /* 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
|
4447 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4448 static void |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4449 mark_face_cache (c) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4450 struct face_cache *c; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4451 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4452 if (c) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4453 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4454 int i, j; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4455 for (i = 0; i < c->used; ++i) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4456 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4457 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
|
4458 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4459 if (face) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4460 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4461 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
|
4462 mark_object (&face->lface[j]); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4463 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4464 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4465 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4466 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4467 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4468 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4469 #ifdef HAVE_WINDOW_SYSTEM |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4470 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4471 /* Mark Lisp objects in image IMG. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4472 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4473 static void |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4474 mark_image (img) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4475 struct image *img; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4476 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4477 mark_object (&img->spec); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4478 |
31892
2f3d88ac2b38
(__malloc_size_t) [DOUG_LEA_MALLOC]: Don't redefine it.
Dave Love <fx@gnu.org>
parents:
31889
diff
changeset
|
4479 if (!NILP (img->data.lisp_val)) |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4480 mark_object (&img->data.lisp_val); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4481 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4482 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4483 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4484 /* 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
|
4485 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
|
4486 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4487 static void |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4488 mark_image_cache (f) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4489 struct frame *f; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4490 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4491 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
|
4492 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4493 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4494 #endif /* HAVE_X_WINDOWS */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4495 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4496 |
300 | 4497 |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
4498 /* 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
|
4499 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
|
4500 all the references contained in it. */ |
300 | 4501 |
1168
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
4502 #define LAST_MARKED_SIZE 500 |
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
4503 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
|
4504 int last_marked_index; |
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
4505 |
46833
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
4506 /* For debugging--call abort when we cdr down this many |
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
4507 links of a list, in mark_object. In debugging, |
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
4508 the call to abort will hit a breakpoint. |
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
4509 Normally this is zero and the check never goes off. */ |
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
4510 int mark_object_loop_halt; |
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
4511 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4512 void |
13553
fb12156faaf5
(mark_object): Don't overwrite original argument value.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
4513 mark_object (argptr) |
fb12156faaf5
(mark_object): Don't overwrite original argument value.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
4514 Lisp_Object *argptr; |
300 | 4515 { |
13553
fb12156faaf5
(mark_object): Don't overwrite original argument value.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
4516 Lisp_Object *objptr = argptr; |
300 | 4517 register Lisp_Object obj; |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4518 #ifdef GC_CHECK_MARKED_OBJECTS |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4519 void *po; |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4520 struct mem_node *m; |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4521 #endif |
46833
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
4522 int cdr_count = 0; |
300 | 4523 |
5868
a7bd57a60cb8
(mark_object): Fetch obj from *objptr at loop, not at the gotos.
Karl Heuer <kwzh@gnu.org>
parents:
5353
diff
changeset
|
4524 loop: |
300 | 4525 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
|
4526 loop2: |
300 | 4527 XUNMARK (obj); |
4528 | |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4529 if (PURE_POINTER_P (XPNTR (obj))) |
300 | 4530 return; |
4531 | |
1168
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
4532 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
|
4533 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
|
4534 last_marked_index = 0; |
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
4535 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4536 /* 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
|
4537 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
|
4538 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
|
4539 #ifdef GC_CHECK_MARKED_OBJECTS |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4540 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4541 po = (void *) XPNTR (obj); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4542 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4543 /* 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
|
4544 structure allocated from the heap. */ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4545 #define CHECK_ALLOCATED() \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4546 do { \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4547 m = mem_find (po); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4548 if (m == MEM_NIL) \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4549 abort (); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4550 } while (0) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4551 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4552 /* 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
|
4553 function LIVEP. */ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4554 #define CHECK_LIVE(LIVEP) \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4555 do { \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4556 if (!LIVEP (m, po)) \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4557 abort (); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4558 } while (0) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4559 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4560 /* 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
|
4561 #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
|
4562 do { \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4563 CHECK_ALLOCATED (); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4564 CHECK_LIVE (LIVEP); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4565 } while (0) \ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4566 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4567 #else /* not GC_CHECK_MARKED_OBJECTS */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4568 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4569 #define CHECK_ALLOCATED() (void) 0 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4570 #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
|
4571 #define CHECK_ALLOCATED_AND_LIVE(LIVEP) (void) 0 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4572 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4573 #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
|
4574 |
10457
2ab3bd0288a9
Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents:
10427
diff
changeset
|
4575 switch (SWITCH_ENUM_CAST (XGCTYPE (obj))) |
300 | 4576 { |
4577 case Lisp_String: | |
4578 { | |
4579 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
|
4580 CHECK_ALLOCATED_AND_LIVE (live_string_p); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4581 MARK_INTERVAL_TREE (ptr->intervals); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4582 MARK_STRING (ptr); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
4583 #ifdef GC_CHECK_STRING_BYTES |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
4584 /* Check that the string size recorded in the string is the |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
4585 same as the one recorded in the sdata structure. */ |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
4586 CHECK_STRING_BYTES (ptr); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
4587 #endif /* GC_CHECK_STRING_BYTES */ |
300 | 4588 } |
4589 break; | |
4590 | |
10009
82f3daf76995
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
10004
diff
changeset
|
4591 case Lisp_Vectorlike: |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4592 #ifdef GC_CHECK_MARKED_OBJECTS |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4593 m = mem_find (po); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4594 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
|
4595 && po != &buffer_defaults |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4596 && po != &buffer_local_symbols) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4597 abort (); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4598 #endif /* GC_CHECK_MARKED_OBJECTS */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4599 |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
4600 if (GC_BUFFERP (obj)) |
10340
ef58c7a5a4d6
(mark_object, mark_buffer): Don't mark buffer twice.
Karl Heuer <kwzh@gnu.org>
parents:
10320
diff
changeset
|
4601 { |
ef58c7a5a4d6
(mark_object, mark_buffer): Don't mark buffer twice.
Karl Heuer <kwzh@gnu.org>
parents:
10320
diff
changeset
|
4602 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
|
4603 { |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4604 #ifdef GC_CHECK_MARKED_OBJECTS |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4605 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
|
4606 { |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4607 struct buffer *b; |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4608 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
|
4609 ; |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4610 if (b == NULL) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4611 abort (); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4612 } |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4613 #endif /* GC_CHECK_MARKED_OBJECTS */ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4614 mark_buffer (obj); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4615 } |
10340
ef58c7a5a4d6
(mark_object, mark_buffer): Don't mark buffer twice.
Karl Heuer <kwzh@gnu.org>
parents:
10320
diff
changeset
|
4616 } |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
4617 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
|
4618 break; |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4619 else if (GC_COMPILEDP (obj)) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4620 /* 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
|
4621 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
|
4622 recursion there. */ |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4623 { |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4624 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
|
4625 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
|
4626 register int i; |
300 | 4627 |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4628 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
|
4629 break; /* Already marked */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4630 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4631 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
|
4632 ptr->size |= ARRAY_MARK_FLAG; /* Else mark it */ |
10009
82f3daf76995
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
10004
diff
changeset
|
4633 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
|
4634 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
|
4635 { |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4636 if (i != COMPILED_CONSTANTS) |
32360
d8b668a486d7
(mark_object): Remove all workarounds installed on
Andreas Schwab <schwab@suse.de>
parents:
32099
diff
changeset
|
4637 mark_object (&ptr->contents[i]); |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4638 } |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4639 /* 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
|
4640 (MIPS-ABI + SysVR4, DC/OSx, etc). */ |
32360
d8b668a486d7
(mark_object): Remove all workarounds installed on
Andreas Schwab <schwab@suse.de>
parents:
32099
diff
changeset
|
4641 objptr = (Lisp_Object *) &ptr->contents[COMPILED_CONSTANTS]; |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4642 goto loop; |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4643 } |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4644 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
|
4645 { |
32360
d8b668a486d7
(mark_object): Remove all workarounds installed on
Andreas Schwab <schwab@suse.de>
parents:
32099
diff
changeset
|
4646 register struct frame *ptr = XFRAME (obj); |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4647 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
|
4648 |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4649 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
|
4650 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
|
4651 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4652 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
|
4653 mark_object (&ptr->name); |
12273
377cbbd8a2ad
(mark_object): Mark icon_name field.
Richard M. Stallman <rms@gnu.org>
parents:
12175
diff
changeset
|
4654 mark_object (&ptr->icon_name); |
14216
5970a52070bb
(mark_object): Mark frame title field.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
4655 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
|
4656 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
|
4657 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
|
4658 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
|
4659 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
|
4660 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
|
4661 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
|
4662 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
|
4663 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
|
4664 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
|
4665 mark_object (&ptr->buffer_predicate); |
17217
571d0c136e48
(mark_object): Mark the buffer_list field.
Richard M. Stallman <rms@gnu.org>
parents:
17021
diff
changeset
|
4666 mark_object (&ptr->buffer_list); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4667 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
|
4668 mark_object (&ptr->tool_bar_window); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4669 mark_face_cache (ptr->face_cache); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4670 #ifdef HAVE_WINDOW_SYSTEM |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4671 mark_image_cache (ptr); |
33764
a832bb73de79
(mark_object) <frame>: Mark tool bar items differently.
Gerd Moellmann <gerd@gnu.org>
parents:
33623
diff
changeset
|
4672 mark_object (&ptr->tool_bar_items); |
25544
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25452
diff
changeset
|
4673 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
|
4674 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
|
4675 #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
|
4676 } |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
4677 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
|
4678 { |
5cd52d4838f8
(mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents:
14959
diff
changeset
|
4679 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
|
4680 |
5cd52d4838f8
(mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents:
14959
diff
changeset
|
4681 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
|
4682 break; /* Already marked */ |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4683 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
|
4684 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
|
4685 } |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4686 else if (GC_WINDOWP (obj)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4687 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4688 register struct Lisp_Vector *ptr = XVECTOR (obj); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4689 struct window *w = XWINDOW (obj); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4690 register EMACS_INT size = ptr->size; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4691 register int i; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4692 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4693 /* Stop if already marked. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4694 if (size & ARRAY_MARK_FLAG) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4695 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4696 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4697 /* Mark it. */ |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4698 CHECK_LIVE (live_vector_p); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4699 ptr->size |= ARRAY_MARK_FLAG; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4700 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4701 /* 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
|
4702 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
|
4703 for (i = 0; |
32360
d8b668a486d7
(mark_object): Remove all workarounds installed on
Andreas Schwab <schwab@suse.de>
parents:
32099
diff
changeset
|
4704 (char *) &ptr->contents[i] < (char *) &w->current_matrix; |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4705 i++) |
32360
d8b668a486d7
(mark_object): Remove all workarounds installed on
Andreas Schwab <schwab@suse.de>
parents:
32099
diff
changeset
|
4706 mark_object (&ptr->contents[i]); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4707 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4708 /* 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
|
4709 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
|
4710 memory. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4711 if (NILP (w->hchild) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4712 && NILP (w->vchild) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4713 && w->current_matrix) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4714 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4715 mark_glyph_matrix (w->current_matrix); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4716 mark_glyph_matrix (w->desired_matrix); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4717 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4718 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4719 else if (GC_HASH_TABLE_P (obj)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4720 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4721 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
|
4722 EMACS_INT size = h->size; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4723 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4724 /* Stop if already marked. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4725 if (size & ARRAY_MARK_FLAG) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4726 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4727 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4728 /* Mark it. */ |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4729 CHECK_LIVE (live_vector_p); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4730 h->size |= ARRAY_MARK_FLAG; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4731 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4732 /* Mark contents. */ |
43005 | 4733 /* Do not mark next_free or next_weak. |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4734 Being in the next_weak chain |
43005 | 4735 should not keep the hash table alive. |
4736 No need to mark `count' since it is an integer. */ | |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4737 mark_object (&h->test); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4738 mark_object (&h->weak); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4739 mark_object (&h->rehash_size); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4740 mark_object (&h->rehash_threshold); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4741 mark_object (&h->hash); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4742 mark_object (&h->next); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4743 mark_object (&h->index); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4744 mark_object (&h->user_hash_function); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4745 mark_object (&h->user_cmp_function); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4746 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4747 /* 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
|
4748 For weak tables, mark only the vector. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4749 if (GC_NILP (h->weak)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4750 mark_object (&h->key_and_value); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4751 else |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4752 XVECTOR (h->key_and_value)->size |= ARRAY_MARK_FLAG; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4753 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4754 } |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4755 else |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4756 { |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4757 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
|
4758 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
|
4759 register int i; |
300 | 4760 |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4761 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
|
4762 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
|
4763 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
|
4764 if (size & PSEUDOVECTOR_FLAG) |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4765 size &= PSEUDOVECTOR_SIZE_MASK; |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4766 |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4767 for (i = 0; i < size; i++) /* and then mark its elements */ |
32360
d8b668a486d7
(mark_object): Remove all workarounds installed on
Andreas Schwab <schwab@suse.de>
parents:
32099
diff
changeset
|
4768 mark_object (&ptr->contents[i]); |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4769 } |
300 | 4770 break; |
4771 | |
4772 case Lisp_Symbol: | |
4773 { | |
32360
d8b668a486d7
(mark_object): Remove all workarounds installed on
Andreas Schwab <schwab@suse.de>
parents:
32099
diff
changeset
|
4774 register struct Lisp_Symbol *ptr = XSYMBOL (obj); |
300 | 4775 struct Lisp_Symbol *ptrx; |
4776 | |
4777 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
|
4778 CHECK_ALLOCATED_AND_LIVE (live_symbol_p); |
300 | 4779 XMARK (ptr->plist); |
4780 mark_object ((Lisp_Object *) &ptr->value); | |
4781 mark_object (&ptr->function); | |
4782 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
|
4783 |
45392
f3d7ab65641f
* alloc.c (Fmake_symbol): Set symbol xname field instead of name.
Ken Raeburn <raeburn@raeburn.org>
parents:
44890
diff
changeset
|
4784 if (!PURE_POINTER_P (XSTRING (ptr->xname))) |
f3d7ab65641f
* alloc.c (Fmake_symbol): Set symbol xname field instead of name.
Ken Raeburn <raeburn@raeburn.org>
parents:
44890
diff
changeset
|
4785 MARK_STRING (XSTRING (ptr->xname)); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46305
diff
changeset
|
4786 MARK_INTERVAL_TREE (STRING_INTERVALS (ptr->xname)); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4787 |
20768 | 4788 /* Note that we do not mark the obarray of the symbol. |
4789 It is safe not to do so because nothing accesses that | |
4790 slot except to check whether it is nil. */ | |
300 | 4791 ptr = ptr->next; |
4792 if (ptr) | |
4793 { | |
5868
a7bd57a60cb8
(mark_object): Fetch obj from *objptr at loop, not at the gotos.
Karl Heuer <kwzh@gnu.org>
parents:
5353
diff
changeset
|
4794 /* 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
|
4795 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
|
4796 ptrx = ptr; /* Use of ptrx avoids compiler bug on Sun */ |
300 | 4797 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
|
4798 /* 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
|
4799 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
|
4800 goto loop2; |
300 | 4801 } |
4802 } | |
4803 break; | |
4804 | |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
4805 case Lisp_Misc: |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4806 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
|
4807 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
|
4808 { |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
4809 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
|
4810 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
|
4811 /* 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
|
4812 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
|
4813 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
|
4814 break; |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
4815 |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4816 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
|
4817 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
|
4818 { |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4819 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
|
4820 = XBUFFER_LOCAL_VALUE (obj); |
21143
ce12eac1ee45
(gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents:
21084
diff
changeset
|
4821 if (XMARKBIT (ptr->realvalue)) break; |
ce12eac1ee45
(gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents:
21084
diff
changeset
|
4822 XMARK (ptr->realvalue); |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4823 /* 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
|
4824 if (EQ (ptr->cdr, Qnil)) |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4825 { |
21143
ce12eac1ee45
(gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents:
21084
diff
changeset
|
4826 objptr = &ptr->realvalue; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4827 goto loop; |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4828 } |
21143
ce12eac1ee45
(gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents:
21084
diff
changeset
|
4829 mark_object (&ptr->realvalue); |
ce12eac1ee45
(gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents:
21084
diff
changeset
|
4830 mark_object (&ptr->buffer); |
ce12eac1ee45
(gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents:
21084
diff
changeset
|
4831 mark_object (&ptr->frame); |
32360
d8b668a486d7
(mark_object): Remove all workarounds installed on
Andreas Schwab <schwab@suse.de>
parents:
32099
diff
changeset
|
4832 objptr = &ptr->cdr; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4833 goto loop; |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4834 } |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4835 |
9463
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4836 case Lisp_Misc_Intfwd: |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4837 case Lisp_Misc_Boolfwd: |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4838 case Lisp_Misc_Objfwd: |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4839 case Lisp_Misc_Buffer_Objfwd: |
11018
2d9bdf1ba3d1
(mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents:
10936
diff
changeset
|
4840 case Lisp_Misc_Kboard_Objfwd: |
9463
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4841 /* Don't bother with Lisp_Buffer_Objfwd, |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4842 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
|
4843 /* 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
|
4844 are protected with staticpro. */ |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4845 break; |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4846 |
9926
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4847 case Lisp_Misc_Overlay: |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4848 { |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4849 struct Lisp_Overlay *ptr = XOVERLAY (obj); |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4850 if (!XMARKBIT (ptr->plist)) |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4851 { |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4852 XMARK (ptr->plist); |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4853 mark_object (&ptr->start); |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4854 mark_object (&ptr->end); |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4855 objptr = &ptr->plist; |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4856 goto loop; |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4857 } |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4858 } |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4859 break; |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4860 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
4861 default: |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
4862 abort (); |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
4863 } |
300 | 4864 break; |
4865 | |
4866 case Lisp_Cons: | |
4867 { | |
4868 register struct Lisp_Cons *ptr = XCONS (obj); | |
4869 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
|
4870 CHECK_ALLOCATED_AND_LIVE (live_cons_p); |
300 | 4871 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
|
4872 /* 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
|
4873 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
|
4874 { |
a9241dc503ab
(mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents:
1168
diff
changeset
|
4875 objptr = &ptr->car; |
46833
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
4876 cdr_count = 0; |
1295
a9241dc503ab
(mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents:
1168
diff
changeset
|
4877 goto loop; |
a9241dc503ab
(mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents:
1168
diff
changeset
|
4878 } |
300 | 4879 mark_object (&ptr->car); |
32360
d8b668a486d7
(mark_object): Remove all workarounds installed on
Andreas Schwab <schwab@suse.de>
parents:
32099
diff
changeset
|
4880 objptr = &ptr->cdr; |
46833
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
4881 cdr_count++; |
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
4882 if (cdr_count == mark_object_loop_halt) |
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
4883 abort (); |
300 | 4884 goto loop; |
4885 } | |
4886 | |
4887 case Lisp_Float: | |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4888 CHECK_ALLOCATED_AND_LIVE (live_float_p); |
300 | 4889 XMARK (XFLOAT (obj)->type); |
4890 break; | |
4891 | |
4892 case Lisp_Int: | |
4893 break; | |
4894 | |
4895 default: | |
4896 abort (); | |
4897 } | |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4898 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4899 #undef CHECK_LIVE |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4900 #undef CHECK_ALLOCATED |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4901 #undef CHECK_ALLOCATED_AND_LIVE |
300 | 4902 } |
4903 | |
4904 /* Mark the pointers in a buffer structure. */ | |
4905 | |
4906 static void | |
4907 mark_buffer (buf) | |
4908 Lisp_Object buf; | |
4909 { | |
4910 register struct buffer *buffer = XBUFFER (buf); | |
4911 register Lisp_Object *ptr; | |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
4912 Lisp_Object base_buffer; |
300 | 4913 |
4914 /* This is the buffer's markbit */ | |
4915 mark_object (&buffer->name); | |
4916 XMARK (buffer->name); | |
4917 | |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
4918 MARK_INTERVAL_TREE (BUF_INTERVALS (buffer)); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4919 |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4920 if (CONSP (buffer->undo_list)) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4921 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4922 Lisp_Object tail; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4923 tail = buffer->undo_list; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4924 |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4925 while (CONSP (tail)) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4926 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4927 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
|
4928 |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4929 if (XMARKBIT (ptr->car)) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4930 break; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4931 XMARK (ptr->car); |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4932 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
|
4933 && ! XMARKBIT (XCAR (ptr->car)) |
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4934 && 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
|
4935 { |
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
4936 XMARK (XCAR_AS_LVALUE (ptr->car)); |
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
4937 mark_object (&XCDR_AS_LVALUE (ptr->car)); |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4938 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4939 else |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4940 mark_object (&ptr->car); |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4941 |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4942 if (CONSP (ptr->cdr)) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4943 tail = ptr->cdr; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4944 else |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4945 break; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4946 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4947 |
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
4948 mark_object (&XCDR_AS_LVALUE (tail)); |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4949 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4950 else |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4951 mark_object (&buffer->undo_list); |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4952 |
300 | 4953 for (ptr = &buffer->name + 1; |
4954 (char *)ptr < (char *)buffer + sizeof (struct buffer); | |
4955 ptr++) | |
4956 mark_object (ptr); | |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
4957 |
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
4958 /* 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
|
4959 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
|
4960 { |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4961 XSETBUFFER (base_buffer, buffer->base_buffer); |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
4962 mark_buffer (base_buffer); |
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
4963 } |
300 | 4964 } |
10649
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
4965 |
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
4966 |
11018
2d9bdf1ba3d1
(mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents:
10936
diff
changeset
|
4967 /* Mark the pointers in the kboard objects. */ |
10649
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
4968 |
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
4969 static void |
11018
2d9bdf1ba3d1
(mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents:
10936
diff
changeset
|
4970 mark_kboards () |
10649
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
4971 { |
11018
2d9bdf1ba3d1
(mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents:
10936
diff
changeset
|
4972 KBOARD *kb; |
11593
f5385353aae3
(mark_kboards): Mark the kbd macro and Vsystem_key_alist.
Karl Heuer <kwzh@gnu.org>
parents:
11430
diff
changeset
|
4973 Lisp_Object *p; |
11018
2d9bdf1ba3d1
(mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents:
10936
diff
changeset
|
4974 for (kb = all_kboards; kb; kb = kb->next_kboard) |
10649
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
4975 { |
11593
f5385353aae3
(mark_kboards): Mark the kbd macro and Vsystem_key_alist.
Karl Heuer <kwzh@gnu.org>
parents:
11430
diff
changeset
|
4976 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
|
4977 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
|
4978 mark_object (p); |
22381
50e1804145be
(mark_kboards): Mark all the Lisp_Object fields.
Richard M. Stallman <rms@gnu.org>
parents:
22220
diff
changeset
|
4979 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
|
4980 mark_object (&kb->Vlast_command); |
50e1804145be
(mark_kboards): Mark all the Lisp_Object fields.
Richard M. Stallman <rms@gnu.org>
parents:
22220
diff
changeset
|
4981 mark_object (&kb->Vreal_last_command); |
12120
1fc112b5fdc4
(mark_kboards): Mark Vprefix_arg instead of
Karl Heuer <kwzh@gnu.org>
parents:
12096
diff
changeset
|
4982 mark_object (&kb->Vprefix_arg); |
22382
f7d2bdefcff7
(mark_kboards): Mark Vlast_prefix_arg too.
Richard M. Stallman <rms@gnu.org>
parents:
22381
diff
changeset
|
4983 mark_object (&kb->Vlast_prefix_arg); |
11018
2d9bdf1ba3d1
(mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents:
10936
diff
changeset
|
4984 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
|
4985 mark_object (&kb->defining_kbd_macro); |
11018
2d9bdf1ba3d1
(mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents:
10936
diff
changeset
|
4986 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
|
4987 mark_object (&kb->Vsystem_key_alist); |
12175
4e36e9e99082
(mark_kboards): Mark system_key_syms member.
Karl Heuer <kwzh@gnu.org>
parents:
12120
diff
changeset
|
4988 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
|
4989 mark_object (&kb->Vdefault_minibuffer_frame); |
43751
c82e347557f1
(mark_kboards): Mark echo_string.
Gerd Moellmann <gerd@gnu.org>
parents:
43713
diff
changeset
|
4990 mark_object (&kb->echo_string); |
10649
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
4991 } |
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
4992 } |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4993 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4994 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4995 /* 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
|
4996 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
|
4997 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4998 int |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4999 survives_gc_p (obj) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5000 Lisp_Object obj; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5001 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5002 int survives_p; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5003 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5004 switch (XGCTYPE (obj)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5005 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5006 case Lisp_Int: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5007 survives_p = 1; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5008 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5009 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5010 case Lisp_Symbol: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5011 survives_p = XMARKBIT (XSYMBOL (obj)->plist); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5012 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5013 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5014 case Lisp_Misc: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5015 switch (XMISCTYPE (obj)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5016 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5017 case Lisp_Misc_Marker: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5018 survives_p = XMARKBIT (obj); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5019 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5020 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5021 case Lisp_Misc_Buffer_Local_Value: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5022 case Lisp_Misc_Some_Buffer_Local_Value: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5023 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
|
5024 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5025 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5026 case Lisp_Misc_Intfwd: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5027 case Lisp_Misc_Boolfwd: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5028 case Lisp_Misc_Objfwd: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5029 case Lisp_Misc_Buffer_Objfwd: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5030 case Lisp_Misc_Kboard_Objfwd: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5031 survives_p = 1; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5032 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5033 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5034 case Lisp_Misc_Overlay: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5035 survives_p = XMARKBIT (XOVERLAY (obj)->plist); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5036 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5037 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5038 default: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5039 abort (); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5040 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5041 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5042 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5043 case Lisp_String: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5044 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5045 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
|
5046 survives_p = STRING_MARKED_P (s); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5047 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5048 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5049 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5050 case Lisp_Vectorlike: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5051 if (GC_BUFFERP (obj)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5052 survives_p = XMARKBIT (XBUFFER (obj)->name); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5053 else if (GC_SUBRP (obj)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5054 survives_p = 1; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5055 else |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5056 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
|
5057 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5058 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5059 case Lisp_Cons: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5060 survives_p = XMARKBIT (XCAR (obj)); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5061 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5062 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5063 case Lisp_Float: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5064 survives_p = XMARKBIT (XFLOAT (obj)->type); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5065 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5066 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5067 default: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5068 abort (); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5069 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5070 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5071 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
|
5072 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5073 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5074 |
300 | 5075 |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
5076 /* Sweep: find all structures not marked, and free them. */ |
300 | 5077 |
5078 static void | |
5079 gc_sweep () | |
5080 { | |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5081 /* 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
|
5082 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
|
5083 sweep_weak_hash_tables (); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5084 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5085 sweep_strings (); |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5086 #ifdef GC_CHECK_STRING_BYTES |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5087 if (!noninteractive) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5088 check_string_bytes (1); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5089 #endif |
300 | 5090 |
5091 /* Put all unmarked conses on free list */ | |
5092 { | |
5093 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
|
5094 struct cons_block **cprev = &cons_block; |
300 | 5095 register int lim = cons_block_index; |
5096 register int num_free = 0, num_used = 0; | |
5097 | |
5098 cons_free_list = 0; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5099 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5100 for (cblk = cons_block; cblk; cblk = *cprev) |
300 | 5101 { |
5102 register int i; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5103 int this_free = 0; |
300 | 5104 for (i = 0; i < lim; i++) |
5105 if (!XMARKBIT (cblk->conses[i].car)) | |
5106 { | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5107 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
|
5108 *(struct Lisp_Cons **)&cblk->conses[i].cdr = cons_free_list; |
300 | 5109 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
|
5110 #if GC_MARK_STACK |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5111 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
|
5112 #endif |
300 | 5113 } |
5114 else | |
5115 { | |
5116 num_used++; | |
5117 XUNMARK (cblk->conses[i].car); | |
5118 } | |
5119 lim = CONS_BLOCK_SIZE; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5120 /* 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
|
5121 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
|
5122 this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5123 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
|
5124 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5125 *cprev = cblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5126 /* Unhook from the free list. */ |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5127 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
|
5128 lisp_free (cblk); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5129 n_cons_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5130 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5131 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5132 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5133 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5134 cprev = &cblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5135 } |
300 | 5136 } |
5137 total_conses = num_used; | |
5138 total_free_conses = num_free; | |
5139 } | |
5140 | |
5141 /* Put all unmarked floats on free list */ | |
5142 { | |
5143 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
|
5144 struct float_block **fprev = &float_block; |
300 | 5145 register int lim = float_block_index; |
5146 register int num_free = 0, num_used = 0; | |
5147 | |
5148 float_free_list = 0; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5149 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5150 for (fblk = float_block; fblk; fblk = *fprev) |
300 | 5151 { |
5152 register int i; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5153 int this_free = 0; |
300 | 5154 for (i = 0; i < lim; i++) |
5155 if (!XMARKBIT (fblk->floats[i].type)) | |
5156 { | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5157 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
|
5158 *(struct Lisp_Float **)&fblk->floats[i].data = float_free_list; |
300 | 5159 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
|
5160 #if GC_MARK_STACK |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5161 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
|
5162 #endif |
300 | 5163 } |
5164 else | |
5165 { | |
5166 num_used++; | |
5167 XUNMARK (fblk->floats[i].type); | |
5168 } | |
5169 lim = FLOAT_BLOCK_SIZE; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5170 /* 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
|
5171 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
|
5172 this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5173 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
|
5174 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5175 *fprev = fblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5176 /* Unhook from the free list. */ |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5177 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
|
5178 lisp_free (fblk); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5179 n_float_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5180 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5181 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5182 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5183 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5184 fprev = &fblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5185 } |
300 | 5186 } |
5187 total_floats = num_used; | |
5188 total_free_floats = num_free; | |
5189 } | |
5190 | |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5191 /* Put all unmarked intervals on free list */ |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5192 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5193 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
|
5194 struct interval_block **iprev = &interval_block; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5195 register int lim = interval_block_index; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5196 register int num_free = 0, num_used = 0; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5197 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5198 interval_free_list = 0; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5199 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5200 for (iblk = interval_block; iblk; iblk = *iprev) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5201 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5202 register int i; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5203 int this_free = 0; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5204 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5205 for (i = 0; i < lim; i++) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5206 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5207 if (! XMARKBIT (iblk->intervals[i].plist)) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5208 { |
28269
fd13be8ae190
Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents:
28220
diff
changeset
|
5209 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
|
5210 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
|
5211 this_free++; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5212 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5213 else |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5214 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5215 num_used++; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5216 XUNMARK (iblk->intervals[i].plist); |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5217 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5218 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5219 lim = INTERVAL_BLOCK_SIZE; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5220 /* 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
|
5221 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
|
5222 deallocate this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5223 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
|
5224 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5225 *iprev = iblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5226 /* Unhook from the free list. */ |
28269
fd13be8ae190
Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents:
28220
diff
changeset
|
5227 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
|
5228 lisp_free (iblk); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5229 n_interval_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5230 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5231 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5232 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5233 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5234 iprev = &iblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5235 } |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5236 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5237 total_intervals = num_used; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5238 total_free_intervals = num_free; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5239 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5240 |
300 | 5241 /* Put all unmarked symbols on free list */ |
5242 { | |
5243 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
|
5244 struct symbol_block **sprev = &symbol_block; |
300 | 5245 register int lim = symbol_block_index; |
5246 register int num_free = 0, num_used = 0; | |
5247 | |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5248 symbol_free_list = NULL; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5249 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5250 for (sblk = symbol_block; sblk; sblk = *sprev) |
300 | 5251 { |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5252 int this_free = 0; |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5253 struct Lisp_Symbol *sym = sblk->symbols; |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5254 struct Lisp_Symbol *end = sym + lim; |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5255 |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5256 for (; sym < end; ++sym) |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5257 { |
34325
a65d8c29442a
(gc_sweep): Add comment.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34308
diff
changeset
|
5258 /* Check if the symbol was created during loadup. In such a case |
a65d8c29442a
(gc_sweep): Add comment.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34308
diff
changeset
|
5259 it might be pointed to by pure bytecode which we don't trace, |
a65d8c29442a
(gc_sweep): Add comment.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34308
diff
changeset
|
5260 so we conservatively assume that it is live. */ |
45392
f3d7ab65641f
* alloc.c (Fmake_symbol): Set symbol xname field instead of name.
Ken Raeburn <raeburn@raeburn.org>
parents:
44890
diff
changeset
|
5261 int pure_p = PURE_POINTER_P (XSTRING (sym->xname)); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5262 |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5263 if (!XMARKBIT (sym->plist) && !pure_p) |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5264 { |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5265 *(struct Lisp_Symbol **) &sym->value = symbol_free_list; |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5266 symbol_free_list = sym; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5267 #if GC_MARK_STACK |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5268 symbol_free_list->function = Vdead; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5269 #endif |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5270 ++this_free; |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5271 } |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5272 else |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5273 { |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5274 ++num_used; |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5275 if (!pure_p) |
45392
f3d7ab65641f
* alloc.c (Fmake_symbol): Set symbol xname field instead of name.
Ken Raeburn <raeburn@raeburn.org>
parents:
44890
diff
changeset
|
5276 UNMARK_STRING (XSTRING (sym->xname)); |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5277 XUNMARK (sym->plist); |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5278 } |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5279 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5280 |
300 | 5281 lim = SYMBOL_BLOCK_SIZE; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5282 /* 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
|
5283 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
|
5284 this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5285 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
|
5286 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5287 *sprev = sblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5288 /* Unhook from the free list. */ |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5289 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
|
5290 lisp_free (sblk); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5291 n_symbol_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5292 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5293 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5294 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5295 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5296 sprev = &sblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5297 } |
300 | 5298 } |
5299 total_symbols = num_used; | |
5300 total_free_symbols = num_free; | |
5301 } | |
5302 | |
21143
ce12eac1ee45
(gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents:
21084
diff
changeset
|
5303 /* 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
|
5304 For a marker, first unchain it from the buffer it points into. */ |
300 | 5305 { |
5306 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
|
5307 struct marker_block **mprev = &marker_block; |
300 | 5308 register int lim = marker_block_index; |
5309 register int num_free = 0, num_used = 0; | |
5310 | |
5311 marker_free_list = 0; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5312 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5313 for (mblk = marker_block; mblk; mblk = *mprev) |
300 | 5314 { |
5315 register int i; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5316 int this_free = 0; |
11679
1ced2d67d411
(gc_cons_threshold): Make this an EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
11593
diff
changeset
|
5317 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
|
5318 |
300 | 5319 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
|
5320 { |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5321 Lisp_Object *markword; |
11243
054ecfce1820
(Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents:
11048
diff
changeset
|
5322 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
|
5323 { |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5324 case Lisp_Misc_Marker: |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5325 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
|
5326 break; |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5327 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
|
5328 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
|
5329 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
|
5330 break; |
9926
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
5331 case Lisp_Misc_Overlay: |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
5332 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
|
5333 break; |
11403
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
5334 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
|
5335 /* 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
|
5336 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
|
5337 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
|
5338 break; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5339 default: |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5340 markword = 0; |
9926
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
5341 break; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5342 } |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5343 if (markword && !XMARKBIT (*markword)) |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5344 { |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5345 Lisp_Object tem; |
11243
054ecfce1820
(Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents:
11048
diff
changeset
|
5346 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
|
5347 { |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5348 /* tem1 avoids Sun compiler bug */ |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5349 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
|
5350 XSETMARKER (tem, tem1); |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5351 unchain_marker (tem); |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5352 } |
11403
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
5353 /* 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
|
5354 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
|
5355 but this might catch bugs faster. */ |
11243
054ecfce1820
(Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents:
11048
diff
changeset
|
5356 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
|
5357 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
|
5358 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
|
5359 this_free++; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5360 } |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5361 else |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5362 { |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5363 num_used++; |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5364 if (markword) |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5365 XUNMARK (*markword); |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5366 } |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5367 } |
300 | 5368 lim = MARKER_BLOCK_SIZE; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5369 /* 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
|
5370 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
|
5371 this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5372 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
|
5373 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5374 *mprev = mblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5375 /* Unhook from the free list. */ |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5376 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
|
5377 lisp_free (mblk); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5378 n_marker_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5379 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5380 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5381 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5382 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5383 mprev = &mblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5384 } |
300 | 5385 } |
5386 | |
5387 total_markers = num_used; | |
5388 total_free_markers = num_free; | |
5389 } | |
5390 | |
5391 /* Free all unmarked buffers */ | |
5392 { | |
5393 register struct buffer *buffer = all_buffers, *prev = 0, *next; | |
5394 | |
5395 while (buffer) | |
5396 if (!XMARKBIT (buffer->name)) | |
5397 { | |
5398 if (prev) | |
5399 prev->next = buffer->next; | |
5400 else | |
5401 all_buffers = buffer->next; | |
5402 next = buffer->next; | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5403 lisp_free (buffer); |
300 | 5404 buffer = next; |
5405 } | |
5406 else | |
5407 { | |
5408 XUNMARK (buffer->name); | |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5409 UNMARK_BALANCE_INTERVALS (BUF_INTERVALS (buffer)); |
300 | 5410 prev = buffer, buffer = buffer->next; |
5411 } | |
5412 } | |
5413 | |
5414 /* Free all unmarked vectors */ | |
5415 { | |
5416 register struct Lisp_Vector *vector = all_vectors, *prev = 0, *next; | |
5417 total_vector_size = 0; | |
5418 | |
5419 while (vector) | |
5420 if (!(vector->size & ARRAY_MARK_FLAG)) | |
5421 { | |
5422 if (prev) | |
5423 prev->next = vector->next; | |
5424 else | |
5425 all_vectors = vector->next; | |
5426 next = vector->next; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5427 lisp_free (vector); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5428 n_vectors--; |
300 | 5429 vector = next; |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5430 |
300 | 5431 } |
5432 else | |
5433 { | |
5434 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
|
5435 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
|
5436 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
|
5437 else |
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
5438 total_vector_size += vector->size; |
300 | 5439 prev = vector, vector = vector->next; |
5440 } | |
5441 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5442 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5443 #ifdef GC_CHECK_STRING_BYTES |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5444 if (!noninteractive) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5445 check_string_bytes (1); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5446 #endif |
300 | 5447 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5448 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5449 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5450 |
300 | 5451 |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5452 /* Debugging aids. */ |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5453 |
5353
6389ed5b45ac
(Fmemory_limit): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents:
4956
diff
changeset
|
5454 DEFUN ("memory-limit", Fmemory_limit, Smemory_limit, 0, 0, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5455 doc: /* Return the address of the last byte Emacs has allocated, divided by 1024. |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5456 This may be helpful in debugging Emacs's memory usage. |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5457 We divide the value by 1024 to make sure it fits in a Lisp integer. */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5458 () |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5459 { |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5460 Lisp_Object end; |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5461 |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
5462 XSETINT (end, (EMACS_INT) sbrk (0) / 1024); |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5463 |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5464 return end; |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5465 } |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5466 |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
5467 DEFUN ("memory-use-counts", Fmemory_use_counts, Smemory_use_counts, 0, 0, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5468 doc: /* Return a list of counters that measure how much consing there has been. |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5469 Each of these counters increments for a certain kind of object. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5470 The counters wrap around from the largest positive integer to zero. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5471 Garbage collection does not decrease them. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5472 The elements of the value are as follows: |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5473 (CONSES FLOATS VECTOR-CELLS SYMBOLS STRING-CHARS MISCS INTERVALS STRINGS) |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5474 All are in units of 1 = one object consed |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5475 except for VECTOR-CELLS and STRING-CHARS, which count the total length of |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5476 objects consed. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5477 MISCS include overlays, markers, and some internal types. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5478 Frames, windows, buffers, and subprocesses count as vectors |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5479 (but the contents of a buffer's text do not count here). */) |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5480 () |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
5481 { |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5482 Lisp_Object consed[8]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5483 |
39633
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
5484 consed[0] = make_number (min (MOST_POSITIVE_FIXNUM, cons_cells_consed)); |
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
5485 consed[1] = make_number (min (MOST_POSITIVE_FIXNUM, floats_consed)); |
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
5486 consed[2] = make_number (min (MOST_POSITIVE_FIXNUM, vector_cells_consed)); |
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
5487 consed[3] = make_number (min (MOST_POSITIVE_FIXNUM, symbols_consed)); |
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
5488 consed[4] = make_number (min (MOST_POSITIVE_FIXNUM, string_chars_consed)); |
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
5489 consed[5] = make_number (min (MOST_POSITIVE_FIXNUM, misc_objects_consed)); |
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
5490 consed[6] = make_number (min (MOST_POSITIVE_FIXNUM, intervals_consed)); |
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
5491 consed[7] = make_number (min (MOST_POSITIVE_FIXNUM, strings_consed)); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5492 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5493 return Flist (8, consed); |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
5494 } |
28406
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5495 |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5496 int suppress_checking; |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5497 void |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5498 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
|
5499 const char *msg; |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5500 const char *file; |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5501 int line; |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5502 { |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5503 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
|
5504 file, line, msg); |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5505 abort (); |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5506 } |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5507 |
300 | 5508 /* Initialization */ |
5509 | |
21514 | 5510 void |
300 | 5511 init_alloc_once () |
5512 { | |
5513 /* Used to do Vpurify_flag = Qt here, but Qt isn't set up yet! */ | |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5514 purebeg = PUREBEG; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5515 pure_size = PURESIZE; |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
5516 pure_bytes_used = 0; |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5517 pure_bytes_used_before_overflow = 0; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5518 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
5519 #if GC_MARK_STACK || defined GC_MALLOC_CHECK |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5520 mem_init (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5521 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
|
5522 #endif |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5523 |
300 | 5524 all_vectors = 0; |
5525 ignore_warnings = 1; | |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
5526 #ifdef DOUG_LEA_MALLOC |
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
5527 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
|
5528 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
|
5529 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
|
5530 #endif |
300 | 5531 init_strings (); |
5532 init_cons (); | |
5533 init_symbol (); | |
5534 init_marker (); | |
5535 init_float (); | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5536 init_intervals (); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5537 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5538 #ifdef REL_ALLOC |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5539 malloc_hysteresis = 32; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5540 #else |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5541 malloc_hysteresis = 0; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5542 #endif |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5543 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5544 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
|
5545 |
300 | 5546 ignore_warnings = 0; |
5547 gcprolist = 0; | |
26364
7b0217d9259c
(Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents:
26164
diff
changeset
|
5548 byte_stack_list = 0; |
300 | 5549 staticidx = 0; |
5550 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
|
5551 gc_cons_threshold = 100000 * sizeof (Lisp_Object); |
300 | 5552 #ifdef VIRT_ADDR_VARIES |
5553 malloc_sbrk_unused = 1<<22; /* A large number */ | |
5554 malloc_sbrk_used = 100000; /* as reasonable as any number */ | |
5555 #endif /* VIRT_ADDR_VARIES */ | |
5556 } | |
5557 | |
21514 | 5558 void |
300 | 5559 init_alloc () |
5560 { | |
5561 gcprolist = 0; | |
26364
7b0217d9259c
(Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents:
26164
diff
changeset
|
5562 byte_stack_list = 0; |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
5563 #if GC_MARK_STACK |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
5564 #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
|
5565 setjmp_tested_p = longjmps_done = 0; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
5566 #endif |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
5567 #endif |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5568 Vgc_elapsed = make_float (0.0); |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5569 gcs_done = 0; |
300 | 5570 } |
5571 | |
5572 void | |
5573 syms_of_alloc () | |
5574 { | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5575 DEFVAR_INT ("gc-cons-threshold", &gc_cons_threshold, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5576 doc: /* *Number of bytes of consing between garbage collections. |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5577 Garbage collection can happen automatically once this many bytes have been |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5578 allocated since the last garbage collection. All data types count. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5579 |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5580 Garbage collection happens automatically only when `eval' is called. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5581 |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5582 By binding this temporarily to a large number, you can effectively |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5583 prevent garbage collection during a part of the program. */); |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5584 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5585 DEFVAR_INT ("pure-bytes-used", &pure_bytes_used, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5586 doc: /* Number of bytes of sharable Lisp data allocated so far. */); |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5587 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5588 DEFVAR_INT ("cons-cells-consed", &cons_cells_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5589 doc: /* Number of cons cells that have been consed so far. */); |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5590 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5591 DEFVAR_INT ("floats-consed", &floats_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5592 doc: /* Number of floats that have been consed so far. */); |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5593 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5594 DEFVAR_INT ("vector-cells-consed", &vector_cells_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5595 doc: /* Number of vector cells that have been consed so far. */); |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5596 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5597 DEFVAR_INT ("symbols-consed", &symbols_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5598 doc: /* Number of symbols that have been consed so far. */); |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5599 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5600 DEFVAR_INT ("string-chars-consed", &string_chars_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5601 doc: /* Number of string characters that have been consed so far. */); |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5602 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5603 DEFVAR_INT ("misc-objects-consed", &misc_objects_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5604 doc: /* Number of miscellaneous objects that have been consed so far. */); |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5605 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5606 DEFVAR_INT ("intervals-consed", &intervals_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5607 doc: /* Number of intervals that have been consed so far. */); |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5608 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5609 DEFVAR_INT ("strings-consed", &strings_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5610 doc: /* Number of strings that have been consed so far. */); |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5611 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5612 DEFVAR_LISP ("purify-flag", &Vpurify_flag, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5613 doc: /* Non-nil means loading Lisp code in order to dump an executable. |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5614 This means that certain objects should be allocated in shared (pure) space. */); |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5615 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5616 DEFVAR_INT ("undo-limit", &undo_limit, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5617 doc: /* Keep no more undo information once it exceeds this size. |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5618 This limit is applied when garbage collection happens. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5619 The size is counted as the number of bytes occupied, |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5620 which includes both saved text and other data. */); |
764 | 5621 undo_limit = 20000; |
300 | 5622 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5623 DEFVAR_INT ("undo-strong-limit", &undo_strong_limit, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5624 doc: /* Don't keep more than this much size of undo information. |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5625 A command which pushes past this size is itself forgotten. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5626 This limit is applied when garbage collection happens. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5627 The size is counted as the number of bytes occupied, |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5628 which includes both saved text and other data. */); |
764 | 5629 undo_strong_limit = 30000; |
300 | 5630 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5631 DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5632 doc: /* Non-nil means display messages at start and end of garbage collection. */); |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
5633 garbage_collection_messages = 0; |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
5634 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5635 DEFVAR_LISP ("post-gc-hook", &Vpost_gc_hook, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5636 doc: /* Hook run after garbage collection has finished. */); |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5637 Vpost_gc_hook = Qnil; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5638 Qpost_gc_hook = intern ("post-gc-hook"); |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5639 staticpro (&Qpost_gc_hook); |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5640 |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
5641 DEFVAR_LISP ("memory-signal-data", &Vmemory_signal_data, |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
5642 doc: /* Precomputed `signal' argument for memory-full error. */); |
6116
64417bbbb128
(memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents:
5874
diff
changeset
|
5643 /* 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
|
5644 not be able to allocate the memory to hold it. */ |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
5645 Vmemory_signal_data |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
5646 = list2 (Qerror, |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
5647 build_string ("Memory exhausted--use M-x save-some-buffers then exit and restart Emacs")); |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
5648 |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
5649 DEFVAR_LISP ("memory-full", &Vmemory_full, |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
5650 doc: /* Non-nil means we are handling a memory-full error. */); |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
5651 Vmemory_full = Qnil; |
6116
64417bbbb128
(memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents:
5874
diff
changeset
|
5652 |
11374
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
5653 staticpro (&Qgc_cons_threshold); |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
5654 Qgc_cons_threshold = intern ("gc-cons-threshold"); |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
5655 |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
5656 staticpro (&Qchar_table_extra_slots); |
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
5657 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
|
5658 |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5659 DEFVAR_LISP ("gc-elapsed", &Vgc_elapsed, |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5660 doc: /* Accumulated time elapsed in garbage collections. |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5661 The time is in seconds as a floating point value. |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5662 Programs may reset this to get statistics in a specific period. */); |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5663 DEFVAR_INT ("gcs-done", &gcs_done, |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5664 doc: /* Accumulated number of garbage collections done. |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5665 Programs may reset this to get statistics in a specific period. */); |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5666 |
300 | 5667 defsubr (&Scons); |
5668 defsubr (&Slist); | |
5669 defsubr (&Svector); | |
5670 defsubr (&Smake_byte_code); | |
5671 defsubr (&Smake_list); | |
5672 defsubr (&Smake_vector); | |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
5673 defsubr (&Smake_char_table); |
300 | 5674 defsubr (&Smake_string); |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
5675 defsubr (&Smake_bool_vector); |
300 | 5676 defsubr (&Smake_symbol); |
5677 defsubr (&Smake_marker); | |
5678 defsubr (&Spurecopy); | |
5679 defsubr (&Sgarbage_collect); | |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5680 defsubr (&Smemory_limit); |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
5681 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
|
5682 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5683 #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
|
5684 defsubr (&Sgc_status); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5685 #endif |
300 | 5686 } |