Mercurial > emacs
annotate src/alloc.c @ 53021:92d82baef50b
* xterm.c (XAW_ARROW_SCROLLBARS): Define it for Xaw 1.5E.
author | Jan Djärv <jan.h.d@swipnet.se> |
---|---|
date | Sat, 08 Nov 2003 12:45:13 +0000 |
parents | 1bbf3f566879 |
children | e8f5463f3d5b |
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> |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
24 #include <limits.h> /* For CHAR_BIT. */ |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25762
diff
changeset
|
25 |
47185
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
26 #ifdef ALLOC_DEBUG |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
27 #undef INLINE |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
28 #endif |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
29 |
13320
e0f3a961851a
Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents:
13219
diff
changeset
|
30 /* Note that this declares bzero on OSF/1. How dumb. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
31 |
3003
5a73d384f45e
* syssignal.h: Don't #include <signal.h>
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
32 #include <signal.h> |
300 | 33 |
26164
d39ec0a27081
more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents:
26088
diff
changeset
|
34 /* 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
|
35 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
|
36 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
|
37 |
26164
d39ec0a27081
more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents:
26088
diff
changeset
|
38 #undef HIDE_LISP_IMPLEMENTATION |
300 | 39 #include "lisp.h" |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
40 #include "process.h" |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
41 #include "intervals.h" |
356 | 42 #include "puresize.h" |
300 | 43 #include "buffer.h" |
44 #include "window.h" | |
31102
6a0caa788013
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30914
diff
changeset
|
45 #include "keyboard.h" |
764 | 46 #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
|
47 #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
|
48 #include "charset.h" |
638 | 49 #include "syssignal.h" |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
50 #include <setjmp.h> |
638 | 51 |
52547
623355edbb1d
(GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents:
52475
diff
changeset
|
52 /* GC_MALLOC_CHECK defined means perform validity checks of malloc'd |
623355edbb1d
(GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents:
52475
diff
changeset
|
53 memory. Can do this only if using gmalloc.c. */ |
623355edbb1d
(GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents:
52475
diff
changeset
|
54 |
623355edbb1d
(GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents:
52475
diff
changeset
|
55 #if defined SYSTEM_MALLOC || defined DOUG_LEA_MALLOC |
623355edbb1d
(GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents:
52475
diff
changeset
|
56 #undef GC_MALLOC_CHECK |
623355edbb1d
(GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents:
52475
diff
changeset
|
57 #endif |
623355edbb1d
(GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents:
52475
diff
changeset
|
58 |
30784
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
59 #ifdef HAVE_UNISTD_H |
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
60 #include <unistd.h> |
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
61 #else |
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
62 extern POINTER_TYPE *sbrk (); |
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
63 #endif |
12096 | 64 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
65 #ifdef DOUG_LEA_MALLOC |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
66 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
67 #include <malloc.h> |
31892
2f3d88ac2b38
(__malloc_size_t) [DOUG_LEA_MALLOC]: Don't redefine it.
Dave Love <fx@gnu.org>
parents:
31889
diff
changeset
|
68 /* 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
|
69 #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
|
70 #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
|
71 #endif |
23973
2eb9e2f5aa33
(MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
23958
diff
changeset
|
72 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
73 /* 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
|
74 value that explicitly means "no limit". */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
75 |
23973
2eb9e2f5aa33
(MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
23958
diff
changeset
|
76 #define MMAP_MAX_AREAS 100000000 |
2eb9e2f5aa33
(MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
23958
diff
changeset
|
77 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
78 #else /* not DOUG_LEA_MALLOC */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
79 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
80 /* 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
|
81 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
82 #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
|
83 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
|
84 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
|
85 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
86 #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
|
87 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
88 /* 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
|
89 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
90 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
|
91 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
92 /* 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
|
93 to a struct Lisp_String. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
94 |
51985
b52e88c3d6d0
(MARK_STRING, UNMARK_STRING, STRING_MARKED_P)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51974
diff
changeset
|
95 #define MARK_STRING(S) ((S)->size |= ARRAY_MARK_FLAG) |
b52e88c3d6d0
(MARK_STRING, UNMARK_STRING, STRING_MARKED_P)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51974
diff
changeset
|
96 #define UNMARK_STRING(S) ((S)->size &= ~ARRAY_MARK_FLAG) |
b52e88c3d6d0
(MARK_STRING, UNMARK_STRING, STRING_MARKED_P)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51974
diff
changeset
|
97 #define STRING_MARKED_P(S) ((S)->size & ARRAY_MARK_FLAG) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
98 |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
99 #define VECTOR_MARK(V) ((V)->size |= ARRAY_MARK_FLAG) |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
100 #define VECTOR_UNMARK(V) ((V)->size &= ~ARRAY_MARK_FLAG) |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
101 #define VECTOR_MARKED_P(V) ((V)->size & ARRAY_MARK_FLAG) |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
102 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
103 /* 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
|
104 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
|
105 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
|
106 strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
107 |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
108 #define GC_STRING_BYTES(S) (STRING_BYTES (S)) |
51985
b52e88c3d6d0
(MARK_STRING, UNMARK_STRING, STRING_MARKED_P)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51974
diff
changeset
|
109 #define GC_STRING_CHARS(S) ((S)->size & ~ARRAY_MARK_FLAG) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
110 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
111 /* 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
|
112 |
300 | 113 int consing_since_gc; |
114 | |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
115 /* 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
|
116 |
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
|
117 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
|
118 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
|
119 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
|
120 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
|
121 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
|
122 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
|
123 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
|
124 EMACS_INT strings_consed; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
125 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
126 /* 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
|
127 |
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
|
128 EMACS_INT gc_cons_threshold; |
300 | 129 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
130 /* Nonzero during GC. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
131 |
300 | 132 int gc_in_progress; |
133 | |
50745
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
134 /* Nonzero means abort if try to GC. |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
135 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
|
136 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
|
137 |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
138 int abort_on_gc; |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
139 |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
140 /* 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
|
141 |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
142 int garbage_collection_messages; |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
143 |
300 | 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_used; |
300 | 148 |
149 #ifndef VIRT_ADDR_VARIES | |
150 extern | |
151 #endif /* VIRT_ADDR_VARIES */ | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
152 int malloc_sbrk_unused; |
300 | 153 |
764 | 154 /* 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
|
155 |
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
|
156 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
|
157 EMACS_INT undo_strong_limit; |
300 | 158 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
159 /* 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
|
160 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
161 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
|
162 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
|
163 static int total_free_floats, total_floats; |
19332
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
164 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
165 /* 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
|
166 out of memory. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
167 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
168 static char *spare_memory; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
169 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
170 /* 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
|
171 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
172 #define SPARE_MEMORY (1 << 14) |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
173 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
174 /* 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
|
175 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
176 static int malloc_hysteresis; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
177 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
178 /* 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
|
179 |
300 | 180 Lisp_Object Vpurify_flag; |
181 | |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
182 /* 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
|
183 |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
184 Lisp_Object Vmemory_full; |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
185 |
300 | 186 #ifndef HAVE_SHM |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
187 |
51908
cb3976b5e59f
(pure, staticvec): Initialize these arrays to nonzero, so that they're
Paul Eggert <eggert@twinsun.com>
parents:
51907
diff
changeset
|
188 /* Force it into data space! Initialize it to a nonzero value; |
cb3976b5e59f
(pure, staticvec): Initialize these arrays to nonzero, so that they're
Paul Eggert <eggert@twinsun.com>
parents:
51907
diff
changeset
|
189 otherwise some compilers put it into BSS. */ |
cb3976b5e59f
(pure, staticvec): Initialize these arrays to nonzero, so that they're
Paul Eggert <eggert@twinsun.com>
parents:
51907
diff
changeset
|
190 |
cb3976b5e59f
(pure, staticvec): Initialize these arrays to nonzero, so that they're
Paul Eggert <eggert@twinsun.com>
parents:
51907
diff
changeset
|
191 EMACS_INT pure[PURESIZE / sizeof (EMACS_INT)] = {1,}; |
300 | 192 #define PUREBEG (char *) pure |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
193 |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
194 #else /* HAVE_SHM */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
195 |
300 | 196 #define pure PURE_SEG_BITS /* Use shared memory segment */ |
197 #define PUREBEG (char *)PURE_SEG_BITS | |
356 | 198 |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
199 #endif /* HAVE_SHM */ |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
200 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
201 /* 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
|
202 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
203 static char *purebeg; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
204 static size_t pure_size; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
205 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
206 /* 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
|
207 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
|
208 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
209 static size_t pure_bytes_used_before_overflow; |
300 | 210 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
211 /* 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
|
212 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
213 #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
|
214 (((PNTR_COMPARISON_TYPE) (P) \ |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
215 < (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
|
216 && ((PNTR_COMPARISON_TYPE) (P) \ |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
217 >= (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
|
218 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
219 /* 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
|
220 |
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
|
221 EMACS_INT pure_bytes_used; |
300 | 222 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
223 /* 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
|
224 displayed. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
225 |
300 | 226 char *pending_malloc_warning; |
227 | |
6116
64417bbbb128
(memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents:
5874
diff
changeset
|
228 /* 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
|
229 |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
230 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
|
231 |
300 | 232 /* Maximum amount of C stack to save when a GC happens. */ |
233 | |
234 #ifndef MAX_SAVE_STACK | |
235 #define MAX_SAVE_STACK 16000 | |
236 #endif | |
237 | |
238 /* Buffer in which we save a copy of the C stack at each GC. */ | |
239 | |
240 char *stack_copy; | |
241 int stack_copy_size; | |
242 | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
243 /* 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
|
244 Currently not used. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
245 |
300 | 246 int ignore_warnings; |
1318 | 247 |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
248 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
|
249 |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
250 /* Hook run after GC has finished. */ |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
251 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
252 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
|
253 |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
254 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
|
255 EMACS_INT gcs_done; /* accumulated GCs */ |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
256 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
257 static void mark_buffer P_ ((Lisp_Object)); |
51578
42f25a716cb8
(mark_kboards): Move to keyboard.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51318
diff
changeset
|
258 extern void mark_kboards P_ ((void)); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
259 static void gc_sweep P_ ((void)); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
260 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
|
261 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
|
262 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
263 #ifdef HAVE_WINDOW_SYSTEM |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
264 static void mark_image P_ ((struct image *)); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
265 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
|
266 #endif /* HAVE_WINDOW_SYSTEM */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
267 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
268 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
|
269 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
|
270 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
|
271 static void sweep_strings P_ ((void)); |
20495 | 272 |
273 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
|
274 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
275 /* 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
|
276 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
|
277 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
|
278 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
279 enum mem_type |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
280 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
281 MEM_TYPE_NON_LISP, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
282 MEM_TYPE_BUFFER, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
283 MEM_TYPE_CONS, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
284 MEM_TYPE_STRING, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
285 MEM_TYPE_MISC, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
286 MEM_TYPE_SYMBOL, |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
287 MEM_TYPE_FLOAT, |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
288 /* Keep the following vector-like types together, with |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
289 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
|
290 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
|
291 MEM_TYPE_VECTOR, |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
292 MEM_TYPE_PROCESS, |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
293 MEM_TYPE_HASH_TABLE, |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
294 MEM_TYPE_FRAME, |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
295 MEM_TYPE_WINDOW |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
296 }; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
297 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
298 #if GC_MARK_STACK || defined GC_MALLOC_CHECK |
27746
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
299 |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
300 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
301 #include <stdio.h> /* For fprintf. */ |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
302 #endif |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
303 |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
304 /* 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
|
305 on free lists recognizable in O(1). */ |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
306 |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
307 Lisp_Object Vdead; |
2556e20596b8
(enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents:
27738
diff
changeset
|
308 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
309 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
310 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
311 enum mem_type allocated_mem_type; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
312 int dont_register_blocks; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
313 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
314 #endif /* GC_MALLOC_CHECK */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
315 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
316 /* 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
|
317 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
|
318 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
|
319 is freed. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
320 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
321 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
|
322 properties: |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
323 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
324 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
|
325 2. Every leaf is black. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
326 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
|
327 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
|
328 the same number of black nodes. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
329 5. The root is always black. |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
330 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
331 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
|
332 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
|
333 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
334 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
|
335 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
|
336 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
|
337 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
|
338 describe them. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
339 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
340 struct mem_node |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
341 { |
48907 | 342 /* Children of this node. These pointers are never NULL. When there |
343 is no child, the value is MEM_NIL, which points to a dummy node. */ | |
344 struct mem_node *left, *right; | |
345 | |
346 /* The parent of this node. In the root node, this is NULL. */ | |
347 struct mem_node *parent; | |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
348 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
349 /* Start and end of allocated region. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
350 void *start, *end; |
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 /* Node color. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
353 enum {MEM_BLACK, MEM_RED} color; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
354 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
355 /* Memory type. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
356 enum mem_type type; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
357 }; |
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 /* Base address of stack. Set in main. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
360 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
361 Lisp_Object *stack_base; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
362 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
363 /* 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
|
364 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
365 static struct mem_node *mem_root; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
366 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
367 /* Lowest and highest known address in the heap. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
368 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
369 static void *min_heap_address, *max_heap_address; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
370 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
371 /* Sentinel node of the tree. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
372 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
373 static struct mem_node mem_z; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
374 #define MEM_NIL &mem_z |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
375 |
30914
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
376 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
|
377 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
|
378 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
|
379 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
|
380 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
|
381 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
|
382 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
|
383 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
|
384 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
|
385 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
|
386 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
|
387 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
|
388 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
|
389 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
|
390 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
|
391 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
|
392 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
|
393 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
|
394 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
|
395 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
|
396 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
|
397 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
398 #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
|
399 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
|
400 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
401 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
402 #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
|
403 |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
404 /* Recording what needs to be marked for gc. */ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
405 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
406 struct gcpro *gcprolist; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
407 |
51908
cb3976b5e59f
(pure, staticvec): Initialize these arrays to nonzero, so that they're
Paul Eggert <eggert@twinsun.com>
parents:
51907
diff
changeset
|
408 /* Addresses of staticpro'd variables. Initialize it to a nonzero |
cb3976b5e59f
(pure, staticvec): Initialize these arrays to nonzero, so that they're
Paul Eggert <eggert@twinsun.com>
parents:
51907
diff
changeset
|
409 value; otherwise some compilers put it into BSS. */ |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
410 |
43313
32f59a921eb9
(NSTATICS): Increase to 1280.
Andreas Schwab <schwab@suse.de>
parents:
43302
diff
changeset
|
411 #define NSTATICS 1280 |
51908
cb3976b5e59f
(pure, staticvec): Initialize these arrays to nonzero, so that they're
Paul Eggert <eggert@twinsun.com>
parents:
51907
diff
changeset
|
412 Lisp_Object *staticvec[NSTATICS] = {&Vpurify_flag}; |
32594
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 /* Index of next unused slot in staticvec. */ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
415 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
416 int staticidx = 0; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
417 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
418 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
|
419 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
420 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
421 /* 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
|
422 ALIGNMENT must be a power of 2. */ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
423 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
424 #define ALIGN(ptr, ALIGNMENT) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
425 ((POINTER_TYPE *) ((((EMACS_UINT)(ptr)) + (ALIGNMENT) - 1) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
426 & ~((ALIGNMENT) - 1))) |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
427 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
428 |
300 | 429 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
430 /************************************************************************ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
431 Malloc |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
432 ************************************************************************/ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
433 |
47185
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
434 /* 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
|
435 |
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
436 void |
300 | 437 malloc_warning (str) |
438 char *str; | |
439 { | |
440 pending_malloc_warning = str; | |
441 } | |
442 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
443 |
47185
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
444 /* 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
|
445 |
20375
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
446 void |
300 | 447 display_malloc_warning () |
448 { | |
47185
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
449 call3 (intern ("display-warning"), |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
450 intern ("alloc"), |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
451 build_string (pending_malloc_warning), |
2ff45b08a155
(display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents:
46833
diff
changeset
|
452 intern ("emergency")); |
300 | 453 pending_malloc_warning = 0; |
454 } | |
455 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
456 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
457 #ifdef DOUG_LEA_MALLOC |
17831
9238a2254a23
(BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents:
17348
diff
changeset
|
458 # 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
|
459 #else |
17831
9238a2254a23
(BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents:
17348
diff
changeset
|
460 # 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
|
461 #endif |
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
462 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
463 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
464 /* 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
|
465 |
20375
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
466 void |
300 | 467 memory_full () |
468 { | |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
469 Vmemory_full = Qt; |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
470 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
471 #ifndef SYSTEM_MALLOC |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
472 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
|
473 #endif |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
474 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
475 /* 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
|
476 if (spare_memory) |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
477 { |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
478 free (spare_memory); |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
479 spare_memory = 0; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
480 } |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
481 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
482 /* 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
|
483 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
|
484 while (1) |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
485 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
|
486 } |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
487 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
488 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
489 /* 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
|
490 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
491 void |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
492 buffer_memory_full () |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
493 { |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
494 /* 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
|
495 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
|
496 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
|
497 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
|
498 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
|
499 malloc. */ |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
500 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
501 #ifndef REL_ALLOC |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
502 memory_full (); |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
503 #endif |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
504 |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
505 Vmemory_full = Qt; |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
506 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
507 /* 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
|
508 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
|
509 while (1) |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
510 Fsignal (Qnil, Vmemory_signal_data); |
300 | 511 } |
512 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
513 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
514 /* Like malloc but check for no memory and block interrupt input.. */ |
300 | 515 |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
516 POINTER_TYPE * |
300 | 517 xmalloc (size) |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
518 size_t size; |
300 | 519 { |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
520 register POINTER_TYPE *val; |
300 | 521 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
522 BLOCK_INPUT; |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
523 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
|
524 UNBLOCK_INPUT; |
300 | 525 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
526 if (!val && size) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
527 memory_full (); |
300 | 528 return val; |
529 } | |
530 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
531 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
532 /* 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
|
533 |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
534 POINTER_TYPE * |
300 | 535 xrealloc (block, size) |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
536 POINTER_TYPE *block; |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
537 size_t size; |
300 | 538 { |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
539 register POINTER_TYPE *val; |
300 | 540 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
541 BLOCK_INPUT; |
590 | 542 /* We must call malloc explicitly when BLOCK is 0, since some |
543 reallocs don't do this. */ | |
544 if (! block) | |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
545 val = (POINTER_TYPE *) malloc (size); |
600
a8d78999e46d
*** empty log message ***
Noah Friedman <friedman@splode.com>
parents:
590
diff
changeset
|
546 else |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
547 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
|
548 UNBLOCK_INPUT; |
300 | 549 |
550 if (!val && size) memory_full (); | |
551 return val; | |
552 } | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
553 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
554 |
52276
5623f26dff58
(lisp_align_malloc): Change type of `aligned'.
Dave Love <fx@gnu.org>
parents:
52256
diff
changeset
|
555 /* Like free but block interrupt input. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
556 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
557 void |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
558 xfree (block) |
29781
4a3b0c2cbcd5
(xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
29743
diff
changeset
|
559 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
|
560 { |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
561 BLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
562 free (block); |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
563 UNBLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
564 } |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
565 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
566 |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
567 /* Like strdup, but uses xmalloc. */ |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
568 |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
569 char * |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
570 xstrdup (s) |
46459
0a9cbcbdbe45
(xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents:
46418
diff
changeset
|
571 const char *s; |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
572 { |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
573 size_t len = strlen (s) + 1; |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
574 char *p = (char *) xmalloc (len); |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
575 bcopy (s, p, len); |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
576 return p; |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
577 } |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
578 |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
579 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
580 /* 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
|
581 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
|
582 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
|
583 |
50468
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
584 static void *lisp_malloc_loser; |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
585 |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
586 static POINTER_TYPE * |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
587 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
|
588 size_t nbytes; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
589 enum mem_type type; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
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 register void *val; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
592 |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
593 BLOCK_INPUT; |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
594 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
595 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
596 allocated_mem_type = type; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
597 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
598 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
599 val = (void *) malloc (nbytes); |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
600 |
50468
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
601 /* 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
|
602 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
|
603 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
|
604 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
|
605 { |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
606 Lisp_Object tem; |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
607 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
|
608 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
|
609 { |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
610 lisp_malloc_loser = val; |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
611 free (val); |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
612 val = 0; |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
613 } |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
614 } |
16fdb9f87d89
(VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents:
50274
diff
changeset
|
615 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
616 #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
|
617 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
|
618 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
|
619 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
620 |
28411
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
621 UNBLOCK_INPUT; |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
622 if (!val && nbytes) |
ecba29fa0198
(xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents:
28406
diff
changeset
|
623 memory_full (); |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
624 return val; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
625 } |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
626 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
627 /* 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
|
628 call to lisp_malloc. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
629 |
30784
dbc1e69a89a9
[HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents:
30557
diff
changeset
|
630 static void |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
631 lisp_free (block) |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
632 POINTER_TYPE *block; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
633 { |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
634 BLOCK_INPUT; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
635 free (block); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
636 #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
|
637 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
|
638 #endif |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
639 UNBLOCK_INPUT; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
640 } |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
641 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
642 /* Allocation of aligned blocks of memory to store Lisp data. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
643 /* The entry point is lisp_align_malloc which returns blocks of at most */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
644 /* BLOCK_BYTES and guarantees they are aligned on a BLOCK_ALIGN boundary. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
645 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
646 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
647 /* BLOCK_ALIGN has to be a power of 2. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
648 #define BLOCK_ALIGN (1 << 10) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
649 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
650 /* Padding to leave at the end of a malloc'd block. This is to give |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
651 malloc a chance to minimize the amount of memory wasted to alignment. |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
652 It should be tuned to the particular malloc library used. |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
653 On glibc-2.3.2, malloc never tries to align, so a padding of 0 is best. |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
654 posix_memalign on the other hand would ideally prefer a value of 4 |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
655 because otherwise, there's 1020 bytes wasted between each ablocks. |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
656 But testing shows that those 1020 will most of the time be efficiently |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
657 used by malloc to place other objects, so a value of 0 is still preferable |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
658 unless you have a lot of cons&floats and virtually nothing else. */ |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
659 #define BLOCK_PADDING 0 |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
660 #define BLOCK_BYTES \ |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
661 (BLOCK_ALIGN - sizeof (struct aligned_block *) - BLOCK_PADDING) |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
662 |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
663 /* Internal data structures and constants. */ |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
664 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
665 #define ABLOCKS_SIZE 16 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
666 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
667 /* An aligned block of memory. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
668 struct ablock |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
669 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
670 union |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
671 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
672 char payload[BLOCK_BYTES]; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
673 struct ablock *next_free; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
674 } x; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
675 /* `abase' is the aligned base of the ablocks. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
676 /* It is overloaded to hold the virtual `busy' field that counts |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
677 the number of used ablock in the parent ablocks. |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
678 The first ablock has the `busy' field, the others have the `abase' |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
679 field. To tell the difference, we assume that pointers will have |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
680 integer values larger than 2 * ABLOCKS_SIZE. The lowest bit of `busy' |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
681 is used to tell whether the real base of the parent ablocks is `abase' |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
682 (if not, the word before the first ablock holds a pointer to the |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
683 real base). */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
684 struct ablocks *abase; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
685 /* The padding of all but the last ablock is unused. The padding of |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
686 the last ablock in an ablocks is not allocated. */ |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
687 #if BLOCK_PADDING |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
688 char padding[BLOCK_PADDING]; |
51758
ff38ea4b40ed
(struct ablock): Only include padding when there is some.
Jason Rumney <jasonr@gnu.org>
parents:
51723
diff
changeset
|
689 #endif |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
690 }; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
691 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
692 /* A bunch of consecutive aligned blocks. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
693 struct ablocks |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
694 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
695 struct ablock blocks[ABLOCKS_SIZE]; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
696 }; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
697 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
698 /* Size of the block requested from malloc or memalign. */ |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
699 #define ABLOCKS_BYTES (sizeof (struct ablocks) - BLOCK_PADDING) |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
700 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
701 #define ABLOCK_ABASE(block) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
702 (((unsigned long) (block)->abase) <= (1 + 2 * ABLOCKS_SIZE) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
703 ? (struct ablocks *)(block) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
704 : (block)->abase) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
705 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
706 /* Virtual `busy' field. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
707 #define ABLOCKS_BUSY(abase) ((abase)->blocks[0].abase) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
708 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
709 /* Pointer to the (not necessarily aligned) malloc block. */ |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
710 #ifdef HAVE_POSIX_MEMALIGN |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
711 #define ABLOCKS_BASE(abase) (abase) |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
712 #else |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
713 #define ABLOCKS_BASE(abase) \ |
52453
62fcd311bb98
Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
714 (1 & (long) ABLOCKS_BUSY (abase) ? abase : ((void**)abase)[-1]) |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
715 #endif |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
716 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
717 /* The list of free ablock. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
718 static struct ablock *free_ablock; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
719 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
720 /* Allocate an aligned block of nbytes. |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
721 Alignment is on a multiple of BLOCK_ALIGN and `nbytes' has to be |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
722 smaller or equal to BLOCK_BYTES. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
723 static POINTER_TYPE * |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
724 lisp_align_malloc (nbytes, type) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
725 size_t nbytes; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
726 enum mem_type type; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
727 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
728 void *base, *val; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
729 struct ablocks *abase; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
730 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
731 eassert (nbytes <= BLOCK_BYTES); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
732 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
733 BLOCK_INPUT; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
734 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
735 #ifdef GC_MALLOC_CHECK |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
736 allocated_mem_type = type; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
737 #endif |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
738 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
739 if (!free_ablock) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
740 { |
52276
5623f26dff58
(lisp_align_malloc): Change type of `aligned'.
Dave Love <fx@gnu.org>
parents:
52256
diff
changeset
|
741 int i; |
5623f26dff58
(lisp_align_malloc): Change type of `aligned'.
Dave Love <fx@gnu.org>
parents:
52256
diff
changeset
|
742 EMACS_INT aligned; /* int gets warning casting to 64-bit pointer. */ |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
743 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
744 #ifdef DOUG_LEA_MALLOC |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
745 /* Prevent mmap'ing the chunk. Lisp data may not be mmap'ed |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
746 because mapped region contents are not preserved in |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
747 a dumped Emacs. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
748 mallopt (M_MMAP_MAX, 0); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
749 #endif |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
750 |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
751 #ifdef HAVE_POSIX_MEMALIGN |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
752 { |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
753 int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES); |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
754 abase = err ? (base = NULL) : base; |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
755 } |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
756 #else |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
757 base = malloc (ABLOCKS_BYTES); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
758 abase = ALIGN (base, BLOCK_ALIGN); |
52837
1bbf3f566879
(lisp_align_malloc): If BASE is 0, call memory_full.
Richard M. Stallman <rms@gnu.org>
parents:
52547
diff
changeset
|
759 if (base == 0) |
1bbf3f566879
(lisp_align_malloc): If BASE is 0, call memory_full.
Richard M. Stallman <rms@gnu.org>
parents:
52547
diff
changeset
|
760 { |
1bbf3f566879
(lisp_align_malloc): If BASE is 0, call memory_full.
Richard M. Stallman <rms@gnu.org>
parents:
52547
diff
changeset
|
761 UNBLOCK_INPUT; |
1bbf3f566879
(lisp_align_malloc): If BASE is 0, call memory_full.
Richard M. Stallman <rms@gnu.org>
parents:
52547
diff
changeset
|
762 memory_full (); |
1bbf3f566879
(lisp_align_malloc): If BASE is 0, call memory_full.
Richard M. Stallman <rms@gnu.org>
parents:
52547
diff
changeset
|
763 } |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
764 #endif |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
765 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
766 aligned = (base == abase); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
767 if (!aligned) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
768 ((void**)abase)[-1] = base; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
769 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
770 #ifdef DOUG_LEA_MALLOC |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
771 /* Back to a reasonable maximum of mmap'ed areas. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
772 mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
773 #endif |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
774 |
52256
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
775 /* If the memory just allocated cannot be addressed thru a Lisp |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
776 object's pointer, and it needs to be, that's equivalent to |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
777 running out of memory. */ |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
778 if (type != MEM_TYPE_NON_LISP) |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
779 { |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
780 Lisp_Object tem; |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
781 char *end = (char *) base + ABLOCKS_BYTES - 1; |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
782 XSETCONS (tem, end); |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
783 if ((char *) XCONS (tem) != end) |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
784 { |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
785 lisp_malloc_loser = base; |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
786 free (base); |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
787 UNBLOCK_INPUT; |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
788 memory_full (); |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
789 } |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
790 } |
36e112575ca8
(lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents:
52166
diff
changeset
|
791 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
792 /* Initialize the blocks and put them on the free list. |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
793 Is `base' was not properly aligned, we can't use the last block. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
794 for (i = 0; i < (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1); i++) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
795 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
796 abase->blocks[i].abase = abase; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
797 abase->blocks[i].x.next_free = free_ablock; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
798 free_ablock = &abase->blocks[i]; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
799 } |
52453
62fcd311bb98
Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
800 ABLOCKS_BUSY (abase) = (struct ablocks *) (long) aligned; |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
801 |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
802 eassert (0 == ((EMACS_UINT)abase) % BLOCK_ALIGN); |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
803 eassert (ABLOCK_ABASE (&abase->blocks[3]) == abase); /* 3 is arbitrary */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
804 eassert (ABLOCK_ABASE (&abase->blocks[0]) == abase); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
805 eassert (ABLOCKS_BASE (abase) == base); |
52453
62fcd311bb98
Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
806 eassert (aligned == (long) ABLOCKS_BUSY (abase)); |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
807 } |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
808 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
809 abase = ABLOCK_ABASE (free_ablock); |
52453
62fcd311bb98
Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
810 ABLOCKS_BUSY (abase) = (struct ablocks *) (2 + (long) ABLOCKS_BUSY (abase)); |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
811 val = free_ablock; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
812 free_ablock = free_ablock->x.next_free; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
813 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
814 #if GC_MARK_STACK && !defined GC_MALLOC_CHECK |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
815 if (val && type != MEM_TYPE_NON_LISP) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
816 mem_insert (val, (char *) val + nbytes, type); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
817 #endif |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
818 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
819 UNBLOCK_INPUT; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
820 if (!val && nbytes) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
821 memory_full (); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
822 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
823 eassert (0 == ((EMACS_UINT)val) % BLOCK_ALIGN); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
824 return val; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
825 } |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
826 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
827 static void |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
828 lisp_align_free (block) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
829 POINTER_TYPE *block; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
830 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
831 struct ablock *ablock = block; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
832 struct ablocks *abase = ABLOCK_ABASE (ablock); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
833 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
834 BLOCK_INPUT; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
835 #if GC_MARK_STACK && !defined GC_MALLOC_CHECK |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
836 mem_delete (mem_find (block)); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
837 #endif |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
838 /* Put on free list. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
839 ablock->x.next_free = free_ablock; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
840 free_ablock = ablock; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
841 /* Update busy count. */ |
52453
62fcd311bb98
Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
842 ABLOCKS_BUSY (abase) = (struct ablocks *) (-2 + (long) ABLOCKS_BUSY (abase)); |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
843 |
52453
62fcd311bb98
Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
844 if (2 > (long) ABLOCKS_BUSY (abase)) |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
845 { /* All the blocks are free. */ |
52453
62fcd311bb98
Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
846 int i = 0, aligned = (long) ABLOCKS_BUSY (abase); |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
847 struct ablock **tem = &free_ablock; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
848 struct ablock *atop = &abase->blocks[aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1]; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
849 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
850 while (*tem) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
851 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
852 if (*tem >= (struct ablock *) abase && *tem < atop) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
853 { |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
854 i++; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
855 *tem = (*tem)->x.next_free; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
856 } |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
857 else |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
858 tem = &(*tem)->x.next_free; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
859 } |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
860 eassert ((aligned & 1) == aligned); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
861 eassert (i == (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1)); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
862 free (ABLOCKS_BASE (abase)); |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
863 } |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
864 UNBLOCK_INPUT; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
865 } |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
866 |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
867 /* Return a new buffer structure allocated from the heap with |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
868 a call to lisp_malloc. */ |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
869 |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
870 struct buffer * |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
871 allocate_buffer () |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
872 { |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
873 struct buffer *b |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
874 = (struct buffer *) lisp_malloc (sizeof (struct buffer), |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
875 MEM_TYPE_BUFFER); |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
876 return b; |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
877 } |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
878 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
879 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
880 /* 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
|
881 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
882 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
|
883 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
|
884 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
|
885 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
|
886 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
|
887 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
|
888 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
|
889 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
890 #ifndef SYSTEM_MALLOC |
30914
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
891 #ifndef DOUG_LEA_MALLOC |
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
892 extern void * (*__malloc_hook) P_ ((size_t)); |
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
893 extern void * (*__realloc_hook) P_ ((void *, size_t)); |
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
894 extern void (*__free_hook) P_ ((void *)); |
6362b1fc09f2
(lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents:
30823
diff
changeset
|
895 /* 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
|
896 #endif /* DOUG_LEA_MALLOC */ |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
897 static void * (*old_malloc_hook) (); |
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
898 static void * (*old_realloc_hook) (); |
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
899 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
|
900 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
901 /* 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
|
902 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
903 static void |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
904 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
|
905 void *ptr; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
906 { |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
907 BLOCK_INPUT; |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
908 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
909 #ifdef GC_MALLOC_CHECK |
32776
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
910 if (ptr) |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
911 { |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
912 struct mem_node *m; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
913 |
32776
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
914 m = mem_find (ptr); |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
915 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
|
916 { |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
917 fprintf (stderr, |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
918 "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
|
919 abort (); |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
920 } |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
921 else |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
922 { |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
923 /* 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
|
924 mem_delete (m); |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
925 } |
416924b6f303
(emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents:
32700
diff
changeset
|
926 } |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
927 #endif /* GC_MALLOC_CHECK */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
928 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
929 __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
|
930 free (ptr); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
931 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
932 /* 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
|
933 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
|
934 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
|
935 if (spare_memory == 0 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
936 /* 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
|
937 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
|
938 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
|
939 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
|
940 && (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
|
941 > 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
|
942 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
|
943 |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
944 __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
|
945 UNBLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
946 } |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
947 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
948 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
949 /* 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
|
950 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
|
951 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
|
952 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
953 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
|
954 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
955 void |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
956 refill_memory_reserve () |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
957 { |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
958 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
|
959 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
|
960 } |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
961 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
962 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
963 /* 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
|
964 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
965 static void * |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
966 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
|
967 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
|
968 { |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
969 void *value; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
970 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
971 BLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
972 __malloc_hook = old_malloc_hook; |
17831
9238a2254a23
(BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents:
17348
diff
changeset
|
973 #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
|
974 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
|
975 #else |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
976 __malloc_extra_blocks = malloc_hysteresis; |
17831
9238a2254a23
(BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents:
17348
diff
changeset
|
977 #endif |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
978 |
3581
152fd924c7bb
* alloc.c (emacs_blocked_malloc, emacs_blocked_realloc): Cast the
Jim Blandy <jimb@redhat.com>
parents:
3536
diff
changeset
|
979 value = (void *) malloc (size); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
980 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
981 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
982 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
983 struct mem_node *m = mem_find (value); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
984 if (m != MEM_NIL) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
985 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
986 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
|
987 value); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
988 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
|
989 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
|
990 m->type); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
991 abort (); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
992 } |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
993 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
994 if (!dont_register_blocks) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
995 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
996 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
|
997 allocated_mem_type = MEM_TYPE_NON_LISP; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
998 } |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
999 } |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1000 #endif /* GC_MALLOC_CHECK */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1001 |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
1002 __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
|
1003 UNBLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1004 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1005 /* 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
|
1006 return value; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1007 } |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1008 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1009 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1010 /* 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
|
1011 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1012 static void * |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1013 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
|
1014 void *ptr; |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
1015 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
|
1016 { |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1017 void *value; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1018 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1019 BLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1020 __realloc_hook = old_realloc_hook; |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1021 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1022 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1023 if (ptr) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1024 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1025 struct mem_node *m = mem_find (ptr); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1026 if (m == MEM_NIL || m->start != ptr) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1027 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1028 fprintf (stderr, |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1029 "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
|
1030 ptr); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1031 abort (); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1032 } |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1033 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1034 mem_delete (m); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1035 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1036 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1037 /* fprintf (stderr, "%p -> realloc\n", ptr); */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1038 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1039 /* Prevent malloc from registering blocks. */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1040 dont_register_blocks = 1; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1041 #endif /* GC_MALLOC_CHECK */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1042 |
3581
152fd924c7bb
* alloc.c (emacs_blocked_malloc, emacs_blocked_realloc): Cast the
Jim Blandy <jimb@redhat.com>
parents:
3536
diff
changeset
|
1043 value = (void *) realloc (ptr, size); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1044 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1045 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1046 dont_register_blocks = 0; |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1047 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1048 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1049 struct mem_node *m = mem_find (value); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1050 if (m != MEM_NIL) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1051 { |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1052 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
|
1053 abort (); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1054 } |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1055 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1056 /* 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
|
1057 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
|
1058 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1059 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1060 /* fprintf (stderr, "%p <- realloc\n", value); */ |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
1061 #endif /* GC_MALLOC_CHECK */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1062 |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
1063 __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
|
1064 UNBLOCK_INPUT; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1065 |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1066 return value; |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1067 } |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1068 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1069 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1070 /* 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
|
1071 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1072 void |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1073 uninterrupt_malloc () |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2370
diff
changeset
|
1074 { |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1075 if (__free_hook != emacs_blocked_free) |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1076 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
|
1077 __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
|
1078 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1079 if (__malloc_hook != emacs_blocked_malloc) |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1080 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
|
1081 __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
|
1082 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1083 if (__realloc_hook != emacs_blocked_realloc) |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1084 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
|
1085 __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
|
1086 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1087 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1088 #endif /* not SYSTEM_MALLOC */ |
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 |
300 | 1091 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1092 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1093 Interval Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1094 ***********************************************************************/ |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
1095 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1096 /* 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
|
1097 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
|
1098 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1099 #define INTERVAL_BLOCK_SIZE \ |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1100 ((1020 - sizeof (struct interval_block *)) / sizeof (struct interval)) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1101 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1102 /* 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
|
1103 structure. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1104 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1105 struct interval_block |
27142
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 interval_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1108 struct interval intervals[INTERVAL_BLOCK_SIZE]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1109 }; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1110 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1111 /* 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
|
1112 blocks. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1113 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1114 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
|
1115 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1116 /* 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
|
1117 structure. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1118 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1119 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
|
1120 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1121 /* 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
|
1122 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1123 static int total_free_intervals, total_intervals; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1124 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1125 /* List of free intervals. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1126 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1127 INTERVAL interval_free_list; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1128 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1129 /* 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
|
1130 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1131 int n_interval_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1132 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1133 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1134 /* Initialize interval allocation. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1135 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1136 static void |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1137 init_intervals () |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1138 { |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
1139 interval_block = NULL; |
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
1140 interval_block_index = INTERVAL_BLOCK_SIZE; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1141 interval_free_list = 0; |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
1142 n_interval_blocks = 0; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1143 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1144 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1145 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1146 /* Return a new interval. */ |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1147 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1148 INTERVAL |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1149 make_interval () |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1150 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1151 INTERVAL val; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1152 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1153 if (interval_free_list) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1154 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1155 val = interval_free_list; |
28269
fd13be8ae190
Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents:
28220
diff
changeset
|
1156 interval_free_list = INTERVAL_PARENT (interval_free_list); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1157 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1158 else |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1159 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1160 if (interval_block_index == INTERVAL_BLOCK_SIZE) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1161 { |
12529 | 1162 register struct interval_block *newi; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1163 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1164 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
|
1165 MEM_TYPE_NON_LISP); |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1166 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1167 newi->next = interval_block; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1168 interval_block = newi; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1169 interval_block_index = 0; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
1170 n_interval_blocks++; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1171 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1172 val = &interval_block->intervals[interval_block_index++]; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1173 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1174 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
|
1175 intervals_consed++; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1176 RESET_INTERVAL (val); |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
1177 val->gcmarkbit = 0; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1178 return val; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1179 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1180 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1181 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1182 /* Mark Lisp objects in interval I. */ |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1183 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1184 static void |
1957
54c8c66cd9ac
(mark_interval): Add ignored arg.
Richard M. Stallman <rms@gnu.org>
parents:
1939
diff
changeset
|
1185 mark_interval (i, dummy) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1186 register INTERVAL i; |
1957
54c8c66cd9ac
(mark_interval): Add ignored arg.
Richard M. Stallman <rms@gnu.org>
parents:
1939
diff
changeset
|
1187 Lisp_Object dummy; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1188 { |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
1189 eassert (!i->gcmarkbit); /* Intervals are never shared. */ |
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
1190 i->gcmarkbit = 1; |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
1191 mark_object (i->plist); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1192 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1193 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1194 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1195 /* 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
|
1196 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
|
1197 |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1198 static void |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1199 mark_interval_tree (tree) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1200 register INTERVAL tree; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1201 { |
4139
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
1202 /* 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
|
1203 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
|
1204 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
|
1205 |
39859
36068b62b4c1
(mark_interval_tree): Use traverse_intervals_noorder.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39682
diff
changeset
|
1206 traverse_intervals_noorder (tree, mark_interval, Qnil); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1207 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1208 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1209 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1210 /* 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
|
1211 |
4139
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
1212 #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
|
1213 do { \ |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
1214 if (!NULL_INTERVAL_P (i) && !i->gcmarkbit) \ |
4139
0b32ee899a3a
Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents:
4087
diff
changeset
|
1215 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
|
1216 } while (0) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1217 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1218 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1219 #define UNMARK_BALANCE_INTERVALS(i) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1220 do { \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1221 if (! NULL_INTERVAL_P (i)) \ |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
1222 (i) = balance_intervals (i); \ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1223 } while (0) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1224 |
28469
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1225 |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1226 /* 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
|
1227 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
|
1228 #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
|
1229 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
|
1230 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
|
1231 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
|
1232 { |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1233 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
|
1234 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
|
1235 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
|
1236 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
|
1237 } |
f66f2b4d5eb7
* alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents:
28411
diff
changeset
|
1238 #endif |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
1239 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1240 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1241 String Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1242 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1243 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1244 /* 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
|
1245 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
|
1246 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
|
1247 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
|
1248 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
|
1249 we keep. |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1250 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1251 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
|
1252 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
|
1253 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
|
1254 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1255 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
|
1256 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
|
1257 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
|
1258 its sdata structure. |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1259 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1260 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
|
1261 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
|
1262 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
|
1263 `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
|
1264 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
|
1265 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
|
1266 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1267 /* 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
|
1268 is 8192 minus malloc overhead. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1269 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1270 #define SBLOCK_SIZE 8188 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1271 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1272 /* 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
|
1273 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
|
1274 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1275 #define LARGE_STRING_BYTES 1024 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1276 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1277 /* 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
|
1278 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
|
1279 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1280 struct sdata |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1281 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1282 /* 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
|
1283 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
|
1284 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
|
1285 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
|
1286 (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
|
1287 contents. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1288 struct Lisp_String *string; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1289 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1290 #ifdef GC_CHECK_STRING_BYTES |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1291 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1292 EMACS_INT nbytes; |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1293 unsigned char data[1]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1294 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1295 #define SDATA_NBYTES(S) (S)->nbytes |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1296 #define SDATA_DATA(S) (S)->data |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1297 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1298 #else /* not GC_CHECK_STRING_BYTES */ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1299 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1300 union |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1301 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1302 /* When STRING in non-null. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1303 unsigned char data[1]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1304 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1305 /* When STRING is null. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1306 EMACS_INT nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1307 } u; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1308 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1309 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1310 #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
|
1311 #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
|
1312 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1313 #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
|
1314 }; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1315 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1316 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1317 /* 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
|
1318 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
|
1319 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
|
1320 as large as needed. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1321 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1322 struct sblock |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1323 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1324 /* Next in list. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1325 struct sblock *next; |
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 /* 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
|
1328 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
|
1329 struct sdata *next_free; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1330 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1331 /* Start of data. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1332 struct sdata first_data; |
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 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1335 /* 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
|
1336 1024 minus malloc overhead. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1337 |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
1338 #define STRING_BLOCK_SIZE \ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1339 ((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
|
1340 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1341 /* 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
|
1342 are allocated. */ |
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 struct string_block |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1345 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1346 struct string_block *next; |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
1347 struct Lisp_String strings[STRING_BLOCK_SIZE]; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1348 }; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1349 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1350 /* 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
|
1351 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
|
1352 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
|
1353 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1354 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
|
1355 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1356 /* List of sblocks for large strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1357 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1358 static struct sblock *large_sblocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1359 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1360 /* 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
|
1361 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1362 static struct string_block *string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1363 static int n_string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1364 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1365 /* Free-list of Lisp_Strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1366 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1367 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
|
1368 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1369 /* 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
|
1370 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1371 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
|
1372 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1373 /* 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
|
1374 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1375 static int total_string_size; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1376 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1377 /* 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
|
1378 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
|
1379 free-list. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1380 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1381 #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
|
1382 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1383 /* 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
|
1384 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
|
1385 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
|
1386 structure starts at a constant offset in front of that. */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1387 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1388 #ifdef GC_CHECK_STRING_BYTES |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1389 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1390 #define SDATA_OF_STRING(S) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1391 ((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
|
1392 - sizeof (EMACS_INT))) |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1393 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1394 #else /* not GC_CHECK_STRING_BYTES */ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1395 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1396 #define SDATA_OF_STRING(S) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1397 ((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
|
1398 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1399 #endif /* not GC_CHECK_STRING_BYTES */ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1400 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1401 /* 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
|
1402 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
|
1403 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
|
1404 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1405 #ifdef GC_CHECK_STRING_BYTES |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1406 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1407 #define SDATA_SIZE(NBYTES) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1408 ((sizeof (struct Lisp_String *) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1409 + (NBYTES) + 1 \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1410 + sizeof (EMACS_INT) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1411 + sizeof (EMACS_INT) - 1) \ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1412 & ~(sizeof (EMACS_INT) - 1)) |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1413 |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1414 #else /* not GC_CHECK_STRING_BYTES */ |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1415 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1416 #define SDATA_SIZE(NBYTES) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1417 ((sizeof (struct Lisp_String *) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1418 + (NBYTES) + 1 \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1419 + sizeof (EMACS_INT) - 1) \ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1420 & ~(sizeof (EMACS_INT) - 1)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1421 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1422 #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
|
1423 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1424 /* 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
|
1425 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1426 void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1427 init_strings () |
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 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
|
1430 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
|
1431 string_blocks = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1432 n_string_blocks = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1433 string_free_list = NULL; |
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 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1436 |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1437 #ifdef GC_CHECK_STRING_BYTES |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1438 |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1439 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
|
1440 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1441 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
|
1442 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
|
1443 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1444 #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
|
1445 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1446 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1447 /* 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
|
1448 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1449 int |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1450 string_bytes (s) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1451 struct Lisp_String *s; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1452 { |
51985
b52e88c3d6d0
(MARK_STRING, UNMARK_STRING, STRING_MARKED_P)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51974
diff
changeset
|
1453 int nbytes = (s->size_byte < 0 ? s->size & ~ARRAY_MARK_FLAG : s->size_byte); |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1454 if (!PURE_POINTER_P (s) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1455 && s->data |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1456 && 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
|
1457 abort (); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1458 return nbytes; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1459 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1460 |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
1461 /* 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
|
1462 |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1463 void |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1464 check_sblock (b) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1465 struct sblock *b; |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1466 { |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1467 struct sdata *from, *end, *from_end; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1468 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1469 end = b->next_free; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1470 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1471 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
|
1472 { |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1473 /* 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
|
1474 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
|
1475 int nbytes; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1476 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1477 /* 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
|
1478 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
|
1479 if (from->string) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1480 CHECK_STRING_BYTES (from->string); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1481 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1482 if (from->string) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1483 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
|
1484 else |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1485 nbytes = SDATA_NBYTES (from); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1486 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1487 nbytes = SDATA_SIZE (nbytes); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1488 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
|
1489 } |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1490 } |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1491 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1492 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1493 /* 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
|
1494 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
|
1495 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
|
1496 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1497 void |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1498 check_string_bytes (all_p) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1499 int all_p; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1500 { |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1501 if (all_p) |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1502 { |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1503 struct sblock *b; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1504 |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1505 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
|
1506 { |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1507 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
|
1508 if (s) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1509 CHECK_STRING_BYTES (s); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1510 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1511 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1512 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
|
1513 check_sblock (b); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1514 } |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1515 else |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1516 check_sblock (current_sblock); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1517 } |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1518 |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1519 #endif /* GC_CHECK_STRING_BYTES */ |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1520 |
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1521 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1522 /* Return a new Lisp_String. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1523 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1524 static struct Lisp_String * |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1525 allocate_string () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1526 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1527 struct Lisp_String *s; |
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 /* 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
|
1530 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
|
1531 if (string_free_list == NULL) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1532 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1533 struct string_block *b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1534 int i; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1535 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1536 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
|
1537 bzero (b, sizeof *b); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1538 b->next = string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1539 string_blocks = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1540 ++n_string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1541 |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
1542 for (i = STRING_BLOCK_SIZE - 1; i >= 0; --i) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1543 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1544 s = b->strings + i; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1545 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
|
1546 string_free_list = s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1547 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1548 |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
1549 total_free_strings += STRING_BLOCK_SIZE; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1550 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1551 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1552 /* 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
|
1553 s = string_free_list; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1554 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
|
1555 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1556 /* 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
|
1557 bzero (s, sizeof *s); |
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 --total_free_strings; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1560 ++total_strings; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1561 ++strings_consed; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1562 consing_since_gc += sizeof *s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1563 |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1564 #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
|
1565 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
|
1566 #ifdef MAC_OS8 |
35660
b9366f467430
* alloc.c (allocate_string) [macintosh]: Call check_string_bytes
Andrew Choi <akochoi@shaw.ca>
parents:
35183
diff
changeset
|
1567 && current_sblock |
b9366f467430
* alloc.c (allocate_string) [macintosh]: Call check_string_bytes
Andrew Choi <akochoi@shaw.ca>
parents:
35183
diff
changeset
|
1568 #endif |
b9366f467430
* alloc.c (allocate_string) [macintosh]: Call check_string_bytes
Andrew Choi <akochoi@shaw.ca>
parents:
35183
diff
changeset
|
1569 ) |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1570 { |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1571 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
|
1572 { |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1573 check_string_bytes_count = 0; |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1574 check_string_bytes (1); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1575 } |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1576 else |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1577 check_string_bytes (0); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
1578 } |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
1579 #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
|
1580 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1581 return s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1582 } |
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 /* 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
|
1586 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
|
1587 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
|
1588 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
|
1589 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
|
1590 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1591 void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1592 allocate_string_data (s, nchars, nbytes) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1593 struct Lisp_String *s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1594 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1595 { |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1596 struct sdata *data, *old_data; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1597 struct sblock *b; |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1598 int needed, old_nbytes; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1599 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1600 /* 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
|
1601 of string data. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1602 needed = SDATA_SIZE (nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1603 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1604 if (nbytes > LARGE_STRING_BYTES) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1605 { |
30557
5056adb52e97
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents:
30317
diff
changeset
|
1606 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
|
1607 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1608 #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
|
1609 /* 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
|
1610 because mapped region contents are not preserved in |
51318 | 1611 a dumped Emacs. |
1612 | |
1613 In case you think of allowing it in a dumped Emacs at the | |
1614 cost of not being able to re-dump, there's another reason: | |
1615 mmap'ed data typically have an address towards the top of the | |
1616 address space, which won't fit into an EMACS_INT (at least on | |
1617 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
|
1618 mallopt (M_MMAP_MAX, 0); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1619 #endif |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1620 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1621 b = (struct sblock *) lisp_malloc (size, MEM_TYPE_NON_LISP); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1622 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1623 #ifdef DOUG_LEA_MALLOC |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1624 /* 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
|
1625 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
|
1626 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1627 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1628 b->next_free = &b->first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1629 b->first_data.string = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1630 b->next = large_sblocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1631 large_sblocks = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1632 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1633 else if (current_sblock == NULL |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1634 || (((char *) current_sblock + SBLOCK_SIZE |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1635 - (char *) current_sblock->next_free) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1636 < needed)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1637 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1638 /* 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
|
1639 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
|
1640 b->next_free = &b->first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1641 b->first_data.string = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1642 b->next = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1643 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1644 if (current_sblock) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1645 current_sblock->next = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1646 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1647 oldest_sblock = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1648 current_sblock = b; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1649 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1650 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1651 b = current_sblock; |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1652 |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1653 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
|
1654 old_nbytes = GC_STRING_BYTES (s); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1655 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1656 data = b->next_free; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1657 data->string = s; |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1658 s->data = SDATA_DATA (data); |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1659 #ifdef GC_CHECK_STRING_BYTES |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1660 SDATA_NBYTES (data) = nbytes; |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1661 #endif |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1662 s->size = nchars; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1663 s->size_byte = nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1664 s->data[nbytes] = '\0'; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1665 b->next_free = (struct sdata *) ((char *) data + needed); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1666 |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1667 /* 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
|
1668 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
|
1669 in it. */ |
30293
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1670 if (old_data) |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1671 { |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1672 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
|
1673 old_data->string = NULL; |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1674 } |
4a27d6a88c43
(allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents:
29781
diff
changeset
|
1675 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1676 consing_since_gc += needed; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1677 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1678 |
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 /* Sweep and compact strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1681 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1682 static void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1683 sweep_strings () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1684 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1685 struct string_block *b, *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1686 struct string_block *live_blocks = NULL; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1687 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1688 string_free_list = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1689 total_strings = total_free_strings = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1690 total_string_size = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1691 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1692 /* 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
|
1693 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
|
1694 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1695 int i, nfree = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1696 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
|
1697 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1698 next = b->next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1699 |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
1700 for (i = 0; i < STRING_BLOCK_SIZE; ++i) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1701 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1702 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
|
1703 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1704 if (s->data) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1705 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1706 /* 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
|
1707 if (STRING_MARKED_P (s)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1708 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1709 /* 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
|
1710 UNMARK_STRING (s); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1711 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1712 if (!NULL_INTERVAL_P (s->intervals)) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1713 UNMARK_BALANCE_INTERVALS (s->intervals); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1714 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1715 ++total_strings; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1716 total_string_size += STRING_BYTES (s); |
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 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1719 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1720 /* 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
|
1721 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
|
1722 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1723 /* 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
|
1724 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
|
1725 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
|
1726 #ifdef GC_CHECK_STRING_BYTES |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1727 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
|
1728 abort (); |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1729 #else |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1730 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
|
1731 #endif |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1732 data->string = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1733 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1734 /* 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
|
1735 know it's free. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1736 s->data = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1737 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1738 /* 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
|
1739 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
|
1740 string_free_list = s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1741 ++nfree; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1742 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1743 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1744 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1745 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1746 /* 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
|
1747 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
|
1748 string_free_list = s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1749 ++nfree; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1750 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1751 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1752 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
1753 /* 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
|
1754 the first two of them. */ |
51907
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
1755 if (nfree == STRING_BLOCK_SIZE |
4073a8ee4fc0
(BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51843
diff
changeset
|
1756 && total_free_strings > STRING_BLOCK_SIZE) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1757 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1758 lisp_free (b); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1759 --n_string_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1760 string_free_list = free_list_before; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1761 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1762 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1763 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1764 total_free_strings += nfree; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1765 b->next = live_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1766 live_blocks = b; |
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 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1769 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1770 string_blocks = live_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1771 free_large_strings (); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1772 compact_small_strings (); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1773 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1774 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1775 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1776 /* Free dead large strings. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1777 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1778 static void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1779 free_large_strings () |
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 struct sblock *b, *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1782 struct sblock *live_blocks = NULL; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1783 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1784 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
|
1785 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1786 next = b->next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1787 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1788 if (b->first_data.string == NULL) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1789 lisp_free (b); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1790 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1791 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1792 b->next = live_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1793 live_blocks = b; |
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 large_sblocks = live_blocks; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1798 } |
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 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1801 /* 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
|
1802 data of live strings after compaction. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1803 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1804 static void |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1805 compact_small_strings () |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1806 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1807 struct sblock *b, *tb, *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1808 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
|
1809 struct sdata *to_end, *from_end; |
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 /* 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
|
1812 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
|
1813 tb = oldest_sblock; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1814 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
|
1815 to = &tb->first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1816 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1817 /* 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
|
1818 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
|
1819 copying will happen this way. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1820 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
|
1821 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1822 end = b->next_free; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1823 xassert ((char *) end <= (char *) b + SBLOCK_SIZE); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1824 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1825 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
|
1826 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1827 /* 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
|
1828 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
|
1829 int nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1830 |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1831 #ifdef GC_CHECK_STRING_BYTES |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1832 /* 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
|
1833 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
|
1834 if (from->string |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1835 && 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
|
1836 abort (); |
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1837 #endif /* GC_CHECK_STRING_BYTES */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1838 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1839 if (from->string) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1840 nbytes = GC_STRING_BYTES (from->string); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1841 else |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
1842 nbytes = SDATA_NBYTES (from); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1843 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1844 nbytes = SDATA_SIZE (nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1845 from_end = (struct sdata *) ((char *) from + nbytes); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1846 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1847 /* 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
|
1848 if (from->string) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1849 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1850 /* 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
|
1851 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
|
1852 if (to_end > tb_end) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1853 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1854 tb->next_free = to; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1855 tb = tb->next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1856 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
|
1857 to = &tb->first_data; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1858 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
|
1859 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1860 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1861 /* 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
|
1862 if (from != to) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1863 { |
30823
8ee3740aaf60
(compact_small_strings): Use safe_bcopy, add an
Gerd Moellmann <gerd@gnu.org>
parents:
30784
diff
changeset
|
1864 xassert (tb != b || to <= from); |
8ee3740aaf60
(compact_small_strings): Use safe_bcopy, add an
Gerd Moellmann <gerd@gnu.org>
parents:
30784
diff
changeset
|
1865 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
|
1866 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
|
1867 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1868 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1869 /* 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
|
1870 to = to_end; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1871 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1872 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1873 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1874 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1875 /* 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
|
1876 we can free them. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1877 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
|
1878 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1879 next = b->next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1880 lisp_free (b); |
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 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1883 tb->next_free = to; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1884 tb->next = NULL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1885 current_sblock = tb; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1886 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1887 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1888 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1889 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
|
1890 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
|
1891 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
|
1892 (length, init) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1893 Lisp_Object length, init; |
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 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1896 register unsigned char *p, *end; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1897 int c, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1898 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
1899 CHECK_NATNUM (length); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
1900 CHECK_NUMBER (init); |
27142
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 c = XINT (init); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1903 if (SINGLE_BYTE_CHAR_P (c)) |
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 nbytes = XINT (length); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1906 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
|
1907 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
|
1908 end = p + SCHARS (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1909 while (p != end) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1910 *p++ = c; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1911 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1912 else |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1913 { |
33800
7f148cfbd1f7
(Fmake_string): Use MAX_MULTIBYTE_LENGTH, instead of hard coded `4'.
Kenichi Handa <handa@m17n.org>
parents:
33764
diff
changeset
|
1914 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
|
1915 int len = CHAR_STRING (c, str); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1916 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1917 nbytes = len * XINT (length); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1918 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
|
1919 p = SDATA (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1920 end = p + nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1921 while (p != end) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1922 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1923 bcopy (str, p, len); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1924 p += len; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1925 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1926 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1927 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1928 *p = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1929 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1930 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1931 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1932 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1933 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
|
1934 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
|
1935 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
|
1936 (length, init) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1937 Lisp_Object length, init; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1938 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1939 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1940 struct Lisp_Bool_Vector *p; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1941 int real_init, i; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1942 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
|
1943 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
1944 CHECK_NATNUM (length); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1945 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1946 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
|
1947 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1948 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
|
1949 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
|
1950 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1951 /* 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
|
1952 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
|
1953 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
|
1954 p = XBOOL_VECTOR (val); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1955 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1956 /* 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
|
1957 p->vector_size = 0; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1958 XSETBOOL_VECTOR (val, p); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1959 p->size = XFASTINT (length); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1960 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1961 real_init = (NILP (init) ? 0 : -1); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1962 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
|
1963 p->data[i] = real_init; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
1964 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1965 /* 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
|
1966 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
|
1967 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
|
1968 &= (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
|
1969 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1970 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1971 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1972 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1973 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1974 /* 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
|
1975 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
|
1976 multibyte, depending on the contents. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1977 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1978 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1979 make_string (contents, nbytes) |
46459
0a9cbcbdbe45
(xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents:
46418
diff
changeset
|
1980 const char *contents; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1981 int nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1982 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1983 register Lisp_Object val; |
28997
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
1984 int nchars, multibyte_nbytes; |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
1985 |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
1986 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
|
1987 if (nbytes == nchars || nbytes != multibyte_nbytes) |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
1988 /* 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
|
1989 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
|
1990 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
|
1991 else |
dda5cbf94928
(make_string): Fix previous change. Be sure to make
Kenichi Handa <handa@m17n.org>
parents:
32776
diff
changeset
|
1992 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
|
1993 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1994 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1995 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1996 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1997 /* 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
|
1998 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
1999 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2000 make_unibyte_string (contents, length) |
46459
0a9cbcbdbe45
(xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents:
46418
diff
changeset
|
2001 const char *contents; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2002 int length; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2003 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2004 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2005 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
|
2006 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
|
2007 STRING_SET_UNIBYTE (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2008 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2009 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2010 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2011 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2012 /* 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
|
2013 bytes at CONTENTS. */ |
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 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2016 make_multibyte_string (contents, nchars, nbytes) |
46459
0a9cbcbdbe45
(xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents:
46418
diff
changeset
|
2017 const char *contents; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2018 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2019 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2020 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2021 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
|
2022 bcopy (contents, SDATA (val), nbytes); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2023 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2024 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2025 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2026 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2027 /* 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
|
2028 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
|
2029 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2030 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2031 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
|
2032 const char *contents; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2033 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2034 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2035 register Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2036 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
|
2037 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
|
2038 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
|
2039 STRING_SET_UNIBYTE (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2040 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2041 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2042 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2043 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2044 /* 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
|
2045 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
|
2046 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
|
2047 characters by itself. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2048 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2049 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2050 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
|
2051 const char *contents; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2052 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2053 int multibyte; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2054 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2055 register Lisp_Object val; |
50200
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2056 |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2057 if (nchars < 0) |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2058 { |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2059 if (multibyte) |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2060 nchars = multibyte_chars_in_text (contents, nbytes); |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2061 else |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2062 nchars = nbytes; |
fdeb795fc0ec
(make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
49911
diff
changeset
|
2063 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2064 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
|
2065 bcopy (contents, SDATA (val), nbytes); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2066 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
|
2067 STRING_SET_UNIBYTE (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2068 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2069 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2070 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2071 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2072 /* 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
|
2073 data warrants. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2074 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2075 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2076 build_string (str) |
46459
0a9cbcbdbe45
(xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents:
46418
diff
changeset
|
2077 const char *str; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2078 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2079 return make_string (str, strlen (str)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2080 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2081 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2082 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2083 /* 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
|
2084 occupying LENGTH bytes. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2085 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2086 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2087 make_uninit_string (length) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2088 int length; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2089 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2090 Lisp_Object val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2091 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
|
2092 STRING_SET_UNIBYTE (val); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2093 return val; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2094 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2095 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2096 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2097 /* 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
|
2098 which occupy NBYTES bytes. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2099 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2100 Lisp_Object |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2101 make_uninit_multibyte_string (nchars, nbytes) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2102 int nchars, nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2103 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2104 Lisp_Object string; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2105 struct Lisp_String *s; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2106 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2107 if (nchars < 0) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2108 abort (); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2109 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2110 s = allocate_string (); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2111 allocate_string_data (s, nchars, nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2112 XSETSTRING (string, s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2113 string_chars_consed += nbytes; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2114 return string; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2115 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2116 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2117 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2118 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2119 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2120 Float Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2121 ***********************************************************************/ |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
2122 |
300 | 2123 /* 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
|
2124 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
|
2125 by GC are put on a free list to be reallocated before allocating |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2126 any new float cells from the latest float_block. */ |
300 | 2127 |
2128 #define FLOAT_BLOCK_SIZE \ | |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2129 (((BLOCK_BYTES - sizeof (struct float_block *)) * CHAR_BIT) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2130 / (sizeof (struct Lisp_Float) * CHAR_BIT + 1)) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2131 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2132 #define GETMARKBIT(block,n) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2133 (((block)->gcmarkbits[(n) / (sizeof(int) * CHAR_BIT)] \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2134 >> ((n) % (sizeof(int) * CHAR_BIT))) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2135 & 1) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2136 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2137 #define SETMARKBIT(block,n) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2138 (block)->gcmarkbits[(n) / (sizeof(int) * CHAR_BIT)] \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2139 |= 1 << ((n) % (sizeof(int) * CHAR_BIT)) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2140 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2141 #define UNSETMARKBIT(block,n) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2142 (block)->gcmarkbits[(n) / (sizeof(int) * CHAR_BIT)] \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2143 &= ~(1 << ((n) % (sizeof(int) * CHAR_BIT))) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2144 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2145 #define FLOAT_BLOCK(fptr) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2146 ((struct float_block *)(((EMACS_UINT)(fptr)) & ~(BLOCK_ALIGN - 1))) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2147 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2148 #define FLOAT_INDEX(fptr) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2149 ((((EMACS_UINT)(fptr)) & (BLOCK_ALIGN - 1)) / sizeof (struct Lisp_Float)) |
300 | 2150 |
2151 struct float_block | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2152 { |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2153 /* Place `floats' at the beginning, to ease up FLOAT_INDEX's job. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2154 struct Lisp_Float floats[FLOAT_BLOCK_SIZE]; |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2155 int gcmarkbits[1 + FLOAT_BLOCK_SIZE / (sizeof(int) * CHAR_BIT)]; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2156 struct float_block *next; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2157 }; |
300 | 2158 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2159 #define FLOAT_MARKED_P(fptr) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2160 GETMARKBIT (FLOAT_BLOCK (fptr), FLOAT_INDEX ((fptr))) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2161 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2162 #define FLOAT_MARK(fptr) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2163 SETMARKBIT (FLOAT_BLOCK (fptr), FLOAT_INDEX ((fptr))) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2164 |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2165 #define FLOAT_UNMARK(fptr) \ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2166 UNSETMARKBIT (FLOAT_BLOCK (fptr), FLOAT_INDEX ((fptr))) |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2167 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2168 /* Current float_block. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2169 |
300 | 2170 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
|
2171 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2172 /* 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
|
2173 |
300 | 2174 int float_block_index; |
2175 | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2176 /* 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
|
2177 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2178 int n_float_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2179 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2180 /* 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
|
2181 |
300 | 2182 struct Lisp_Float *float_free_list; |
2183 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2184 |
39297
aff361cfdccb
Fix a typo in a comment. From Pavel Janik.
Eli Zaretskii <eliz@gnu.org>
parents:
39228
diff
changeset
|
2185 /* Initialize float allocation. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2186 |
300 | 2187 void |
2188 init_float () | |
2189 { | |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2190 float_block = NULL; |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2191 float_block_index = FLOAT_BLOCK_SIZE; /* Force alloc of new float_block. */ |
300 | 2192 float_free_list = 0; |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2193 n_float_blocks = 0; |
300 | 2194 } |
2195 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2196 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2197 /* 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
|
2198 |
21514 | 2199 void |
300 | 2200 free_float (ptr) |
2201 struct Lisp_Float *ptr; | |
2202 { | |
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
|
2203 *(struct Lisp_Float **)&ptr->data = float_free_list; |
300 | 2204 float_free_list = ptr; |
2205 } | |
2206 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2207 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2208 /* 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
|
2209 |
300 | 2210 Lisp_Object |
2211 make_float (float_value) | |
2212 double float_value; | |
2213 { | |
2214 register Lisp_Object val; | |
2215 | |
2216 if (float_free_list) | |
2217 { | |
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
|
2218 /* 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
|
2219 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
|
2220 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
|
2221 float_free_list = *(struct Lisp_Float **)&float_free_list->data; |
300 | 2222 } |
2223 else | |
2224 { | |
2225 if (float_block_index == FLOAT_BLOCK_SIZE) | |
2226 { | |
12529 | 2227 register struct float_block *new; |
2228 | |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2229 new = (struct float_block *) lisp_align_malloc (sizeof *new, |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2230 MEM_TYPE_FLOAT); |
300 | 2231 new->next = float_block; |
2232 float_block = new; | |
2233 float_block_index = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2234 n_float_blocks++; |
300 | 2235 } |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
2236 XSETFLOAT (val, &float_block->floats[float_block_index++]); |
300 | 2237 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2238 |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
2239 XFLOAT_DATA (val) = float_value; |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
2240 FLOAT_UNMARK (XFLOAT (val)); |
300 | 2241 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
|
2242 floats_consed++; |
300 | 2243 return val; |
2244 } | |
2245 | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2246 |
300 | 2247 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2248 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2249 Cons Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2250 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2251 |
300 | 2252 /* We store cons cells inside of cons_blocks, allocating a new |
2253 cons_block with malloc whenever necessary. Cons cells reclaimed by | |
2254 GC are put on a free list to be reallocated before allocating | |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2255 any new cons cells from the latest cons_block. */ |
300 | 2256 |
2257 #define CONS_BLOCK_SIZE \ | |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2258 (((BLOCK_BYTES - sizeof (struct cons_block *)) * CHAR_BIT) \ |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2259 / (sizeof (struct Lisp_Cons) * CHAR_BIT + 1)) |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2260 |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2261 #define CONS_BLOCK(fptr) \ |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2262 ((struct cons_block *)(((EMACS_UINT)(fptr)) & ~(BLOCK_ALIGN - 1))) |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2263 |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2264 #define CONS_INDEX(fptr) \ |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2265 ((((EMACS_UINT)(fptr)) & (BLOCK_ALIGN - 1)) / sizeof (struct Lisp_Cons)) |
300 | 2266 |
2267 struct cons_block | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2268 { |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2269 /* Place `conses' at the beginning, to ease up CONS_INDEX's job. */ |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2270 struct Lisp_Cons conses[CONS_BLOCK_SIZE]; |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2271 int gcmarkbits[1 + CONS_BLOCK_SIZE / (sizeof(int) * CHAR_BIT)]; |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2272 struct cons_block *next; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2273 }; |
300 | 2274 |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2275 #define CONS_MARKED_P(fptr) \ |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2276 GETMARKBIT (CONS_BLOCK (fptr), CONS_INDEX ((fptr))) |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2277 |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2278 #define CONS_MARK(fptr) \ |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2279 SETMARKBIT (CONS_BLOCK (fptr), CONS_INDEX ((fptr))) |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2280 |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2281 #define CONS_UNMARK(fptr) \ |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2282 UNSETMARKBIT (CONS_BLOCK (fptr), CONS_INDEX ((fptr))) |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2283 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2284 /* Current cons_block. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2285 |
300 | 2286 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
|
2287 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2288 /* 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
|
2289 |
300 | 2290 int cons_block_index; |
2291 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2292 /* 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
|
2293 |
300 | 2294 struct Lisp_Cons *cons_free_list; |
2295 | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2296 /* 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
|
2297 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2298 int n_cons_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2299 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2300 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2301 /* Initialize cons allocation. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2302 |
300 | 2303 void |
2304 init_cons () | |
2305 { | |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2306 cons_block = NULL; |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2307 cons_block_index = CONS_BLOCK_SIZE; /* Force alloc of new cons_block. */ |
300 | 2308 cons_free_list = 0; |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2309 n_cons_blocks = 0; |
300 | 2310 } |
2311 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2312 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2313 /* 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
|
2314 |
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
2315 void |
300 | 2316 free_cons (ptr) |
2317 struct Lisp_Cons *ptr; | |
2318 { | |
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
|
2319 *(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
|
2320 #if GC_MARK_STACK |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2321 ptr->car = Vdead; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2322 #endif |
300 | 2323 cons_free_list = ptr; |
2324 } | |
2325 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2326 |
300 | 2327 DEFUN ("cons", Fcons, Scons, 2, 2, 0, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
2328 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
|
2329 (car, cdr) |
300 | 2330 Lisp_Object car, cdr; |
2331 { | |
2332 register Lisp_Object val; | |
2333 | |
2334 if (cons_free_list) | |
2335 { | |
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
|
2336 /* 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
|
2337 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
|
2338 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
|
2339 cons_free_list = *(struct Lisp_Cons **)&cons_free_list->cdr; |
300 | 2340 } |
2341 else | |
2342 { | |
2343 if (cons_block_index == CONS_BLOCK_SIZE) | |
2344 { | |
12529 | 2345 register struct cons_block *new; |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2346 new = (struct cons_block *) lisp_align_malloc (sizeof *new, |
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2347 MEM_TYPE_CONS); |
300 | 2348 new->next = cons_block; |
2349 cons_block = new; | |
2350 cons_block_index = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2351 n_cons_blocks++; |
300 | 2352 } |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
2353 XSETCONS (val, &cons_block->conses[cons_block_index++]); |
300 | 2354 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2355 |
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
2356 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
|
2357 XSETCDR (val, cdr); |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
2358 CONS_UNMARK (XCONS (val)); |
300 | 2359 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
|
2360 cons_cells_consed++; |
300 | 2361 return val; |
2362 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2363 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2364 |
20849
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2365 /* 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
|
2366 |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2367 Lisp_Object |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2368 list2 (arg1, arg2) |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2369 Lisp_Object arg1, arg2; |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2370 { |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2371 return Fcons (arg1, Fcons (arg2, Qnil)); |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2372 } |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2373 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2374 |
20849
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2375 Lisp_Object |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2376 list3 (arg1, arg2, arg3) |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2377 Lisp_Object arg1, arg2, arg3; |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2378 { |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2379 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
|
2380 } |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2381 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2382 |
20849
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2383 Lisp_Object |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2384 list4 (arg1, arg2, arg3, arg4) |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2385 Lisp_Object arg1, arg2, arg3, arg4; |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2386 { |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2387 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
|
2388 } |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2389 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2390 |
20849
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2391 Lisp_Object |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2392 list5 (arg1, arg2, arg3, arg4, arg5) |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2393 Lisp_Object arg1, arg2, arg3, arg4, arg5; |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2394 { |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2395 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
|
2396 Fcons (arg5, Qnil))))); |
3b2f72ed135c
(list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
20768
diff
changeset
|
2397 } |
300 | 2398 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2399 |
300 | 2400 DEFUN ("list", Flist, Slist, 0, MANY, 0, |
40977 | 2401 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
|
2402 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
|
2403 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
|
2404 (nargs, args) |
300 | 2405 int nargs; |
2406 register Lisp_Object *args; | |
2407 { | |
13610
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2408 register Lisp_Object val; |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2409 val = Qnil; |
300 | 2410 |
13610
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2411 while (nargs > 0) |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2412 { |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2413 nargs--; |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2414 val = Fcons (args[nargs], val); |
8e82e46aa77b
(Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents:
13553
diff
changeset
|
2415 } |
300 | 2416 return val; |
2417 } | |
2418 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2419 |
300 | 2420 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
|
2421 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
|
2422 (length, init) |
300 | 2423 register Lisp_Object length, init; |
2424 { | |
2425 register Lisp_Object val; | |
2426 register int size; | |
2427 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
2428 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
|
2429 size = XFASTINT (length); |
300 | 2430 |
2431 val = Qnil; | |
35762
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2432 while (size > 0) |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2433 { |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2434 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
|
2435 --size; |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2436 |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2437 if (size > 0) |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2438 { |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2439 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
|
2440 --size; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2441 |
35762
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2442 if (size > 0) |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2443 { |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2444 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
|
2445 --size; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2446 |
35762
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2447 if (size > 0) |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2448 { |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2449 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
|
2450 --size; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2451 |
35762
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2452 if (size > 0) |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2453 { |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2454 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
|
2455 --size; |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2456 } |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2457 } |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2458 } |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2459 } |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2460 |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2461 QUIT; |
e197a82c3286
(Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents:
35660
diff
changeset
|
2462 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2463 |
300 | 2464 return val; |
2465 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2466 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2467 |
300 | 2468 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2469 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2470 Vector Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2471 ***********************************************************************/ |
300 | 2472 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2473 /* 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
|
2474 |
300 | 2475 struct Lisp_Vector *all_vectors; |
2476 | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2477 /* 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
|
2478 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2479 int n_vectors; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2480 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2481 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2482 /* 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
|
2483 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
|
2484 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2485 static struct Lisp_Vector * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2486 allocate_vectorlike (len, type) |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2487 EMACS_INT len; |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2488 enum mem_type type; |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2489 { |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2490 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
|
2491 size_t nbytes; |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2492 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
2493 #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
|
2494 /* 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
|
2495 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
|
2496 a dumped Emacs. */ |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
2497 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
|
2498 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2499 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2500 nbytes = sizeof *p + (len - 1) * sizeof p->contents[0]; |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2501 p = (struct Lisp_Vector *) lisp_malloc (nbytes, type); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2502 |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
2503 #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
|
2504 /* 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
|
2505 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
|
2506 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2507 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2508 consing_since_gc += nbytes; |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
2509 vector_cells_consed += len; |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2510 |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2511 p->next = all_vectors; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2512 all_vectors = p; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2513 ++n_vectors; |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2514 return p; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2515 } |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2516 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2517 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2518 /* Allocate a vector with NSLOTS slots. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2519 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2520 struct Lisp_Vector * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2521 allocate_vector (nslots) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2522 EMACS_INT nslots; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2523 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2524 struct Lisp_Vector *v = allocate_vectorlike (nslots, MEM_TYPE_VECTOR); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2525 v->size = nslots; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2526 return v; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2527 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2528 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2529 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2530 /* Allocate other vector-like structures. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2531 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2532 struct Lisp_Hash_Table * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2533 allocate_hash_table () |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2534 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2535 EMACS_INT len = VECSIZE (struct Lisp_Hash_Table); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2536 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
|
2537 EMACS_INT i; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2538 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2539 v->size = len; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2540 for (i = 0; i < len; ++i) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2541 v->contents[i] = Qnil; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2542 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2543 return (struct Lisp_Hash_Table *) v; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2544 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2545 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2546 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2547 struct window * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2548 allocate_window () |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2549 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2550 EMACS_INT len = VECSIZE (struct window); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2551 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_WINDOW); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2552 EMACS_INT i; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2553 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2554 for (i = 0; i < len; ++i) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2555 v->contents[i] = Qnil; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2556 v->size = len; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2557 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2558 return (struct window *) v; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2559 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2560 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2561 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2562 struct frame * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2563 allocate_frame () |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2564 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2565 EMACS_INT len = VECSIZE (struct frame); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2566 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_FRAME); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2567 EMACS_INT i; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2568 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2569 for (i = 0; i < len; ++i) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2570 v->contents[i] = make_number (0); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2571 v->size = len; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2572 return (struct frame *) v; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2573 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2574 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2575 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2576 struct Lisp_Process * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2577 allocate_process () |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2578 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2579 EMACS_INT len = VECSIZE (struct Lisp_Process); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2580 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_PROCESS); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2581 EMACS_INT i; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2582 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2583 for (i = 0; i < len; ++i) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2584 v->contents[i] = Qnil; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2585 v->size = len; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2586 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2587 return (struct Lisp_Process *) v; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2588 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2589 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2590 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2591 struct Lisp_Vector * |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2592 allocate_other_vector (len) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2593 EMACS_INT len; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2594 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2595 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_VECTOR); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2596 EMACS_INT i; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2597 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2598 for (i = 0; i < len; ++i) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2599 v->contents[i] = Qnil; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2600 v->size = len; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2601 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2602 return v; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2603 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2604 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2605 |
300 | 2606 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
|
2607 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
|
2608 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
|
2609 (length, init) |
300 | 2610 register Lisp_Object length, init; |
2611 { | |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2612 Lisp_Object vector; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2613 register EMACS_INT sizei; |
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2614 register int index; |
300 | 2615 register struct Lisp_Vector *p; |
2616 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
2617 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
|
2618 sizei = XFASTINT (length); |
300 | 2619 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
2620 p = allocate_vector (sizei); |
300 | 2621 for (index = 0; index < sizei; index++) |
2622 p->contents[index] = init; | |
2623 | |
9968
943a61c764a5
(Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents:
9953
diff
changeset
|
2624 XSETVECTOR (vector, p); |
300 | 2625 return vector; |
2626 } | |
2627 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2628 |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
2629 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
|
2630 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
|
2631 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
|
2632 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
|
2633 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
|
2634 (purpose, init) |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
2635 register Lisp_Object purpose, init; |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
2636 { |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
2637 Lisp_Object vector; |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
2638 Lisp_Object n; |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
2639 CHECK_SYMBOL (purpose); |
17328
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2640 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
|
2641 CHECK_NUMBER (n); |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
2642 if (XINT (n) < 0 || XINT (n) > 10) |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
2643 args_out_of_range (n, Qnil); |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
2644 /* 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
|
2645 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
|
2646 init); |
17328
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2647 XCHAR_TABLE (vector)->top = Qt; |
13150
3778c95adca9
(Fmake_char_table): Initialize parent to nil.
Erik Naggum <erik@naggum.no>
parents:
13141
diff
changeset
|
2648 XCHAR_TABLE (vector)->parent = Qnil; |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
2649 XCHAR_TABLE (vector)->purpose = purpose; |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
2650 XSETCHAR_TABLE (vector, XCHAR_TABLE (vector)); |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
2651 return vector; |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
2652 } |
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
2653 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2654 |
17328
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2655 /* 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
|
2656 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
|
2657 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
|
2658 |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2659 Lisp_Object |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2660 make_sub_char_table (defalt) |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2661 Lisp_Object defalt; |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2662 { |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2663 Lisp_Object vector |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2664 = 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
|
2665 XCHAR_TABLE (vector)->top = Qnil; |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2666 XCHAR_TABLE (vector)->defalt = defalt; |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2667 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
|
2668 return vector; |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2669 } |
e2a6f31ee014
(Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents:
17217
diff
changeset
|
2670 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2671 |
300 | 2672 DEFUN ("vector", Fvector, Svector, 0, MANY, 0, |
40977 | 2673 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
|
2674 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
|
2675 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
|
2676 (nargs, args) |
300 | 2677 register int nargs; |
2678 Lisp_Object *args; | |
2679 { | |
2680 register Lisp_Object len, val; | |
2681 register int index; | |
2682 register struct Lisp_Vector *p; | |
2683 | |
9295
17d393a8eed6
(free_float, make_float, free_cons, Flist, Fvector, Fmake_byte_code,
Karl Heuer <kwzh@gnu.org>
parents:
9261
diff
changeset
|
2684 XSETFASTINT (len, nargs); |
300 | 2685 val = Fmake_vector (len, Qnil); |
2686 p = XVECTOR (val); | |
2687 for (index = 0; index < nargs; index++) | |
2688 p->contents[index] = args[index]; | |
2689 return val; | |
2690 } | |
2691 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2692 |
300 | 2693 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
|
2694 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
|
2695 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
|
2696 stack size, (optional) doc string, and (optional) interactive spec. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
2697 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
|
2698 significance. |
50626
a5a77c7717cb
(Fmake_byte_code): Improve the `usage' string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50468
diff
changeset
|
2699 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
|
2700 (nargs, args) |
300 | 2701 register int nargs; |
2702 Lisp_Object *args; | |
2703 { | |
2704 register Lisp_Object len, val; | |
2705 register int index; | |
2706 register struct Lisp_Vector *p; | |
2707 | |
9295
17d393a8eed6
(free_float, make_float, free_cons, Flist, Fvector, Fmake_byte_code,
Karl Heuer <kwzh@gnu.org>
parents:
9261
diff
changeset
|
2708 XSETFASTINT (len, nargs); |
485 | 2709 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
|
2710 val = make_pure_vector ((EMACS_INT) nargs); |
300 | 2711 else |
2712 val = Fmake_vector (len, Qnil); | |
28997
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
2713 |
fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents:
28469
diff
changeset
|
2714 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
|
2715 /* 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
|
2716 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
|
2717 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
|
2718 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
|
2719 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
|
2720 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
|
2721 |
300 | 2722 p = XVECTOR (val); |
2723 for (index = 0; index < nargs; index++) | |
2724 { | |
485 | 2725 if (!NILP (Vpurify_flag)) |
300 | 2726 args[index] = Fpurecopy (args[index]); |
2727 p->contents[index] = args[index]; | |
2728 } | |
18104
b2a669ef69b1
(Fmake_byte_code): Set val from p, not from val.
Richard M. Stallman <rms@gnu.org>
parents:
18010
diff
changeset
|
2729 XSETCOMPILED (val, p); |
300 | 2730 return val; |
2731 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2732 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2733 |
300 | 2734 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2735 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2736 Symbol Allocation |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2737 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2738 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2739 /* 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
|
2740 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
|
2741 own overhead. */ |
300 | 2742 |
2743 #define SYMBOL_BLOCK_SIZE \ | |
2744 ((1020 - sizeof (struct symbol_block *)) / sizeof (struct Lisp_Symbol)) | |
2745 | |
2746 struct symbol_block | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2747 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2748 struct symbol_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2749 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
|
2750 }; |
300 | 2751 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2752 /* 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
|
2753 structure in it. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2754 |
300 | 2755 struct symbol_block *symbol_block; |
2756 int symbol_block_index; | |
2757 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2758 /* List of free symbols. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2759 |
300 | 2760 struct Lisp_Symbol *symbol_free_list; |
2761 | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2762 /* 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
|
2763 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2764 int n_symbol_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2765 |
27738
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 /* Initialize symbol allocation. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2768 |
300 | 2769 void |
2770 init_symbol () | |
2771 { | |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
2772 symbol_block = NULL; |
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
2773 symbol_block_index = SYMBOL_BLOCK_SIZE; |
300 | 2774 symbol_free_list = 0; |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
2775 n_symbol_blocks = 0; |
300 | 2776 } |
2777 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2778 |
300 | 2779 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
|
2780 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
|
2781 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
|
2782 (name) |
14093
338f645e6b9a
(Fmake_symbol): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2783 Lisp_Object name; |
300 | 2784 { |
2785 register Lisp_Object val; | |
2786 register struct Lisp_Symbol *p; | |
2787 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40113
diff
changeset
|
2788 CHECK_STRING (name); |
300 | 2789 |
2790 if (symbol_free_list) | |
2791 { | |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
2792 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
|
2793 symbol_free_list = *(struct Lisp_Symbol **)&symbol_free_list->value; |
300 | 2794 } |
2795 else | |
2796 { | |
2797 if (symbol_block_index == SYMBOL_BLOCK_SIZE) | |
2798 { | |
12529 | 2799 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
|
2800 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
|
2801 MEM_TYPE_SYMBOL); |
300 | 2802 new->next = symbol_block; |
2803 symbol_block = new; | |
2804 symbol_block_index = 0; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2805 n_symbol_blocks++; |
300 | 2806 } |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
2807 XSETSYMBOL (val, &symbol_block->symbols[symbol_block_index++]); |
300 | 2808 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2809 |
300 | 2810 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
|
2811 p->xname = name; |
300 | 2812 p->plist = Qnil; |
2813 p->value = Qunbound; | |
2814 p->function = Qunbound; | |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
2815 p->next = NULL; |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
2816 p->gcmarkbit = 0; |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
2817 p->interned = SYMBOL_UNINTERNED; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
2818 p->constant = 0; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
2819 p->indirect_variable = 0; |
300 | 2820 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
|
2821 symbols_consed++; |
300 | 2822 return val; |
2823 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2824 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2825 |
300 | 2826 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2827 /*********************************************************************** |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2828 Marker (Misc) Allocation |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2829 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2830 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2831 /* Allocation of markers and other objects that share that structure. |
300 | 2832 Works like allocation of conses. */ |
2833 | |
2834 #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
|
2835 ((1020 - sizeof (struct marker_block *)) / sizeof (union Lisp_Misc)) |
300 | 2836 |
2837 struct marker_block | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2838 { |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2839 struct marker_block *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2840 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
|
2841 }; |
300 | 2842 |
2843 struct marker_block *marker_block; | |
2844 int marker_block_index; | |
2845 | |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2846 union Lisp_Misc *marker_free_list; |
300 | 2847 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2848 /* 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
|
2849 |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2850 int n_marker_blocks; |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2851 |
300 | 2852 void |
2853 init_marker () | |
2854 { | |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
2855 marker_block = NULL; |
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
2856 marker_block_index = MARKER_BLOCK_SIZE; |
300 | 2857 marker_free_list = 0; |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
2858 n_marker_blocks = 0; |
300 | 2859 } |
2860 | |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2861 /* 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
|
2862 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2863 Lisp_Object |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2864 allocate_misc () |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2865 { |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2866 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
|
2867 |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2868 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
|
2869 { |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2870 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
|
2871 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
|
2872 } |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2873 else |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2874 { |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2875 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
|
2876 { |
12529 | 2877 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
|
2878 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
|
2879 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
|
2880 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
|
2881 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
|
2882 marker_block_index = 0; |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
2883 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
|
2884 } |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2885 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
|
2886 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2887 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2888 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
|
2889 misc_objects_consed++; |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
2890 XMARKER (val)->gcmarkbit = 0; |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2891 return val; |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2892 } |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2893 |
49055
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2894 /* 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
|
2895 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
|
2896 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
|
2897 |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2898 Lisp_Object |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2899 make_save_value (pointer, integer) |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2900 void *pointer; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2901 int integer; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2902 { |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2903 register Lisp_Object val; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2904 register struct Lisp_Save_Value *p; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2905 |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2906 val = allocate_misc (); |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2907 XMISCTYPE (val) = Lisp_Misc_Save_Value; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2908 p = XSAVE_VALUE (val); |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2909 p->pointer = pointer; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2910 p->integer = integer; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2911 return val; |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2912 } |
cea2e52c7ca5
(make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents:
48907
diff
changeset
|
2913 |
300 | 2914 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
|
2915 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
|
2916 () |
300 | 2917 { |
2918 register Lisp_Object val; | |
2919 register struct Lisp_Marker *p; | |
638 | 2920 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
2921 val = allocate_misc (); |
11243
054ecfce1820
(Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents:
11048
diff
changeset
|
2922 XMISCTYPE (val) = Lisp_Misc_Marker; |
300 | 2923 p = XMARKER (val); |
2924 p->buffer = 0; | |
20565
aa9b7c5f0f62
(Fmake_marker): Initialize marker's bytepos and charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20495
diff
changeset
|
2925 p->bytepos = 0; |
aa9b7c5f0f62
(Fmake_marker): Initialize marker's bytepos and charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20495
diff
changeset
|
2926 p->charpos = 0; |
51668
0f333fd92a1d
(survives_gc_p): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51658
diff
changeset
|
2927 p->next = NULL; |
13008
f042ef632b22
(Fmake_marker): Initialize insertion_type to 0.
Richard M. Stallman <rms@gnu.org>
parents:
12748
diff
changeset
|
2928 p->insertion_type = 0; |
300 | 2929 return val; |
2930 } | |
19332
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2931 |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2932 /* 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
|
2933 |
20375
1dd0bd0749b5
(malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20057
diff
changeset
|
2934 void |
19332
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2935 free_marker (marker) |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2936 Lisp_Object marker; |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2937 { |
51668
0f333fd92a1d
(survives_gc_p): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51658
diff
changeset
|
2938 unchain_marker (XMARKER (marker)); |
19621
74151390752c
(free_marker): Call unchain_marker.
Richard M. Stallman <rms@gnu.org>
parents:
19332
diff
changeset
|
2939 |
19332
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2940 XMISC (marker)->u_marker.type = Lisp_Misc_Free; |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2941 XMISC (marker)->u_free.chain = marker_free_list; |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2942 marker_free_list = XMISC (marker); |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2943 |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2944 total_free_markers++; |
58f14958f5d5
(free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18621
diff
changeset
|
2945 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2946 |
21258
693573ac0944
(make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
2947 |
300 | 2948 /* 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
|
2949 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
|
2950 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
|
2951 |
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
2952 Any number of arguments, even zero arguments, are allowed. */ |
300 | 2953 |
2954 Lisp_Object | |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
2955 make_event_array (nargs, args) |
300 | 2956 register int nargs; |
2957 Lisp_Object *args; | |
2958 { | |
2959 int i; | |
2960 | |
2961 for (i = 0; i < nargs; i++) | |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
2962 /* 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
|
2963 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
|
2964 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
|
2965 if (!INTEGERP (args[i]) |
3536
58d5ee6ec253
(make_event_array): Ignore bits above CHAR_META.
Richard M. Stallman <rms@gnu.org>
parents:
3181
diff
changeset
|
2966 || (XUINT (args[i]) & ~(-CHAR_META)) >= 0200) |
300 | 2967 return Fvector (nargs, args); |
2968 | |
2969 /* Since the loop exited, we know that all the things in it are | |
2970 characters, so we can make a string. */ | |
2971 { | |
6492
8372dce85f8a
(make_event_array): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6227
diff
changeset
|
2972 Lisp_Object result; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2973 |
18104
b2a669ef69b1
(Fmake_byte_code): Set val from p, not from val.
Richard M. Stallman <rms@gnu.org>
parents:
18010
diff
changeset
|
2974 result = Fmake_string (make_number (nargs), make_number (0)); |
300 | 2975 for (i = 0; i < nargs; i++) |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
2976 { |
46418
b12a32662433
* alloc.c (make_event_array): Use SSET for storing into a string.
Ken Raeburn <raeburn@raeburn.org>
parents:
46370
diff
changeset
|
2977 SSET (result, i, XINT (args[i])); |
2013
e2a164ac4088
(Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
2978 /* 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
|
2979 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
|
2980 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
|
2981 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
2982 |
300 | 2983 return result; |
2984 } | |
2985 } | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2986 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
2987 |
300 | 2988 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2989 /************************************************************************ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2990 C Stack Marking |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2991 ************************************************************************/ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
2992 |
32700
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
2993 #if GC_MARK_STACK || defined GC_MALLOC_CHECK |
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
2994 |
42403 | 2995 /* Conservative C stack marking requires a method to identify possibly |
2996 live Lisp objects given a pointer value. We do this by keeping | |
2997 track of blocks of Lisp data that are allocated in a red-black tree | |
2998 (see also the comment of mem_node which is the type of nodes in | |
2999 that tree). Function lisp_malloc adds information for an allocated | |
3000 block to the red-black tree with calls to mem_insert, and function | |
3001 lisp_free removes it with mem_delete. Functions live_string_p etc | |
3002 call mem_find to lookup information about a given pointer in the | |
3003 tree, and use that to determine if the pointer points to a Lisp | |
3004 object or not. */ | |
3005 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3006 /* 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
|
3007 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3008 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3009 mem_init () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3010 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3011 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
|
3012 mem_z.parent = NULL; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3013 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
|
3014 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
|
3015 mem_root = MEM_NIL; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3016 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3017 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3018 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3019 /* 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
|
3020 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
|
3021 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3022 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
|
3023 mem_find (start) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3024 void *start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3025 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3026 struct mem_node *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3027 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3028 if (start < min_heap_address || start > max_heap_address) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3029 return MEM_NIL; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3030 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3031 /* 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
|
3032 mem_z.start = start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3033 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
|
3034 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3035 p = mem_root; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3036 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
|
3037 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
|
3038 return p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3039 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3040 |
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 /* 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
|
3043 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
|
3044 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
|
3045 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3046 static struct mem_node * |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3047 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
|
3048 void *start, *end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3049 enum mem_type type; |
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 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
|
3052 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3053 if (start < min_heap_address) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3054 min_heap_address = start; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3055 if (end > max_heap_address) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3056 max_heap_address = end; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3057 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3058 /* 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
|
3059 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
|
3060 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
|
3061 c = mem_root; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3062 parent = NULL; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3063 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3064 #if GC_MARK_STACK != GC_MAKE_GCPROS_NOOPS |
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 while (c != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3067 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3068 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
|
3069 abort (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3070 parent = c; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3071 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
|
3072 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3073 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3074 #else /* GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3075 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3076 while (c != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3077 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3078 parent = c; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3079 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
|
3080 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3081 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3082 #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
|
3083 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3084 /* Create a new node. */ |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3085 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3086 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
|
3087 if (x == NULL) |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3088 abort (); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3089 #else |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3090 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
|
3091 #endif |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3092 x->start = start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3093 x->end = end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3094 x->type = type; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3095 x->parent = parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3096 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
|
3097 x->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3098 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3099 /* 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
|
3100 if (parent) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3101 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3102 if (start < parent->start) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3103 parent->left = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3104 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3105 parent->right = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3106 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3107 else |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3108 mem_root = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3109 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3110 /* 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
|
3111 mem_insert_fixup (x); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3112 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3113 return x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3114 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3115 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3116 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3117 /* 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
|
3118 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
|
3119 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3120 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3121 mem_insert_fixup (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3122 struct mem_node *x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3123 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3124 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
|
3125 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3126 /* 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
|
3127 red-black tree property #3. */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3128 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3129 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
|
3130 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3131 /* 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
|
3132 "uncle". */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3133 struct mem_node *y = x->parent->parent->right; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3134 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3135 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
|
3136 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3137 /* 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
|
3138 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
|
3139 with the grandparent. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3140 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
|
3141 y->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3142 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
|
3143 x = x->parent->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3144 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3145 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3146 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3147 /* 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
|
3148 red, uncle is black. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3149 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
|
3150 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3151 x = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3152 mem_rotate_left (x); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3153 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3154 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3155 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
|
3156 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
|
3157 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
|
3158 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3159 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3160 else |
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 /* 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
|
3163 struct mem_node *y = x->parent->parent->left; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3164 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3165 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
|
3166 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3167 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
|
3168 y->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3169 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
|
3170 x = x->parent->parent; |
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 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3173 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3174 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
|
3175 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3176 x = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3177 mem_rotate_right (x); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3178 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3179 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3180 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
|
3181 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
|
3182 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
|
3183 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3184 } |
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 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3187 /* 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
|
3188 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
|
3189 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
|
3190 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3191 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3192 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3193 /* (x) (y) |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3194 / \ / \ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3195 a (y) ===> (x) c |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3196 / \ / \ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3197 b c a b */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3198 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3199 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3200 mem_rotate_left (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3201 struct mem_node *x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3202 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3203 struct mem_node *y; |
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 /* 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
|
3206 y = x->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3207 x->right = y->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3208 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
|
3209 y->left->parent = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3210 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3211 /* 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
|
3212 if (y != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3213 y->parent = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3214 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3215 /* 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
|
3216 if (x->parent) |
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 (x == x->parent->left) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3219 x->parent->left = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3220 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3221 x->parent->right = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3222 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3223 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3224 mem_root = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3225 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3226 /* 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
|
3227 y->left = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3228 if (x != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3229 x->parent = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3230 } |
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 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3233 /* (x) (Y) |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3234 / \ / \ |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3235 (y) c ===> a (x) |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3236 / \ / \ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3237 a b b c */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3238 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3239 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3240 mem_rotate_right (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3241 struct mem_node *x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3242 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3243 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
|
3244 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3245 x->left = y->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3246 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
|
3247 y->right->parent = x; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3248 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3249 if (y != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3250 y->parent = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3251 if (x->parent) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3252 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3253 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
|
3254 x->parent->right = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3255 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3256 x->parent->left = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3257 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3258 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3259 mem_root = y; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3260 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3261 y->right = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3262 if (x != MEM_NIL) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3263 x->parent = y; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3264 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3265 |
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 /* 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
|
3268 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3269 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3270 mem_delete (z) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3271 struct mem_node *z; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3272 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3273 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
|
3274 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3275 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
|
3276 return; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3277 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3278 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
|
3279 y = z; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3280 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3281 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3282 y = z->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3283 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
|
3284 y = y->left; |
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 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3287 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
|
3288 x = y->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3289 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3290 x = y->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3291 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3292 x->parent = y->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3293 if (y->parent) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3294 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3295 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
|
3296 y->parent->left = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3297 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3298 y->parent->right = x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3299 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3300 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3301 mem_root = x; |
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 if (y != z) |
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 z->start = y->start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3306 z->end = y->end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3307 z->type = y->type; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3308 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3309 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3310 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
|
3311 mem_delete_fixup (x); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3312 |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3313 #ifdef GC_MALLOC_CHECK |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3314 _free_internal (y); |
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3315 #else |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3316 xfree (y); |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
3317 #endif |
27738
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 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3320 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3321 /* 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
|
3322 deletion. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3323 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3324 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3325 mem_delete_fixup (x) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3326 struct mem_node *x; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3327 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3328 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
|
3329 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3330 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
|
3331 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3332 struct mem_node *w = x->parent->right; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3333 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3334 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
|
3335 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3336 w->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3337 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
|
3338 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
|
3339 w = x->parent->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3340 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3341 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3342 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
|
3343 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3344 w->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3345 x = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3346 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3347 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3348 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3349 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
|
3350 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3351 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
|
3352 w->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3353 mem_rotate_right (w); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3354 w = x->parent->right; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3355 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3356 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
|
3357 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
|
3358 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
|
3359 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
|
3360 x = mem_root; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3361 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3362 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3363 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3364 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3365 struct mem_node *w = x->parent->left; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3366 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3367 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
|
3368 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3369 w->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3370 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
|
3371 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
|
3372 w = x->parent->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3373 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3374 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3375 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
|
3376 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3377 w->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3378 x = x->parent; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3379 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3380 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3381 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3382 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
|
3383 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3384 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
|
3385 w->color = MEM_RED; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3386 mem_rotate_left (w); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3387 w = x->parent->left; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3388 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3389 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3390 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
|
3391 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
|
3392 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
|
3393 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
|
3394 x = mem_root; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3395 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3396 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3397 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3398 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3399 x->color = MEM_BLACK; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3400 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3401 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3402 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3403 /* 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
|
3404 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
|
3405 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3406 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3407 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
|
3408 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3409 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3410 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3411 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
|
3412 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3413 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
|
3414 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
|
3415 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3416 /* 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
|
3417 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
|
3418 return (offset >= 0 |
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3419 && 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
|
3420 && ((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
|
3421 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3422 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3423 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3424 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3425 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3426 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3427 /* 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
|
3428 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
|
3429 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3430 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3431 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
|
3432 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3433 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3434 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3435 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
|
3436 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3437 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
|
3438 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
|
3439 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3440 /* 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
|
3441 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
|
3442 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
|
3443 return (offset >= 0 |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
3444 && offset < (CONS_BLOCK_SIZE * sizeof b->conses[0]) |
37049
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3445 && 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
|
3446 && (b != cons_block |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3447 || 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
|
3448 && !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
|
3449 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3450 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3451 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3452 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3453 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3454 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3455 /* 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
|
3456 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
|
3457 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3458 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3459 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
|
3460 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3461 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3462 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3463 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
|
3464 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3465 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
|
3466 int offset = (char *) p - (char *) &b->symbols[0]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3467 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3468 /* 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
|
3469 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
|
3470 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
|
3471 return (offset >= 0 |
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3472 && 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
|
3473 && (b != symbol_block |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3474 || 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
|
3475 && !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
|
3476 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3477 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3478 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3479 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3480 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3481 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3482 /* 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
|
3483 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
|
3484 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3485 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3486 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
|
3487 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3488 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3489 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3490 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
|
3491 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3492 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
|
3493 int offset = (char *) p - (char *) &b->floats[0]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3494 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
3495 /* P must point to the start of a Lisp_Float and not be |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
3496 one of the unused cells in the current float block. */ |
37049
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3497 return (offset >= 0 |
51779
f01acdb936f9
(live_float_p): Check that p is not past the `floats' array,
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51770
diff
changeset
|
3498 && offset < (FLOAT_BLOCK_SIZE * sizeof b->floats[0]) |
37049
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3499 && 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
|
3500 && (b != float_block |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
3501 || offset / sizeof b->floats[0] < float_block_index)); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3502 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3503 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3504 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3505 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3506 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3507 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3508 /* 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
|
3509 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
|
3510 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3511 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3512 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
|
3513 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3514 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3515 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3516 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
|
3517 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3518 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
|
3519 int offset = (char *) p - (char *) &b->markers[0]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3520 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3521 /* 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
|
3522 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
|
3523 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
|
3524 return (offset >= 0 |
184d1fb71cc1
(live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents:
36487
diff
changeset
|
3525 && 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
|
3526 && (b != marker_block |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3527 || 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
|
3528 && ((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
|
3529 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3530 else |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3531 return 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3532 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3533 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3534 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3535 /* 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
|
3536 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
|
3537 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3538 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3539 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
|
3540 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3541 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3542 { |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3543 return (p == m->start |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3544 && m->type >= MEM_TYPE_VECTOR |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3545 && 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
|
3546 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3547 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3548 |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
3549 /* Value is non-zero if P is a pointer to a live buffer. M is a |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3550 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
|
3551 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3552 static INLINE int |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3553 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
|
3554 struct mem_node *m; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3555 void *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3556 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3557 /* 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
|
3558 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
|
3559 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
|
3560 && p == m->start |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3561 && !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
|
3562 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3563 |
32700
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
3564 #endif /* GC_MARK_STACK || defined GC_MALLOC_CHECK */ |
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
3565 |
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
3566 #if GC_MARK_STACK |
25c6c2562e31
(toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents:
32699
diff
changeset
|
3567 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3568 #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
|
3569 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3570 /* 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
|
3571 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
|
3572 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3573 #define MAX_ZOMBIES 10 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3574 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
|
3575 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3576 /* Number of zombie objects. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3577 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3578 static int nzombies; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3579 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3580 /* Number of garbage collections. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3581 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3582 static int ngcs; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3583 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3584 /* 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
|
3585 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3586 static double avg_zombies; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3587 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3588 /* 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
|
3589 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3590 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
|
3591 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3592 /* 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
|
3593 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3594 static double avg_live; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3595 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3596 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
|
3597 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
|
3598 () |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3599 { |
49357 | 3600 Lisp_Object args[8], zombie_list = Qnil; |
3601 int i; | |
3602 for (i = 0; i < nzombies; i++) | |
3603 zombie_list = Fcons (zombies[i], zombie_list); | |
3604 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
|
3605 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
|
3606 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
|
3607 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
|
3608 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
|
3609 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
|
3610 args[6] = make_number (max_zombies); |
49357 | 3611 args[7] = zombie_list; |
3612 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
|
3613 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3614 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3615 #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
|
3616 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3617 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3618 /* 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
|
3619 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3620 static INLINE void |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3621 mark_maybe_object (obj) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3622 Lisp_Object obj; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3623 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3624 void *po = (void *) XPNTR (obj); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3625 struct mem_node *m = mem_find (po); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3626 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3627 if (m != MEM_NIL) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3628 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3629 int mark_p = 0; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3630 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3631 switch (XGCTYPE (obj)) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3632 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3633 case Lisp_String: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3634 mark_p = (live_string_p (m, po) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3635 && !STRING_MARKED_P ((struct Lisp_String *) po)); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3636 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3637 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3638 case Lisp_Cons: |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
3639 mark_p = (live_cons_p (m, po) && !CONS_MARKED_P (XCONS (obj))); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3640 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3641 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3642 case Lisp_Symbol: |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
3643 mark_p = (live_symbol_p (m, po) && !XSYMBOL (obj)->gcmarkbit); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3644 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3645 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3646 case Lisp_Float: |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
3647 mark_p = (live_float_p (m, po) && !FLOAT_MARKED_P (XFLOAT (obj))); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3648 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3649 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3650 case Lisp_Vectorlike: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3651 /* 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
|
3652 buffer because checking that dereferences the pointer |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3653 PO which might point anywhere. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3654 if (live_vector_p (m, po)) |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
3655 mark_p = !GC_SUBRP (obj) && !VECTOR_MARKED_P (XVECTOR (obj)); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3656 else if (live_buffer_p (m, po)) |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
3657 mark_p = GC_BUFFERP (obj) && !VECTOR_MARKED_P (XBUFFER (obj)); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3658 break; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3659 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3660 case Lisp_Misc: |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
3661 mark_p = (live_misc_p (m, po) && !XMARKER (obj)->gcmarkbit); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3662 break; |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
3663 |
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
3664 case Lisp_Int: |
31897
a292cc13911a
(GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents:
31892
diff
changeset
|
3665 case Lisp_Type_Limit: |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
3666 break; |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3667 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3668 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3669 if (mark_p) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3670 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3671 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3672 if (nzombies < MAX_ZOMBIES) |
49357 | 3673 zombies[nzombies] = obj; |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3674 ++nzombies; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3675 #endif |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
3676 mark_object (obj); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3677 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3678 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3679 } |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3680 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3681 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3682 /* 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
|
3683 marked. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3684 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3685 static INLINE void |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3686 mark_maybe_pointer (p) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3687 void *p; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3688 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3689 struct mem_node *m; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3690 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3691 /* 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
|
3692 assume that Lisp data is aligned on even addresses. */ |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3693 if ((EMACS_INT) p & 1) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3694 return; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3695 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3696 m = mem_find (p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3697 if (m != MEM_NIL) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3698 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3699 Lisp_Object obj = Qnil; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3700 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3701 switch (m->type) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3702 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3703 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
|
3704 /* Nothing to do; not a pointer to Lisp memory. */ |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3705 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3706 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3707 case MEM_TYPE_BUFFER: |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
3708 if (live_buffer_p (m, p) && !VECTOR_MARKED_P((struct buffer *)p)) |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3709 XSETVECTOR (obj, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3710 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3711 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3712 case MEM_TYPE_CONS: |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
3713 if (live_cons_p (m, p) && !CONS_MARKED_P ((struct Lisp_Cons *) p)) |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3714 XSETCONS (obj, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3715 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3716 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3717 case MEM_TYPE_STRING: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3718 if (live_string_p (m, p) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3719 && !STRING_MARKED_P ((struct Lisp_String *) p)) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3720 XSETSTRING (obj, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3721 break; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3722 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3723 case MEM_TYPE_MISC: |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
3724 if (live_misc_p (m, p) && !((struct Lisp_Free *) p)->gcmarkbit) |
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
3725 XSETMISC (obj, p); |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3726 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3727 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3728 case MEM_TYPE_SYMBOL: |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
3729 if (live_symbol_p (m, p) && !((struct Lisp_Symbol *) p)->gcmarkbit) |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3730 XSETSYMBOL (obj, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3731 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3732 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3733 case MEM_TYPE_FLOAT: |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
3734 if (live_float_p (m, p) && !FLOAT_MARKED_P (p)) |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3735 XSETFLOAT (obj, p); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3736 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3737 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3738 case MEM_TYPE_VECTOR: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3739 case MEM_TYPE_PROCESS: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3740 case MEM_TYPE_HASH_TABLE: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3741 case MEM_TYPE_FRAME: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3742 case MEM_TYPE_WINDOW: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3743 if (live_vector_p (m, p)) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3744 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3745 Lisp_Object tem; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3746 XSETVECTOR (tem, p); |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
3747 if (!GC_SUBRP (tem) && !VECTOR_MARKED_P (XVECTOR (tem))) |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3748 obj = tem; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3749 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3750 break; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3751 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3752 default: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3753 abort (); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3754 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3755 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3756 if (!GC_NILP (obj)) |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
3757 mark_object (obj); |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3758 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3759 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3760 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3761 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3762 /* 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
|
3763 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3764 static void |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3765 mark_memory (start, end) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3766 void *start, *end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3767 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3768 Lisp_Object *p; |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3769 void **pp; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3770 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3771 #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
|
3772 nzombies = 0; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3773 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3774 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3775 /* 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
|
3776 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
|
3777 if (end < start) |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3778 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3779 void *tem = start; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3780 start = end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3781 end = tem; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3782 } |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3783 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3784 /* Mark Lisp_Objects. */ |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3785 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
|
3786 mark_maybe_object (*p); |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3787 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3788 /* 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
|
3789 situations, the C compiler optimizes Lisp objects away, so that |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3790 only a pointer to them remains. Example: |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3791 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3792 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
|
3793 () |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3794 { |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3795 Lisp_Object obj = build_string ("test"); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3796 struct Lisp_String *s = XSTRING (obj); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3797 Fgarbage_collect (); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3798 fprintf (stderr, "test `%s'\n", s->data); |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3799 return Qnil; |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3800 } |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3801 |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3802 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
|
3803 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
|
3804 pointer `s'. */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3805 |
36435
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3806 for (pp = (void **) start; (void *) pp < end; ++pp) |
5a989d353a68
(toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents:
35762
diff
changeset
|
3807 mark_maybe_pointer (*pp); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3808 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3809 |
48316 | 3810 /* setjmp will work with GCC unless NON_SAVING_SETJMP is defined in |
3811 the GCC system configuration. In gcc 3.2, the only systems for | |
3812 which this is so are i386-sco5 non-ELF, i386-sysv3 (maybe included | |
3813 by others?) and ns32k-pc532-min. */ | |
28365
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 #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
|
3816 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3817 static int setjmp_tested_p, longjmps_done; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3818 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3819 #define SETJMP_WILL_LIKELY_WORK "\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3820 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3821 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
|
3822 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
|
3823 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
|
3824 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3825 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
|
3826 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
|
3827 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
|
3828 \n\ |
43200
4082674ce69b
(SETJMP_WILL_LIKELY_WORK, SETJMP_WILL_NOT_WORK):
Kim F. Storm <storm@cua.dk>
parents:
43161
diff
changeset
|
3829 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
|
3830 " |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3831 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3832 #define SETJMP_WILL_NOT_WORK "\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3833 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3834 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
|
3835 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
|
3836 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
|
3837 solution for your system.\n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3838 \n\ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3839 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
|
3840 try to find a way to make it work on your system.\n\ |
48316 | 3841 \n\ |
3842 Note that you may get false negatives, depending on the compiler.\n\ | |
3843 In particular, you need to use -O with GCC for this test.\n\ | |
3844 \n\ | |
43200
4082674ce69b
(SETJMP_WILL_LIKELY_WORK, SETJMP_WILL_NOT_WORK):
Kim F. Storm <storm@cua.dk>
parents:
43161
diff
changeset
|
3845 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
|
3846 " |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3847 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3848 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3849 /* 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
|
3850 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
|
3851 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
|
3852 conservative stack marking. Only the sources or a disassembly |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3853 can prove that. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3854 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3855 static void |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3856 test_setjmp () |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3857 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3858 char buf[10]; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3859 register int x; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3860 jmp_buf jbuf; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3861 int result = 0; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3862 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3863 /* Arrange for X to be put in a register. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3864 sprintf (buf, "1"); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3865 x = strlen (buf); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3866 x = 2 * x - 1; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3867 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3868 setjmp (jbuf); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3869 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
|
3870 { |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3871 /* 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
|
3872 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3873 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
|
3874 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
|
3875 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
|
3876 isn't sure. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3877 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3878 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
|
3879 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
|
3880 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3881 if (x == 1) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3882 fprintf (stderr, SETJMP_WILL_LIKELY_WORK); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3883 else |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3884 { |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3885 fprintf (stderr, SETJMP_WILL_NOT_WORK); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3886 exit (1); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3887 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3888 } |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3889 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3890 ++longjmps_done; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3891 x = 2; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3892 if (longjmps_done == 1) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3893 longjmp (jbuf, 1); |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3894 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3895 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3896 #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
|
3897 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3898 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3899 #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
|
3900 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3901 /* 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
|
3902 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3903 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3904 check_gcpros () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3905 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3906 struct gcpro *p; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3907 int i; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3908 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3909 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
|
3910 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
|
3911 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
|
3912 /* 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
|
3913 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
|
3914 abort (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3915 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3916 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3917 #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
|
3918 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3919 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3920 dump_zombies () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3921 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3922 int i; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3923 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3924 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
|
3925 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
|
3926 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3927 fprintf (stderr, " %d = ", i); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3928 debug_print (zombies[i]); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3929 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3930 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3931 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3932 #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
|
3933 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3934 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3935 /* Mark live Lisp objects on the C stack. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3936 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3937 There are several system-dependent problems to consider when |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3938 porting this to new architectures: |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3939 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3940 Processor Registers |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3941 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3942 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
|
3943 variables or are used to pass parameters. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3944 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3945 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
|
3946 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
|
3947 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
|
3948 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3949 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
|
3950 implementation assumes that calling setjmp saves registers we need |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3951 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
|
3952 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
|
3953 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
|
3954 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3955 Stack Layout |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3956 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3957 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
|
3958 For example, the stack might look like this |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3959 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3960 +----------------+ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3961 | Lisp_Object | size = 4 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3962 +----------------+ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3963 | something else | size = 2 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3964 +----------------+ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3965 | Lisp_Object | size = 4 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3966 +----------------+ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3967 | ... | |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3968 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3969 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
|
3970 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
|
3971 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
|
3972 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
|
3973 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
|
3974 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
|
3975 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
|
3976 from the stack start. |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3977 |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3978 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
|
3979 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
|
3980 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3981 static void |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3982 mark_stack () |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3983 { |
43160
630c8b6deafd
(mark_stack): Don't assume sizeof (Lisp_Object) is 4.
Andreas Schwab <schwab@suse.de>
parents:
43005
diff
changeset
|
3984 int i; |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3985 jmp_buf j; |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
3986 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
|
3987 void *end; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3988 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3989 /* 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
|
3990 the process is contained in the stack. */ |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
3991 /* Fixme: Code in the Boehm GC suggests flushing (with `flushrs') is |
49414
668c96afa702
(mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents:
49357
diff
changeset
|
3992 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
|
3993 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
|
3994 #ifdef sparc |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3995 asm ("ta 3"); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3996 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
3997 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
3998 /* 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
|
3999 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
|
4000 pass parameters. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4001 #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
|
4002 GC_SAVE_REGISTERS_ON_STACK (end); |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4003 #else /* not GC_SAVE_REGISTERS_ON_STACK */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4004 |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4005 #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
|
4006 setjmp will definitely work, test it |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4007 and print a message with the result |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4008 of the test. */ |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4009 if (!setjmp_tested_p) |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4010 { |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4011 setjmp_tested_p = 1; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4012 test_setjmp (); |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4013 } |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4014 #endif /* GC_SETJMP_WORKS */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4015 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4016 setjmp (j); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4017 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
|
4018 #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
|
4019 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4020 /* 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
|
4021 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
|
4022 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
|
4023 #ifndef GC_LISP_OBJECT_ALIGNMENT |
49414
668c96afa702
(mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents:
49357
diff
changeset
|
4024 #ifdef __GNUC__ |
668c96afa702
(mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents:
49357
diff
changeset
|
4025 #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
|
4026 #else |
43160
630c8b6deafd
(mark_stack): Don't assume sizeof (Lisp_Object) is 4.
Andreas Schwab <schwab@suse.de>
parents:
43005
diff
changeset
|
4027 #define GC_LISP_OBJECT_ALIGNMENT sizeof (Lisp_Object) |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
4028 #endif |
49414
668c96afa702
(mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents:
49357
diff
changeset
|
4029 #endif |
43161
8a549ab185a2
Fix thinko in last change.
Andreas Schwab <schwab@suse.de>
parents:
43160
diff
changeset
|
4030 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
|
4031 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
|
4032 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4033 #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
|
4034 check_gcpros (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4035 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4036 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4037 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4038 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4039 #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
|
4040 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4041 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4042 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4043 /*********************************************************************** |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4044 Pure Storage Management |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4045 ***********************************************************************/ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4046 |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4047 /* 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
|
4048 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
|
4049 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
|
4050 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4051 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
|
4052 the allocated object is recorded in pure_types. */ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4053 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4054 static POINTER_TYPE * |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4055 pure_alloc (size, type) |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4056 size_t size; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4057 int type; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4058 { |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4059 POINTER_TYPE *result; |
49159
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4060 size_t alignment = sizeof (EMACS_INT); |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4061 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4062 /* Give Lisp_Floats an extra alignment. */ |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4063 if (type == Lisp_Float) |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4064 { |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4065 #if defined __GNUC__ && __GNUC__ >= 2 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4066 alignment = __alignof (struct Lisp_Float); |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4067 #else |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4068 alignment = sizeof (struct Lisp_Float); |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4069 #endif |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4070 } |
49159
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4071 |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4072 again: |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
4073 result = ALIGN (purebeg + pure_bytes_used, alignment); |
49159
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4074 pure_bytes_used = ((char *)result - (char *)purebeg) + size; |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4075 |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4076 if (pure_bytes_used <= pure_size) |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4077 return result; |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4078 |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4079 /* Don't allocate a large amount here, |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4080 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
|
4081 might not be usable. */ |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4082 purebeg = (char *) xmalloc (10000); |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4083 pure_size = 10000; |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4084 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
|
4085 pure_bytes_used = 0; |
bc82a79251b5
(pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents:
49158
diff
changeset
|
4086 goto again; |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4087 } |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4088 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4089 |
44149
a3e6cfa20afd
(check_pure_size): Update the comment.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44100
diff
changeset
|
4090 /* 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
|
4091 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4092 void |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4093 check_pure_size () |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4094 { |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4095 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
|
4096 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
|
4097 (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
|
4098 } |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4099 |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4100 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4101 /* 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
|
4102 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
|
4103 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
|
4104 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4105 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
|
4106 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
|
4107 string; then the string is not protected from gc. */ |
300 | 4108 |
4109 Lisp_Object | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4110 make_pure_string (data, nchars, nbytes, multibyte) |
300 | 4111 char *data; |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4112 int nchars, nbytes; |
21258
693573ac0944
(make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
4113 int multibyte; |
300 | 4114 { |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4115 Lisp_Object string; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4116 struct Lisp_String *s; |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4117 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4118 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
|
4119 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
|
4120 s->size = nchars; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4121 s->size_byte = multibyte ? nbytes : -1; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4122 bcopy (data, s->data, nbytes); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4123 s->data[nbytes] = '\0'; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4124 s->intervals = NULL_INTERVAL; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4125 XSETSTRING (string, s); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4126 return string; |
300 | 4127 } |
4128 | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4129 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4130 /* 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
|
4131 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
|
4132 |
300 | 4133 Lisp_Object |
4134 pure_cons (car, cdr) | |
4135 Lisp_Object car, cdr; | |
4136 { | |
4137 register Lisp_Object new; | |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4138 struct Lisp_Cons *p; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4139 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4140 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
|
4141 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
|
4142 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
|
4143 XSETCDR (new, Fpurecopy (cdr)); |
300 | 4144 return new; |
4145 } | |
4146 | |
4147 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4148 /* 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
|
4149 |
300 | 4150 Lisp_Object |
4151 make_pure_float (num) | |
4152 double num; | |
4153 { | |
4154 register Lisp_Object new; | |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4155 struct Lisp_Float *p; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4156 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4157 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
|
4158 XSETFLOAT (new, p); |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4159 XFLOAT_DATA (new) = num; |
300 | 4160 return new; |
4161 } | |
4162 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4163 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4164 /* 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
|
4165 pure space. */ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4166 |
300 | 4167 Lisp_Object |
4168 make_pure_vector (len) | |
8817
48ff00bebef6
(pure, pure_size): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
4169 EMACS_INT len; |
300 | 4170 { |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4171 Lisp_Object new; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4172 struct Lisp_Vector *p; |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4173 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
|
4174 |
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4175 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
|
4176 XSETVECTOR (new, p); |
300 | 4177 XVECTOR (new)->size = len; |
4178 return new; | |
4179 } | |
4180 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4181 |
300 | 4182 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
|
4183 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
|
4184 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
|
4185 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
|
4186 (obj) |
300 | 4187 register Lisp_Object obj; |
4188 { | |
485 | 4189 if (NILP (Vpurify_flag)) |
300 | 4190 return obj; |
4191 | |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4192 if (PURE_POINTER_P (XPNTR (obj))) |
300 | 4193 return obj; |
4194 | |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4195 if (CONSP (obj)) |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4196 return pure_cons (XCAR (obj), XCDR (obj)); |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4197 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
|
4198 return make_pure_float (XFLOAT_DATA (obj)); |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4199 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
|
4200 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
|
4201 SBYTES (obj), |
21258
693573ac0944
(make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
4202 STRING_MULTIBYTE (obj)); |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4203 else if (COMPILEDP (obj) || VECTORP (obj)) |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4204 { |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4205 register struct Lisp_Vector *vec; |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4206 register int i, size; |
300 | 4207 |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4208 size = XVECTOR (obj)->size; |
10427
5faba1b094d5
(Fpurecopy): Mask size field when copying pseudovector.
Karl Heuer <kwzh@gnu.org>
parents:
10414
diff
changeset
|
4209 if (size & PSEUDOVECTOR_FLAG) |
5faba1b094d5
(Fpurecopy): Mask size field when copying pseudovector.
Karl Heuer <kwzh@gnu.org>
parents:
10414
diff
changeset
|
4210 size &= PSEUDOVECTOR_SIZE_MASK; |
16100
ccd19852de65
(Fpurecopy): Cast arg to make_pure_vector.
Richard M. Stallman <rms@gnu.org>
parents:
16051
diff
changeset
|
4211 vec = XVECTOR (make_pure_vector ((EMACS_INT) size)); |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4212 for (i = 0; i < size; i++) |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4213 vec->contents[i] = Fpurecopy (XVECTOR (obj)->contents[i]); |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4214 if (COMPILEDP (obj)) |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4215 XSETCOMPILED (obj, vec); |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4216 else |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4217 XSETVECTOR (obj, vec); |
300 | 4218 return obj; |
4219 } | |
10004
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4220 else if (MARKERP (obj)) |
2c57cb7eba5f
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9968
diff
changeset
|
4221 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
|
4222 |
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31576
diff
changeset
|
4223 return obj; |
300 | 4224 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4225 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4226 |
300 | 4227 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4228 /*********************************************************************** |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4229 Protection from GC |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4230 ***********************************************************************/ |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4231 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4232 /* 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
|
4233 VARADDRESS. */ |
300 | 4234 |
4235 void | |
4236 staticpro (varaddress) | |
4237 Lisp_Object *varaddress; | |
4238 { | |
4239 staticvec[staticidx++] = varaddress; | |
4240 if (staticidx >= NSTATICS) | |
4241 abort (); | |
4242 } | |
4243 | |
4244 struct catchtag | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4245 { |
300 | 4246 Lisp_Object tag; |
4247 Lisp_Object val; | |
4248 struct catchtag *next; | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4249 }; |
300 | 4250 |
4251 struct backtrace | |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4252 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4253 struct backtrace *next; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4254 Lisp_Object *function; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4255 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
|
4256 int nargs; /* Length of vector. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4257 /* 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
|
4258 unevalled args. */ |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4259 char evalargs; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4260 }; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4261 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4262 |
300 | 4263 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4264 /*********************************************************************** |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4265 Protection from GC |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4266 ***********************************************************************/ |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
4267 |
11374
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4268 /* Temporarily prevent garbage collection. */ |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4269 |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4270 int |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4271 inhibit_garbage_collection () |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4272 { |
46293
1fb8f75062c6
Use macro SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents:
46285
diff
changeset
|
4273 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
|
4274 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
|
4275 |
a555c6419185
(inhibit_garbage_collection): Don't exceed value an int can hold.
Andreas Schwab <schwab@suse.de>
parents:
41831
diff
changeset
|
4276 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
|
4277 return count; |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4278 } |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
4279 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4280 |
300 | 4281 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
|
4282 doc: /* Reclaim storage for Lisp objects no longer needed. |
51788
43d663a05e2d
(Fgarbage_collect): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
51779
diff
changeset
|
4283 Garbage collection happens automatically if you cons more than |
43d663a05e2d
(Fgarbage_collect): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
51779
diff
changeset
|
4284 `gc-cons-threshold' bytes of Lisp data since previous garbage collection. |
43d663a05e2d
(Fgarbage_collect): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
51779
diff
changeset
|
4285 `garbage-collect' normally returns a list with info on amount of space in use: |
39914
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
4286 ((USED-CONSES . FREE-CONSES) (USED-SYMS . FREE-SYMS) |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
4287 (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
|
4288 (USED-FLOATS . FREE-FLOATS) (USED-INTERVALS . FREE-INTERVALS) |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
4289 (USED-STRINGS . FREE-STRINGS)) |
51788
43d663a05e2d
(Fgarbage_collect): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
51779
diff
changeset
|
4290 However, if there was overflow in pure space, `garbage-collect' |
43d663a05e2d
(Fgarbage_collect): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
51779
diff
changeset
|
4291 returns nil, because real GC can't be done. */) |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
4292 () |
300 | 4293 { |
4294 register struct specbinding *bind; | |
4295 struct catchtag *catch; | |
4296 struct handler *handler; | |
4297 register struct backtrace *backlist; | |
4298 char stack_top_variable; | |
4299 register int i; | |
25343
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
4300 int message_p; |
34270
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
4301 Lisp_Object total[8]; |
46285
3f111801efb4
Rename BINDING_STACK_SIZE to SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents:
45392
diff
changeset
|
4302 int count = SPECPDL_INDEX (); |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4303 EMACS_TIME t1, t2, t3; |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4304 |
50745
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
4305 if (abort_on_gc) |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
4306 abort (); |
fedd03de0f46
(abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50626
diff
changeset
|
4307 |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4308 EMACS_GET_TIME (t1); |
300 | 4309 |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4310 /* 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
|
4311 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
|
4312 if (pure_bytes_used_before_overflow) |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4313 return Qnil; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4314 |
11892
6be0b7a0ac44
(Fgarbage_collect): Clear consing_since_gc first thing.
Karl Heuer <kwzh@gnu.org>
parents:
11727
diff
changeset
|
4315 /* 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
|
4316 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
|
4317 consing_since_gc = 0; |
6be0b7a0ac44
(Fgarbage_collect): Clear consing_since_gc first thing.
Karl Heuer <kwzh@gnu.org>
parents:
11727
diff
changeset
|
4318 |
25343
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
4319 /* 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
|
4320 message_p = push_message (); |
47391
1afd007f814f
(Fgarbage_collect): Use pop_message_unwind.
Richard M. Stallman <rms@gnu.org>
parents:
47185
diff
changeset
|
4321 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
|
4322 |
300 | 4323 /* Save a copy of the contents of the stack, for debugging. */ |
4324 #if MAX_SAVE_STACK > 0 | |
485 | 4325 if (NILP (Vpurify_flag)) |
300 | 4326 { |
4327 i = &stack_top_variable - stack_bottom; | |
4328 if (i < 0) i = -i; | |
4329 if (i < MAX_SAVE_STACK) | |
4330 { | |
4331 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
|
4332 stack_copy = (char *) xmalloc (stack_copy_size = i); |
300 | 4333 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
|
4334 stack_copy = (char *) xrealloc (stack_copy, (stack_copy_size = i)); |
300 | 4335 if (stack_copy) |
4336 { | |
8817
48ff00bebef6
(pure, pure_size): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
4337 if ((EMACS_INT) (&stack_top_variable - stack_bottom) > 0) |
300 | 4338 bcopy (stack_bottom, stack_copy, i); |
4339 else | |
4340 bcopy (&stack_top_variable, stack_copy, i); | |
4341 } | |
4342 } | |
4343 } | |
4344 #endif /* MAX_SAVE_STACK > 0 */ | |
4345 | |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4346 if (garbage_collection_messages) |
10395
c121703d35c7
(Fgarbage_collect): Don't log the GC message.
Karl Heuer <kwzh@gnu.org>
parents:
10389
diff
changeset
|
4347 message1_nolog ("Garbage collecting..."); |
300 | 4348 |
23534
6f9c70db3a58
(Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents:
22382
diff
changeset
|
4349 BLOCK_INPUT; |
6f9c70db3a58
(Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents:
22382
diff
changeset
|
4350 |
22220
a0cd311af6e3
(Fgarbage_collect): Call shrink_regexp_cache.
Richard M. Stallman <rms@gnu.org>
parents:
21948
diff
changeset
|
4351 shrink_regexp_cache (); |
a0cd311af6e3
(Fgarbage_collect): Call shrink_regexp_cache.
Richard M. Stallman <rms@gnu.org>
parents:
21948
diff
changeset
|
4352 |
21680
c744d468bfb6
(Fgarbage_collect): Don't truncate command-history here.
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
4353 /* Don't keep undo information around forever. */ |
300 | 4354 { |
4355 register struct buffer *nextb = all_buffers; | |
4356 | |
4357 while (nextb) | |
4358 { | |
648 | 4359 /* If a buffer's undo list is Qt, that means that undo is |
4360 turned off in that buffer. Calling truncate_undo_list on | |
4361 Qt tends to return NULL, which effectively turns undo back on. | |
4362 So don't call truncate_undo_list if undo_list is Qt. */ | |
4363 if (! EQ (nextb->undo_list, Qt)) | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4364 nextb->undo_list |
764 | 4365 = truncate_undo_list (nextb->undo_list, undo_limit, |
4366 undo_strong_limit); | |
41831
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4367 |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4368 /* 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
|
4369 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
|
4370 { |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4371 /* 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
|
4372 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
|
4373 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
|
4374 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
|
4375 |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4376 if (nextb->text->gap_size > size) |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4377 { |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4378 struct buffer *save_current = current_buffer; |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4379 current_buffer = nextb; |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4380 make_gap (-(nextb->text->gap_size - size)); |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4381 current_buffer = save_current; |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4382 } |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4383 } |
fa7af2e13043
(Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents:
40977
diff
changeset
|
4384 |
300 | 4385 nextb = nextb->next; |
4386 } | |
4387 } | |
4388 | |
4389 gc_in_progress = 1; | |
4390 | |
16231 | 4391 /* clear_marks (); */ |
300 | 4392 |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
4393 /* Mark all the special slots that serve as the roots of accessibility. */ |
300 | 4394 |
4395 for (i = 0; i < staticidx; i++) | |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4396 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
|
4397 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4398 #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
|
4399 || 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
|
4400 mark_stack (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4401 #else |
51228
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
4402 { |
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
4403 register struct gcpro *tail; |
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
4404 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
|
4405 for (i = 0; i < tail->nvars; i++) |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
4406 mark_object (tail->var[i]); |
51228
42d9bef83464
(Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51029
diff
changeset
|
4407 } |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4408 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4409 |
26364
7b0217d9259c
(Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents:
26164
diff
changeset
|
4410 mark_byte_stack (); |
300 | 4411 for (bind = specpdl; bind != specpdl_ptr; bind++) |
4412 { | |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4413 mark_object (bind->symbol); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4414 mark_object (bind->old_value); |
300 | 4415 } |
4416 for (catch = catchlist; catch; catch = catch->next) | |
4417 { | |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4418 mark_object (catch->tag); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4419 mark_object (catch->val); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4420 } |
300 | 4421 for (handler = handlerlist; handler; handler = handler->next) |
4422 { | |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4423 mark_object (handler->handler); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4424 mark_object (handler->var); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4425 } |
300 | 4426 for (backlist = backtrace_list; backlist; backlist = backlist->next) |
4427 { | |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
4428 mark_object (*backlist->function); |
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
4429 |
300 | 4430 if (backlist->nargs == UNEVALLED || backlist->nargs == MANY) |
4431 i = 0; | |
4432 else | |
4433 i = backlist->nargs - 1; | |
4434 for (; i >= 0; i--) | |
52473
a3fd06a8c844
(init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52453
diff
changeset
|
4435 mark_object (backlist->args[i]); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4436 } |
11018
2d9bdf1ba3d1
(mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents:
10936
diff
changeset
|
4437 mark_kboards (); |
300 | 4438 |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4439 /* 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
|
4440 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
|
4441 and delete them. */ |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4442 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4443 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
|
4444 |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4445 while (nextb) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4446 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4447 /* 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
|
4448 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
|
4449 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
|
4450 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
|
4451 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
|
4452 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4453 Lisp_Object tail, prev; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4454 tail = nextb->undo_list; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4455 prev = Qnil; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4456 while (CONSP (tail)) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4457 { |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4458 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
|
4459 && GC_MARKERP (XCAR (XCAR (tail))) |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
4460 && !XMARKER (XCAR (XCAR (tail)))->gcmarkbit) |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4461 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4462 if (NILP (prev)) |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4463 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
|
4464 else |
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
4465 { |
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39914
diff
changeset
|
4466 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
|
4467 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
|
4468 } |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4469 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4470 else |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4471 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4472 prev = tail; |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
4473 tail = XCDR (tail); |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4474 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4475 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4476 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4477 |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4478 nextb = nextb->next; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4479 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4480 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
4481 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4482 #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
|
4483 mark_stack (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4484 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4485 |
49322 | 4486 #ifdef USE_GTK |
4487 { | |
4488 extern void xg_mark_data (); | |
4489 xg_mark_data (); | |
4490 } | |
4491 #endif | |
4492 | |
300 | 4493 gc_sweep (); |
4494 | |
4495 /* Clear the mark bits that we set in certain root slots. */ | |
4496 | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4497 #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
|
4498 || GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES) |
51252
beb851c49c65
(Fgarbage_collect): Fix last change.
Andreas Schwab <schwab@suse.de>
parents:
51228
diff
changeset
|
4499 { |
beb851c49c65
(Fgarbage_collect): Fix last change.
Andreas Schwab <schwab@suse.de>
parents:
51228
diff
changeset
|
4500 register struct gcpro *tail; |
beb851c49c65
(Fgarbage_collect): Fix last change.
Andreas Schwab <schwab@suse.de>
parents:
51228
diff
changeset
|
4501 } |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4502 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4503 |
26378
cbf297593a79
(Fgarbage_collect): Call unmark_byte_stack.
Gerd Moellmann <gerd@gnu.org>
parents:
26372
diff
changeset
|
4504 unmark_byte_stack (); |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4505 VECTOR_UNMARK (&buffer_defaults); |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4506 VECTOR_UNMARK (&buffer_local_symbols); |
300 | 4507 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4508 #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
|
4509 dump_zombies (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4510 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4511 |
23534
6f9c70db3a58
(Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents:
22382
diff
changeset
|
4512 UNBLOCK_INPUT; |
6f9c70db3a58
(Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents:
22382
diff
changeset
|
4513 |
16231 | 4514 /* clear_marks (); */ |
300 | 4515 gc_in_progress = 0; |
4516 | |
4517 consing_since_gc = 0; | |
4518 if (gc_cons_threshold < 10000) | |
4519 gc_cons_threshold = 10000; | |
4520 | |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4521 if (garbage_collection_messages) |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4522 { |
25343
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
4523 if (message_p || minibuf_level > 0) |
fe92158a9e83
(Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents:
25133
diff
changeset
|
4524 restore_message (); |
14959
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4525 else |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4526 message1_nolog ("Garbage collecting...done"); |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
4527 } |
300 | 4528 |
35170
a9b677239421
(Fgarbage_collect): Use a record_unwind_protect to
Gerd Moellmann <gerd@gnu.org>
parents:
34325
diff
changeset
|
4529 unbind_to (count, Qnil); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4530 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4531 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
|
4532 make_number (total_free_conses)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4533 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
|
4534 make_number (total_free_symbols)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4535 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
|
4536 make_number (total_free_markers)); |
34270
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
4537 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
|
4538 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
|
4539 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
|
4540 make_number (total_free_floats)); |
34270
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
4541 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
|
4542 make_number (total_free_intervals)); |
34270
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
4543 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
|
4544 make_number (total_free_strings)); |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4545 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4546 #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
|
4547 { |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4548 /* 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
|
4549 double nlive = 0; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4550 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4551 for (i = 0; i < 7; ++i) |
49357 | 4552 if (CONSP (total[i])) |
4553 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
|
4554 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4555 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
|
4556 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
|
4557 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
|
4558 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
|
4559 ++ngcs; |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4560 } |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4561 #endif |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4562 |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4563 if (!NILP (Vpost_gc_hook)) |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4564 { |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4565 int count = inhibit_garbage_collection (); |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4566 safe_run_hooks (Qpost_gc_hook); |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4567 unbind_to (count, Qnil); |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
4568 } |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4569 |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4570 /* Accumulate statistics. */ |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4571 EMACS_GET_TIME (t2); |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4572 EMACS_SUB_TIME (t3, t2, t1); |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4573 if (FLOATP (Vgc_elapsed)) |
49911
d9ade23e09df
(Fgarbage_collect): Don't use XSETFLOAT.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49600
diff
changeset
|
4574 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
|
4575 EMACS_SECS (t3) + |
d9ade23e09df
(Fgarbage_collect): Don't use XSETFLOAT.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49600
diff
changeset
|
4576 EMACS_USECS (t3) * 1.0e-6); |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4577 gcs_done++; |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
4578 |
34270
773e6aa2ec38
(Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents:
33800
diff
changeset
|
4579 return Flist (sizeof total / sizeof *total, total); |
300 | 4580 } |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4581 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4582 |
25367
823e14641544
(mark_glyph_matrix): Mark strings only.
Gerd Moellmann <gerd@gnu.org>
parents:
25343
diff
changeset
|
4583 /* 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
|
4584 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
|
4585 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4586 static void |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4587 mark_glyph_matrix (matrix) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4588 struct glyph_matrix *matrix; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4589 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4590 struct glyph_row *row = matrix->rows; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4591 struct glyph_row *end = row + matrix->nrows; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4592 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4593 for (; row < end; ++row) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4594 if (row->enabled_p) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4595 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4596 int area; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4597 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
|
4598 { |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4599 struct glyph *glyph = row->glyphs[area]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4600 struct glyph *end_glyph = glyph + row->used[area]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4601 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4602 for (; glyph < end_glyph; ++glyph) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4603 if (GC_STRINGP (glyph->object) |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4604 && !STRING_MARKED_P (XSTRING (glyph->object))) |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4605 mark_object (glyph->object); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4606 } |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4607 } |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4608 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4609 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
4610 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4611 /* 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
|
4612 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4613 static void |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4614 mark_face_cache (c) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4615 struct face_cache *c; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4616 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4617 if (c) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4618 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4619 int i, j; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4620 for (i = 0; i < c->used; ++i) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4621 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4622 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
|
4623 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4624 if (face) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4625 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4626 for (j = 0; j < LFACE_VECTOR_SIZE; ++j) |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4627 mark_object (face->lface[j]); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4628 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4629 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4630 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4631 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4632 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4633 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4634 #ifdef HAVE_WINDOW_SYSTEM |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4635 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4636 /* Mark Lisp objects in image IMG. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4637 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4638 static void |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4639 mark_image (img) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4640 struct image *img; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4641 { |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4642 mark_object (img->spec); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4643 |
31892
2f3d88ac2b38
(__malloc_size_t) [DOUG_LEA_MALLOC]: Don't redefine it.
Dave Love <fx@gnu.org>
parents:
31889
diff
changeset
|
4644 if (!NILP (img->data.lisp_val)) |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4645 mark_object (img->data.lisp_val); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4646 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4647 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4648 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4649 /* 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
|
4650 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
|
4651 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4652 static void |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4653 mark_image_cache (f) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4654 struct frame *f; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4655 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4656 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
|
4657 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4658 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4659 #endif /* HAVE_X_WINDOWS */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4660 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4661 |
300 | 4662 |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
4663 /* 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
|
4664 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
|
4665 all the references contained in it. */ |
300 | 4666 |
1168
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
4667 #define LAST_MARKED_SIZE 500 |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4668 Lisp_Object last_marked[LAST_MARKED_SIZE]; |
1168
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
4669 int last_marked_index; |
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
4670 |
46833
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
4671 /* 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
|
4672 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
|
4673 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
|
4674 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
|
4675 int mark_object_loop_halt; |
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
4676 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4677 void |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4678 mark_object (arg) |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4679 Lisp_Object arg; |
300 | 4680 { |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4681 register Lisp_Object obj = arg; |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4682 #ifdef GC_CHECK_MARKED_OBJECTS |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4683 void *po; |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4684 struct mem_node *m; |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4685 #endif |
46833
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
4686 int cdr_count = 0; |
300 | 4687 |
5868
a7bd57a60cb8
(mark_object): Fetch obj from *objptr at loop, not at the gotos.
Karl Heuer <kwzh@gnu.org>
parents:
5353
diff
changeset
|
4688 loop: |
300 | 4689 |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
4690 if (PURE_POINTER_P (XPNTR (obj))) |
300 | 4691 return; |
4692 | |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4693 last_marked[last_marked_index++] = obj; |
1168
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
4694 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
|
4695 last_marked_index = 0; |
2b07af77d7ec
(mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents:
1114
diff
changeset
|
4696 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4697 /* 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
|
4698 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
|
4699 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
|
4700 #ifdef GC_CHECK_MARKED_OBJECTS |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4701 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4702 po = (void *) XPNTR (obj); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4703 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4704 /* 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
|
4705 structure allocated from the heap. */ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4706 #define CHECK_ALLOCATED() \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4707 do { \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4708 m = mem_find (po); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4709 if (m == MEM_NIL) \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4710 abort (); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4711 } while (0) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4712 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4713 /* 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
|
4714 function LIVEP. */ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4715 #define CHECK_LIVE(LIVEP) \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4716 do { \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4717 if (!LIVEP (m, po)) \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4718 abort (); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4719 } while (0) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4720 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4721 /* 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
|
4722 #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
|
4723 do { \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4724 CHECK_ALLOCATED (); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4725 CHECK_LIVE (LIVEP); \ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4726 } while (0) \ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4727 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4728 #else /* not GC_CHECK_MARKED_OBJECTS */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4729 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4730 #define CHECK_ALLOCATED() (void) 0 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4731 #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
|
4732 #define CHECK_ALLOCATED_AND_LIVE(LIVEP) (void) 0 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4733 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4734 #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
|
4735 |
10457
2ab3bd0288a9
Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents:
10427
diff
changeset
|
4736 switch (SWITCH_ENUM_CAST (XGCTYPE (obj))) |
300 | 4737 { |
4738 case Lisp_String: | |
4739 { | |
4740 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
|
4741 CHECK_ALLOCATED_AND_LIVE (live_string_p); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
4742 MARK_INTERVAL_TREE (ptr->intervals); |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4743 MARK_STRING (ptr); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
4744 #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
|
4745 /* 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
|
4746 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
|
4747 CHECK_STRING_BYTES (ptr); |
32587
b3918817f15f
(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents:
32360
diff
changeset
|
4748 #endif /* GC_CHECK_STRING_BYTES */ |
300 | 4749 } |
4750 break; | |
4751 | |
10009
82f3daf76995
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
10004
diff
changeset
|
4752 case Lisp_Vectorlike: |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4753 #ifdef GC_CHECK_MARKED_OBJECTS |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4754 m = mem_find (po); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4755 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
|
4756 && po != &buffer_defaults |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4757 && po != &buffer_local_symbols) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4758 abort (); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4759 #endif /* GC_CHECK_MARKED_OBJECTS */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4760 |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
4761 if (GC_BUFFERP (obj)) |
10340
ef58c7a5a4d6
(mark_object, mark_buffer): Don't mark buffer twice.
Karl Heuer <kwzh@gnu.org>
parents:
10320
diff
changeset
|
4762 { |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4763 if (!VECTOR_MARKED_P (XBUFFER (obj))) |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4764 { |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4765 #ifdef GC_CHECK_MARKED_OBJECTS |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4766 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
|
4767 { |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4768 struct buffer *b; |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4769 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
|
4770 ; |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4771 if (b == NULL) |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4772 abort (); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4773 } |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4774 #endif /* GC_CHECK_MARKED_OBJECTS */ |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4775 mark_buffer (obj); |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4776 } |
10340
ef58c7a5a4d6
(mark_object, mark_buffer): Don't mark buffer twice.
Karl Heuer <kwzh@gnu.org>
parents:
10320
diff
changeset
|
4777 } |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
4778 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
|
4779 break; |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4780 else if (GC_COMPILEDP (obj)) |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
4781 /* 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
|
4782 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
|
4783 recursion there. */ |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4784 { |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4785 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
|
4786 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
|
4787 register int i; |
300 | 4788 |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4789 if (VECTOR_MARKED_P (ptr)) |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4790 break; /* Already marked */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4791 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4792 CHECK_LIVE (live_vector_p); |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4793 VECTOR_MARK (ptr); /* Else mark it */ |
10009
82f3daf76995
(Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
10004
diff
changeset
|
4794 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
|
4795 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
|
4796 { |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4797 if (i != COMPILED_CONSTANTS) |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4798 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
|
4799 } |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4800 obj = ptr->contents[COMPILED_CONSTANTS]; |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4801 goto loop; |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4802 } |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4803 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
|
4804 { |
32360
d8b668a486d7
(mark_object): Remove all workarounds installed on
Andreas Schwab <schwab@suse.de>
parents:
32099
diff
changeset
|
4805 register struct frame *ptr = XFRAME (obj); |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4806 |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4807 if (VECTOR_MARKED_P (ptr)) break; /* Already marked */ |
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4808 VECTOR_MARK (ptr); /* Else mark it */ |
1295
a9241dc503ab
(mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents:
1168
diff
changeset
|
4809 |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4810 CHECK_LIVE (live_vector_p); |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4811 mark_object (ptr->name); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4812 mark_object (ptr->icon_name); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4813 mark_object (ptr->title); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4814 mark_object (ptr->focus_frame); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4815 mark_object (ptr->selected_window); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4816 mark_object (ptr->minibuffer_window); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4817 mark_object (ptr->param_alist); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4818 mark_object (ptr->scroll_bars); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4819 mark_object (ptr->condemned_scroll_bars); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4820 mark_object (ptr->menu_bar_items); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4821 mark_object (ptr->face_alist); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4822 mark_object (ptr->menu_bar_vector); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4823 mark_object (ptr->buffer_predicate); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4824 mark_object (ptr->buffer_list); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4825 mark_object (ptr->menu_bar_window); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4826 mark_object (ptr->tool_bar_window); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4827 mark_face_cache (ptr->face_cache); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4828 #ifdef HAVE_WINDOW_SYSTEM |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4829 mark_image_cache (ptr); |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4830 mark_object (ptr->tool_bar_items); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4831 mark_object (ptr->desired_tool_bar_string); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4832 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
|
4833 #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
|
4834 } |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
4835 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
|
4836 { |
5cd52d4838f8
(mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents:
14959
diff
changeset
|
4837 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
|
4838 |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4839 if (VECTOR_MARKED_P (ptr)) |
15379
5cd52d4838f8
(mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents:
14959
diff
changeset
|
4840 break; /* Already marked */ |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4841 CHECK_LIVE (live_vector_p); |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4842 VECTOR_MARK (ptr); /* Else mark it */ |
15379
5cd52d4838f8
(mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents:
14959
diff
changeset
|
4843 } |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4844 else if (GC_WINDOWP (obj)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4845 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4846 register struct Lisp_Vector *ptr = XVECTOR (obj); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4847 struct window *w = XWINDOW (obj); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4848 register int i; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4849 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4850 /* Stop if already marked. */ |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4851 if (VECTOR_MARKED_P (ptr)) |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4852 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4853 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4854 /* Mark it. */ |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4855 CHECK_LIVE (live_vector_p); |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4856 VECTOR_MARK (ptr); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4857 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4858 /* 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
|
4859 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
|
4860 for (i = 0; |
32360
d8b668a486d7
(mark_object): Remove all workarounds installed on
Andreas Schwab <schwab@suse.de>
parents:
32099
diff
changeset
|
4861 (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
|
4862 i++) |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4863 mark_object (ptr->contents[i]); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4864 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4865 /* 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
|
4866 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
|
4867 memory. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4868 if (NILP (w->hchild) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4869 && NILP (w->vchild) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4870 && w->current_matrix) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4871 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4872 mark_glyph_matrix (w->current_matrix); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4873 mark_glyph_matrix (w->desired_matrix); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4874 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4875 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4876 else if (GC_HASH_TABLE_P (obj)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4877 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4878 struct Lisp_Hash_Table *h = XHASH_TABLE (obj); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4879 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4880 /* Stop if already marked. */ |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4881 if (VECTOR_MARKED_P (h)) |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4882 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4883 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4884 /* Mark it. */ |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4885 CHECK_LIVE (live_vector_p); |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4886 VECTOR_MARK (h); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4887 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4888 /* Mark contents. */ |
43005 | 4889 /* Do not mark next_free or next_weak. |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4890 Being in the next_weak chain |
43005 | 4891 should not keep the hash table alive. |
4892 No need to mark `count' since it is an integer. */ | |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4893 mark_object (h->test); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4894 mark_object (h->weak); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4895 mark_object (h->rehash_size); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4896 mark_object (h->rehash_threshold); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4897 mark_object (h->hash); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4898 mark_object (h->next); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4899 mark_object (h->index); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4900 mark_object (h->user_hash_function); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4901 mark_object (h->user_cmp_function); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4902 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4903 /* 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
|
4904 For weak tables, mark only the vector. */ |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4905 if (GC_NILP (h->weak)) |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4906 mark_object (h->key_and_value); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4907 else |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4908 VECTOR_MARK (XVECTOR (h->key_and_value)); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4909 } |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4910 else |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4911 { |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4912 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
|
4913 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
|
4914 register int i; |
300 | 4915 |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4916 if (VECTOR_MARKED_P (ptr)) break; /* Already marked */ |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4917 CHECK_LIVE (live_vector_p); |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
4918 VECTOR_MARK (ptr); /* Else mark it */ |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4919 if (size & PSEUDOVECTOR_FLAG) |
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4920 size &= PSEUDOVECTOR_SIZE_MASK; |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
4921 |
10291
96273a6ec492
(mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents:
10206
diff
changeset
|
4922 for (i = 0; i < size; i++) /* and then mark its elements */ |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4923 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
|
4924 } |
300 | 4925 break; |
4926 | |
4927 case Lisp_Symbol: | |
4928 { | |
32360
d8b668a486d7
(mark_object): Remove all workarounds installed on
Andreas Schwab <schwab@suse.de>
parents:
32099
diff
changeset
|
4929 register struct Lisp_Symbol *ptr = XSYMBOL (obj); |
300 | 4930 struct Lisp_Symbol *ptrx; |
4931 | |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
4932 if (ptr->gcmarkbit) break; |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4933 CHECK_ALLOCATED_AND_LIVE (live_symbol_p); |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
4934 ptr->gcmarkbit = 1; |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4935 mark_object (ptr->value); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4936 mark_object (ptr->function); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4937 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
|
4938 |
45392
f3d7ab65641f
* alloc.c (Fmake_symbol): Set symbol xname field instead of name.
Ken Raeburn <raeburn@raeburn.org>
parents:
44890
diff
changeset
|
4939 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
|
4940 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
|
4941 MARK_INTERVAL_TREE (STRING_INTERVALS (ptr->xname)); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
4942 |
20768 | 4943 /* Note that we do not mark the obarray of the symbol. |
4944 It is safe not to do so because nothing accesses that | |
4945 slot except to check whether it is nil. */ | |
300 | 4946 ptr = ptr->next; |
4947 if (ptr) | |
4948 { | |
2507
7ba4316ae840
* alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
4949 ptrx = ptr; /* Use of ptrx avoids compiler bug on Sun */ |
300 | 4950 XSETSYMBOL (obj, ptrx); |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4951 goto loop; |
300 | 4952 } |
4953 } | |
4954 break; | |
4955 | |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
4956 case Lisp_Misc: |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
4957 CHECK_ALLOCATED_AND_LIVE (live_misc_p); |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
4958 if (XMARKER (obj)->gcmarkbit) |
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
4959 break; |
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
4960 XMARKER (obj)->gcmarkbit = 1; |
11243
054ecfce1820
(Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents:
11048
diff
changeset
|
4961 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
|
4962 { |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4963 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
|
4964 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
|
4965 { |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4966 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
|
4967 = XBUFFER_LOCAL_VALUE (obj); |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4968 /* 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
|
4969 if (EQ (ptr->cdr, Qnil)) |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4970 { |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4971 obj = ptr->realvalue; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4972 goto loop; |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4973 } |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4974 mark_object (ptr->realvalue); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4975 mark_object (ptr->buffer); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4976 mark_object (ptr->frame); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
4977 obj = ptr->cdr; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4978 goto loop; |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4979 } |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
4980 |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
4981 case Lisp_Misc_Marker: |
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
4982 /* DO NOT mark thru the marker's chain. |
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
4983 The buffer's markers chain does not preserve markers from gc; |
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
4984 instead, markers are removed from the chain when freed by gc. */ |
9463
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4985 case Lisp_Misc_Intfwd: |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4986 case Lisp_Misc_Boolfwd: |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4987 case Lisp_Misc_Objfwd: |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4988 case Lisp_Misc_Buffer_Objfwd: |
11018
2d9bdf1ba3d1
(mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents:
10936
diff
changeset
|
4989 case Lisp_Misc_Kboard_Objfwd: |
9463
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4990 /* Don't bother with Lisp_Buffer_Objfwd, |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4991 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
|
4992 /* 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
|
4993 are protected with staticpro. */ |
52166
25f780eb3fd8
(mark_object): Handle Lisp_Misc_Save_Value.
Andreas Schwab <schwab@suse.de>
parents:
51985
diff
changeset
|
4994 case Lisp_Misc_Save_Value: |
9463
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4995 break; |
a40af805e036
(mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9437
diff
changeset
|
4996 |
9926
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4997 case Lisp_Misc_Overlay: |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4998 { |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
4999 struct Lisp_Overlay *ptr = XOVERLAY (obj); |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5000 mark_object (ptr->start); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5001 mark_object (ptr->end); |
51843
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5002 mark_object (ptr->plist); |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5003 if (ptr->next) |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5004 { |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5005 XSETMISC (obj, ptr->next); |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5006 goto loop; |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5007 } |
9926
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
5008 } |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
5009 break; |
2a9f99682f82
(mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9893
diff
changeset
|
5010 |
9437
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
5011 default: |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
5012 abort (); |
c7d7fb56b42d
(MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents:
9367
diff
changeset
|
5013 } |
300 | 5014 break; |
5015 | |
5016 case Lisp_Cons: | |
5017 { | |
5018 register struct Lisp_Cons *ptr = XCONS (obj); | |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5019 if (CONS_MARKED_P (ptr)) break; |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5020 CHECK_ALLOCATED_AND_LIVE (live_cons_p); |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5021 CONS_MARK (ptr); |
1295
a9241dc503ab
(mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents:
1168
diff
changeset
|
5022 /* 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
|
5023 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
|
5024 { |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5025 obj = ptr->car; |
46833
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5026 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
|
5027 goto loop; |
a9241dc503ab
(mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents:
1168
diff
changeset
|
5028 } |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5029 mark_object (ptr->car); |
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5030 obj = ptr->cdr; |
46833
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5031 cdr_count++; |
b80760a75295
(mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents:
46459
diff
changeset
|
5032 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
|
5033 abort (); |
300 | 5034 goto loop; |
5035 } | |
5036 | |
5037 case Lisp_Float: | |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5038 CHECK_ALLOCATED_AND_LIVE (live_float_p); |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
5039 FLOAT_MARK (XFLOAT (obj)); |
300 | 5040 break; |
5041 | |
5042 case Lisp_Int: | |
5043 break; | |
5044 | |
5045 default: | |
5046 abort (); | |
5047 } | |
29743
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5048 |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5049 #undef CHECK_LIVE |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5050 #undef CHECK_ALLOCATED |
1d802b332e0d
(mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents:
28997
diff
changeset
|
5051 #undef CHECK_ALLOCATED_AND_LIVE |
300 | 5052 } |
5053 | |
5054 /* Mark the pointers in a buffer structure. */ | |
5055 | |
5056 static void | |
5057 mark_buffer (buf) | |
5058 Lisp_Object buf; | |
5059 { | |
5060 register struct buffer *buffer = XBUFFER (buf); | |
51843
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5061 register Lisp_Object *ptr, tmp; |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5062 Lisp_Object base_buffer; |
300 | 5063 |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5064 VECTOR_MARK (buffer); |
300 | 5065 |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5066 MARK_INTERVAL_TREE (BUF_INTERVALS (buffer)); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5067 |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5068 if (CONSP (buffer->undo_list)) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5069 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5070 Lisp_Object tail; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5071 tail = buffer->undo_list; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5072 |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5073 /* We mark the undo list specially because |
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5074 its pointers to markers should be weak. */ |
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5075 |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5076 while (CONSP (tail)) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5077 { |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5078 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
|
5079 |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5080 if (CONS_MARKED_P (ptr)) |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5081 break; |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5082 CONS_MARK (ptr); |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5083 if (GC_CONSP (ptr->car) |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5084 && !CONS_MARKED_P (XCONS (ptr->car)) |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25544
diff
changeset
|
5085 && 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
|
5086 { |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5087 CONS_MARK (XCONS (ptr->car)); |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5088 mark_object (XCDR (ptr->car)); |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5089 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5090 else |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5091 mark_object (ptr->car); |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5092 |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5093 if (CONSP (ptr->cdr)) |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5094 tail = ptr->cdr; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5095 else |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5096 break; |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5097 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5098 |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5099 mark_object (XCDR (tail)); |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5100 } |
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5101 else |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5102 mark_object (buffer->undo_list); |
21306
dc2cbd40703c
(mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents:
21258
diff
changeset
|
5103 |
51843
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5104 if (buffer->overlays_before) |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5105 { |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5106 XSETMISC (tmp, buffer->overlays_before); |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5107 mark_object (tmp); |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5108 } |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5109 if (buffer->overlays_after) |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5110 { |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5111 XSETMISC (tmp, buffer->overlays_after); |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5112 mark_object (tmp); |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5113 } |
65772ad7d4e1
(mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51788
diff
changeset
|
5114 |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5115 for (ptr = &buffer->name; |
300 | 5116 (char *)ptr < (char *)buffer + sizeof (struct buffer); |
5117 ptr++) | |
51770
ad47aa3ee2d7
(mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51758
diff
changeset
|
5118 mark_object (*ptr); |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5119 |
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5120 /* If this is an indirect buffer, mark its base buffer. */ |
51686
17c015f1f795
(mark_buffer): Fix missed buffer->name in last patch.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51683
diff
changeset
|
5121 if (buffer->base_buffer && !VECTOR_MARKED_P (buffer->base_buffer)) |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5122 { |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5123 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
|
5124 mark_buffer (base_buffer); |
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5125 } |
300 | 5126 } |
10649
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
5127 |
52cdd8cc8d3e
(mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents:
10581
diff
changeset
|
5128 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5129 /* 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
|
5130 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
|
5131 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5132 int |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5133 survives_gc_p (obj) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5134 Lisp_Object obj; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5135 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5136 int survives_p; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5137 |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5138 switch (XGCTYPE (obj)) |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5139 { |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5140 case Lisp_Int: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5141 survives_p = 1; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5142 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5143 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5144 case Lisp_Symbol: |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5145 survives_p = XSYMBOL (obj)->gcmarkbit; |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5146 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5147 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5148 case Lisp_Misc: |
51668
0f333fd92a1d
(survives_gc_p): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51658
diff
changeset
|
5149 survives_p = XMARKER (obj)->gcmarkbit; |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5150 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5151 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5152 case Lisp_String: |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5153 survives_p = STRING_MARKED_P (XSTRING (obj)); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5154 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5155 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5156 case Lisp_Vectorlike: |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5157 survives_p = GC_SUBRP (obj) || VECTOR_MARKED_P (XVECTOR (obj)); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5158 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5159 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5160 case Lisp_Cons: |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5161 survives_p = CONS_MARKED_P (XCONS (obj)); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5162 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5163 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5164 case Lisp_Float: |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
5165 survives_p = FLOAT_MARKED_P (XFLOAT (obj)); |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5166 break; |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5167 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5168 default: |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5169 abort (); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5170 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5171 |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5172 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
|
5173 } |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5174 |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5175 |
300 | 5176 |
1908
d649f2179d67
* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents:
1893
diff
changeset
|
5177 /* Sweep: find all structures not marked, and free them. */ |
300 | 5178 |
5179 static void | |
5180 gc_sweep () | |
5181 { | |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5182 /* 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
|
5183 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
|
5184 sweep_weak_hash_tables (); |
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5185 |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5186 sweep_strings (); |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5187 #ifdef GC_CHECK_STRING_BYTES |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5188 if (!noninteractive) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5189 check_string_bytes (1); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5190 #endif |
300 | 5191 |
5192 /* Put all unmarked conses on free list */ | |
5193 { | |
5194 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
|
5195 struct cons_block **cprev = &cons_block; |
300 | 5196 register int lim = cons_block_index; |
5197 register int num_free = 0, num_used = 0; | |
5198 | |
5199 cons_free_list = 0; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5200 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5201 for (cblk = cons_block; cblk; cblk = *cprev) |
300 | 5202 { |
5203 register int i; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5204 int this_free = 0; |
300 | 5205 for (i = 0; i < lim; i++) |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5206 if (!CONS_MARKED_P (&cblk->conses[i])) |
300 | 5207 { |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5208 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
|
5209 *(struct Lisp_Cons **)&cblk->conses[i].cdr = cons_free_list; |
300 | 5210 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
|
5211 #if GC_MARK_STACK |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5212 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
|
5213 #endif |
300 | 5214 } |
5215 else | |
5216 { | |
5217 num_used++; | |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5218 CONS_UNMARK (&cblk->conses[i]); |
300 | 5219 } |
5220 lim = CONS_BLOCK_SIZE; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5221 /* 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
|
5222 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
|
5223 this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5224 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
|
5225 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5226 *cprev = cblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5227 /* Unhook from the free list. */ |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5228 cons_free_list = *(struct Lisp_Cons **) &cblk->conses[0].cdr; |
51938
20d4eb1de9b0
Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51908
diff
changeset
|
5229 lisp_align_free (cblk); |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5230 n_cons_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5231 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5232 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5233 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5234 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5235 cprev = &cblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5236 } |
300 | 5237 } |
5238 total_conses = num_used; | |
5239 total_free_conses = num_free; | |
5240 } | |
5241 | |
5242 /* Put all unmarked floats on free list */ | |
5243 { | |
5244 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
|
5245 struct float_block **fprev = &float_block; |
300 | 5246 register int lim = float_block_index; |
5247 register int num_free = 0, num_used = 0; | |
5248 | |
5249 float_free_list = 0; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5250 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5251 for (fblk = float_block; fblk; fblk = *fprev) |
300 | 5252 { |
5253 register int i; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5254 int this_free = 0; |
300 | 5255 for (i = 0; i < lim; i++) |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
5256 if (!FLOAT_MARKED_P (&fblk->floats[i])) |
300 | 5257 { |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5258 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
|
5259 *(struct Lisp_Float **)&fblk->floats[i].data = float_free_list; |
300 | 5260 float_free_list = &fblk->floats[i]; |
5261 } | |
5262 else | |
5263 { | |
5264 num_used++; | |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
5265 FLOAT_UNMARK (&fblk->floats[i]); |
300 | 5266 } |
5267 lim = FLOAT_BLOCK_SIZE; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5268 /* 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
|
5269 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
|
5270 this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5271 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
|
5272 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5273 *fprev = fblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5274 /* Unhook from the free list. */ |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5275 float_free_list = *(struct Lisp_Float **) &fblk->floats[0].data; |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
5276 lisp_align_free (fblk); |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5277 n_float_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5278 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5279 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5280 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5281 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5282 fprev = &fblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5283 } |
300 | 5284 } |
5285 total_floats = num_used; | |
5286 total_free_floats = num_free; | |
5287 } | |
5288 | |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5289 /* Put all unmarked intervals on free list */ |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5290 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5291 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
|
5292 struct interval_block **iprev = &interval_block; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5293 register int lim = interval_block_index; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5294 register int num_free = 0, num_used = 0; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5295 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5296 interval_free_list = 0; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5297 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5298 for (iblk = interval_block; iblk; iblk = *iprev) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5299 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5300 register int i; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5301 int this_free = 0; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5302 |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5303 for (i = 0; i < lim; i++) |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5304 { |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5305 if (!iblk->intervals[i].gcmarkbit) |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5306 { |
28269
fd13be8ae190
Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents:
28220
diff
changeset
|
5307 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
|
5308 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
|
5309 this_free++; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5310 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5311 else |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5312 { |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5313 num_used++; |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5314 iblk->intervals[i].gcmarkbit = 0; |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5315 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5316 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5317 lim = INTERVAL_BLOCK_SIZE; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5318 /* 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
|
5319 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
|
5320 deallocate this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5321 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
|
5322 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5323 *iprev = iblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5324 /* Unhook from the free list. */ |
28269
fd13be8ae190
Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents:
28220
diff
changeset
|
5325 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
|
5326 lisp_free (iblk); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5327 n_interval_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5328 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5329 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5330 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5331 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5332 iprev = &iblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5333 } |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5334 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5335 total_intervals = num_used; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5336 total_free_intervals = num_free; |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5337 } |
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5338 |
300 | 5339 /* Put all unmarked symbols on free list */ |
5340 { | |
5341 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
|
5342 struct symbol_block **sprev = &symbol_block; |
300 | 5343 register int lim = symbol_block_index; |
5344 register int num_free = 0, num_used = 0; | |
5345 | |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5346 symbol_free_list = NULL; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5347 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5348 for (sblk = symbol_block; sblk; sblk = *sprev) |
300 | 5349 { |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5350 int this_free = 0; |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5351 struct Lisp_Symbol *sym = sblk->symbols; |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5352 struct Lisp_Symbol *end = sym + lim; |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5353 |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5354 for (; sym < end; ++sym) |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5355 { |
34325
a65d8c29442a
(gc_sweep): Add comment.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34308
diff
changeset
|
5356 /* 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
|
5357 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
|
5358 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
|
5359 int pure_p = PURE_POINTER_P (XSTRING (sym->xname)); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5360 |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5361 if (!sym->gcmarkbit && !pure_p) |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5362 { |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5363 *(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
|
5364 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
|
5365 #if GC_MARK_STACK |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5366 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
|
5367 #endif |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5368 ++this_free; |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5369 } |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5370 else |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5371 { |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5372 ++num_used; |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5373 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
|
5374 UNMARK_STRING (XSTRING (sym->xname)); |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5375 sym->gcmarkbit = 0; |
34308
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5376 } |
6d490e8ef117
(gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents:
34270
diff
changeset
|
5377 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5378 |
300 | 5379 lim = SYMBOL_BLOCK_SIZE; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5380 /* 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
|
5381 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
|
5382 this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5383 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
|
5384 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5385 *sprev = sblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5386 /* Unhook from the free list. */ |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5387 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
|
5388 lisp_free (sblk); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5389 n_symbol_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5390 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5391 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5392 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5393 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5394 sprev = &sblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5395 } |
300 | 5396 } |
5397 total_symbols = num_used; | |
5398 total_free_symbols = num_free; | |
5399 } | |
5400 | |
21143
ce12eac1ee45
(gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents:
21084
diff
changeset
|
5401 /* 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
|
5402 For a marker, first unchain it from the buffer it points into. */ |
300 | 5403 { |
5404 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
|
5405 struct marker_block **mprev = &marker_block; |
300 | 5406 register int lim = marker_block_index; |
5407 register int num_free = 0, num_used = 0; | |
5408 | |
5409 marker_free_list = 0; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5410 |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5411 for (mblk = marker_block; mblk; mblk = *mprev) |
300 | 5412 { |
5413 register int i; | |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5414 int this_free = 0; |
11403
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
5415 |
300 | 5416 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
|
5417 { |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5418 if (!mblk->markers[i].u_marker.gcmarkbit) |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5419 { |
11243
054ecfce1820
(Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents:
11048
diff
changeset
|
5420 if (mblk->markers[i].u_marker.type == Lisp_Misc_Marker) |
51668
0f333fd92a1d
(survives_gc_p): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51658
diff
changeset
|
5421 unchain_marker (&mblk->markers[i].u_marker); |
11403
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
5422 /* 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
|
5423 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
|
5424 but this might catch bugs faster. */ |
11243
054ecfce1820
(Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents:
11048
diff
changeset
|
5425 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
|
5426 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
|
5427 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
|
5428 this_free++; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5429 } |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5430 else |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5431 { |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5432 num_used++; |
51658
00b3e009b3f5
(make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51578
diff
changeset
|
5433 mblk->markers[i].u_marker.gcmarkbit = 0; |
9893
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5434 } |
8421d09f2afe
(mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents:
9463
diff
changeset
|
5435 } |
300 | 5436 lim = MARKER_BLOCK_SIZE; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5437 /* 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
|
5438 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
|
5439 this block. */ |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5440 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
|
5441 { |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5442 *mprev = mblk->next; |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5443 /* Unhook from the free list. */ |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5444 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
|
5445 lisp_free (mblk); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5446 n_marker_blocks--; |
20057
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5447 } |
612cd201aea5
(gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents:
19666
diff
changeset
|
5448 else |
21379
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5449 { |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5450 num_free += this_free; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5451 mprev = &mblk->next; |
1701bf5b9dec
(gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents:
21306
diff
changeset
|
5452 } |
300 | 5453 } |
5454 | |
5455 total_markers = num_used; | |
5456 total_free_markers = num_free; | |
5457 } | |
5458 | |
5459 /* Free all unmarked buffers */ | |
5460 { | |
5461 register struct buffer *buffer = all_buffers, *prev = 0, *next; | |
5462 | |
5463 while (buffer) | |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5464 if (!VECTOR_MARKED_P (buffer)) |
300 | 5465 { |
5466 if (prev) | |
5467 prev->next = buffer->next; | |
5468 else | |
5469 all_buffers = buffer->next; | |
5470 next = buffer->next; | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5471 lisp_free (buffer); |
300 | 5472 buffer = next; |
5473 } | |
5474 else | |
5475 { | |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5476 VECTOR_UNMARK (buffer); |
10307
e6e75fd0916d
(mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10291
diff
changeset
|
5477 UNMARK_BALANCE_INTERVALS (BUF_INTERVALS (buffer)); |
300 | 5478 prev = buffer, buffer = buffer->next; |
5479 } | |
5480 } | |
5481 | |
5482 /* Free all unmarked vectors */ | |
5483 { | |
5484 register struct Lisp_Vector *vector = all_vectors, *prev = 0, *next; | |
5485 total_vector_size = 0; | |
5486 | |
5487 while (vector) | |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5488 if (!VECTOR_MARKED_P (vector)) |
300 | 5489 { |
5490 if (prev) | |
5491 prev->next = vector->next; | |
5492 else | |
5493 all_vectors = vector->next; | |
5494 next = vector->next; | |
23958
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5495 lisp_free (vector); |
7094b74ce0a6
(lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
23534
diff
changeset
|
5496 n_vectors--; |
300 | 5497 vector = next; |
25024
3bb745067f0e
(gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents:
23973
diff
changeset
|
5498 |
300 | 5499 } |
5500 else | |
5501 { | |
51683
fb960854a12c
(VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51668
diff
changeset
|
5502 VECTOR_UNMARK (vector); |
11403
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
5503 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
|
5504 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
|
5505 else |
bd3241a14d0a
(gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents:
11374
diff
changeset
|
5506 total_vector_size += vector->size; |
300 | 5507 prev = vector, vector = vector->next; |
5508 } | |
5509 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49529
diff
changeset
|
5510 |
35183
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5511 #ifdef GC_CHECK_STRING_BYTES |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5512 if (!noninteractive) |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5513 check_string_bytes (1); |
cc2a06489f0d
(CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents:
35170
diff
changeset
|
5514 #endif |
300 | 5515 } |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5516 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5517 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5518 |
300 | 5519 |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5520 /* Debugging aids. */ |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5521 |
5353
6389ed5b45ac
(Fmemory_limit): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents:
4956
diff
changeset
|
5522 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
|
5523 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
|
5524 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
|
5525 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
|
5526 () |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5527 { |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5528 Lisp_Object end; |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5529 |
9261
e5ba7993d378
(VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents:
9144
diff
changeset
|
5530 XSETINT (end, (EMACS_INT) sbrk (0) / 1024); |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5531 |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5532 return end; |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5533 } |
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5534 |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
5535 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
|
5536 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
|
5537 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
|
5538 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
|
5539 Garbage collection does not decrease them. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5540 The elements of the value are as follows: |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5541 (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
|
5542 All are in units of 1 = one object consed |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5543 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
|
5544 objects consed. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5545 MISCS include overlays, markers, and some internal types. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5546 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
|
5547 (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
|
5548 () |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
5549 { |
27142
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5550 Lisp_Object consed[8]; |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5551 |
39633
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
5552 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
|
5553 consed[1] = make_number (min (MOST_POSITIVE_FIXNUM, floats_consed)); |
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
5554 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
|
5555 consed[3] = make_number (min (MOST_POSITIVE_FIXNUM, symbols_consed)); |
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
5556 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
|
5557 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
|
5558 consed[6] = make_number (min (MOST_POSITIVE_FIXNUM, intervals_consed)); |
a0bf0cb8ff3e
(inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents:
39572
diff
changeset
|
5559 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
|
5560 |
f742c86fcc15
(Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents:
27006
diff
changeset
|
5561 return Flist (8, consed); |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
5562 } |
28406
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5563 |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5564 int suppress_checking; |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5565 void |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5566 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
|
5567 const char *msg; |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5568 const char *file; |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5569 int line; |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5570 { |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5571 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
|
5572 file, line, msg); |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5573 abort (); |
451721e784a8
Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents:
28374
diff
changeset
|
5574 } |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5575 |
300 | 5576 /* Initialization */ |
5577 | |
21514 | 5578 void |
300 | 5579 init_alloc_once () |
5580 { | |
5581 /* 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
|
5582 purebeg = PUREBEG; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5583 pure_size = PURESIZE; |
32594
e0646c73bf81
(pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents:
32587
diff
changeset
|
5584 pure_bytes_used = 0; |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5585 pure_bytes_used_before_overflow = 0; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5586 |
51723
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
5587 /* Initialize the list of free aligned blocks. */ |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
5588 free_ablock = NULL; |
635066222916
(ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51686
diff
changeset
|
5589 |
32692
0343fe9ef3ac
(toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents:
32609
diff
changeset
|
5590 #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
|
5591 mem_init (); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5592 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
|
5593 #endif |
39572
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5594 |
300 | 5595 all_vectors = 0; |
5596 ignore_warnings = 1; | |
17345
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
5597 #ifdef DOUG_LEA_MALLOC |
4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents:
17328
diff
changeset
|
5598 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
|
5599 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
|
5600 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
|
5601 #endif |
300 | 5602 init_strings (); |
5603 init_cons (); | |
5604 init_symbol (); | |
5605 init_marker (); | |
5606 init_float (); | |
27738
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5607 init_intervals (); |
1300
b13b79e28eb5
* alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents:
1295
diff
changeset
|
5608 |
10673
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5609 #ifdef REL_ALLOC |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5610 malloc_hysteresis = 32; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5611 #else |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5612 malloc_hysteresis = 0; |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5613 #endif |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5614 |
337c3a4d5fef
(emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents:
10649
diff
changeset
|
5615 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
|
5616 |
300 | 5617 ignore_warnings = 0; |
5618 gcprolist = 0; | |
26364
7b0217d9259c
(Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents:
26164
diff
changeset
|
5619 byte_stack_list = 0; |
300 | 5620 staticidx = 0; |
5621 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
|
5622 gc_cons_threshold = 100000 * sizeof (Lisp_Object); |
300 | 5623 #ifdef VIRT_ADDR_VARIES |
5624 malloc_sbrk_unused = 1<<22; /* A large number */ | |
5625 malloc_sbrk_used = 100000; /* as reasonable as any number */ | |
5626 #endif /* VIRT_ADDR_VARIES */ | |
5627 } | |
5628 | |
21514 | 5629 void |
300 | 5630 init_alloc () |
5631 { | |
5632 gcprolist = 0; | |
26364
7b0217d9259c
(Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents:
26164
diff
changeset
|
5633 byte_stack_list = 0; |
28365
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
5634 #if GC_MARK_STACK |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
5635 #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
|
5636 setjmp_tested_p = longjmps_done = 0; |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
5637 #endif |
a72abbd8dc16
(mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
5638 #endif |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5639 Vgc_elapsed = make_float (0.0); |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5640 gcs_done = 0; |
300 | 5641 } |
5642 | |
5643 void | |
5644 syms_of_alloc () | |
5645 { | |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5646 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
|
5647 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
|
5648 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
|
5649 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
|
5650 |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5651 Garbage collection happens automatically only when `eval' is called. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5652 |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5653 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
|
5654 prevent garbage collection during a part of the program. */); |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5655 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5656 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
|
5657 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
|
5658 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5659 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
|
5660 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
|
5661 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5662 DEFVAR_INT ("floats-consed", &floats_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5663 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
|
5664 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5665 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
|
5666 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
|
5667 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5668 DEFVAR_INT ("symbols-consed", &symbols_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5669 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
|
5670 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5671 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
|
5672 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
|
5673 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5674 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
|
5675 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
|
5676 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5677 DEFVAR_INT ("intervals-consed", &intervals_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5678 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
|
5679 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5680 DEFVAR_INT ("strings-consed", &strings_consed, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5681 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
|
5682 |
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5683 DEFVAR_LISP ("purify-flag", &Vpurify_flag, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5684 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
|
5685 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
|
5686 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5687 DEFVAR_INT ("undo-limit", &undo_limit, |
40107
d3cc7dd5d75a
Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents:
39988
diff
changeset
|
5688 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
|
5689 This limit is applied when garbage collection happens. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5690 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
|
5691 which includes both saved text and other data. */); |
764 | 5692 undo_limit = 20000; |
300 | 5693 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5694 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
|
5695 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
|
5696 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
|
5697 This limit is applied when garbage collection happens. |
91951fb5b9e5
Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents:
39859
diff
changeset
|
5698 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
|
5699 which includes both saved text and other data. */); |
764 | 5700 undo_strong_limit = 30000; |
300 | 5701 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5702 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
|
5703 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
|
5704 garbage_collection_messages = 0; |
f2b5d784fa88
(garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14764
diff
changeset
|
5705 |
39988
eac4e9ae201c
Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
5706 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
|
5707 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
|
5708 Vpost_gc_hook = Qnil; |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5709 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
|
5710 staticpro (&Qpost_gc_hook); |
715a67381594
(purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents:
39297
diff
changeset
|
5711 |
46305
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
5712 DEFVAR_LISP ("memory-signal-data", &Vmemory_signal_data, |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
5713 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
|
5714 /* 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
|
5715 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
|
5716 Vmemory_signal_data |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
5717 = list2 (Qerror, |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
5718 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
|
5719 |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
5720 DEFVAR_LISP ("memory-full", &Vmemory_full, |
fed6b815dbeb
(Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
46293
diff
changeset
|
5721 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
|
5722 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
|
5723 |
11374
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
5724 staticpro (&Qgc_cons_threshold); |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
5725 Qgc_cons_threshold = intern ("gc-cons-threshold"); |
1ebc81f84aa4
(inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
5726 |
13219
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
5727 staticpro (&Qchar_table_extra_slots); |
99b5164a319d
(Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13150
diff
changeset
|
5728 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
|
5729 |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5730 DEFVAR_LISP ("gc-elapsed", &Vgc_elapsed, |
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5731 doc: /* Accumulated time elapsed in garbage collections. |
51974
111cc76606c6
(syms_of_alloc): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
51938
diff
changeset
|
5732 The time is in seconds as a floating point value. */); |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5733 DEFVAR_INT ("gcs-done", &gcs_done, |
51974
111cc76606c6
(syms_of_alloc): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
51938
diff
changeset
|
5734 doc: /* Accumulated number of garbage collections done. */); |
49529
fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents:
49414
diff
changeset
|
5735 |
300 | 5736 defsubr (&Scons); |
5737 defsubr (&Slist); | |
5738 defsubr (&Svector); | |
5739 defsubr (&Smake_byte_code); | |
5740 defsubr (&Smake_list); | |
5741 defsubr (&Smake_vector); | |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
5742 defsubr (&Smake_char_table); |
300 | 5743 defsubr (&Smake_string); |
13141
4a4d1d8e89e5
(Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
13008
diff
changeset
|
5744 defsubr (&Smake_bool_vector); |
300 | 5745 defsubr (&Smake_symbol); |
5746 defsubr (&Smake_marker); | |
5747 defsubr (&Spurecopy); | |
5748 defsubr (&Sgarbage_collect); | |
1327
ef16e7c0d402
* alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents:
1318
diff
changeset
|
5749 defsubr (&Smemory_limit); |
12748
3433bb446e06
(cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents:
12605
diff
changeset
|
5750 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
|
5751 |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5752 #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
|
5753 defsubr (&Sgc_status); |
581c76c41ca4
(mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents:
27727
diff
changeset
|
5754 #endif |
300 | 5755 } |
52401 | 5756 |
5757 /* arch-tag: 6695ca10-e3c5-4c2c-8bc3-ed26a7dda857 | |
5758 (do not change this comment) */ |