annotate src/alloc.c @ 28406:451721e784a8

Stop assuming interval pointers and lisp objects can be distinguished by inspection. Beginnings of support for expensive internal consistency checks. * config.in (ENABLE_CHECKING): Undef. * lisp.h (struct interval): Replace "parent" field with a union of interval pointer and Lisp_Object; add new bitfield to use as discriminant. Change other flag fields to bitfields. (CHECK): New macro for consistency checking. If ENABLE_CHECKING is defined and the supplied test fails, print a message and abort. (eassert): New macro. Use CHECK to provide an assert-like facility. * intervals.h (NULL_INTERVAL_P): Now applies only to real interval pointers; abort if the value looks like a lisp object. (NULL_INTERVAL_P, NULL_PARENT, HAS_PARENT, HAS_OBJECT, SET_PARENT, SET_OBJECT, INTERVAL_PARENT, GET_INTERVAL_OBJECT, COPY_PARENT): Modify for new interval parent definition. * alloc.c (mark_interval_tree, MARK_INTERVAL_TREE, UNMARK_BALANCE_INTERVALS): Update references that need an addressable lisp object in the interval structure. (die): New function. (suppress_checking): New variable. * intervals.c (interval_start_pos): Just return 0 if there's no parent object.
author Ken Raeburn <raeburn@raeburn.org>
date Wed, 29 Mar 2000 22:14:34 +0000
parents 7a3e8a76057b
children ecba29fa0198
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 /* Storage allocation and gc for GNU Emacs Lisp interpreter.
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2 Copyright (C) 1985, 86, 88, 93, 94, 95, 97, 98, 1999, 2000
20708
ed9ed828415e Update copyright year.
Richard M. Stallman <rms@gnu.org>
parents: 20659
diff changeset
3 Free Software Foundation, Inc.
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5 This file is part of GNU Emacs.
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 GNU Emacs is free software; you can redistribute it and/or modify
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 any later version.
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 GNU Emacs is distributed in the hope that it will be useful,
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 GNU General Public License for more details.
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25762
diff changeset
22 #include <config.h>
28374
7a3e8a76057b Include stdio.h. Test STDC_HEADERS, not __STDC__.
Dave Love <fx@gnu.org>
parents: 28365
diff changeset
23 #include <stdio.h>
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25762
diff changeset
24
13320
e0f3a961851a Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents: 13219
diff changeset
25 /* Note that this declares bzero on OSF/1. How dumb. */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
26
3003
5a73d384f45e * syssignal.h: Don't #include <signal.h>
Jim Blandy <jimb@redhat.com>
parents: 2961
diff changeset
27 #include <signal.h>
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 26088
diff changeset
29 /* This file is part of the core Lisp implementation, and thus must
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 26088
diff changeset
30 deal with the real data structures. If the Lisp implementation is
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 26088
diff changeset
31 replaced, this file likely will not be used. */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
32
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 26088
diff changeset
33 #undef HIDE_LISP_IMPLEMENTATION
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 #include "lisp.h"
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
35 #include "intervals.h"
356
5b180834eacf *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 300
diff changeset
36 #include "puresize.h"
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 #include "buffer.h"
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 #include "window.h"
764
bb24f1180bb6 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
39 #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
40 #include "blockinput.h"
11341
e0f3fa4e7bf3 Include keyboard.h.
Richard M. Stallman <rms@gnu.org>
parents: 11243
diff changeset
41 #include "keyboard.h"
21084
371ed7bdfd2b (Fmake_string): Handle the case INIT is a multibyte character correctly.
Richard M. Stallman <rms@gnu.org>
parents: 20849
diff changeset
42 #include "charset.h"
638
40b255f55df3 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 624
diff changeset
43 #include "syssignal.h"
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
44 #include <setjmp.h>
638
40b255f55df3 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 624
diff changeset
45
12096
cdc859dd813b Declare sbrk.
Karl Heuer <kwzh@gnu.org>
parents: 11892
diff changeset
46 extern char *sbrk ();
cdc859dd813b Declare sbrk.
Karl Heuer <kwzh@gnu.org>
parents: 11892
diff changeset
47
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
48 #ifdef DOUG_LEA_MALLOC
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
49
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
50 #include <malloc.h>
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
51 #define __malloc_size_t int
23973
2eb9e2f5aa33 (MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 23958
diff changeset
52
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
53 /* 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
54 value that explicitly means "no limit". */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
55
23973
2eb9e2f5aa33 (MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 23958
diff changeset
56 #define MMAP_MAX_AREAS 100000000
2eb9e2f5aa33 (MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 23958
diff changeset
57
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
58 #else /* not DOUG_LEA_MALLOC */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
59
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
60 /* 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
61
28374
7a3e8a76057b Include stdio.h. Test STDC_HEADERS, not __STDC__.
Dave Love <fx@gnu.org>
parents: 28365
diff changeset
62 #if defined (STDC_HEADERS)
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
63 #include <stddef.h>
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
64 #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
65 #else
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
66 #define __malloc_size_t unsigned int
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
67 #endif
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
68 extern __malloc_size_t _bytes_used;
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
69 extern int __malloc_extra_blocks;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
70
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
71 #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
72
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 #define max(A,B) ((A) > (B) ? (A) : (B))
11727
53ccd2d608ee (gc_cons_threshold): Change back to int.
Richard M. Stallman <rms@gnu.org>
parents: 11679
diff changeset
74 #define min(A,B) ((A) < (B) ? (A) : (B))
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 /* Macro to verify that storage intended for Lisp objects is not
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 out of range to fit in the space for a pointer.
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 ADDRESS is the start of the block, and SIZE
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 is the amount of space within which objects can start. */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
80
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 #define VALIDATE_LISP_STORAGE(address, size) \
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 do \
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 { \
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 Lisp_Object val; \
9261
e5ba7993d378 (VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents: 9144
diff changeset
85 XSETCONS (val, (char *) address + size); \
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 if ((char *) XCONS (val) != (char *) address + size) \
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 { \
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
88 xfree (address); \
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 memory_full (); \
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 } \
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 } while (0)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
93 /* 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
94
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
95 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
96
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
97 /* 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
98 to a struct Lisp_String. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
99
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
100 #define MARK_STRING(S) XMARK ((S)->size)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
101 #define UNMARK_STRING(S) XUNMARK ((S)->size)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
102 #define STRING_MARKED_P(S) XMARKBIT ((S)->size)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
103
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
104 /* 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
105 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
106 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
107 strings. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
108
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
109 #define GC_STRING_BYTES(S) (STRING_BYTES (S) & ~MARKBIT)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
110 #define GC_STRING_CHARS(S) ((S)->size & ~MARKBIT)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
111
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
112 /* 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
113
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 int consing_since_gc;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115
12748
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
116 /* 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
117
12748
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
118 int cons_cells_consed;
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
119 int floats_consed;
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
120 int vector_cells_consed;
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
121 int symbols_consed;
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
122 int string_chars_consed;
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
123 int misc_objects_consed;
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
124 int intervals_consed;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
125 int strings_consed;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
126
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
127 /* 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
128
11727
53ccd2d608ee (gc_cons_threshold): Change back to int.
Richard M. Stallman <rms@gnu.org>
parents: 11679
diff changeset
129 int gc_cons_threshold;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
131 /* Nonzero during GC. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
132
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 int gc_in_progress;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134
14959
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
135 /* Nonzero means display messages at beginning and end of GC. */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
136
14959
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
137 int garbage_collection_messages;
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
138
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 #ifndef VIRT_ADDR_VARIES
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 extern
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 #endif /* VIRT_ADDR_VARIES */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
142 int malloc_sbrk_used;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 #ifndef VIRT_ADDR_VARIES
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 extern
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 #endif /* VIRT_ADDR_VARIES */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
147 int malloc_sbrk_unused;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148
764
bb24f1180bb6 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
149 /* Two limits controlling how much undo information to keep. */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
150
764
bb24f1180bb6 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
151 int undo_limit;
bb24f1180bb6 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
152 int undo_strong_limit;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
154 /* Number of live and free conses etc. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
155
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
156 static int total_conses, total_markers, total_symbols, total_vector_size;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
157 static int total_free_conses, total_free_markers, total_free_symbols;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
158 static int total_free_floats, total_floats;
19332
58f14958f5d5 (free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents: 18621
diff changeset
159
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
160 /* Points to memory space allocated as "spare", to be freed if we run
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
161 out of memory. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
162
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
163 static char *spare_memory;
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
164
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
165 /* Amount of spare memory to keep in reserve. */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
166
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
167 #define SPARE_MEMORY (1 << 14)
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
168
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
169 /* Number of extra blocks malloc should get when it needs more core. */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
170
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
171 static int malloc_hysteresis;
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
172
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
173 /* Nonzero when malloc is called for allocating Lisp object space.
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
174 Currently set but not used. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
175
12529
c7d32f5da2b3 (Flist): Rewritten.
Karl Heuer <kwzh@gnu.org>
parents: 12273
diff changeset
176 int allocating_for_lisp;
c7d32f5da2b3 (Flist): Rewritten.
Karl Heuer <kwzh@gnu.org>
parents: 12273
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
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 Lisp_Object Vpurify_flag;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 #ifndef HAVE_SHM
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
183
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
184 /* Force it into data space! */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
185
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
186 EMACS_INT pure[PURESIZE / sizeof (EMACS_INT)] = {0,};
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 #define PUREBEG (char *) pure
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
188
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
189 #else /* not HAVE_SHM */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
190
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 #define pure PURE_SEG_BITS /* Use shared memory segment */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 #define PUREBEG (char *)PURE_SEG_BITS
356
5b180834eacf *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 300
diff changeset
193
5b180834eacf *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 300
diff changeset
194 /* This variable is used only by the XPNTR macro when HAVE_SHM is
5b180834eacf *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 300
diff changeset
195 defined. If we used the PURESIZE macro directly there, that would
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
196 make most of Emacs dependent on puresize.h, which we don't want -
356
5b180834eacf *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 300
diff changeset
197 you should be able to change that without too much recompilation.
5b180834eacf *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 300
diff changeset
198 So map_in_data initializes pure_size, and the dependencies work
5b180834eacf *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 300
diff changeset
199 out. */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
200
8817
48ff00bebef6 (pure, pure_size): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents: 7307
diff changeset
201 EMACS_INT pure_size;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
202
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 #endif /* not HAVE_SHM */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
205 /* Value is non-zero if P points into pure space. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
206
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
207 #define PURE_POINTER_P(P) \
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
208 (((PNTR_COMPARISON_TYPE) (P) \
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
209 < (PNTR_COMPARISON_TYPE) ((char *) pure + PURESIZE)) \
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
210 && ((PNTR_COMPARISON_TYPE) (P) \
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
211 >= (PNTR_COMPARISON_TYPE) pure))
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
212
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
213 /* Index in pure at which next pure object will be allocated.. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
214
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 int pureptr;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
217 /* If nonzero, this is a warning delivered by malloc and not yet
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
218 displayed. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
219
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 char *pending_malloc_warning;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221
6116
64417bbbb128 (memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents: 5874
diff changeset
222 /* Pre-computed signal argument for use when memory is exhausted. */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
223
6133
752d4237f869 (memory_signal_data): No longer static.
Richard M. Stallman <rms@gnu.org>
parents: 6116
diff changeset
224 Lisp_Object memory_signal_data;
6116
64417bbbb128 (memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents: 5874
diff changeset
225
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 /* Maximum amount of C stack to save when a GC happens. */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 #ifndef MAX_SAVE_STACK
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 #define MAX_SAVE_STACK 16000
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 #endif
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 /* Buffer in which we save a copy of the C stack at each GC. */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 char *stack_copy;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 int stack_copy_size;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
237 /* Non-zero means ignore malloc warnings. Set during initialization.
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
238 Currently not used. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
239
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 int ignore_warnings;
1318
0edeba6fc9fc Fixed typos.
Joseph Arceneaux <jla@gnu.org>
parents: 1300
diff changeset
241
13219
99b5164a319d (Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13150
diff changeset
242 Lisp_Object Qgc_cons_threshold, Qchar_table_extra_slots;
11374
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
243
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
244 static void mark_buffer P_ ((Lisp_Object));
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
245 static void mark_kboards P_ ((void));
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
246 static void gc_sweep P_ ((void));
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
247 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
248 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
249
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
250 #ifdef HAVE_WINDOW_SYSTEM
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
251 static void mark_image P_ ((struct image *));
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
252 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
253 #endif /* HAVE_WINDOW_SYSTEM */
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
254
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
255 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
256 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
257 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
258 static void sweep_strings P_ ((void));
20495
db1be942dc12 (Fgarbage_collect):
Richard M. Stallman <rms@gnu.org>
parents: 20391
diff changeset
259
db1be942dc12 (Fgarbage_collect):
Richard M. Stallman <rms@gnu.org>
parents: 20391
diff changeset
260 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
261
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
262 /* 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
263 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
264 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
265
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
266 enum mem_type
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
267 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
268 MEM_TYPE_NON_LISP,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
269 MEM_TYPE_BUFFER,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
270 MEM_TYPE_CONS,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
271 MEM_TYPE_STRING,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
272 MEM_TYPE_MISC,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
273 MEM_TYPE_SYMBOL,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
274 MEM_TYPE_FLOAT,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
275 MEM_TYPE_VECTOR
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
276 };
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
277
27746
2556e20596b8 (enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents: 27738
diff changeset
278 #if GC_MARK_STACK
2556e20596b8 (enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents: 27738
diff changeset
279
2556e20596b8 (enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents: 27738
diff changeset
280 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
2556e20596b8 (enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents: 27738
diff changeset
281 #include <stdio.h> /* For fprintf. */
2556e20596b8 (enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents: 27738
diff changeset
282 #endif
2556e20596b8 (enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents: 27738
diff changeset
283
2556e20596b8 (enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents: 27738
diff changeset
284 /* 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
285 on free lists recognizable in O(1). */
2556e20596b8 (enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents: 27738
diff changeset
286
2556e20596b8 (enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents: 27738
diff changeset
287 Lisp_Object Vdead;
2556e20596b8 (enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents: 27738
diff changeset
288
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
289 struct mem_node;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
290 static void *lisp_malloc P_ ((int, enum mem_type));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
291 static void mark_stack P_ ((void));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
292 static void init_stack P_ ((Lisp_Object *));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
293 static int live_vector_p P_ ((struct mem_node *, void *));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
294 static int live_buffer_p P_ ((struct mem_node *, void *));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
295 static int live_string_p P_ ((struct mem_node *, void *));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
296 static int live_cons_p P_ ((struct mem_node *, void *));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
297 static int live_symbol_p P_ ((struct mem_node *, void *));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
298 static int live_float_p P_ ((struct mem_node *, void *));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
299 static int live_misc_p P_ ((struct mem_node *, void *));
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
300 static void mark_maybe_object P_ ((Lisp_Object));
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
301 static void mark_memory P_ ((void *, void *));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
302 static void mem_init P_ ((void));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
303 static struct mem_node *mem_insert P_ ((void *, void *, enum mem_type));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
304 static void mem_insert_fixup P_ ((struct mem_node *));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
305 static void mem_rotate_left P_ ((struct mem_node *));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
306 static void mem_rotate_right P_ ((struct mem_node *));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
307 static void mem_delete P_ ((struct mem_node *));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
308 static void mem_delete_fixup P_ ((struct mem_node *));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
309 static INLINE struct mem_node *mem_find P_ ((void *));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
310
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
311 #if GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
312 static void check_gcpros P_ ((void));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
313 #endif
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
314
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
315 #endif /* GC_MARK_STACK != 0 */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
316
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
318 /************************************************************************
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
319 Malloc
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
320 ************************************************************************/
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
321
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
322 /* Write STR to Vstandard_output plus some advice on how to free some
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
323 memory. Called when memory gets low. */
1908
d649f2179d67 * alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents: 1893
diff changeset
324
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 Lisp_Object
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 malloc_warning_1 (str)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 Lisp_Object str;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 Fprinc (str, Vstandard_output);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 write_string ("\nKilling some buffers may delay running out of memory.\n", -1);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 write_string ("However, certainly by the time you receive the 95% warning,\n", -1);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 write_string ("you should clean up, kill this Emacs, and start a new one.", -1);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 return Qnil;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
336
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
337 /* Function malloc calls this if it finds we are near exhausting
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
338 storage. */
20375
1dd0bd0749b5 (malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents: 20057
diff changeset
339
1dd0bd0749b5 (malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents: 20057
diff changeset
340 void
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 malloc_warning (str)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 char *str;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 pending_malloc_warning = str;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
347
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
348 /* Display a malloc warning in buffer *Danger*. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
349
20375
1dd0bd0749b5 (malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents: 20057
diff changeset
350 void
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 display_malloc_warning ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 register Lisp_Object val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 val = build_string (pending_malloc_warning);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 pending_malloc_warning = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 internal_with_output_to_temp_buffer (" *Danger*", malloc_warning_1, val);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
360
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
361 #ifdef DOUG_LEA_MALLOC
17831
9238a2254a23 (BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents: 17348
diff changeset
362 # define BYTES_USED (mallinfo ().arena)
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
363 #else
17831
9238a2254a23 (BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents: 17348
diff changeset
364 # define BYTES_USED _bytes_used
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
365 #endif
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
366
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
367
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
368 /* Called if malloc returns zero. */
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
369
20375
1dd0bd0749b5 (malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents: 20057
diff changeset
370 void
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 memory_full ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 {
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
373 #ifndef SYSTEM_MALLOC
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
374 bytes_used_when_full = BYTES_USED;
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
375 #endif
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
376
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
377 /* The first time we get here, free the spare memory. */
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
378 if (spare_memory)
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
379 {
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
380 free (spare_memory);
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
381 spare_memory = 0;
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
382 }
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
383
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
384 /* This used to call error, but if we've run out of memory, we could
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
385 get infinite recursion trying to build the string. */
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
386 while (1)
18621
53b95f307c75 (memory_full): Pass Qnil to Fsignal for ERROR_SYMBOL.
Richard M. Stallman <rms@gnu.org>
parents: 18104
diff changeset
387 Fsignal (Qnil, memory_signal_data);
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
388 }
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
389
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
390
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
391 /* Called if we can't allocate relocatable space for a buffer. */
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
392
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
393 void
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
394 buffer_memory_full ()
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
395 {
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
396 /* If buffers use the relocating allocator, no need to free
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
397 spare_memory, because we may have plenty of malloc space left
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
398 that we could get, and if we don't, the malloc that fails will
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
399 itself cause spare_memory to be freed. If buffers don't use the
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
400 relocating allocator, treat this like any other failing
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
401 malloc. */
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
402
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
403 #ifndef REL_ALLOC
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
404 memory_full ();
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
405 #endif
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
406
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
407 /* This used to call error, but if we've run out of memory, we could
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
408 get infinite recursion trying to build the string. */
6116
64417bbbb128 (memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents: 5874
diff changeset
409 while (1)
64417bbbb128 (memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents: 5874
diff changeset
410 Fsignal (Qerror, memory_signal_data);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
413
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
414 /* Like malloc but check for no memory and block interrupt input.. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 long *
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 xmalloc (size)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418 int size;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 register long *val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
422 BLOCK_INPUT;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 val = (long *) malloc (size);
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
424 UNBLOCK_INPUT;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
426 if (!val && size)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
427 memory_full ();
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 return val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
431
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
432 /* Like realloc but check for no memory and block interrupt input.. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
433
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 long *
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435 xrealloc (block, size)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436 long *block;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 int size;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 register long *val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
441 BLOCK_INPUT;
590
1a6483439acc *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
442 /* We must call malloc explicitly when BLOCK is 0, since some
1a6483439acc *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
443 reallocs don't do this. */
1a6483439acc *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
444 if (! block)
1a6483439acc *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
445 val = (long *) malloc (size);
600
a8d78999e46d *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 590
diff changeset
446 else
590
1a6483439acc *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
447 val = (long *) realloc (block, size);
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
448 UNBLOCK_INPUT;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450 if (!val && size) memory_full ();
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 return val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452 }
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
453
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
454
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
455 /* Like free but block interrupt input.. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
456
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
457 void
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
458 xfree (block)
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
459 long *block;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
460 {
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
461 BLOCK_INPUT;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
462 free (block);
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
463 UNBLOCK_INPUT;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
464 }
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
465
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
466
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
467 /* 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
468 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
469 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
470
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
471 static void *
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
472 lisp_malloc (nbytes, type)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
473 int nbytes;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
474 enum mem_type type;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
475 {
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
476 register void *val;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
477
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
478 BLOCK_INPUT;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
479 allocating_for_lisp++;
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
480 val = (void *) malloc (nbytes);
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
481 allocating_for_lisp--;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
482 UNBLOCK_INPUT;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
483
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
484 if (!val && nbytes)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
485 memory_full ();
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
486
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
487 #if GC_MARK_STACK
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
488 if (type != MEM_TYPE_NON_LISP)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
489 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
490 #endif
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
491
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
492 return val;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
493 }
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
494
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
495
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
496 /* Return a new buffer structure allocated from the heap with
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
497 a call to lisp_malloc. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
498
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
499 struct buffer *
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
500 allocate_buffer ()
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
501 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
502 return (struct buffer *) lisp_malloc (sizeof (struct buffer),
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
503 MEM_TYPE_BUFFER);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
504 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
505
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
506
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
507 /* 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
508 call to lisp_malloc. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
509
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
510 void
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
511 lisp_free (block)
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
512 long *block;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
513 {
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
514 BLOCK_INPUT;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
515 allocating_for_lisp++;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
516 free (block);
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
517 #if GC_MARK_STACK
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
518 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
519 #endif
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
520 allocating_for_lisp--;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
521 UNBLOCK_INPUT;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
522 }
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
523
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
524
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
525 /* 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
526
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
527 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
528 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
529 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
530 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
531 might call malloc, so we can't really protect them unless you're
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
532 using GNU malloc. Fortunately, most of the major operating can use
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
533 GNU malloc. */
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
534
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
535 #ifndef SYSTEM_MALLOC
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
536
2507
7ba4316ae840 * alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
537 extern void * (*__malloc_hook) ();
7ba4316ae840 * alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
538 static void * (*old_malloc_hook) ();
7ba4316ae840 * alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
539 extern void * (*__realloc_hook) ();
7ba4316ae840 * alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
540 static void * (*old_realloc_hook) ();
7ba4316ae840 * alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
541 extern void (*__free_hook) ();
7ba4316ae840 * alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
542 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
543
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
544 /* 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
545
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
546 static void
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
547 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
548 void *ptr;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
549 {
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
550 BLOCK_INPUT;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
551 __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
552 free (ptr);
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
553 /* 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
554 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
555 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
556 if (spare_memory == 0
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
557 /* 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
558 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
559 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
560 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
561 && (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
562 > BYTES_USED + max (malloc_hysteresis, 4) * SPARE_MEMORY))
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
563 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
564
2507
7ba4316ae840 * alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
565 __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
566 UNBLOCK_INPUT;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
567 }
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
568
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
569
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
570 /* 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
571 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
572 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
573
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
574 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
575
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
576 void
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
577 refill_memory_reserve ()
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
578 {
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
579 if (spare_memory == 0)
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
580 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
581 }
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
582
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
583
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
584 /* 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
585
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
586 static void *
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
587 emacs_blocked_malloc (size)
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
588 unsigned size;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
589 {
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
590 void *value;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
591
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
592 BLOCK_INPUT;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
593 __malloc_hook = old_malloc_hook;
17831
9238a2254a23 (BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents: 17348
diff changeset
594 #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
595 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
596 #else
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
597 __malloc_extra_blocks = malloc_hysteresis;
17831
9238a2254a23 (BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents: 17348
diff changeset
598 #endif
3581
152fd924c7bb * alloc.c (emacs_blocked_malloc, emacs_blocked_realloc): Cast the
Jim Blandy <jimb@redhat.com>
parents: 3536
diff changeset
599 value = (void *) malloc (size);
2507
7ba4316ae840 * alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
600 __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
601 UNBLOCK_INPUT;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
602
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
603 return value;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
604 }
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
605
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
606
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
607 /* 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
608
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
609 static void *
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
610 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
611 void *ptr;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
612 unsigned size;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
613 {
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
614 void *value;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
615
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
616 BLOCK_INPUT;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
617 __realloc_hook = old_realloc_hook;
3581
152fd924c7bb * alloc.c (emacs_blocked_malloc, emacs_blocked_realloc): Cast the
Jim Blandy <jimb@redhat.com>
parents: 3536
diff changeset
618 value = (void *) realloc (ptr, size);
2507
7ba4316ae840 * alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
619 __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
620 UNBLOCK_INPUT;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
621
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
622 return value;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
623 }
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
624
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
625
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
626 /* 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
627
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
628 void
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
629 uninterrupt_malloc ()
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
630 {
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
631 if (__free_hook != emacs_blocked_free)
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
632 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
633 __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
634
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
635 if (__malloc_hook != emacs_blocked_malloc)
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
636 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
637 __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
638
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
639 if (__realloc_hook != emacs_blocked_realloc)
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
640 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
641 __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
642 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
643
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
644 #endif /* not SYSTEM_MALLOC */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
645
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
646
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
647
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
648 /***********************************************************************
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
649 Interval Allocation
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
650 ***********************************************************************/
1908
d649f2179d67 * alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents: 1893
diff changeset
651
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
652 /* 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
653 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
654
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
655 #define INTERVAL_BLOCK_SIZE \
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
656 ((1020 - sizeof (struct interval_block *)) / sizeof (struct interval))
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
657
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
658 /* 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
659 structure. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
660
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
661 struct interval_block
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
662 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
663 struct interval_block *next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
664 struct interval intervals[INTERVAL_BLOCK_SIZE];
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
665 };
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
666
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
667 /* 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
668 blocks. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
669
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
670 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
671
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
672 /* 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
673 structure. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
674
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
675 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
676
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
677 /* 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
678
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
679 static int total_free_intervals, total_intervals;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
680
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
681 /* List of free intervals. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
682
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
683 INTERVAL interval_free_list;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
684
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
685 /* 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
686
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
687 int n_interval_blocks;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
688
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
689
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
690 /* Initialize interval allocation. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
691
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
692 static void
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
693 init_intervals ()
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
694 {
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
695 interval_block
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
696 = (struct interval_block *) lisp_malloc (sizeof *interval_block,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
697 MEM_TYPE_NON_LISP);
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
698 interval_block->next = 0;
13320
e0f3a961851a Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents: 13219
diff changeset
699 bzero ((char *) interval_block->intervals, sizeof interval_block->intervals);
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
700 interval_block_index = 0;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
701 interval_free_list = 0;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
702 n_interval_blocks = 1;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
703 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
704
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
705
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
706 /* Return a new interval. */
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
707
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
708 INTERVAL
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
709 make_interval ()
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
710 {
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
711 INTERVAL val;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
712
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
713 if (interval_free_list)
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
714 {
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
715 val = interval_free_list;
28269
fd13be8ae190 Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents: 28220
diff changeset
716 interval_free_list = INTERVAL_PARENT (interval_free_list);
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
717 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
718 else
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
719 {
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
720 if (interval_block_index == INTERVAL_BLOCK_SIZE)
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
721 {
12529
c7d32f5da2b3 (Flist): Rewritten.
Karl Heuer <kwzh@gnu.org>
parents: 12273
diff changeset
722 register struct interval_block *newi;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
723
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
724 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
725 MEM_TYPE_NON_LISP);
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
726
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
727 VALIDATE_LISP_STORAGE (newi, sizeof *newi);
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
728 newi->next = interval_block;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
729 interval_block = newi;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
730 interval_block_index = 0;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
731 n_interval_blocks++;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
732 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
733 val = &interval_block->intervals[interval_block_index++];
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
734 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
735 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
736 intervals_consed++;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
737 RESET_INTERVAL (val);
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
738 return val;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
739 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
740
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
741
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
742 /* Mark Lisp objects in interval I. */
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
743
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
744 static void
1957
54c8c66cd9ac (mark_interval): Add ignored arg.
Richard M. Stallman <rms@gnu.org>
parents: 1939
diff changeset
745 mark_interval (i, dummy)
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
746 register INTERVAL i;
1957
54c8c66cd9ac (mark_interval): Add ignored arg.
Richard M. Stallman <rms@gnu.org>
parents: 1939
diff changeset
747 Lisp_Object dummy;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
748 {
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
749 if (XMARKBIT (i->plist))
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
750 abort ();
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
751 mark_object (&i->plist);
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
752 XMARK (i->plist);
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
753 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
754
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
755
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
756 /* 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
757 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
758
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
759 static void
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
760 mark_interval_tree (tree)
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
761 register INTERVAL tree;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
762 {
4139
0b32ee899a3a Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents: 4087
diff changeset
763 /* 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
764 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
765 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
766
0b32ee899a3a Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents: 4087
diff changeset
767 /* XMARK expands to an assignment; the LHS of an assignment can't be
0b32ee899a3a Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents: 4087
diff changeset
768 a cast. */
28406
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
769 XMARK (tree->up.obj);
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
770
1957
54c8c66cd9ac (mark_interval): Add ignored arg.
Richard M. Stallman <rms@gnu.org>
parents: 1939
diff changeset
771 traverse_intervals (tree, 1, 0, mark_interval, Qnil);
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
772 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
773
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
774
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
775 /* 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
776
4139
0b32ee899a3a Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents: 4087
diff changeset
777 #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
778 do { \
0b32ee899a3a Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents: 4087
diff changeset
779 if (!NULL_INTERVAL_P (i) \
28406
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
780 && ! XMARKBIT (i->up.obj)) \
4139
0b32ee899a3a Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents: 4087
diff changeset
781 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
782 } while (0)
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
783
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
784
1908
d649f2179d67 * alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents: 1893
diff changeset
785 /* The oddity in the call to XUNMARK is necessary because XUNMARK
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
786 expands to an assignment to its argument, and most C compilers
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
787 don't support casts on the left operand of `='. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
788
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
789 #define UNMARK_BALANCE_INTERVALS(i) \
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
790 do { \
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
791 if (! NULL_INTERVAL_P (i)) \
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
792 { \
28406
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
793 XUNMARK ((i)->up.obj); \
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
794 (i) = balance_intervals (i); \
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
795 } \
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
796 } while (0)
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
797
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
798
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
799
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
800 /***********************************************************************
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
801 String Allocation
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
802 ***********************************************************************/
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
803
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
804 /* 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
805 string_block is allocated, all the Lisp_Strings it contains are
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
806 added to a free-list stiing_free_list. When a new Lisp_String is
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
807 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
808 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
809 we keep.
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
810
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
811 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
812 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
813 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
814
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
815 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
816 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
817 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
818 its sdata structure.
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
819
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
820 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
821 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
822 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
823 `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
824 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
825 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
826
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
827 /* 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
828 is 8192 minus malloc overhead. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
829
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
830 #define SBLOCK_SIZE 8188
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
831
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
832 /* 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
833 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
834
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
835 #define LARGE_STRING_BYTES 1024
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
836
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
837 /* 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
838 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
839
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
840 struct sdata
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
841 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
842 /* 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
843 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
844 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
845 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
846 (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
847 contents. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
848 struct Lisp_String *string;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
849
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
850 union
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
851 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
852 /* When STRING in non-null. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
853 unsigned char data[1];
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
854
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
855 /* When STRING is null. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
856 EMACS_INT nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
857 } u;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
858 };
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
859
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
860 /* 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
861 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
862 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
863 as large as needed. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
864
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
865 struct sblock
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
866 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
867 /* Next in list. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
868 struct sblock *next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
869
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
870 /* 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
871 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
872 struct sdata *next_free;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
873
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
874 /* Start of data. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
875 struct sdata first_data;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
876 };
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
877
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
878 /* 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
879 1024 minus malloc overhead. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
880
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
881 #define STRINGS_IN_STRING_BLOCK \
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
882 ((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
883
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
884 /* 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
885 are allocated. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
886
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
887 struct string_block
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
888 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
889 struct string_block *next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
890 struct Lisp_String strings[STRINGS_IN_STRING_BLOCK];
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
891 };
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
892
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
893 /* 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
894 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
895 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
896
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
897 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
898
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
899 /* List of sblocks for large strings. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
900
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
901 static struct sblock *large_sblocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
902
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
903 /* 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
904
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
905 static struct string_block *string_blocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
906 static int n_string_blocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
907
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
908 /* Free-list of Lisp_Strings. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
909
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
910 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
911
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
912 /* 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
913
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
914 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
915
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
916 /* 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
917
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
918 static int total_string_size;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
919
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
920 /* 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
921 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
922 free-list. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
923
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
924 #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
925
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
926 /* 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
927 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
928 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
929 structure starts at a constant offset in front of that. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
930
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
931 #define SDATA_OF_STRING(S) \
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
932 ((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
933
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
934 /* 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
935 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
936 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
937
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
938 #define SDATA_SIZE(NBYTES) \
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
939 ((sizeof (struct Lisp_String *) \
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
940 + (NBYTES) + 1 \
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
941 + sizeof (EMACS_INT) - 1) \
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
942 & ~(sizeof (EMACS_INT) - 1))
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
943
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
944
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
945 /* 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
946
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
947 void
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
948 init_strings ()
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
949 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
950 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
951 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
952 string_blocks = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
953 n_string_blocks = 0;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
954 string_free_list = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
955 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
956
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
957
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
958 /* Return a new Lisp_String. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
959
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
960 static struct Lisp_String *
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
961 allocate_string ()
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
962 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
963 struct Lisp_String *s;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
964
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
965 /* 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
966 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
967 if (string_free_list == NULL)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
968 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
969 struct string_block *b;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
970 int i;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
971
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
972 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
973 VALIDATE_LISP_STORAGE (b, sizeof *b);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
974 bzero (b, sizeof *b);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
975 b->next = string_blocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
976 string_blocks = b;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
977 ++n_string_blocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
978
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
979 for (i = STRINGS_IN_STRING_BLOCK - 1; i >= 0; --i)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
980 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
981 s = b->strings + i;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
982 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
983 string_free_list = s;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
984 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
985
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
986 total_free_strings += STRINGS_IN_STRING_BLOCK;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
987 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
988
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
989 /* 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
990 s = string_free_list;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
991 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
992
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
993 /* 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
994 bzero (s, sizeof *s);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
995
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
996 --total_free_strings;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
997 ++total_strings;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
998 ++strings_consed;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
999 consing_since_gc += sizeof *s;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1000
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1001 return s;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1002 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1003
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1004
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1005 /* 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
1006 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
1007 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
1008 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
1009 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
1010
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1011 void
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1012 allocate_string_data (s, nchars, nbytes)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1013 struct Lisp_String *s;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1014 int nchars, nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1015 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1016 struct sdata *data;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1017 struct sblock *b;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1018 int needed;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1019
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1020 /* 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
1021 of string data. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1022 needed = SDATA_SIZE (nbytes);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1023
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1024 if (nbytes > LARGE_STRING_BYTES)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1025 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1026 int size = sizeof *b - sizeof (struct sdata) + needed;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1027
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1028 #ifdef DOUG_LEA_MALLOC
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1029 /* Prevent mmap'ing the chunk (which is potentially very large). */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1030 mallopt (M_MMAP_MAX, 0);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1031 #endif
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1032
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1033 b = (struct sblock *) lisp_malloc (size, MEM_TYPE_NON_LISP);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1034
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1035 #ifdef DOUG_LEA_MALLOC
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1036 /* 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
1037 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
1038 #endif
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1039
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1040 b->next_free = &b->first_data;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1041 b->first_data.string = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1042 b->next = large_sblocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1043 large_sblocks = b;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1044 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1045 else if (current_sblock == NULL
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1046 || (((char *) current_sblock + SBLOCK_SIZE
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1047 - (char *) current_sblock->next_free)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1048 < needed))
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1049 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1050 /* 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
1051 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
1052 b->next_free = &b->first_data;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1053 b->first_data.string = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1054 b->next = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1055
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1056 if (current_sblock)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1057 current_sblock->next = b;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1058 else
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1059 oldest_sblock = b;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1060 current_sblock = b;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1061 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1062 else
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1063 b = current_sblock;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1064
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1065 /* If S had already data assigned, mark that as free by setting
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1066 its string back-pointer to null, and recording the size of
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1067 the data in it.. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1068 if (s->data)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1069 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1070 data = SDATA_OF_STRING (s);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1071 data->u.nbytes = GC_STRING_BYTES (s);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1072 data->string = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1073 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1074
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1075 data = b->next_free;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1076 data->string = s;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1077 s->data = data->u.data;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1078 s->size = nchars;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1079 s->size_byte = nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1080 s->data[nbytes] = '\0';
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1081 b->next_free = (struct sdata *) ((char *) data + needed);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1082
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1083 consing_since_gc += needed;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1084 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1085
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1086
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1087 /* Sweep and compact strings. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1088
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1089 static void
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1090 sweep_strings ()
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1091 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1092 struct string_block *b, *next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1093 struct string_block *live_blocks = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1094
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1095 string_free_list = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1096 total_strings = total_free_strings = 0;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1097 total_string_size = 0;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1098
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1099 /* 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
1100 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
1101 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1102 int i, nfree = 0;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1103 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
1104
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1105 next = b->next;
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 for (i = 0; i < STRINGS_IN_STRING_BLOCK; ++i)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1108 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1109 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
1110
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1111 if (s->data)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1112 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1113 /* 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
1114 if (STRING_MARKED_P (s))
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1115 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1116 /* 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
1117 UNMARK_STRING (s);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1118
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1119 if (!NULL_INTERVAL_P (s->intervals))
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1120 UNMARK_BALANCE_INTERVALS (s->intervals);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1121
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1122 ++total_strings;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1123 total_string_size += STRING_BYTES (s);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1124 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1125 else
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1126 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1127 /* 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
1128 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
1129
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1130 /* 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
1131 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
1132 back-pointer so that we know it's free. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1133 data->u.nbytes = GC_STRING_BYTES (s);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1134 data->string = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1135
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1136 /* 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
1137 know it's free. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1138 s->data = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1139
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1140 /* 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
1141 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
1142 string_free_list = s;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1143 ++nfree;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1144 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1145 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1146 else
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1147 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1148 /* 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
1149 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
1150 string_free_list = s;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1151 ++nfree;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1152 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1153 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1154
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1155 /* 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
1156 the first two of them. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1157 if (nfree == STRINGS_IN_STRING_BLOCK
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1158 && total_free_strings > STRINGS_IN_STRING_BLOCK)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1159 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1160 lisp_free (b);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1161 --n_string_blocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1162 string_free_list = free_list_before;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1163 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1164 else
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1165 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1166 total_free_strings += nfree;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1167 b->next = live_blocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1168 live_blocks = b;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1169 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1170 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1171
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1172 string_blocks = live_blocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1173 free_large_strings ();
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1174 compact_small_strings ();
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1175 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1176
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1177
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1178 /* Free dead large strings. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1179
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1180 static void
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1181 free_large_strings ()
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1182 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1183 struct sblock *b, *next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1184 struct sblock *live_blocks = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1185
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1186 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
1187 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1188 next = b->next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1189
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1190 if (b->first_data.string == NULL)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1191 lisp_free (b);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1192 else
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1193 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1194 b->next = live_blocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1195 live_blocks = b;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1196 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1197 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1198
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1199 large_sblocks = live_blocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1200 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1201
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1202
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1203 /* 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
1204 data of live strings after compaction. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1205
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1206 static void
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1207 compact_small_strings ()
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1208 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1209 struct sblock *b, *tb, *next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1210 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
1211 struct sdata *to_end, *from_end;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1212
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1213 /* 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
1214 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
1215 tb = oldest_sblock;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1216 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
1217 to = &tb->first_data;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1218
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1219 /* 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
1220 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
1221 copying will happen this way. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1222 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
1223 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1224 end = b->next_free;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1225 xassert ((char *) end <= (char *) b + SBLOCK_SIZE);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1226
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1227 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
1228 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1229 /* 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
1230 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
1231 int nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1232
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1233 if (from->string)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1234 nbytes = GC_STRING_BYTES (from->string);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1235 else
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1236 nbytes = from->u.nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1237
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1238 nbytes = SDATA_SIZE (nbytes);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1239 from_end = (struct sdata *) ((char *) from + nbytes);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1240
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1241 /* 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
1242 if (from->string)
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 /* 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
1245 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
1246 if (to_end > tb_end)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1247 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1248 tb->next_free = to;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1249 tb = tb->next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1250 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
1251 to = &tb->first_data;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1252 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
1253 }
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 /* 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
1256 if (from != to)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1257 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1258 bcopy (from, to, nbytes);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1259 to->string->data = to->u.data;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1260 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1261
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1262 /* 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
1263 to = to_end;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1264 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1265 }
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
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1268 /* 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
1269 we can free them. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1270 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
1271 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1272 next = b->next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1273 lisp_free (b);
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
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1276 tb->next_free = to;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1277 tb->next = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1278 current_sblock = tb;
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
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 DEFUN ("make-string", Fmake_string, Smake_string, 2, 2, 0,
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1283 "Return a newly created string of length LENGTH, with each element being INIT.\n\
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1284 Both LENGTH and INIT must be numbers.")
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1285 (length, init)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1286 Lisp_Object length, init;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1287 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1288 register Lisp_Object val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1289 register unsigned char *p, *end;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1290 int c, nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1291
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1292 CHECK_NATNUM (length, 0);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1293 CHECK_NUMBER (init, 1);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1294
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1295 c = XINT (init);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1296 if (SINGLE_BYTE_CHAR_P (c))
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1297 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1298 nbytes = XINT (length);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1299 val = make_uninit_string (nbytes);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1300 p = XSTRING (val)->data;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1301 end = p + XSTRING (val)->size;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1302 while (p != end)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1303 *p++ = c;
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 else
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1306 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1307 unsigned char str[4];
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1308 int len = CHAR_STRING (c, str);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1309
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1310 nbytes = len * XINT (length);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1311 val = make_uninit_multibyte_string (XINT (length), nbytes);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1312 p = XSTRING (val)->data;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1313 end = p + nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1314 while (p != end)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1315 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1316 bcopy (str, p, len);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1317 p += len;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1318 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1319 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1320
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1321 *p = 0;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1322 return val;
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
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1325
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1326 DEFUN ("make-bool-vector", Fmake_bool_vector, Smake_bool_vector, 2, 2, 0,
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1327 "Return a new bool-vector of length LENGTH, using INIT for as each element.\n\
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1328 LENGTH must be a number. INIT matters only in whether it is t or nil.")
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1329 (length, init)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1330 Lisp_Object length, init;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1331 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1332 register Lisp_Object val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1333 struct Lisp_Bool_Vector *p;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1334 int real_init, i;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1335 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
1336
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1337 CHECK_NATNUM (length, 0);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1338
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1339 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
1340
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1341 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
1342 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
1343
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1344 /* 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
1345 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
1346 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
1347 p = XBOOL_VECTOR (val);
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1348
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1349 /* 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
1350 p->vector_size = 0;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1351 XSETBOOL_VECTOR (val, p);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1352 p->size = XFASTINT (length);
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 real_init = (NILP (init) ? 0 : -1);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1355 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
1356 p->data[i] = real_init;
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1357
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1358 /* 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
1359 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
1360 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
1361 &= (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
1362
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1363 return val;
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
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 /* 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
1368 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
1369 multibyte, depending on the contents. */
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 Lisp_Object
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1372 make_string (contents, nbytes)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1373 char *contents;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1374 int nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1375 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1376 register Lisp_Object val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1377 int nchars = chars_in_text (contents, nbytes);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1378 val = make_uninit_multibyte_string (nchars, nbytes);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1379 bcopy (contents, XSTRING (val)->data, nbytes);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1380 if (STRING_BYTES (XSTRING (val)) == XSTRING (val)->size)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1381 SET_STRING_BYTES (XSTRING (val), -1);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1382 return val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1383 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1384
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1385
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1386 /* 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
1387
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1388 Lisp_Object
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1389 make_unibyte_string (contents, length)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1390 char *contents;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1391 int length;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1392 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1393 register Lisp_Object val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1394 val = make_uninit_string (length);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1395 bcopy (contents, XSTRING (val)->data, length);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1396 SET_STRING_BYTES (XSTRING (val), -1);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1397 return val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1398 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1399
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1400
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1401 /* 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
1402 bytes at CONTENTS. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1403
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1404 Lisp_Object
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1405 make_multibyte_string (contents, nchars, nbytes)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1406 char *contents;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1407 int nchars, nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1408 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1409 register Lisp_Object val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1410 val = make_uninit_multibyte_string (nchars, nbytes);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1411 bcopy (contents, XSTRING (val)->data, nbytes);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1412 return val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1413 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1414
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1415
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1416 /* 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
1417 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
1418
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1419 Lisp_Object
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1420 make_string_from_bytes (contents, nchars, nbytes)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1421 char *contents;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1422 int nchars, nbytes;
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 register Lisp_Object val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1425 val = make_uninit_multibyte_string (nchars, nbytes);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1426 bcopy (contents, XSTRING (val)->data, nbytes);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1427 if (STRING_BYTES (XSTRING (val)) == XSTRING (val)->size)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1428 SET_STRING_BYTES (XSTRING (val), -1);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1429 return val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1430 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1431
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1432
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1433 /* Make a 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
1434 CONTENTS. The argument MULTIBYTE controls whether to label the
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1435 string as multibyte. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1436
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1437 Lisp_Object
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1438 make_specified_string (contents, nchars, nbytes, multibyte)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1439 char *contents;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1440 int nchars, nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1441 int multibyte;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1442 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1443 register Lisp_Object val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1444 val = make_uninit_multibyte_string (nchars, nbytes);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1445 bcopy (contents, XSTRING (val)->data, nbytes);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1446 if (!multibyte)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1447 SET_STRING_BYTES (XSTRING (val), -1);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1448 return val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1449 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1450
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1451
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1452 /* 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
1453 data warrants. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1454
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1455 Lisp_Object
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1456 build_string (str)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1457 char *str;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1458 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1459 return make_string (str, strlen (str));
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1460 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1461
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1462
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1463 /* 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
1464 occupying LENGTH bytes. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1465
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1466 Lisp_Object
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1467 make_uninit_string (length)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1468 int length;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1469 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1470 Lisp_Object val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1471 val = make_uninit_multibyte_string (length, length);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1472 SET_STRING_BYTES (XSTRING (val), -1);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1473 return val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1474 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1475
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1476
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1477 /* 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
1478 which occupy NBYTES bytes. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1479
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1480 Lisp_Object
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1481 make_uninit_multibyte_string (nchars, nbytes)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1482 int nchars, nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1483 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1484 Lisp_Object string;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1485 struct Lisp_String *s;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1486
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1487 if (nchars < 0)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1488 abort ();
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1489
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1490 s = allocate_string ();
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1491 allocate_string_data (s, nchars, nbytes);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1492 XSETSTRING (string, s);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1493 string_chars_consed += nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1494 return string;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1495 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1496
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1497
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1498
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1499 /***********************************************************************
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1500 Float Allocation
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1501 ***********************************************************************/
1908
d649f2179d67 * alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents: 1893
diff changeset
1502
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1503 /* 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
1504 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
1505 by GC are put on a free list to be reallocated before allocating
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1506 any new float cells from the latest float_block.
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1507
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1508 Each float_block is just under 1020 bytes long, since malloc really
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1509 allocates in units of powers of two and uses 4 bytes for its own
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1510 overhead. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1511
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1512 #define FLOAT_BLOCK_SIZE \
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1513 ((1020 - sizeof (struct float_block *)) / sizeof (struct Lisp_Float))
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1514
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1515 struct float_block
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1516 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1517 struct float_block *next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1518 struct Lisp_Float floats[FLOAT_BLOCK_SIZE];
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1519 };
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1520
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1521 /* Current float_block. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1522
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1523 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
1524
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1525 /* 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
1526
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1527 int float_block_index;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1528
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1529 /* 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
1530
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1531 int n_float_blocks;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1532
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1533 /* 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
1534
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1535 struct Lisp_Float *float_free_list;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1536
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1537
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1538 /* Initialze float allocation. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1539
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1540 void
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1541 init_float ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1542 {
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1543 float_block = (struct float_block *) lisp_malloc (sizeof *float_block,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1544 MEM_TYPE_FLOAT);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1545 float_block->next = 0;
13320
e0f3a961851a Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents: 13219
diff changeset
1546 bzero ((char *) float_block->floats, sizeof float_block->floats);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1547 float_block_index = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1548 float_free_list = 0;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1549 n_float_blocks = 1;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1550 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1551
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1552
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1553 /* 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
1554
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21379
diff changeset
1555 void
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1556 free_float (ptr)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1557 struct Lisp_Float *ptr;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1558 {
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
1559 *(struct Lisp_Float **)&ptr->data = float_free_list;
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1560 #if GC_MARK_STACK
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1561 ptr->type = Vdead;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1562 #endif
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1563 float_free_list = ptr;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1564 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1565
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1566
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1567 /* 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
1568
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1569 Lisp_Object
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1570 make_float (float_value)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1571 double float_value;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1572 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1573 register Lisp_Object val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1574
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1575 if (float_free_list)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1576 {
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
1577 /* 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
1578 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
1579 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
1580 float_free_list = *(struct Lisp_Float **)&float_free_list->data;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1581 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1582 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1583 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1584 if (float_block_index == FLOAT_BLOCK_SIZE)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1585 {
12529
c7d32f5da2b3 (Flist): Rewritten.
Karl Heuer <kwzh@gnu.org>
parents: 12273
diff changeset
1586 register struct float_block *new;
c7d32f5da2b3 (Flist): Rewritten.
Karl Heuer <kwzh@gnu.org>
parents: 12273
diff changeset
1587
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1588 new = (struct float_block *) lisp_malloc (sizeof *new,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1589 MEM_TYPE_FLOAT);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1590 VALIDATE_LISP_STORAGE (new, sizeof *new);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1591 new->next = float_block;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1592 float_block = new;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1593 float_block_index = 0;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1594 n_float_blocks++;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1595 }
9261
e5ba7993d378 (VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents: 9144
diff changeset
1596 XSETFLOAT (val, &float_block->floats[float_block_index++]);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1597 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1598
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
1599 XFLOAT_DATA (val) = float_value;
9295
17d393a8eed6 (free_float, make_float, free_cons, Flist, Fvector, Fmake_byte_code,
Karl Heuer <kwzh@gnu.org>
parents: 9261
diff changeset
1600 XSETFASTINT (XFLOAT (val)->type, 0); /* bug chasing -wsr */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1601 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
1602 floats_consed++;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1603 return val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1604 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1605
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1606
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1607
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1608 /***********************************************************************
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1609 Cons Allocation
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1610 ***********************************************************************/
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1611
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1612 /* We store cons cells inside of cons_blocks, allocating a new
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1613 cons_block with malloc whenever necessary. Cons cells reclaimed by
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1614 GC are put on a free list to be reallocated before allocating
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1615 any new cons cells from the latest cons_block.
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1616
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1617 Each cons_block is just under 1020 bytes long,
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1618 since malloc really allocates in units of powers of two
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1619 and uses 4 bytes for its own overhead. */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1620
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1621 #define CONS_BLOCK_SIZE \
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1622 ((1020 - sizeof (struct cons_block *)) / sizeof (struct Lisp_Cons))
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1623
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1624 struct cons_block
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1625 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1626 struct cons_block *next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1627 struct Lisp_Cons conses[CONS_BLOCK_SIZE];
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1628 };
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1629
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1630 /* Current cons_block. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1631
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1632 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
1633
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1634 /* 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
1635
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1636 int cons_block_index;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1637
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1638 /* 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
1639
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1640 struct Lisp_Cons *cons_free_list;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1641
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1642 /* 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
1643
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1644 int n_cons_blocks;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1645
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1646
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1647 /* Initialize cons allocation. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1648
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1649 void
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1650 init_cons ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1651 {
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1652 cons_block = (struct cons_block *) lisp_malloc (sizeof *cons_block,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1653 MEM_TYPE_CONS);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1654 cons_block->next = 0;
13320
e0f3a961851a Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents: 13219
diff changeset
1655 bzero ((char *) cons_block->conses, sizeof cons_block->conses);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1656 cons_block_index = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1657 cons_free_list = 0;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1658 n_cons_blocks = 1;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1659 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1660
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1661
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1662 /* 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
1663
1dd0bd0749b5 (malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents: 20057
diff changeset
1664 void
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1665 free_cons (ptr)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1666 struct Lisp_Cons *ptr;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1667 {
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
1668 *(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
1669 #if GC_MARK_STACK
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1670 ptr->car = Vdead;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1671 #endif
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1672 cons_free_list = ptr;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1673 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1674
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1675
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1676 DEFUN ("cons", Fcons, Scons, 2, 2, 0,
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1677 "Create a new cons, give it CAR and CDR as components, and return it.")
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1678 (car, cdr)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1679 Lisp_Object car, cdr;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1680 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1681 register Lisp_Object val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1682
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1683 if (cons_free_list)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1684 {
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
1685 /* 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
1686 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
1687 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
1688 cons_free_list = *(struct Lisp_Cons **)&cons_free_list->cdr;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1689 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1690 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1691 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1692 if (cons_block_index == CONS_BLOCK_SIZE)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1693 {
12529
c7d32f5da2b3 (Flist): Rewritten.
Karl Heuer <kwzh@gnu.org>
parents: 12273
diff changeset
1694 register struct cons_block *new;
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1695 new = (struct cons_block *) lisp_malloc (sizeof *new,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1696 MEM_TYPE_CONS);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1697 VALIDATE_LISP_STORAGE (new, sizeof *new);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1698 new->next = cons_block;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1699 cons_block = new;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1700 cons_block_index = 0;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1701 n_cons_blocks++;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1702 }
9261
e5ba7993d378 (VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents: 9144
diff changeset
1703 XSETCONS (val, &cons_block->conses[cons_block_index++]);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1704 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1705
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
1706 XCAR (val) = car;
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
1707 XCDR (val) = cdr;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1708 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
1709 cons_cells_consed++;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1710 return val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1711 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1712
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1713
20849
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1714 /* 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
1715
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1716 Lisp_Object
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1717 list2 (arg1, arg2)
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1718 Lisp_Object arg1, arg2;
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1719 {
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1720 return Fcons (arg1, Fcons (arg2, Qnil));
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1721 }
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1722
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1723
20849
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1724 Lisp_Object
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1725 list3 (arg1, arg2, arg3)
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1726 Lisp_Object arg1, arg2, arg3;
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1727 {
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1728 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
1729 }
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1730
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1731
20849
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1732 Lisp_Object
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1733 list4 (arg1, arg2, arg3, arg4)
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1734 Lisp_Object arg1, arg2, arg3, arg4;
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1735 {
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1736 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
1737 }
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1738
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1739
20849
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1740 Lisp_Object
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1741 list5 (arg1, arg2, arg3, arg4, arg5)
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1742 Lisp_Object arg1, arg2, arg3, arg4, arg5;
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1743 {
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1744 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
1745 Fcons (arg5, Qnil)))));
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
1746 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1747
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1748
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1749 DEFUN ("list", Flist, Slist, 0, MANY, 0,
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1750 "Return a newly created list with specified arguments as elements.\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1751 Any number of arguments, even zero arguments, are allowed.")
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1752 (nargs, args)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1753 int nargs;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1754 register Lisp_Object *args;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1755 {
13610
8e82e46aa77b (Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents: 13553
diff changeset
1756 register Lisp_Object val;
8e82e46aa77b (Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents: 13553
diff changeset
1757 val = Qnil;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1758
13610
8e82e46aa77b (Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents: 13553
diff changeset
1759 while (nargs > 0)
8e82e46aa77b (Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents: 13553
diff changeset
1760 {
8e82e46aa77b (Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents: 13553
diff changeset
1761 nargs--;
8e82e46aa77b (Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents: 13553
diff changeset
1762 val = Fcons (args[nargs], val);
8e82e46aa77b (Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents: 13553
diff changeset
1763 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1764 return val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1765 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1766
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1767
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1768 DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0,
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1769 "Return a newly created list of length LENGTH, with each element being INIT.")
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1770 (length, init)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1771 register Lisp_Object length, init;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1772 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1773 register Lisp_Object val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1774 register int size;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1775
9953
e0672d4cf470 (Fmake_list, Fmake_vector, Fmake_string): Use CHECK_NATNUM instead of its
Karl Heuer <kwzh@gnu.org>
parents: 9942
diff changeset
1776 CHECK_NATNUM (length, 0);
e0672d4cf470 (Fmake_list, Fmake_vector, Fmake_string): Use CHECK_NATNUM instead of its
Karl Heuer <kwzh@gnu.org>
parents: 9942
diff changeset
1777 size = XFASTINT (length);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1778
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1779 val = Qnil;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1780 while (size-- > 0)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1781 val = Fcons (init, val);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1782 return val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1783 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1784
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1785
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1786
27142
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 Vector Allocation
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1789 ***********************************************************************/
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1790
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1791 /* 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
1792
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1793 struct Lisp_Vector *all_vectors;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1794
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1795 /* 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
1796
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1797 int n_vectors;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1798
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1799
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1800 /* 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
1801 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
1802
9968
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
1803 struct Lisp_Vector *
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
1804 allocate_vectorlike (len)
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
1805 EMACS_INT len;
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
1806 {
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
1807 struct Lisp_Vector *p;
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1808 int nbytes;
9968
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
1809
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
1810 #ifdef DOUG_LEA_MALLOC
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1811 /* Prevent mmap'ing the chunk (which is potentially very large).. */
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
1812 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
1813 #endif
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1814
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1815 nbytes = sizeof *p + (len - 1) * sizeof p->contents[0];
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1816 p = (struct Lisp_Vector *) lisp_malloc (nbytes, MEM_TYPE_VECTOR);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1817
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
1818 #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
1819 /* 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
1820 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
1821 #endif
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1822
9968
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
1823 VALIDATE_LISP_STORAGE (p, 0);
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1824 consing_since_gc += nbytes;
12748
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
1825 vector_cells_consed += len;
9968
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
1826
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
1827 p->next = all_vectors;
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
1828 all_vectors = p;
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1829 ++n_vectors;
9968
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
1830 return p;
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
1831 }
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
1832
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1833
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1834 DEFUN ("make-vector", Fmake_vector, Smake_vector, 2, 2, 0,
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1835 "Return a newly created vector of length LENGTH, with each element being INIT.\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1836 See also the function `vector'.")
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1837 (length, init)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1838 register Lisp_Object length, init;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1839 {
9968
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
1840 Lisp_Object vector;
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
1841 register EMACS_INT sizei;
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
1842 register int index;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1843 register struct Lisp_Vector *p;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1844
9953
e0672d4cf470 (Fmake_list, Fmake_vector, Fmake_string): Use CHECK_NATNUM instead of its
Karl Heuer <kwzh@gnu.org>
parents: 9942
diff changeset
1845 CHECK_NATNUM (length, 0);
e0672d4cf470 (Fmake_list, Fmake_vector, Fmake_string): Use CHECK_NATNUM instead of its
Karl Heuer <kwzh@gnu.org>
parents: 9942
diff changeset
1846 sizei = XFASTINT (length);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1847
9968
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
1848 p = allocate_vectorlike (sizei);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1849 p->size = sizei;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1850 for (index = 0; index < sizei; index++)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1851 p->contents[index] = init;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1852
9968
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
1853 XSETVECTOR (vector, p);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1854 return vector;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1855 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1856
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1857
13219
99b5164a319d (Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13150
diff changeset
1858 DEFUN ("make-char-table", Fmake_char_table, Smake_char_table, 1, 2, 0,
13322
336cbb88a1e3 (Fmake_char_table): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 13320
diff changeset
1859 "Return a newly created char-table, with purpose PURPOSE.\n\
13141
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
1860 Each element is initialized to INIT, which defaults to nil.\n\
16479
52eaaf1cc0e3 (Fmake_char_table): Doc fix.
Erik Naggum <erik@naggum.no>
parents: 16231
diff changeset
1861 PURPOSE should be a symbol which has a `char-table-extra-slots' property.\n\
13219
99b5164a319d (Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13150
diff changeset
1862 The property's value should be an integer between 0 and 10.")
99b5164a319d (Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13150
diff changeset
1863 (purpose, init)
99b5164a319d (Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13150
diff changeset
1864 register Lisp_Object purpose, init;
13141
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
1865 {
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
1866 Lisp_Object vector;
13219
99b5164a319d (Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13150
diff changeset
1867 Lisp_Object n;
99b5164a319d (Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13150
diff changeset
1868 CHECK_SYMBOL (purpose, 1);
17328
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
1869 n = Fget (purpose, Qchar_table_extra_slots);
13219
99b5164a319d (Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13150
diff changeset
1870 CHECK_NUMBER (n, 0);
13141
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
1871 if (XINT (n) < 0 || XINT (n) > 10)
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
1872 args_out_of_range (n, Qnil);
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
1873 /* 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
1874 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
1875 init);
17328
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
1876 XCHAR_TABLE (vector)->top = Qt;
13150
3778c95adca9 (Fmake_char_table): Initialize parent to nil.
Erik Naggum <erik@naggum.no>
parents: 13141
diff changeset
1877 XCHAR_TABLE (vector)->parent = Qnil;
13219
99b5164a319d (Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13150
diff changeset
1878 XCHAR_TABLE (vector)->purpose = purpose;
13141
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
1879 XSETCHAR_TABLE (vector, XCHAR_TABLE (vector));
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
1880 return vector;
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
1881 }
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
1882
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1883
17328
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
1884 /* 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
1885 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
1886 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
1887
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
1888 Lisp_Object
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
1889 make_sub_char_table (defalt)
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
1890 Lisp_Object defalt;
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
1891 {
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
1892 Lisp_Object vector
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
1893 = 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
1894 XCHAR_TABLE (vector)->top = Qnil;
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
1895 XCHAR_TABLE (vector)->defalt = defalt;
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
1896 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
1897 return vector;
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
1898 }
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
1899
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1900
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1901 DEFUN ("vector", Fvector, Svector, 0, MANY, 0,
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1902 "Return a newly created vector with specified arguments as elements.\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1903 Any number of arguments, even zero arguments, are allowed.")
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1904 (nargs, args)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1905 register int nargs;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1906 Lisp_Object *args;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1907 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1908 register Lisp_Object len, val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1909 register int index;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1910 register struct Lisp_Vector *p;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1911
9295
17d393a8eed6 (free_float, make_float, free_cons, Flist, Fvector, Fmake_byte_code,
Karl Heuer <kwzh@gnu.org>
parents: 9261
diff changeset
1912 XSETFASTINT (len, nargs);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1913 val = Fmake_vector (len, Qnil);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1914 p = XVECTOR (val);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1915 for (index = 0; index < nargs; index++)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1916 p->contents[index] = args[index];
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1917 return val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1918 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1919
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1920
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1921 DEFUN ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0,
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1922 "Create a byte-code object with specified arguments as elements.\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1923 The arguments should be the arglist, bytecode-string, constant vector,\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1924 stack size, (optional) doc string, and (optional) interactive spec.\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1925 The first four arguments are required; at most six have any\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1926 significance.")
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1927 (nargs, args)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1928 register int nargs;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1929 Lisp_Object *args;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1930 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1931 register Lisp_Object len, val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1932 register int index;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1933 register struct Lisp_Vector *p;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1934
9295
17d393a8eed6 (free_float, make_float, free_cons, Flist, Fvector, Fmake_byte_code,
Karl Heuer <kwzh@gnu.org>
parents: 9261
diff changeset
1935 XSETFASTINT (len, nargs);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 434
diff changeset
1936 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
1937 val = make_pure_vector ((EMACS_INT) nargs);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1938 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1939 val = Fmake_vector (len, Qnil);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1940 p = XVECTOR (val);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1941 for (index = 0; index < nargs; index++)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1942 {
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 434
diff changeset
1943 if (!NILP (Vpurify_flag))
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1944 args[index] = Fpurecopy (args[index]);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1945 p->contents[index] = args[index];
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1946 }
18104
b2a669ef69b1 (Fmake_byte_code): Set val from p, not from val.
Richard M. Stallman <rms@gnu.org>
parents: 18010
diff changeset
1947 XSETCOMPILED (val, p);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1948 return val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1949 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1950
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1951
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1952
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1953 /***********************************************************************
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1954 Symbol Allocation
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1955 ***********************************************************************/
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1956
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1957 /* 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
1958 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
1959 own overhead. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1960
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1961 #define SYMBOL_BLOCK_SIZE \
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1962 ((1020 - sizeof (struct symbol_block *)) / sizeof (struct Lisp_Symbol))
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1963
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1964 struct symbol_block
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1965 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1966 struct symbol_block *next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1967 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
1968 };
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1969
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1970 /* 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
1971 structure in it. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1972
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1973 struct symbol_block *symbol_block;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1974 int symbol_block_index;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1975
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1976 /* List of free symbols. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1977
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1978 struct Lisp_Symbol *symbol_free_list;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1979
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1980 /* 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
1981
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1982 int n_symbol_blocks;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1983
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1984
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1985 /* Initialize symbol allocation. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1986
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1987 void
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1988 init_symbol ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1989 {
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1990 symbol_block = (struct symbol_block *) lisp_malloc (sizeof *symbol_block,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1991 MEM_TYPE_SYMBOL);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1992 symbol_block->next = 0;
13320
e0f3a961851a Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents: 13219
diff changeset
1993 bzero ((char *) symbol_block->symbols, sizeof symbol_block->symbols);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1994 symbol_block_index = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1995 symbol_free_list = 0;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1996 n_symbol_blocks = 1;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1997 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1998
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1999
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2000 DEFUN ("make-symbol", Fmake_symbol, Smake_symbol, 1, 1, 0,
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2001 "Return a newly allocated uninterned symbol whose name is NAME.\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2002 Its value and function definition are void, and its property list is nil.")
14093
338f645e6b9a (Fmake_symbol): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
2003 (name)
338f645e6b9a (Fmake_symbol): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
2004 Lisp_Object name;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2005 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2006 register Lisp_Object val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2007 register struct Lisp_Symbol *p;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2008
14093
338f645e6b9a (Fmake_symbol): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
2009 CHECK_STRING (name, 0);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2010
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2011 if (symbol_free_list)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2012 {
9261
e5ba7993d378 (VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents: 9144
diff changeset
2013 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
2014 symbol_free_list = *(struct Lisp_Symbol **)&symbol_free_list->value;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2015 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2016 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2017 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2018 if (symbol_block_index == SYMBOL_BLOCK_SIZE)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2019 {
12529
c7d32f5da2b3 (Flist): Rewritten.
Karl Heuer <kwzh@gnu.org>
parents: 12273
diff changeset
2020 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
2021 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
2022 MEM_TYPE_SYMBOL);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2023 VALIDATE_LISP_STORAGE (new, sizeof *new);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2024 new->next = symbol_block;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2025 symbol_block = new;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2026 symbol_block_index = 0;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
2027 n_symbol_blocks++;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2028 }
9261
e5ba7993d378 (VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents: 9144
diff changeset
2029 XSETSYMBOL (val, &symbol_block->symbols[symbol_block_index++]);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2030 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2031
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2032 p = XSYMBOL (val);
14095
d612434249db (Fmake_symbol): Harmonize arguments with documentation (correctly).
Erik Naggum <erik@naggum.no>
parents: 14093
diff changeset
2033 p->name = XSTRING (name);
16223
bab3f12493b6 (Fmake_symbol): Initialize `obarray' field.
Erik Naggum <erik@naggum.no>
parents: 16101
diff changeset
2034 p->obarray = Qnil;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2035 p->plist = Qnil;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2036 p->value = Qunbound;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2037 p->function = Qunbound;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2038 p->next = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2039 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
2040 symbols_consed++;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2041 return val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2042 }
27142
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
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2045
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2046 /***********************************************************************
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2047 Marker (Misc) Allocation
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
9437
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
2050 /* Allocation of markers and other objects that share that structure.
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2051 Works like allocation of conses. */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2052
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2053 #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
2054 ((1020 - sizeof (struct marker_block *)) / sizeof (union Lisp_Misc))
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2055
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2056 struct marker_block
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
2057 {
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2058 struct marker_block *next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2059 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
2060 };
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2061
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2062 struct marker_block *marker_block;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2063 int marker_block_index;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2064
9437
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
2065 union Lisp_Misc *marker_free_list;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2066
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
2067 /* 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
2068
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
2069 int n_marker_blocks;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
2070
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2071 void
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2072 init_marker ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2073 {
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2074 marker_block = (struct marker_block *) lisp_malloc (sizeof *marker_block,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2075 MEM_TYPE_MISC);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2076 marker_block->next = 0;
13320
e0f3a961851a Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents: 13219
diff changeset
2077 bzero ((char *) marker_block->markers, sizeof marker_block->markers);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2078 marker_block_index = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2079 marker_free_list = 0;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
2080 n_marker_blocks = 1;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2081 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2082
9437
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
2083 /* 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
2084
9437
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
2085 Lisp_Object
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
2086 allocate_misc ()
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
2087 {
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
2088 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
2089
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
2090 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
2091 {
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
2092 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
2093 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
2094 }
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
2095 else
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
2096 {
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
2097 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
2098 {
12529
c7d32f5da2b3 (Flist): Rewritten.
Karl Heuer <kwzh@gnu.org>
parents: 12273
diff changeset
2099 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
2100 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
2101 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
2102 VALIDATE_LISP_STORAGE (new, sizeof *new);
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
2103 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
2104 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
2105 marker_block_index = 0;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
2106 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
2107 }
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
2108 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
2109 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2110
9437
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
2111 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
2112 misc_objects_consed++;
9437
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
2113 return val;
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
2114 }
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
2115
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2116 DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0,
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2117 "Return a newly allocated marker which does not point at any place.")
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2118 ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2119 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2120 register Lisp_Object val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2121 register struct Lisp_Marker *p;
638
40b255f55df3 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 624
diff changeset
2122
9437
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
2123 val = allocate_misc ();
11243
054ecfce1820 (Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents: 11048
diff changeset
2124 XMISCTYPE (val) = Lisp_Misc_Marker;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2125 p = XMARKER (val);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2126 p->buffer = 0;
20565
aa9b7c5f0f62 (Fmake_marker): Initialize marker's bytepos and charpos.
Richard M. Stallman <rms@gnu.org>
parents: 20495
diff changeset
2127 p->bytepos = 0;
aa9b7c5f0f62 (Fmake_marker): Initialize marker's bytepos and charpos.
Richard M. Stallman <rms@gnu.org>
parents: 20495
diff changeset
2128 p->charpos = 0;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2129 p->chain = Qnil;
13008
f042ef632b22 (Fmake_marker): Initialize insertion_type to 0.
Richard M. Stallman <rms@gnu.org>
parents: 12748
diff changeset
2130 p->insertion_type = 0;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2131 return val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2132 }
19332
58f14958f5d5 (free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents: 18621
diff changeset
2133
58f14958f5d5 (free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents: 18621
diff changeset
2134 /* 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
2135
20375
1dd0bd0749b5 (malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents: 20057
diff changeset
2136 void
19332
58f14958f5d5 (free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents: 18621
diff changeset
2137 free_marker (marker)
58f14958f5d5 (free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents: 18621
diff changeset
2138 Lisp_Object marker;
58f14958f5d5 (free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents: 18621
diff changeset
2139 {
19621
74151390752c (free_marker): Call unchain_marker.
Richard M. Stallman <rms@gnu.org>
parents: 19332
diff changeset
2140 unchain_marker (marker);
74151390752c (free_marker): Call unchain_marker.
Richard M. Stallman <rms@gnu.org>
parents: 19332
diff changeset
2141
19332
58f14958f5d5 (free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents: 18621
diff changeset
2142 XMISC (marker)->u_marker.type = Lisp_Misc_Free;
58f14958f5d5 (free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents: 18621
diff changeset
2143 XMISC (marker)->u_free.chain = marker_free_list;
58f14958f5d5 (free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents: 18621
diff changeset
2144 marker_free_list = XMISC (marker);
58f14958f5d5 (free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents: 18621
diff changeset
2145
58f14958f5d5 (free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents: 18621
diff changeset
2146 total_free_markers++;
58f14958f5d5 (free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents: 18621
diff changeset
2147 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2148
21258
693573ac0944 (make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21244
diff changeset
2149
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2150 /* 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
2151 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
2152 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
2153
e2a164ac4088 (Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
2154 Any number of arguments, even zero arguments, are allowed. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2155
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2156 Lisp_Object
2013
e2a164ac4088 (Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
2157 make_event_array (nargs, args)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2158 register int nargs;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2159 Lisp_Object *args;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2160 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2161 int i;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2162
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2163 for (i = 0; i < nargs; i++)
2013
e2a164ac4088 (Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
2164 /* 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
2165 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
2166 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
2167 if (!INTEGERP (args[i])
3536
58d5ee6ec253 (make_event_array): Ignore bits above CHAR_META.
Richard M. Stallman <rms@gnu.org>
parents: 3181
diff changeset
2168 || (XUINT (args[i]) & ~(-CHAR_META)) >= 0200)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2169 return Fvector (nargs, args);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2170
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2171 /* Since the loop exited, we know that all the things in it are
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2172 characters, so we can make a string. */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2173 {
6492
8372dce85f8a (make_event_array): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents: 6227
diff changeset
2174 Lisp_Object result;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2175
18104
b2a669ef69b1 (Fmake_byte_code): Set val from p, not from val.
Richard M. Stallman <rms@gnu.org>
parents: 18010
diff changeset
2176 result = Fmake_string (make_number (nargs), make_number (0));
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2177 for (i = 0; i < nargs; i++)
2013
e2a164ac4088 (Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
2178 {
e2a164ac4088 (Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
2179 XSTRING (result)->data[i] = XINT (args[i]);
e2a164ac4088 (Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
2180 /* 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
2181 if (XINT (args[i]) & CHAR_META)
e2a164ac4088 (Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
2182 XSTRING (result)->data[i] |= 0x80;
e2a164ac4088 (Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
2183 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2184
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2185 return result;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2186 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2187 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2188
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2189
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2190
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2191 /************************************************************************
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2192 C Stack Marking
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2193 ************************************************************************/
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2194
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2195 #if GC_MARK_STACK
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
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2198 /* Base address of stack. Set in main. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2199
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2200 Lisp_Object *stack_base;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2201
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2202 /* A node in the red-black tree describing allocated memory containing
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2203 Lisp data. Each such block is recorded with its start and end
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2204 address when it is allocated, and removed from the tree when it
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2205 is freed.
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2206
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2207 A red-black tree is a balanced binary tree with the following
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2208 properties:
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2209
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2210 1. Every node is either red or black.
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2211 2. Every leaf is black.
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2212 3. If a node is red, then both of its children are black.
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2213 4. Every simple path from a node to a descendant leaf contains
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2214 the same number of black nodes.
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2215 5. The root is always black.
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2216
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2217 When nodes are inserted into the tree, or deleted from the tree,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2218 the tree is "fixed" so that these properties are always true.
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2219
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2220 A red-black tree with N internal nodes has height at most 2
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2221 log(N+1). Searches, insertions and deletions are done in O(log N).
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2222 Please see a text book about data structures for a detailed
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2223 description of red-black trees. Any book worth its salt should
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2224 describe them. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2225
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2226 struct mem_node
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2227 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2228 struct mem_node *left, *right, *parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2229
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2230 /* Start and end of allocated region. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2231 void *start, *end;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2232
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2233 /* Node color. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2234 enum {MEM_BLACK, MEM_RED} color;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2235
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2236 /* Memory type. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2237 enum mem_type type;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2238 };
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2239
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2240 /* Root of the tree describing allocated Lisp memory. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2241
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2242 static struct mem_node *mem_root;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2243
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2244 /* Sentinel node of the tree. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2245
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2246 static struct mem_node mem_z;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2247 #define MEM_NIL &mem_z
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2248
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2249
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2250 /* 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
2251
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2252 static void
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2253 mem_init ()
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2254 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2255 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
2256 mem_z.parent = NULL;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2257 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
2258 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
2259 mem_root = MEM_NIL;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2260 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2261
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2262
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2263 /* 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
2264 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
2265
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2266 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
2267 mem_find (start)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2268 void *start;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2269 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2270 struct mem_node *p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2271
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2272 /* 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
2273 mem_z.start = start;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2274 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
2275
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2276 p = mem_root;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2277 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
2278 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
2279 return p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2280 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2281
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2282
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2283 /* 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
2284 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
2285 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
2286
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2287 static struct mem_node *
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2288 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
2289 void *start, *end;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2290 enum mem_type type;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2291 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2292 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
2293
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2294 /* 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
2295 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
2296 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
2297 c = mem_root;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2298 parent = NULL;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2299
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2300 #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
2301
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2302 while (c != MEM_NIL)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2303 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2304 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
2305 abort ();
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2306 parent = c;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2307 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
2308 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2309
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2310 #else /* GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2311
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2312 while (c != MEM_NIL)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2313 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2314 parent = c;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2315 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
2316 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2317
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2318 #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
2319
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2320 /* Create a new node. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2321 x = (struct mem_node *) xmalloc (sizeof *x);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2322 x->start = start;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2323 x->end = end;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2324 x->type = type;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2325 x->parent = parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2326 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
2327 x->color = MEM_RED;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2328
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2329 /* 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
2330 if (parent)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2331 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2332 if (start < parent->start)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2333 parent->left = x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2334 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2335 parent->right = x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2336 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2337 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2338 mem_root = x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2339
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2340 /* 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
2341 mem_insert_fixup (x);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2342 return x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2343 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2344
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2345
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2346 /* 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
2347 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
2348
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2349 static void
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2350 mem_insert_fixup (x)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2351 struct mem_node *x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2352 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2353 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
2354 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2355 /* 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
2356 red-black tree property #3. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2357
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2358 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
2359 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2360 /* 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
2361 "uncle". */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2362 struct mem_node *y = x->parent->parent->right;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2363
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2364 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
2365 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2366 /* 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
2367 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
2368 with the grandparent. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2369 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
2370 y->color = MEM_BLACK;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2371 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
2372 x = x->parent->parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2373 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2374 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2375 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2376 /* 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
2377 red, uncle is black. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2378 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
2379 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2380 x = x->parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2381 mem_rotate_left (x);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2382 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2383
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2384 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
2385 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
2386 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
2387 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2388 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2389 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2390 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2391 /* 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
2392 struct mem_node *y = x->parent->parent->left;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2393
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2394 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
2395 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2396 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
2397 y->color = MEM_BLACK;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2398 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
2399 x = x->parent->parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2400 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2401 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2402 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2403 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
2404 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2405 x = x->parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2406 mem_rotate_right (x);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2407 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2408
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2409 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
2410 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
2411 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
2412 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2413 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2414 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2415
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2416 /* 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
2417 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
2418 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
2419 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2420
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2421
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2422 /* (x) (y)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2423 / \ / \
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2424 a (y) ===> (x) c
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2425 / \ / \
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2426 b c a b */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2427
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2428 static void
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2429 mem_rotate_left (x)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2430 struct mem_node *x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2431 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2432 struct mem_node *y;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2433
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2434 /* 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
2435 y = x->right;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2436 x->right = y->left;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2437 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
2438 y->left->parent = x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2439
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2440 /* 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
2441 if (y != MEM_NIL)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2442 y->parent = x->parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2443
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2444 /* 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
2445 if (x->parent)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2446 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2447 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
2448 x->parent->left = y;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2449 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2450 x->parent->right = y;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2451 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2452 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2453 mem_root = y;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2454
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2455 /* 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
2456 y->left = x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2457 if (x != MEM_NIL)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2458 x->parent = y;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2459 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2460
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2461
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2462 /* (x) (Y)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2463 / \ / \
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2464 (y) c ===> a (x)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2465 / \ / \
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2466 a b b c */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2467
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2468 static void
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2469 mem_rotate_right (x)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2470 struct mem_node *x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2471 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2472 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
2473
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2474 x->left = y->right;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2475 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
2476 y->right->parent = x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2477
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2478 if (y != MEM_NIL)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2479 y->parent = x->parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2480 if (x->parent)
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 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
2483 x->parent->right = y;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2484 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2485 x->parent->left = y;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2486 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2487 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2488 mem_root = y;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2489
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2490 y->right = x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2491 if (x != MEM_NIL)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2492 x->parent = y;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2493 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2494
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2495
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2496 /* 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
2497
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2498 static void
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2499 mem_delete (z)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2500 struct mem_node *z;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2501 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2502 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
2503
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2504 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
2505 return;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2506
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2507 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
2508 y = z;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2509 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2510 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2511 y = z->right;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2512 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
2513 y = y->left;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2514 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2515
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2516 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
2517 x = y->left;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2518 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2519 x = y->right;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2520
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2521 x->parent = y->parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2522 if (y->parent)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2523 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2524 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
2525 y->parent->left = x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2526 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2527 y->parent->right = x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2528 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2529 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2530 mem_root = x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2531
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2532 if (y != z)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2533 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2534 z->start = y->start;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2535 z->end = y->end;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2536 z->type = y->type;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2537 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2538
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2539 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
2540 mem_delete_fixup (x);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2541 xfree (y);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2542 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2543
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2544
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2545 /* 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
2546 deletion. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2547
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2548 static void
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2549 mem_delete_fixup (x)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2550 struct mem_node *x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2551 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2552 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
2553 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2554 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
2555 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2556 struct mem_node *w = x->parent->right;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2557
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2558 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
2559 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2560 w->color = MEM_BLACK;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2561 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
2562 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
2563 w = x->parent->right;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2564 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2565
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2566 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
2567 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2568 w->color = MEM_RED;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2569 x = x->parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2570 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2571 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2572 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2573 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
2574 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2575 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
2576 w->color = MEM_RED;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2577 mem_rotate_right (w);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2578 w = x->parent->right;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2579 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2580 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
2581 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
2582 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
2583 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
2584 x = mem_root;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2585 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2586 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2587 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2588 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2589 struct mem_node *w = x->parent->left;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2590
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2591 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
2592 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2593 w->color = MEM_BLACK;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2594 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
2595 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
2596 w = x->parent->left;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2597 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2598
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2599 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
2600 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2601 w->color = MEM_RED;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2602 x = x->parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2603 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2604 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2605 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2606 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
2607 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2608 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
2609 w->color = MEM_RED;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2610 mem_rotate_left (w);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2611 w = x->parent->left;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2612 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2613
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2614 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
2615 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
2616 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
2617 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
2618 x = mem_root;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2619 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2620 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2621 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2622
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2623 x->color = MEM_BLACK;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2624 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2625
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2626
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2627 /* 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
2628 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
2629
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2630 static INLINE int
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2631 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
2632 struct mem_node *m;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2633 void *p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2634 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2635 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
2636 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2637 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
2638 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
2639
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2640 /* 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
2641 must not be on the free-list. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2642 return (offset % sizeof b->strings[0] == 0
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2643 && ((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
2644 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2645 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2646 return 0;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2647 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2648
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2649
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2650 /* 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
2651 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
2652
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2653 static INLINE int
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2654 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
2655 struct mem_node *m;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2656 void *p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2657 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2658 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
2659 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2660 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
2661 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
2662
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2663 /* 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
2664 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
2665 and not be on the free-list. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2666 return (offset % sizeof b->conses[0] == 0
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2667 && (b != cons_block
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2668 || 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
2669 && !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
2670 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2671 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2672 return 0;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2673 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2674
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2675
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2676 /* 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
2677 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
2678
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2679 static INLINE int
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2680 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
2681 struct mem_node *m;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2682 void *p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2683 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2684 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
2685 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2686 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
2687 int offset = (char *) p - (char *) &b->symbols[0];
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2688
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2689 /* 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
2690 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
2691 and not be on the free-list. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2692 return (offset % sizeof b->symbols[0] == 0
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2693 && (b != symbol_block
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2694 || 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
2695 && !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
2696 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2697 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2698 return 0;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2699 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2700
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2701
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2702 /* 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
2703 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
2704
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2705 static INLINE int
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2706 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
2707 struct mem_node *m;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2708 void *p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2709 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2710 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
2711 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2712 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
2713 int offset = (char *) p - (char *) &b->floats[0];
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2714
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2715 /* P must point to the start of a Lisp_Float, not be
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2716 one of the unused cells in the current float block,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2717 and not be on the free-list. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2718 return (offset % sizeof b->floats[0] == 0
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2719 && (b != float_block
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2720 || offset / sizeof b->floats[0] < float_block_index)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2721 && !EQ (((struct Lisp_Float *) p)->type, Vdead));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2722 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2723 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2724 return 0;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2725 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2726
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2727
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2728 /* 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
2729 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
2730
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2731 static INLINE int
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2732 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
2733 struct mem_node *m;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2734 void *p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2735 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2736 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
2737 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2738 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
2739 int offset = (char *) p - (char *) &b->markers[0];
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2740
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2741 /* 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
2742 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
2743 and not be on the free-list. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2744 return (offset % sizeof b->markers[0] == 0
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2745 && (b != marker_block
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2746 || 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
2747 && ((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
2748 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2749 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2750 return 0;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2751 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2752
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2753
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2754 /* 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
2755 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
2756
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2757 static INLINE int
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2758 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
2759 struct mem_node *m;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2760 void *p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2761 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2762 return m->type == MEM_TYPE_VECTOR && p == m->start;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2763 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2764
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2765
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2766 /* Value is non-zero of P is a pointer to a live buffer. M is a
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2767 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
2768
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2769 static INLINE int
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2770 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
2771 struct mem_node *m;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2772 void *p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2773 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2774 /* 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
2775 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
2776 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
2777 && p == m->start
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2778 && !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
2779 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2780
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2781
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2782 #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
2783
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2784 /* 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
2785 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
2786
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2787 #define MAX_ZOMBIES 10
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2788 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
2789
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2790 /* Number of zombie objects. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2791
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2792 static int nzombies;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2793
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2794 /* Number of garbage collections. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2795
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2796 static int ngcs;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2797
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2798 /* 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
2799
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2800 static double avg_zombies;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2801
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2802 /* 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
2803
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2804 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
2805
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2806 /* 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
2807
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2808 static double avg_live;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2809
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2810 DEFUN ("gc-status", Fgc_status, Sgc_status, 0, 0, "",
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2811 "Show information about live and zombie objects.")
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2812 ()
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2813 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2814 Lisp_Object args[7];
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2815 args[0] = build_string ("%d GCs, avg live/zombies = %.2f/%.2f (%f%%), max %d/%d");
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2816 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
2817 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
2818 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
2819 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
2820 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
2821 args[6] = make_number (max_zombies);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2822 return Fmessage (7, args);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2823 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2824
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2825 #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
2826
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2827
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2828 /* 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
2829
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2830 static INLINE void
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2831 mark_maybe_object (obj)
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2832 Lisp_Object obj;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2833 {
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2834 void *po = (void *) XPNTR (obj);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2835 struct mem_node *m = mem_find (po);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2836
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2837 if (m != MEM_NIL)
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2838 {
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2839 int mark_p = 0;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2840
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2841 switch (XGCTYPE (obj))
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2842 {
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2843 case Lisp_String:
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2844 mark_p = (live_string_p (m, po)
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2845 && !STRING_MARKED_P ((struct Lisp_String *) po));
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2846 break;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2847
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2848 case Lisp_Cons:
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2849 mark_p = (live_cons_p (m, po)
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2850 && !XMARKBIT (XCONS (obj)->car));
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2851 break;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2852
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2853 case Lisp_Symbol:
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2854 mark_p = (live_symbol_p (m, po)
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2855 && !XMARKBIT (XSYMBOL (obj)->plist));
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2856 break;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2857
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2858 case Lisp_Float:
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2859 mark_p = (live_float_p (m, po)
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2860 && !XMARKBIT (XFLOAT (obj)->type));
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2861 break;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2862
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2863 case Lisp_Vectorlike:
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2864 /* 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
2865 buffer because checking that dereferences the pointer
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2866 PO which might point anywhere. */
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2867 if (live_vector_p (m, po))
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2868 mark_p = (!GC_SUBRP (obj)
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2869 && !(XVECTOR (obj)->size & ARRAY_MARK_FLAG));
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2870 else if (live_buffer_p (m, po))
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2871 mark_p = GC_BUFFERP (obj) && !XMARKBIT (XBUFFER (obj)->name);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2872 break;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2873
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2874 case Lisp_Misc:
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2875 if (live_misc_p (m, po))
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2876 {
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2877 switch (XMISCTYPE (obj))
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2878 {
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2879 case Lisp_Misc_Marker:
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2880 mark_p = !XMARKBIT (XMARKER (obj)->chain);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2881 break;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2882
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2883 case Lisp_Misc_Buffer_Local_Value:
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2884 case Lisp_Misc_Some_Buffer_Local_Value:
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2885 mark_p = !XMARKBIT (XBUFFER_LOCAL_VALUE (obj)->realvalue);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2886 break;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2887
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2888 case Lisp_Misc_Overlay:
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2889 mark_p = !XMARKBIT (XOVERLAY (obj)->plist);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2890 break;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2891 }
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2892 }
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2893 break;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2894 }
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2895
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2896 if (mark_p)
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2897 {
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2898 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2899 if (nzombies < MAX_ZOMBIES)
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2900 zombies[nzombies] = *p;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2901 ++nzombies;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2902 #endif
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2903 mark_object (&obj);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2904 }
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2905 }
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2906 }
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2907
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2908 /* Mark Lisp objects in the address range START..END. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2909
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2910 static void
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2911 mark_memory (start, end)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2912 void *start, *end;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2913 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2914 Lisp_Object *p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2915
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2916 #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
2917 nzombies = 0;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2918 #endif
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2919
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2920 /* 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
2921 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
2922 if (end < start)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2923 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2924 void *tem = start;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2925 start = end;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2926 end = tem;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2927 }
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2928
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2929 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
2930 mark_maybe_object (*p);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2931 }
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2932
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2933
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2934 #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
2935
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2936 static int setjmp_tested_p, longjmps_done;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2937
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2938 #define SETJMP_WILL_LIKELY_WORK "\
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2939 \n\
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2940 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
2941 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
2942 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
2943 \n\
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2944 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
2945 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
2946 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
2947 \n\
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2948 Please mail the result to <gerd@gnu.org>.\n\
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2949 "
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2950
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2951 #define SETJMP_WILL_NOT_WORK "\
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2952 \n\
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2953 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
2954 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
2955 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
2956 solution for your system.\n\
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2957 \n\
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2958 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
2959 try to find a way to make it work on your system.\n\
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2960 Please mail the result to <gerd@gnu.org>.\n\
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2961 "
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2962
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2963
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2964 /* 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
2965 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
2966 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
2967 conservative stack marking. Only the sources or a disassembly
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2968 can prove that. */
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2969
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2970 static void
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2971 test_setjmp ()
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2972 {
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2973 char buf[10];
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2974 register int x;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2975 jmp_buf jbuf;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2976 int result = 0;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2977
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2978 /* Arrange for X to be put in a register. */
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2979 sprintf (buf, "1");
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2980 x = strlen (buf);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2981 x = 2 * x - 1;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2982
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2983 setjmp (jbuf);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2984 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
2985 {
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2986 /* 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
2987
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2988 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
2989 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
2990 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
2991 isn't sure.
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2992
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2993 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
2994 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
2995
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2996 if (x == 1)
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2997 fprintf (stderr, SETJMP_WILL_LIKELY_WORK);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
2998 else
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2999 {
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3000 fprintf (stderr, SETJMP_WILL_NOT_WORK);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3001 exit (1);
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3002 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3003 }
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3004
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3005 ++longjmps_done;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3006 x = 2;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3007 if (longjmps_done == 1)
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3008 longjmp (jbuf, 1);
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3009 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3010
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3011 #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
3012
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3013
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3014 #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
3015
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3016 /* 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
3017
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3018 static void
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3019 check_gcpros ()
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3020 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3021 struct gcpro *p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3022 int i;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3023
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3024 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
3025 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
3026 if (!survives_gc_p (p->var[i]))
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3027 abort ();
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3028 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3029
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3030 #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
3031
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3032 static void
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3033 dump_zombies ()
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 int i;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3036
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3037 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
3038 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
3039 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3040 fprintf (stderr, " %d = ", i);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3041 debug_print (zombies[i]);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3042 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3043 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3044
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3045 #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
3046
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3047
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3048 /* Mark live Lisp objects on the C stack.
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3049
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3050 There are several system-dependent problems to consider when
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3051 porting this to new architectures:
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3052
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3053 Processor Registers
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3054
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3055 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
3056 variables or are used to pass parameters.
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3057
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3058 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
3059 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
3060 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
3061
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3062 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
3063 implementation assumes that calling setjmp saves registers we need
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3064 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
3065 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
3066 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
3067
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3068 Stack Layout
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3069
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3070 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
3071 For example, the stack might look like this
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3072
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3073 +----------------+
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3074 | Lisp_Object | size = 4
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3075 +----------------+
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3076 | something else | size = 2
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3077 +----------------+
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3078 | Lisp_Object | size = 4
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3079 +----------------+
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3080 | ... |
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3081
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3082 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
3083 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
3084 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
3085 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
3086 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
3087 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
3088 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
3089 from the stack start.
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3090
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3091 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
3092 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
3093
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3094 static void
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3095 mark_stack ()
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3096 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3097 jmp_buf j;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3098 int stack_grows_down_p = (char *) &j > (char *) stack_base;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3099 void *end;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3100
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3101 /* 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
3102 the process is contained in the stack. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3103 #ifdef sparc
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3104 asm ("ta 3");
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3105 #endif
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3106
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3107 /* 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
3108 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
3109 pass parameters. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3110 #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
3111 GC_SAVE_REGISTERS_ON_STACK (end);
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3112 #else /* not GC_SAVE_REGISTERS_ON_STACK */
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3113
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3114 #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
3115 setjmp will definitely work, test it
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3116 and print a message with the result
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3117 of the test. */
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3118 if (!setjmp_tested_p)
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3119 {
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3120 setjmp_tested_p = 1;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3121 test_setjmp ();
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3122 }
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3123 #endif /* GC_SETJMP_WORKS */
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3124
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3125 setjmp (j);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3126 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
3127 #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
3128
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3129 /* 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
3130 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
3131 over the stack segments. */
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3132 #if GC_LISP_OBJECT_ALIGNMENT == 1
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3133 mark_memory (stack_base, end);
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3134 mark_memory ((char *) stack_base + 1, end);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3135 mark_memory ((char *) stack_base + 2, end);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3136 mark_memory ((char *) stack_base + 3, end);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3137 #elif GC_LISP_OBJECT_ALIGNMENT == 2
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3138 mark_memory (stack_base, end);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3139 mark_memory ((char *) stack_base + 2, end);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3140 #else
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3141 mark_memory (stack_base, end);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
3142 #endif
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3143
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3144 #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
3145 check_gcpros ();
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3146 #endif
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3147 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3148
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3149
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3150 #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
3151
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3152
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3153
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3154 /***********************************************************************
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3155 Pure Storage Management
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3156 ***********************************************************************/
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3157
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3158 /* 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
3159 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
3160 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
3161
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3162 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
3163 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
3164 string; then the string is not protected from gc. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3165
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3166 Lisp_Object
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3167 make_pure_string (data, nchars, nbytes, multibyte)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3168 char *data;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3169 int nchars, nbytes;
21258
693573ac0944 (make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21244
diff changeset
3170 int multibyte;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3171 {
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3172 Lisp_Object string;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3173 struct Lisp_String *s;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3174 int string_size, data_size;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3175
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3176 #define PAD(SZ) (((SZ) + sizeof (EMACS_INT) - 1) & ~(sizeof (EMACS_INT) - 1))
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3177
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3178 string_size = PAD (sizeof (struct Lisp_String));
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3179 data_size = PAD (nbytes + 1);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3180
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3181 #undef PAD
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3182
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3183 if (pureptr + string_size + data_size > PURESIZE)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3184 error ("Pure Lisp storage exhausted");
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3185
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3186 s = (struct Lisp_String *) (PUREBEG + pureptr);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3187 pureptr += string_size;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3188 s->data = (unsigned char *) (PUREBEG + pureptr);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3189 pureptr += data_size;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3190
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3191 s->size = nchars;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3192 s->size_byte = multibyte ? nbytes : -1;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3193 bcopy (data, s->data, nbytes);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3194 s->data[nbytes] = '\0';
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3195 s->intervals = NULL_INTERVAL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3196
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3197 XSETSTRING (string, s);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3198 return string;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3199 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3200
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3201
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3202 /* 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
3203 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
3204
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3205 Lisp_Object
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3206 pure_cons (car, cdr)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3207 Lisp_Object car, cdr;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3208 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3209 register Lisp_Object new;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3210
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3211 if (pureptr + sizeof (struct Lisp_Cons) > PURESIZE)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3212 error ("Pure Lisp storage exhausted");
9261
e5ba7993d378 (VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents: 9144
diff changeset
3213 XSETCONS (new, PUREBEG + pureptr);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3214 pureptr += sizeof (struct Lisp_Cons);
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
3215 XCAR (new) = Fpurecopy (car);
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
3216 XCDR (new) = Fpurecopy (cdr);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3217 return new;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3218 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3219
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3220
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3221 /* 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
3222
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3223 Lisp_Object
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3224 make_pure_float (num)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3225 double num;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3226 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3227 register Lisp_Object new;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3228
1939
def7b9c64935 * alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents: 1936
diff changeset
3229 /* Make sure that PUREBEG + pureptr is aligned on at least a sizeof
def7b9c64935 * alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents: 1936
diff changeset
3230 (double) boundary. Some architectures (like the sparc) require
def7b9c64935 * alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents: 1936
diff changeset
3231 this, and I suspect that floats are rare enough that it's no
def7b9c64935 * alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents: 1936
diff changeset
3232 tragedy for those that do. */
def7b9c64935 * alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents: 1936
diff changeset
3233 {
def7b9c64935 * alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents: 1936
diff changeset
3234 int alignment;
def7b9c64935 * alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents: 1936
diff changeset
3235 char *p = PUREBEG + pureptr;
def7b9c64935 * alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents: 1936
diff changeset
3236
1936
82bbf90208d4 * alloc.c (make_pure_float): Align pureptr according to __alignof,
Jim Blandy <jimb@redhat.com>
parents: 1908
diff changeset
3237 #ifdef __GNUC__
82bbf90208d4 * alloc.c (make_pure_float): Align pureptr according to __alignof,
Jim Blandy <jimb@redhat.com>
parents: 1908
diff changeset
3238 #if __GNUC__ >= 2
1939
def7b9c64935 * alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents: 1936
diff changeset
3239 alignment = __alignof (struct Lisp_Float);
1936
82bbf90208d4 * alloc.c (make_pure_float): Align pureptr according to __alignof,
Jim Blandy <jimb@redhat.com>
parents: 1908
diff changeset
3240 #else
1939
def7b9c64935 * alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents: 1936
diff changeset
3241 alignment = sizeof (struct Lisp_Float);
1936
82bbf90208d4 * alloc.c (make_pure_float): Align pureptr according to __alignof,
Jim Blandy <jimb@redhat.com>
parents: 1908
diff changeset
3242 #endif
82bbf90208d4 * alloc.c (make_pure_float): Align pureptr according to __alignof,
Jim Blandy <jimb@redhat.com>
parents: 1908
diff changeset
3243 #else
1939
def7b9c64935 * alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents: 1936
diff changeset
3244 alignment = sizeof (struct Lisp_Float);
1936
82bbf90208d4 * alloc.c (make_pure_float): Align pureptr according to __alignof,
Jim Blandy <jimb@redhat.com>
parents: 1908
diff changeset
3245 #endif
1939
def7b9c64935 * alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents: 1936
diff changeset
3246 p = (char *) (((unsigned long) p + alignment - 1) & - alignment);
def7b9c64935 * alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents: 1936
diff changeset
3247 pureptr = p - PUREBEG;
def7b9c64935 * alloc.c (make_pure_float): Assure that PUREBEG + pureptr is
Jim Blandy <jimb@redhat.com>
parents: 1936
diff changeset
3248 }
1908
d649f2179d67 * alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents: 1893
diff changeset
3249
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3250 if (pureptr + sizeof (struct Lisp_Float) > PURESIZE)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3251 error ("Pure Lisp storage exhausted");
9261
e5ba7993d378 (VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents: 9144
diff changeset
3252 XSETFLOAT (new, PUREBEG + pureptr);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3253 pureptr += sizeof (struct Lisp_Float);
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
3254 XFLOAT_DATA (new) = num;
9295
17d393a8eed6 (free_float, make_float, free_cons, Flist, Fvector, Fmake_byte_code,
Karl Heuer <kwzh@gnu.org>
parents: 9261
diff changeset
3255 XSETFASTINT (XFLOAT (new)->type, 0); /* bug chasing -wsr */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3256 return new;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3257 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3258
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3259
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3260 /* 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
3261 pure space. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3262
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3263 Lisp_Object
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3264 make_pure_vector (len)
8817
48ff00bebef6 (pure, pure_size): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents: 7307
diff changeset
3265 EMACS_INT len;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3266 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3267 register Lisp_Object new;
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3268 register EMACS_INT size = (sizeof (struct Lisp_Vector)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3269 + (len - 1) * sizeof (Lisp_Object));
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3270
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3271 if (pureptr + size > PURESIZE)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3272 error ("Pure Lisp storage exhausted");
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3273
9261
e5ba7993d378 (VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents: 9144
diff changeset
3274 XSETVECTOR (new, PUREBEG + pureptr);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3275 pureptr += size;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3276 XVECTOR (new)->size = len;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3277 return new;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3278 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3279
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3280
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3281 DEFUN ("purecopy", Fpurecopy, Spurecopy, 1, 1, 0,
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3282 "Make a copy of OBJECT in pure storage.\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3283 Recursively copies contents of vectors and cons cells.\n\
27348
46cf02cace2d (purecopy): Doc fix.
Dave Love <fx@gnu.org>
parents: 27142
diff changeset
3284 Does not copy symbols. Copies strings without text properties.")
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3285 (obj)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3286 register Lisp_Object obj;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3287 {
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 434
diff changeset
3288 if (NILP (Vpurify_flag))
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3289 return obj;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3290
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3291 if ((PNTR_COMPARISON_TYPE) XPNTR (obj) < (PNTR_COMPARISON_TYPE) ((char *) pure + PURESIZE)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3292 && (PNTR_COMPARISON_TYPE) XPNTR (obj) >= (PNTR_COMPARISON_TYPE) pure)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3293 return obj;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3294
10004
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
3295 if (CONSP (obj))
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
3296 return pure_cons (XCAR (obj), XCDR (obj));
10004
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
3297 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
3298 return make_pure_float (XFLOAT_DATA (obj));
10004
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
3299 else if (STRINGP (obj))
20587
eaf988c7e291 (make_pure_string): New arg length_byte.
Richard M. Stallman <rms@gnu.org>
parents: 20565
diff changeset
3300 return make_pure_string (XSTRING (obj)->data, XSTRING (obj)->size,
21258
693573ac0944 (make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21244
diff changeset
3301 STRING_BYTES (XSTRING (obj)),
693573ac0944 (make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21244
diff changeset
3302 STRING_MULTIBYTE (obj));
10004
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
3303 else if (COMPILEDP (obj) || VECTORP (obj))
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
3304 {
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
3305 register struct Lisp_Vector *vec;
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
3306 register int i, size;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3307
10004
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
3308 size = XVECTOR (obj)->size;
10427
5faba1b094d5 (Fpurecopy): Mask size field when copying pseudovector.
Karl Heuer <kwzh@gnu.org>
parents: 10414
diff changeset
3309 if (size & PSEUDOVECTOR_FLAG)
5faba1b094d5 (Fpurecopy): Mask size field when copying pseudovector.
Karl Heuer <kwzh@gnu.org>
parents: 10414
diff changeset
3310 size &= PSEUDOVECTOR_SIZE_MASK;
16100
ccd19852de65 (Fpurecopy): Cast arg to make_pure_vector.
Richard M. Stallman <rms@gnu.org>
parents: 16051
diff changeset
3311 vec = XVECTOR (make_pure_vector ((EMACS_INT) size));
10004
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
3312 for (i = 0; i < size; i++)
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
3313 vec->contents[i] = Fpurecopy (XVECTOR (obj)->contents[i]);
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
3314 if (COMPILEDP (obj))
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
3315 XSETCOMPILED (obj, vec);
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
3316 else
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
3317 XSETVECTOR (obj, vec);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3318 return obj;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3319 }
10004
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
3320 else if (MARKERP (obj))
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
3321 error ("Attempt to copy a marker to pure storage");
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
3322 else
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
3323 return obj;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3324 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3325
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3326
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3327
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3328 /***********************************************************************
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3329 Protection from GC
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3330 ***********************************************************************/
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3331
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3332 /* Recording what needs to be marked for gc. */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3333
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3334 struct gcpro *gcprolist;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3335
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3336 /* Addresses of staticpro'd variables. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3337
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3338 #define NSTATICS 1024
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3339 Lisp_Object *staticvec[NSTATICS] = {0};
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3340
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3341 /* Index of next unused slot in staticvec. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3342
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3343 int staticidx = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3344
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3345
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3346 /* 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
3347 VARADDRESS. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3348
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3349 void
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3350 staticpro (varaddress)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3351 Lisp_Object *varaddress;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3352 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3353 staticvec[staticidx++] = varaddress;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3354 if (staticidx >= NSTATICS)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3355 abort ();
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3356 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3357
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3358 struct catchtag
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3359 {
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3360 Lisp_Object tag;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3361 Lisp_Object val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3362 struct catchtag *next;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3363 };
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3364
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3365 struct backtrace
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3366 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3367 struct backtrace *next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3368 Lisp_Object *function;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3369 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
3370 int nargs; /* Length of vector. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3371 /* 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
3372 unevalled args. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3373 char evalargs;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3374 };
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3375
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3376
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3377
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3378 /***********************************************************************
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3379 Protection from GC
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3380 ***********************************************************************/
1908
d649f2179d67 * alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents: 1893
diff changeset
3381
11374
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
3382 /* Temporarily prevent garbage collection. */
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
3383
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
3384 int
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
3385 inhibit_garbage_collection ()
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
3386 {
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
3387 int count = specpdl_ptr - specpdl;
11679
1ced2d67d411 (gc_cons_threshold): Make this an EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents: 11593
diff changeset
3388 Lisp_Object number;
13363
941c37982f37 (BITS_PER_SHORT, BITS_PER_INT, BITS_PER_LONG):
Karl Heuer <kwzh@gnu.org>
parents: 13322
diff changeset
3389 int nbits = min (VALBITS, BITS_PER_INT);
11374
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
3390
11727
53ccd2d608ee (gc_cons_threshold): Change back to int.
Richard M. Stallman <rms@gnu.org>
parents: 11679
diff changeset
3391 XSETINT (number, ((EMACS_INT) 1 << (nbits - 1)) - 1);
11679
1ced2d67d411 (gc_cons_threshold): Make this an EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents: 11593
diff changeset
3392
1ced2d67d411 (gc_cons_threshold): Make this an EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents: 11593
diff changeset
3393 specbind (Qgc_cons_threshold, number);
11374
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
3394
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
3395 return count;
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
3396 }
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
3397
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3398
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3399 DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "",
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3400 "Reclaim storage for Lisp objects no longer needed.\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3401 Returns info on amount of space in use:\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3402 ((USED-CONSES . FREE-CONSES) (USED-SYMS . FREE-SYMS)\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3403 (USED-MARKERS . FREE-MARKERS) USED-STRING-CHARS USED-VECTOR-SLOTS\n\
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3404 (USED-FLOATS . FREE-FLOATS) (USED-INTERVALS . FREE-INTERVALS\n\
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3405 (USED-STRINGS . FREE-STRINGS))\n\
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3406 Garbage collection happens automatically if you cons more than\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3407 `gc-cons-threshold' bytes of Lisp data since previous garbage collection.")
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3408 ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3409 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3410 register struct gcpro *tail;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3411 register struct specbinding *bind;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3412 struct catchtag *catch;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3413 struct handler *handler;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3414 register struct backtrace *backlist;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3415 char stack_top_variable;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3416 register int i;
25343
fe92158a9e83 (Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents: 25133
diff changeset
3417 int message_p;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3418 Lisp_Object total[7];
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3419
11892
6be0b7a0ac44 (Fgarbage_collect): Clear consing_since_gc first thing.
Karl Heuer <kwzh@gnu.org>
parents: 11727
diff changeset
3420 /* 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
3421 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
3422 consing_since_gc = 0;
6be0b7a0ac44 (Fgarbage_collect): Clear consing_since_gc first thing.
Karl Heuer <kwzh@gnu.org>
parents: 11727
diff changeset
3423
25343
fe92158a9e83 (Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents: 25133
diff changeset
3424 /* 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
3425 message_p = push_message ();
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3426
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3427 /* Save a copy of the contents of the stack, for debugging. */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3428 #if MAX_SAVE_STACK > 0
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 434
diff changeset
3429 if (NILP (Vpurify_flag))
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3430 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3431 i = &stack_top_variable - stack_bottom;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3432 if (i < 0) i = -i;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3433 if (i < MAX_SAVE_STACK)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3434 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3435 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
3436 stack_copy = (char *) xmalloc (stack_copy_size = i);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3437 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
3438 stack_copy = (char *) xrealloc (stack_copy, (stack_copy_size = i));
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3439 if (stack_copy)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3440 {
8817
48ff00bebef6 (pure, pure_size): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents: 7307
diff changeset
3441 if ((EMACS_INT) (&stack_top_variable - stack_bottom) > 0)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3442 bcopy (stack_bottom, stack_copy, i);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3443 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3444 bcopy (&stack_top_variable, stack_copy, i);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3445 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3446 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3447 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3448 #endif /* MAX_SAVE_STACK > 0 */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3449
14959
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
3450 if (garbage_collection_messages)
10395
c121703d35c7 (Fgarbage_collect): Don't log the GC message.
Karl Heuer <kwzh@gnu.org>
parents: 10389
diff changeset
3451 message1_nolog ("Garbage collecting...");
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3452
23534
6f9c70db3a58 (Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents: 22382
diff changeset
3453 BLOCK_INPUT;
6f9c70db3a58 (Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents: 22382
diff changeset
3454
22220
a0cd311af6e3 (Fgarbage_collect): Call shrink_regexp_cache.
Richard M. Stallman <rms@gnu.org>
parents: 21948
diff changeset
3455 shrink_regexp_cache ();
a0cd311af6e3 (Fgarbage_collect): Call shrink_regexp_cache.
Richard M. Stallman <rms@gnu.org>
parents: 21948
diff changeset
3456
21680
c744d468bfb6 (Fgarbage_collect): Don't truncate command-history here.
Richard M. Stallman <rms@gnu.org>
parents: 21514
diff changeset
3457 /* Don't keep undo information around forever. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3458 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3459 register struct buffer *nextb = all_buffers;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3460
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3461 while (nextb)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3462 {
648
70b112526394 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 638
diff changeset
3463 /* If a buffer's undo list is Qt, that means that undo is
70b112526394 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 638
diff changeset
3464 turned off in that buffer. Calling truncate_undo_list on
70b112526394 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 638
diff changeset
3465 Qt tends to return NULL, which effectively turns undo back on.
70b112526394 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 638
diff changeset
3466 So don't call truncate_undo_list if undo_list is Qt. */
70b112526394 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 638
diff changeset
3467 if (! EQ (nextb->undo_list, Qt))
70b112526394 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 638
diff changeset
3468 nextb->undo_list
764
bb24f1180bb6 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3469 = truncate_undo_list (nextb->undo_list, undo_limit,
bb24f1180bb6 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3470 undo_strong_limit);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3471 nextb = nextb->next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3472 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3473 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3474
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3475 gc_in_progress = 1;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3476
16231
5ce3b59f093b Comment changes.
Erik Naggum <erik@naggum.no>
parents: 16223
diff changeset
3477 /* clear_marks (); */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3478
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3479 /* Mark all the special slots that serve as the roots of accessibility.
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3480
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3481 Usually the special slots to mark are contained in particular structures.
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3482 Then we know no slot is marked twice because the structures don't overlap.
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3483 In some cases, the structures point to the slots to be marked.
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3484 For these, we use MARKBIT to avoid double marking of the slot. */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3485
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3486 for (i = 0; i < staticidx; i++)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3487 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
3488
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3489 #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
3490 || 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
3491 mark_stack ();
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3492 #else
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3493 for (tail = gcprolist; tail; tail = tail->next)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3494 for (i = 0; i < tail->nvars; i++)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3495 if (!XMARKBIT (tail->var[i]))
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3496 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3497 mark_object (&tail->var[i]);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3498 XMARK (tail->var[i]);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3499 }
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3500 #endif
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3501
26364
7b0217d9259c (Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents: 26164
diff changeset
3502 mark_byte_stack ();
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3503 for (bind = specpdl; bind != specpdl_ptr; bind++)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3504 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3505 mark_object (&bind->symbol);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3506 mark_object (&bind->old_value);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3507 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3508 for (catch = catchlist; catch; catch = catch->next)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3509 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3510 mark_object (&catch->tag);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3511 mark_object (&catch->val);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3512 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3513 for (handler = handlerlist; handler; handler = handler->next)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3514 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3515 mark_object (&handler->handler);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3516 mark_object (&handler->var);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3517 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3518 for (backlist = backtrace_list; backlist; backlist = backlist->next)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3519 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3520 if (!XMARKBIT (*backlist->function))
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3521 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3522 mark_object (backlist->function);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3523 XMARK (*backlist->function);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3524 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3525 if (backlist->nargs == UNEVALLED || backlist->nargs == MANY)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3526 i = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3527 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3528 i = backlist->nargs - 1;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3529 for (; i >= 0; i--)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3530 if (!XMARKBIT (backlist->args[i]))
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3531 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3532 mark_object (&backlist->args[i]);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3533 XMARK (backlist->args[i]);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3534 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3535 }
11018
2d9bdf1ba3d1 (mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents: 10936
diff changeset
3536 mark_kboards ();
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3537
21306
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3538 /* 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
3539 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
3540 and delete them. */
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3541 {
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3542 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
3543
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3544 while (nextb)
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3545 {
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3546 /* 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
3547 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
3548 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
3549 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
3550 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
3551 {
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3552 Lisp_Object tail, prev;
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3553 tail = nextb->undo_list;
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3554 prev = Qnil;
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3555 while (CONSP (tail))
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3556 {
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
3557 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
3558 && GC_MARKERP (XCAR (XCAR (tail)))
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
3559 && ! XMARKBIT (XMARKER (XCAR (XCAR (tail)))->chain))
21306
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3560 {
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3561 if (NILP (prev))
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
3562 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
3563 else
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
3564 tail = XCDR (prev) = XCDR (tail);
21306
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3565 }
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3566 else
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3567 {
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3568 prev = tail;
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
3569 tail = XCDR (tail);
21306
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3570 }
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3571 }
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3572 }
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3573
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3574 nextb = nextb->next;
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3575 }
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3576 }
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
3577
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3578 #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
3579 mark_stack ();
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3580 #endif
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3581
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3582 gc_sweep ();
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3583
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3584 /* Clear the mark bits that we set in certain root slots. */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3585
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3586 #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
3587 || GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3588 for (tail = gcprolist; tail; tail = tail->next)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3589 for (i = 0; i < tail->nvars; i++)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3590 XUNMARK (tail->var[i]);
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3591 #endif
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3592
26378
cbf297593a79 (Fgarbage_collect): Call unmark_byte_stack.
Gerd Moellmann <gerd@gnu.org>
parents: 26372
diff changeset
3593 unmark_byte_stack ();
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3594 for (backlist = backtrace_list; backlist; backlist = backlist->next)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3595 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3596 XUNMARK (*backlist->function);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3597 if (backlist->nargs == UNEVALLED || backlist->nargs == MANY)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3598 i = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3599 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3600 i = backlist->nargs - 1;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3601 for (; i >= 0; i--)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3602 XUNMARK (backlist->args[i]);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3603 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3604 XUNMARK (buffer_defaults.name);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3605 XUNMARK (buffer_local_symbols.name);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3606
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3607 #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
3608 dump_zombies ();
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3609 #endif
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3610
23534
6f9c70db3a58 (Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents: 22382
diff changeset
3611 UNBLOCK_INPUT;
6f9c70db3a58 (Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents: 22382
diff changeset
3612
16231
5ce3b59f093b Comment changes.
Erik Naggum <erik@naggum.no>
parents: 16223
diff changeset
3613 /* clear_marks (); */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3614 gc_in_progress = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3615
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3616 consing_since_gc = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3617 if (gc_cons_threshold < 10000)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3618 gc_cons_threshold = 10000;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3619
14959
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
3620 if (garbage_collection_messages)
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
3621 {
25343
fe92158a9e83 (Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents: 25133
diff changeset
3622 if (message_p || minibuf_level > 0)
fe92158a9e83 (Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents: 25133
diff changeset
3623 restore_message ();
14959
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
3624 else
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
3625 message1_nolog ("Garbage collecting...done");
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
3626 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3627
25343
fe92158a9e83 (Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents: 25133
diff changeset
3628 pop_message ();
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3629
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3630 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
3631 make_number (total_free_conses));
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3632 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
3633 make_number (total_free_symbols));
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3634 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
3635 make_number (total_free_markers));
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3636 total[3] = Fcons (make_number (total_string_size),
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3637 make_number (total_vector_size));
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3638 total[4] = Fcons (make_number (total_floats),
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3639 make_number (total_free_floats));
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3640 total[5] = Fcons (make_number (total_intervals),
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3641 make_number (total_free_intervals));
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3642 total[6] = Fcons (make_number (total_strings),
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3643 make_number (total_free_strings));
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3644
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3645 #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
3646 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3647 /* 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
3648 double nlive = 0;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3649
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3650 for (i = 0; i < 7; ++i)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3651 nlive += XFASTINT (XCAR (total[i]));
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3652
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3653 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
3654 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
3655 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
3656 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
3657 ++ngcs;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3658 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3659 #endif
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3660
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3661 return Flist (7, total);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3662 }
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3663
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3664
25367
823e14641544 (mark_glyph_matrix): Mark strings only.
Gerd Moellmann <gerd@gnu.org>
parents: 25343
diff changeset
3665 /* 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
3666 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
3667
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3668 static void
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3669 mark_glyph_matrix (matrix)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3670 struct glyph_matrix *matrix;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3671 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3672 struct glyph_row *row = matrix->rows;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3673 struct glyph_row *end = row + matrix->nrows;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3674
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3675 for (; row < end; ++row)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3676 if (row->enabled_p)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3677 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3678 int area;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3679 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
3680 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3681 struct glyph *glyph = row->glyphs[area];
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3682 struct glyph *end_glyph = glyph + row->used[area];
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3683
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3684 for (; glyph < end_glyph; ++glyph)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3685 if (GC_STRINGP (glyph->object)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3686 && !STRING_MARKED_P (XSTRING (glyph->object)))
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3687 mark_object (&glyph->object);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3688 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3689 }
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3690 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3691
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3692
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3693 /* 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
3694
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3695 static void
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3696 mark_face_cache (c)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3697 struct face_cache *c;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3698 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3699 if (c)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3700 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3701 int i, j;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3702 for (i = 0; i < c->used; ++i)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3703 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3704 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
3705
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3706 if (face)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3707 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3708 for (j = 0; j < LFACE_VECTOR_SIZE; ++j)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3709 mark_object (&face->lface[j]);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3710 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3711 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3712 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3713 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3714
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3715
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3716 #ifdef HAVE_WINDOW_SYSTEM
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3717
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3718 /* Mark Lisp objects in image IMG. */
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3719
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3720 static void
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3721 mark_image (img)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3722 struct image *img;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3723 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3724 mark_object (&img->spec);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3725
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3726 if (!NILP (img->data.lisp_val))
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3727 mark_object (&img->data.lisp_val);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3728 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3729
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3730
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3731 /* 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
3732 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
3733
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3734 static void
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3735 mark_image_cache (f)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3736 struct frame *f;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3737 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3738 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
3739 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3740
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3741 #endif /* HAVE_X_WINDOWS */
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3742
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3743
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3744
1908
d649f2179d67 * alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents: 1893
diff changeset
3745 /* 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
3746 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
3747 all the references contained in it. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3748
1168
2b07af77d7ec (mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents: 1114
diff changeset
3749 #define LAST_MARKED_SIZE 500
2b07af77d7ec (mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents: 1114
diff changeset
3750 Lisp_Object *last_marked[LAST_MARKED_SIZE];
2b07af77d7ec (mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents: 1114
diff changeset
3751 int last_marked_index;
2b07af77d7ec (mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents: 1114
diff changeset
3752
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3753 void
13553
fb12156faaf5 (mark_object): Don't overwrite original argument value.
Richard M. Stallman <rms@gnu.org>
parents: 13363
diff changeset
3754 mark_object (argptr)
fb12156faaf5 (mark_object): Don't overwrite original argument value.
Richard M. Stallman <rms@gnu.org>
parents: 13363
diff changeset
3755 Lisp_Object *argptr;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3756 {
13553
fb12156faaf5 (mark_object): Don't overwrite original argument value.
Richard M. Stallman <rms@gnu.org>
parents: 13363
diff changeset
3757 Lisp_Object *objptr = argptr;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3758 register Lisp_Object obj;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3759
5868
a7bd57a60cb8 (mark_object): Fetch obj from *objptr at loop, not at the gotos.
Karl Heuer <kwzh@gnu.org>
parents: 5353
diff changeset
3760 loop:
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3761 obj = *objptr;
5868
a7bd57a60cb8 (mark_object): Fetch obj from *objptr at loop, not at the gotos.
Karl Heuer <kwzh@gnu.org>
parents: 5353
diff changeset
3762 loop2:
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3763 XUNMARK (obj);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3764
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3765 if (PURE_POINTER_P ((PNTR_COMPARISON_TYPE) XPNTR (obj)))
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3766 return;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3767
1168
2b07af77d7ec (mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents: 1114
diff changeset
3768 last_marked[last_marked_index++] = objptr;
2b07af77d7ec (mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents: 1114
diff changeset
3769 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
3770 last_marked_index = 0;
2b07af77d7ec (mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents: 1114
diff changeset
3771
10457
2ab3bd0288a9 Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents: 10427
diff changeset
3772 switch (SWITCH_ENUM_CAST (XGCTYPE (obj)))
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3773 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3774 case Lisp_String:
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3775 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3776 register struct Lisp_String *ptr = XSTRING (obj);
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
3777 MARK_INTERVAL_TREE (ptr->intervals);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3778 MARK_STRING (ptr);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3779 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3780 break;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3781
10009
82f3daf76995 (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 10004
diff changeset
3782 case Lisp_Vectorlike:
10307
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
3783 if (GC_BUFFERP (obj))
10340
ef58c7a5a4d6 (mark_object, mark_buffer): Don't mark buffer twice.
Karl Heuer <kwzh@gnu.org>
parents: 10320
diff changeset
3784 {
ef58c7a5a4d6 (mark_object, mark_buffer): Don't mark buffer twice.
Karl Heuer <kwzh@gnu.org>
parents: 10320
diff changeset
3785 if (!XMARKBIT (XBUFFER (obj)->name))
ef58c7a5a4d6 (mark_object, mark_buffer): Don't mark buffer twice.
Karl Heuer <kwzh@gnu.org>
parents: 10320
diff changeset
3786 mark_buffer (obj);
ef58c7a5a4d6 (mark_object, mark_buffer): Don't mark buffer twice.
Karl Heuer <kwzh@gnu.org>
parents: 10320
diff changeset
3787 }
10307
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
3788 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
3789 break;
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3790 else if (GC_COMPILEDP (obj))
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3791 /* 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
3792 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
3793 recursion there. */
10291
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3794 {
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3795 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
3796 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
3797 /* See comment above under Lisp_Vector. */
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3798 struct Lisp_Vector *volatile ptr1 = ptr;
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3799 register int i;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3800
10291
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3801 if (size & ARRAY_MARK_FLAG)
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3802 break; /* Already marked */
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3803 ptr->size |= ARRAY_MARK_FLAG; /* Else mark it */
10009
82f3daf76995 (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 10004
diff changeset
3804 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
3805 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
3806 {
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3807 if (i != COMPILED_CONSTANTS)
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3808 mark_object (&ptr1->contents[i]);
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3809 }
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3810 /* This cast should be unnecessary, but some Mips compiler complains
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3811 (MIPS-ABI + SysVR4, DC/OSx, etc). */
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3812 objptr = (Lisp_Object *) &ptr1->contents[COMPILED_CONSTANTS];
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3813 goto loop;
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3814 }
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3815 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
3816 {
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3817 /* See comment above under Lisp_Vector for why this is volatile. */
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3818 register struct frame *volatile ptr = XFRAME (obj);
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3819 register EMACS_INT size = ptr->size;
1295
a9241dc503ab (mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents: 1168
diff changeset
3820
10291
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3821 if (size & ARRAY_MARK_FLAG) break; /* Already marked */
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3822 ptr->size |= ARRAY_MARK_FLAG; /* Else mark it */
1295
a9241dc503ab (mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents: 1168
diff changeset
3823
10291
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3824 mark_object (&ptr->name);
12273
377cbbd8a2ad (mark_object): Mark icon_name field.
Richard M. Stallman <rms@gnu.org>
parents: 12175
diff changeset
3825 mark_object (&ptr->icon_name);
14216
5970a52070bb (mark_object): Mark frame title field.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
3826 mark_object (&ptr->title);
10291
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3827 mark_object (&ptr->focus_frame);
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3828 mark_object (&ptr->selected_window);
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3829 mark_object (&ptr->minibuffer_window);
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3830 mark_object (&ptr->param_alist);
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3831 mark_object (&ptr->scroll_bars);
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3832 mark_object (&ptr->condemned_scroll_bars);
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3833 mark_object (&ptr->menu_bar_items);
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3834 mark_object (&ptr->face_alist);
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3835 mark_object (&ptr->menu_bar_vector);
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3836 mark_object (&ptr->buffer_predicate);
17217
571d0c136e48 (mark_object): Mark the buffer_list field.
Richard M. Stallman <rms@gnu.org>
parents: 17021
diff changeset
3837 mark_object (&ptr->buffer_list);
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3838 mark_object (&ptr->menu_bar_window);
25544
693ca9ba497a Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents: 25452
diff changeset
3839 mark_object (&ptr->tool_bar_window);
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3840 mark_face_cache (ptr->face_cache);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3841 #ifdef HAVE_WINDOW_SYSTEM
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3842 mark_image_cache (ptr);
25544
693ca9ba497a Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents: 25452
diff changeset
3843 mark_object (&ptr->desired_tool_bar_items);
693ca9ba497a Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents: 25452
diff changeset
3844 mark_object (&ptr->current_tool_bar_items);
693ca9ba497a Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents: 25452
diff changeset
3845 mark_object (&ptr->desired_tool_bar_string);
693ca9ba497a Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents: 25452
diff changeset
3846 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
3847 #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
3848 }
13141
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
3849 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
3850 {
5cd52d4838f8 (mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents: 14959
diff changeset
3851 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
3852
5cd52d4838f8 (mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents: 14959
diff changeset
3853 if (ptr->size & ARRAY_MARK_FLAG)
5cd52d4838f8 (mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents: 14959
diff changeset
3854 break; /* Already marked */
5cd52d4838f8 (mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents: 14959
diff changeset
3855 ptr->size |= ARRAY_MARK_FLAG; /* Else mark it */
5cd52d4838f8 (mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents: 14959
diff changeset
3856 }
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3857 else if (GC_WINDOWP (obj))
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3858 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3859 register struct Lisp_Vector *ptr = XVECTOR (obj);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3860 struct window *w = XWINDOW (obj);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3861 register EMACS_INT size = ptr->size;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3862 /* The reason we use ptr1 is to avoid an apparent hardware bug
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3863 that happens occasionally on the FSF's HP 300s.
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3864 The bug is that a2 gets clobbered by recursive calls to mark_object.
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3865 The clobberage seems to happen during function entry,
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3866 perhaps in the moveml instruction.
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3867 Yes, this is a crock, but we have to do it. */
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3868 struct Lisp_Vector *volatile ptr1 = ptr;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3869 register int i;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3870
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3871 /* Stop if already marked. */
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3872 if (size & ARRAY_MARK_FLAG)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3873 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3874
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3875 /* Mark it. */
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3876 ptr->size |= ARRAY_MARK_FLAG;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3877
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3878 /* 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
3879 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
3880 for (i = 0;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3881 (char *) &ptr1->contents[i] < (char *) &w->current_matrix;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3882 i++)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3883 mark_object (&ptr1->contents[i]);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3884
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3885 /* 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
3886 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
3887 memory. */
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3888 if (NILP (w->hchild)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3889 && NILP (w->vchild)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3890 && w->current_matrix)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3891 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3892 mark_glyph_matrix (w->current_matrix);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3893 mark_glyph_matrix (w->desired_matrix);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3894 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3895 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3896 else if (GC_HASH_TABLE_P (obj))
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3897 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3898 struct Lisp_Hash_Table *h = XHASH_TABLE (obj);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3899 EMACS_INT size = h->size;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3900
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3901 /* Stop if already marked. */
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3902 if (size & ARRAY_MARK_FLAG)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3903 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3904
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3905 /* Mark it. */
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3906 h->size |= ARRAY_MARK_FLAG;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3907
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3908 /* Mark contents. */
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3909 mark_object (&h->test);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3910 mark_object (&h->weak);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3911 mark_object (&h->rehash_size);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3912 mark_object (&h->rehash_threshold);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3913 mark_object (&h->hash);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3914 mark_object (&h->next);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3915 mark_object (&h->index);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3916 mark_object (&h->user_hash_function);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3917 mark_object (&h->user_cmp_function);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3918
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3919 /* 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
3920 For weak tables, mark only the vector. */
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3921 if (GC_NILP (h->weak))
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3922 mark_object (&h->key_and_value);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3923 else
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3924 XVECTOR (h->key_and_value)->size |= ARRAY_MARK_FLAG;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3925
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3926 }
10291
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3927 else
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3928 {
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3929 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
3930 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
3931 /* The reason we use ptr1 is to avoid an apparent hardware bug
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3932 that happens occasionally on the FSF's HP 300s.
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3933 The bug is that a2 gets clobbered by recursive calls to mark_object.
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3934 The clobberage seems to happen during function entry,
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3935 perhaps in the moveml instruction.
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3936 Yes, this is a crock, but we have to do it. */
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3937 struct Lisp_Vector *volatile ptr1 = ptr;
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3938 register int i;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3939
10291
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3940 if (size & ARRAY_MARK_FLAG) break; /* Already marked */
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3941 ptr->size |= ARRAY_MARK_FLAG; /* Else mark it */
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3942 if (size & PSEUDOVECTOR_FLAG)
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3943 size &= PSEUDOVECTOR_SIZE_MASK;
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
3944
10291
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3945 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
3946 mark_object (&ptr1->contents[i]);
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
3947 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3948 break;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3949
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3950 case Lisp_Symbol:
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3951 {
4494
15b073a6c860 (mark_object): Declare ptr volatile, or don't use it
Richard M. Stallman <rms@gnu.org>
parents: 4212
diff changeset
3952 /* See comment above under Lisp_Vector for why this is volatile. */
15b073a6c860 (mark_object): Declare ptr volatile, or don't use it
Richard M. Stallman <rms@gnu.org>
parents: 4212
diff changeset
3953 register struct Lisp_Symbol *volatile ptr = XSYMBOL (obj);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3954 struct Lisp_Symbol *ptrx;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3955
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3956 if (XMARKBIT (ptr->plist)) break;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3957 XMARK (ptr->plist);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3958 mark_object ((Lisp_Object *) &ptr->value);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3959 mark_object (&ptr->function);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3960 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
3961
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3962 if (!PURE_POINTER_P (ptr->name))
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3963 MARK_STRING (ptr->name);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3964 MARK_INTERVAL_TREE (ptr->name->intervals);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3965
20768
6ebcbdec2e07 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
3966 /* Note that we do not mark the obarray of the symbol.
6ebcbdec2e07 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
3967 It is safe not to do so because nothing accesses that
6ebcbdec2e07 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
3968 slot except to check whether it is nil. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3969 ptr = ptr->next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3970 if (ptr)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3971 {
5868
a7bd57a60cb8 (mark_object): Fetch obj from *objptr at loop, not at the gotos.
Karl Heuer <kwzh@gnu.org>
parents: 5353
diff changeset
3972 /* For the benefit of the last_marked log. */
a7bd57a60cb8 (mark_object): Fetch obj from *objptr at loop, not at the gotos.
Karl Heuer <kwzh@gnu.org>
parents: 5353
diff changeset
3973 objptr = (Lisp_Object *)&XSYMBOL (obj)->next;
2507
7ba4316ae840 * alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
3974 ptrx = ptr; /* Use of ptrx avoids compiler bug on Sun */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3975 XSETSYMBOL (obj, ptrx);
5868
a7bd57a60cb8 (mark_object): Fetch obj from *objptr at loop, not at the gotos.
Karl Heuer <kwzh@gnu.org>
parents: 5353
diff changeset
3976 /* We can't goto loop here because *objptr doesn't contain an
a7bd57a60cb8 (mark_object): Fetch obj from *objptr at loop, not at the gotos.
Karl Heuer <kwzh@gnu.org>
parents: 5353
diff changeset
3977 actual Lisp_Object with valid datatype field. */
a7bd57a60cb8 (mark_object): Fetch obj from *objptr at loop, not at the gotos.
Karl Heuer <kwzh@gnu.org>
parents: 5353
diff changeset
3978 goto loop2;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3979 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3980 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3981 break;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3982
9437
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3983 case Lisp_Misc:
11243
054ecfce1820 (Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents: 11048
diff changeset
3984 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
3985 {
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3986 case Lisp_Misc_Marker:
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3987 XMARK (XMARKER (obj)->chain);
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3988 /* DO NOT mark thru the marker's chain.
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3989 The buffer's markers chain does not preserve markers from gc;
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3990 instead, markers are removed from the chain when freed by gc. */
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3991 break;
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3992
9893
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
3993 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
3994 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
3995 {
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
3996 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
3997 = XBUFFER_LOCAL_VALUE (obj);
21143
ce12eac1ee45 (gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents: 21084
diff changeset
3998 if (XMARKBIT (ptr->realvalue)) break;
ce12eac1ee45 (gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents: 21084
diff changeset
3999 XMARK (ptr->realvalue);
9893
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4000 /* 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
4001 if (EQ (ptr->cdr, Qnil))
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4002 {
21143
ce12eac1ee45 (gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents: 21084
diff changeset
4003 objptr = &ptr->realvalue;
9893
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4004 goto loop;
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4005 }
21143
ce12eac1ee45 (gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents: 21084
diff changeset
4006 mark_object (&ptr->realvalue);
ce12eac1ee45 (gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents: 21084
diff changeset
4007 mark_object (&ptr->buffer);
ce12eac1ee45 (gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents: 21084
diff changeset
4008 mark_object (&ptr->frame);
9893
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4009 /* See comment above under Lisp_Vector for why not use ptr here. */
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4010 objptr = &XBUFFER_LOCAL_VALUE (obj)->cdr;
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4011 goto loop;
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4012 }
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4013
9463
a40af805e036 (mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9437
diff changeset
4014 case Lisp_Misc_Intfwd:
a40af805e036 (mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9437
diff changeset
4015 case Lisp_Misc_Boolfwd:
a40af805e036 (mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9437
diff changeset
4016 case Lisp_Misc_Objfwd:
a40af805e036 (mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9437
diff changeset
4017 case Lisp_Misc_Buffer_Objfwd:
11018
2d9bdf1ba3d1 (mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents: 10936
diff changeset
4018 case Lisp_Misc_Kboard_Objfwd:
9463
a40af805e036 (mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9437
diff changeset
4019 /* Don't bother with Lisp_Buffer_Objfwd,
a40af805e036 (mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9437
diff changeset
4020 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
4021 /* 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
4022 are protected with staticpro. */
a40af805e036 (mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9437
diff changeset
4023 break;
a40af805e036 (mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9437
diff changeset
4024
9926
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
4025 case Lisp_Misc_Overlay:
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
4026 {
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
4027 struct Lisp_Overlay *ptr = XOVERLAY (obj);
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
4028 if (!XMARKBIT (ptr->plist))
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
4029 {
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
4030 XMARK (ptr->plist);
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
4031 mark_object (&ptr->start);
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
4032 mark_object (&ptr->end);
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
4033 objptr = &ptr->plist;
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
4034 goto loop;
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
4035 }
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
4036 }
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
4037 break;
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
4038
9437
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
4039 default:
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
4040 abort ();
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
4041 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4042 break;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4043
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4044 case Lisp_Cons:
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4045 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4046 register struct Lisp_Cons *ptr = XCONS (obj);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4047 if (XMARKBIT (ptr->car)) break;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4048 XMARK (ptr->car);
1295
a9241dc503ab (mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents: 1168
diff changeset
4049 /* 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
4050 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
4051 {
a9241dc503ab (mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents: 1168
diff changeset
4052 objptr = &ptr->car;
a9241dc503ab (mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents: 1168
diff changeset
4053 goto loop;
a9241dc503ab (mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents: 1168
diff changeset
4054 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4055 mark_object (&ptr->car);
4494
15b073a6c860 (mark_object): Declare ptr volatile, or don't use it
Richard M. Stallman <rms@gnu.org>
parents: 4212
diff changeset
4056 /* See comment above under Lisp_Vector for why not use ptr here. */
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
4057 objptr = &XCDR (obj);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4058 goto loop;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4059 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4060
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4061 case Lisp_Float:
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4062 XMARK (XFLOAT (obj)->type);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4063 break;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4064
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4065 case Lisp_Int:
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4066 break;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4067
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4068 default:
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4069 abort ();
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4070 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4071 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4072
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4073 /* Mark the pointers in a buffer structure. */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4074
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4075 static void
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4076 mark_buffer (buf)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4077 Lisp_Object buf;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4078 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4079 register struct buffer *buffer = XBUFFER (buf);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4080 register Lisp_Object *ptr;
10307
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
4081 Lisp_Object base_buffer;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4082
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4083 /* This is the buffer's markbit */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4084 mark_object (&buffer->name);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4085 XMARK (buffer->name);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4086
10307
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
4087 MARK_INTERVAL_TREE (BUF_INTERVALS (buffer));
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4088
21306
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4089 if (CONSP (buffer->undo_list))
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4090 {
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4091 Lisp_Object tail;
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4092 tail = buffer->undo_list;
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4093
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4094 while (CONSP (tail))
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4095 {
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4096 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
4097
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4098 if (XMARKBIT (ptr->car))
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4099 break;
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4100 XMARK (ptr->car);
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4101 if (GC_CONSP (ptr->car)
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
4102 && ! XMARKBIT (XCAR (ptr->car))
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
4103 && 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
4104 {
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
4105 XMARK (XCAR (ptr->car));
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
4106 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
4107 }
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4108 else
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4109 mark_object (&ptr->car);
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4110
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4111 if (CONSP (ptr->cdr))
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4112 tail = ptr->cdr;
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4113 else
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4114 break;
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4115 }
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4116
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
4117 mark_object (&XCDR (tail));
21306
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4118 }
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4119 else
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4120 mark_object (&buffer->undo_list);
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4121
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4122 for (ptr = &buffer->name + 1;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4123 (char *)ptr < (char *)buffer + sizeof (struct buffer);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4124 ptr++)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4125 mark_object (ptr);
10307
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
4126
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
4127 /* If this is an indirect buffer, mark its base buffer. */
10340
ef58c7a5a4d6 (mark_object, mark_buffer): Don't mark buffer twice.
Karl Heuer <kwzh@gnu.org>
parents: 10320
diff changeset
4128 if (buffer->base_buffer && !XMARKBIT (buffer->base_buffer->name))
10307
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
4129 {
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
4130 XSETBUFFER (base_buffer, buffer->base_buffer);
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
4131 mark_buffer (base_buffer);
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
4132 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4133 }
10649
52cdd8cc8d3e (mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents: 10581
diff changeset
4134
52cdd8cc8d3e (mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents: 10581
diff changeset
4135
11018
2d9bdf1ba3d1 (mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents: 10936
diff changeset
4136 /* Mark the pointers in the kboard objects. */
10649
52cdd8cc8d3e (mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents: 10581
diff changeset
4137
52cdd8cc8d3e (mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents: 10581
diff changeset
4138 static void
11018
2d9bdf1ba3d1 (mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents: 10936
diff changeset
4139 mark_kboards ()
10649
52cdd8cc8d3e (mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents: 10581
diff changeset
4140 {
11018
2d9bdf1ba3d1 (mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents: 10936
diff changeset
4141 KBOARD *kb;
11593
f5385353aae3 (mark_kboards): Mark the kbd macro and Vsystem_key_alist.
Karl Heuer <kwzh@gnu.org>
parents: 11430
diff changeset
4142 Lisp_Object *p;
11018
2d9bdf1ba3d1 (mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents: 10936
diff changeset
4143 for (kb = all_kboards; kb; kb = kb->next_kboard)
10649
52cdd8cc8d3e (mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents: 10581
diff changeset
4144 {
11593
f5385353aae3 (mark_kboards): Mark the kbd macro and Vsystem_key_alist.
Karl Heuer <kwzh@gnu.org>
parents: 11430
diff changeset
4145 if (kb->kbd_macro_buffer)
f5385353aae3 (mark_kboards): Mark the kbd macro and Vsystem_key_alist.
Karl Heuer <kwzh@gnu.org>
parents: 11430
diff changeset
4146 for (p = kb->kbd_macro_buffer; p < kb->kbd_macro_ptr; p++)
f5385353aae3 (mark_kboards): Mark the kbd macro and Vsystem_key_alist.
Karl Heuer <kwzh@gnu.org>
parents: 11430
diff changeset
4147 mark_object (p);
22381
50e1804145be (mark_kboards): Mark all the Lisp_Object fields.
Richard M. Stallman <rms@gnu.org>
parents: 22220
diff changeset
4148 mark_object (&kb->Voverriding_terminal_local_map);
50e1804145be (mark_kboards): Mark all the Lisp_Object fields.
Richard M. Stallman <rms@gnu.org>
parents: 22220
diff changeset
4149 mark_object (&kb->Vlast_command);
50e1804145be (mark_kboards): Mark all the Lisp_Object fields.
Richard M. Stallman <rms@gnu.org>
parents: 22220
diff changeset
4150 mark_object (&kb->Vreal_last_command);
12120
1fc112b5fdc4 (mark_kboards): Mark Vprefix_arg instead of
Karl Heuer <kwzh@gnu.org>
parents: 12096
diff changeset
4151 mark_object (&kb->Vprefix_arg);
22382
f7d2bdefcff7 (mark_kboards): Mark Vlast_prefix_arg too.
Richard M. Stallman <rms@gnu.org>
parents: 22381
diff changeset
4152 mark_object (&kb->Vlast_prefix_arg);
11018
2d9bdf1ba3d1 (mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents: 10936
diff changeset
4153 mark_object (&kb->kbd_queue);
22381
50e1804145be (mark_kboards): Mark all the Lisp_Object fields.
Richard M. Stallman <rms@gnu.org>
parents: 22220
diff changeset
4154 mark_object (&kb->defining_kbd_macro);
11018
2d9bdf1ba3d1 (mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents: 10936
diff changeset
4155 mark_object (&kb->Vlast_kbd_macro);
11593
f5385353aae3 (mark_kboards): Mark the kbd macro and Vsystem_key_alist.
Karl Heuer <kwzh@gnu.org>
parents: 11430
diff changeset
4156 mark_object (&kb->Vsystem_key_alist);
12175
4e36e9e99082 (mark_kboards): Mark system_key_syms member.
Karl Heuer <kwzh@gnu.org>
parents: 12120
diff changeset
4157 mark_object (&kb->system_key_syms);
22381
50e1804145be (mark_kboards): Mark all the Lisp_Object fields.
Richard M. Stallman <rms@gnu.org>
parents: 22220
diff changeset
4158 mark_object (&kb->Vdefault_minibuffer_frame);
10649
52cdd8cc8d3e (mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents: 10581
diff changeset
4159 }
52cdd8cc8d3e (mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents: 10581
diff changeset
4160 }
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4161
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4162
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4163 /* 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
4164 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
4165
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4166 int
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4167 survives_gc_p (obj)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4168 Lisp_Object obj;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4169 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4170 int survives_p;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4171
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4172 switch (XGCTYPE (obj))
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4173 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4174 case Lisp_Int:
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4175 survives_p = 1;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4176 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4177
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4178 case Lisp_Symbol:
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4179 survives_p = XMARKBIT (XSYMBOL (obj)->plist);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4180 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4181
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4182 case Lisp_Misc:
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4183 switch (XMISCTYPE (obj))
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4184 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4185 case Lisp_Misc_Marker:
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4186 survives_p = XMARKBIT (obj);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4187 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4188
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4189 case Lisp_Misc_Buffer_Local_Value:
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4190 case Lisp_Misc_Some_Buffer_Local_Value:
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4191 survives_p = XMARKBIT (XBUFFER_LOCAL_VALUE (obj)->realvalue);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4192 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4193
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4194 case Lisp_Misc_Intfwd:
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4195 case Lisp_Misc_Boolfwd:
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4196 case Lisp_Misc_Objfwd:
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4197 case Lisp_Misc_Buffer_Objfwd:
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4198 case Lisp_Misc_Kboard_Objfwd:
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4199 survives_p = 1;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4200 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4201
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4202 case Lisp_Misc_Overlay:
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4203 survives_p = XMARKBIT (XOVERLAY (obj)->plist);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4204 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4205
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4206 default:
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4207 abort ();
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4208 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4209 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4210
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4211 case Lisp_String:
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4212 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4213 struct Lisp_String *s = XSTRING (obj);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4214 survives_p = STRING_MARKED_P (s);
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4215 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4216 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4217
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4218 case Lisp_Vectorlike:
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4219 if (GC_BUFFERP (obj))
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4220 survives_p = XMARKBIT (XBUFFER (obj)->name);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4221 else if (GC_SUBRP (obj))
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4222 survives_p = 1;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4223 else
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4224 survives_p = XVECTOR (obj)->size & ARRAY_MARK_FLAG;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4225 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4226
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4227 case Lisp_Cons:
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4228 survives_p = XMARKBIT (XCAR (obj));
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4229 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4230
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4231 case Lisp_Float:
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4232 survives_p = XMARKBIT (XFLOAT (obj)->type);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4233 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4234
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4235 default:
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4236 abort ();
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4237 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4238
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4239 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
4240 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4241
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4242
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4243
1908
d649f2179d67 * alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents: 1893
diff changeset
4244 /* Sweep: find all structures not marked, and free them. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4245
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4246 static void
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4247 gc_sweep ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4248 {
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4249 /* 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
4250 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
4251 sweep_weak_hash_tables ();
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4252
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4253 sweep_strings ();
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4254
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4255 /* Put all unmarked conses on free list */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4256 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4257 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
4258 struct cons_block **cprev = &cons_block;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4259 register int lim = cons_block_index;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4260 register int num_free = 0, num_used = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4261
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4262 cons_free_list = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4263
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4264 for (cblk = cons_block; cblk; cblk = *cprev)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4265 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4266 register int i;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4267 int this_free = 0;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4268 for (i = 0; i < lim; i++)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4269 if (!XMARKBIT (cblk->conses[i].car))
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4270 {
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4271 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
4272 *(struct Lisp_Cons **)&cblk->conses[i].cdr = cons_free_list;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4273 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
4274 #if GC_MARK_STACK
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4275 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
4276 #endif
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4277 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4278 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4279 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4280 num_used++;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4281 XUNMARK (cblk->conses[i].car);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4282 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4283 lim = CONS_BLOCK_SIZE;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4284 /* 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
4285 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
4286 this block. */
21379
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4287 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
4288 {
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4289 *cprev = cblk->next;
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4290 /* Unhook from the free list. */
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4291 cons_free_list = *(struct Lisp_Cons **) &cblk->conses[0].cdr;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
4292 lisp_free (cblk);
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
4293 n_cons_blocks--;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4294 }
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4295 else
21379
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4296 {
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4297 num_free += this_free;
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4298 cprev = &cblk->next;
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4299 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4300 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4301 total_conses = num_used;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4302 total_free_conses = num_free;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4303 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4304
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4305 /* Put all unmarked floats on free list */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4306 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4307 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
4308 struct float_block **fprev = &float_block;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4309 register int lim = float_block_index;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4310 register int num_free = 0, num_used = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4311
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4312 float_free_list = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4313
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4314 for (fblk = float_block; fblk; fblk = *fprev)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4315 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4316 register int i;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4317 int this_free = 0;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4318 for (i = 0; i < lim; i++)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4319 if (!XMARKBIT (fblk->floats[i].type))
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4320 {
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4321 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
4322 *(struct Lisp_Float **)&fblk->floats[i].data = float_free_list;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4323 float_free_list = &fblk->floats[i];
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4324 #if GC_MARK_STACK
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4325 float_free_list->type = Vdead;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4326 #endif
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4327 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4328 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4329 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4330 num_used++;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4331 XUNMARK (fblk->floats[i].type);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4332 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4333 lim = FLOAT_BLOCK_SIZE;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4334 /* 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
4335 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
4336 this block. */
21379
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4337 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
4338 {
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4339 *fprev = fblk->next;
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4340 /* Unhook from the free list. */
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4341 float_free_list = *(struct Lisp_Float **) &fblk->floats[0].data;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
4342 lisp_free (fblk);
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
4343 n_float_blocks--;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4344 }
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4345 else
21379
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4346 {
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4347 num_free += this_free;
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4348 fprev = &fblk->next;
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4349 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4350 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4351 total_floats = num_used;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4352 total_free_floats = num_free;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4353 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4354
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4355 /* Put all unmarked intervals on free list */
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4356 {
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4357 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
4358 struct interval_block **iprev = &interval_block;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4359 register int lim = interval_block_index;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4360 register int num_free = 0, num_used = 0;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4361
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4362 interval_free_list = 0;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4363
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4364 for (iblk = interval_block; iblk; iblk = *iprev)
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4365 {
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4366 register int i;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4367 int this_free = 0;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4368
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4369 for (i = 0; i < lim; i++)
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4370 {
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4371 if (! XMARKBIT (iblk->intervals[i].plist))
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4372 {
28269
fd13be8ae190 Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents: 28220
diff changeset
4373 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
4374 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
4375 this_free++;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4376 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4377 else
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4378 {
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4379 num_used++;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4380 XUNMARK (iblk->intervals[i].plist);
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4381 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4382 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4383 lim = INTERVAL_BLOCK_SIZE;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4384 /* 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
4385 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
4386 deallocate this block. */
21379
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4387 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
4388 {
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4389 *iprev = iblk->next;
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4390 /* Unhook from the free list. */
28269
fd13be8ae190 Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents: 28220
diff changeset
4391 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
4392 lisp_free (iblk);
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
4393 n_interval_blocks--;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4394 }
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4395 else
21379
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4396 {
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4397 num_free += this_free;
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4398 iprev = &iblk->next;
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4399 }
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4400 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4401 total_intervals = num_used;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4402 total_free_intervals = num_free;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4403 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4404
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4405 /* Put all unmarked symbols on free list */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4406 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4407 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
4408 struct symbol_block **sprev = &symbol_block;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4409 register int lim = symbol_block_index;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4410 register int num_free = 0, num_used = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4411
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4412 symbol_free_list = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4413
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4414 for (sblk = symbol_block; sblk; sblk = *sprev)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4415 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4416 register int i;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4417 int this_free = 0;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4418 for (i = 0; i < lim; i++)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4419 if (!XMARKBIT (sblk->symbols[i].plist))
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4420 {
9942
c189487b08dd (free_float): Don't assume XFASTINT accesses the raw bits.
Karl Heuer <kwzh@gnu.org>
parents: 9926
diff changeset
4421 *(struct Lisp_Symbol **)&sblk->symbols[i].value = symbol_free_list;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4422 symbol_free_list = &sblk->symbols[i];
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4423 #if GC_MARK_STACK
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4424 symbol_free_list->function = Vdead;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4425 #endif
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4426 this_free++;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4427 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4428 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4429 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4430 num_used++;
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4431 if (!PURE_POINTER_P (sblk->symbols[i].name))
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4432 UNMARK_STRING (sblk->symbols[i].name);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4433 XUNMARK (sblk->symbols[i].plist);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4434 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4435 lim = SYMBOL_BLOCK_SIZE;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4436 /* 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
4437 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
4438 this block. */
21379
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4439 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
4440 {
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4441 *sprev = sblk->next;
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4442 /* Unhook from the free list. */
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4443 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
4444 lisp_free (sblk);
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
4445 n_symbol_blocks--;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4446 }
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4447 else
21379
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4448 {
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4449 num_free += this_free;
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4450 sprev = &sblk->next;
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4451 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4452 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4453 total_symbols = num_used;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4454 total_free_symbols = num_free;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4455 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4456
21143
ce12eac1ee45 (gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents: 21084
diff changeset
4457 /* 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
4458 For a marker, first unchain it from the buffer it points into. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4459 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4460 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
4461 struct marker_block **mprev = &marker_block;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4462 register int lim = marker_block_index;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4463 register int num_free = 0, num_used = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4464
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4465 marker_free_list = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4466
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4467 for (mblk = marker_block; mblk; mblk = *mprev)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4468 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4469 register int i;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4470 int this_free = 0;
11679
1ced2d67d411 (gc_cons_threshold): Make this an EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents: 11593
diff changeset
4471 EMACS_INT already_free = -1;
11403
bd3241a14d0a (gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents: 11374
diff changeset
4472
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4473 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
4474 {
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4475 Lisp_Object *markword;
11243
054ecfce1820 (Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents: 11048
diff changeset
4476 switch (mblk->markers[i].u_marker.type)
9893
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4477 {
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4478 case Lisp_Misc_Marker:
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4479 markword = &mblk->markers[i].u_marker.chain;
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4480 break;
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4481 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
4482 case Lisp_Misc_Some_Buffer_Local_Value:
21143
ce12eac1ee45 (gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents: 21084
diff changeset
4483 markword = &mblk->markers[i].u_buffer_local_value.realvalue;
9893
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4484 break;
9926
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
4485 case Lisp_Misc_Overlay:
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
4486 markword = &mblk->markers[i].u_overlay.plist;
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
4487 break;
11403
bd3241a14d0a (gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents: 11374
diff changeset
4488 case Lisp_Misc_Free:
bd3241a14d0a (gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents: 11374
diff changeset
4489 /* If the object was already free, keep it
bd3241a14d0a (gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents: 11374
diff changeset
4490 on the free list. */
18621
53b95f307c75 (memory_full): Pass Qnil to Fsignal for ERROR_SYMBOL.
Richard M. Stallman <rms@gnu.org>
parents: 18104
diff changeset
4491 markword = (Lisp_Object *) &already_free;
11403
bd3241a14d0a (gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents: 11374
diff changeset
4492 break;
9893
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4493 default:
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4494 markword = 0;
9926
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
4495 break;
9893
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4496 }
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4497 if (markword && !XMARKBIT (*markword))
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4498 {
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4499 Lisp_Object tem;
11243
054ecfce1820 (Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents: 11048
diff changeset
4500 if (mblk->markers[i].u_marker.type == Lisp_Misc_Marker)
9893
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4501 {
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4502 /* tem1 avoids Sun compiler bug */
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4503 struct Lisp_Marker *tem1 = &mblk->markers[i].u_marker;
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4504 XSETMARKER (tem, tem1);
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4505 unchain_marker (tem);
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4506 }
11403
bd3241a14d0a (gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents: 11374
diff changeset
4507 /* 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
4508 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
4509 but this might catch bugs faster. */
11243
054ecfce1820 (Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents: 11048
diff changeset
4510 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
4511 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
4512 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
4513 this_free++;
9893
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4514 }
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4515 else
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4516 {
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4517 num_used++;
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4518 if (markword)
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4519 XUNMARK (*markword);
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4520 }
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
4521 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4522 lim = MARKER_BLOCK_SIZE;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4523 /* 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
4524 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
4525 this block. */
21379
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4526 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
4527 {
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4528 *mprev = mblk->next;
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4529 /* Unhook from the free list. */
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4530 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
4531 lisp_free (mblk);
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
4532 n_marker_blocks--;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4533 }
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
4534 else
21379
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4535 {
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4536 num_free += this_free;
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4537 mprev = &mblk->next;
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
4538 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4539 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4540
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4541 total_markers = num_used;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4542 total_free_markers = num_free;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4543 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4544
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4545 /* Free all unmarked buffers */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4546 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4547 register struct buffer *buffer = all_buffers, *prev = 0, *next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4548
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4549 while (buffer)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4550 if (!XMARKBIT (buffer->name))
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4551 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4552 if (prev)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4553 prev->next = buffer->next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4554 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4555 all_buffers = buffer->next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4556 next = buffer->next;
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4557 lisp_free (buffer);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4558 buffer = next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4559 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4560 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4561 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4562 XUNMARK (buffer->name);
10307
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
4563 UNMARK_BALANCE_INTERVALS (BUF_INTERVALS (buffer));
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4564 prev = buffer, buffer = buffer->next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4565 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4566 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4567
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4568 /* Free all unmarked vectors */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4569 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4570 register struct Lisp_Vector *vector = all_vectors, *prev = 0, *next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4571 total_vector_size = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4572
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4573 while (vector)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4574 if (!(vector->size & ARRAY_MARK_FLAG))
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4575 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4576 if (prev)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4577 prev->next = vector->next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4578 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4579 all_vectors = vector->next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4580 next = vector->next;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
4581 lisp_free (vector);
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
4582 n_vectors--;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4583 vector = next;
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4584
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4585 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4586 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4587 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4588 vector->size &= ~ARRAY_MARK_FLAG;
11403
bd3241a14d0a (gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents: 11374
diff changeset
4589 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
4590 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
4591 else
bd3241a14d0a (gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents: 11374
diff changeset
4592 total_vector_size += vector->size;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4593 prev = vector, vector = vector->next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4594 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4595 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4596 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4597
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
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4600
1327
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
4601 /* Debugging aids. */
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
4602
5353
6389ed5b45ac (Fmemory_limit): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 4956
diff changeset
4603 DEFUN ("memory-limit", Fmemory_limit, Smemory_limit, 0, 0, 0,
1327
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
4604 "Return the address of the last byte Emacs has allocated, divided by 1024.\n\
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
4605 This may be helpful in debugging Emacs's memory usage.\n\
1893
b047e77f3be4 (Fmemory_limit): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 1784
diff changeset
4606 We divide the value by 1024 to make sure it fits in a Lisp integer.")
1327
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
4607 ()
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
4608 {
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
4609 Lisp_Object end;
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
4610
9261
e5ba7993d378 (VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents: 9144
diff changeset
4611 XSETINT (end, (EMACS_INT) sbrk (0) / 1024);
1327
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
4612
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
4613 return end;
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
4614 }
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
4615
12748
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
4616 DEFUN ("memory-use-counts", Fmemory_use_counts, Smemory_use_counts, 0, 0, 0,
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
4617 "Return a list of counters that measure how much consing there has been.\n\
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
4618 Each of these counters increments for a certain kind of object.\n\
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
4619 The counters wrap around from the largest positive integer to zero.\n\
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
4620 Garbage collection does not decrease them.\n\
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
4621 The elements of the value are as follows:\n\
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4622 (CONSES FLOATS VECTOR-CELLS SYMBOLS STRING-CHARS MISCS INTERVALS STRINGS)\n\
12748
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
4623 All are in units of 1 = one object consed\n\
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
4624 except for VECTOR-CELLS and STRING-CHARS, which count the total length of\n\
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
4625 objects consed.\n\
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
4626 MISCS include overlays, markers, and some internal types.\n\
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
4627 Frames, windows, buffers, and subprocesses count as vectors\n\
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
4628 (but the contents of a buffer's text do not count here).")
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
4629 ()
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
4630 {
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4631 Lisp_Object consed[8];
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4632
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4633 XSETINT (consed[0],
13320
e0f3a961851a Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents: 13219
diff changeset
4634 cons_cells_consed & ~(((EMACS_INT) 1) << (VALBITS - 1)));
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4635 XSETINT (consed[1],
13320
e0f3a961851a Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents: 13219
diff changeset
4636 floats_consed & ~(((EMACS_INT) 1) << (VALBITS - 1)));
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4637 XSETINT (consed[2],
13320
e0f3a961851a Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents: 13219
diff changeset
4638 vector_cells_consed & ~(((EMACS_INT) 1) << (VALBITS - 1)));
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4639 XSETINT (consed[3],
13320
e0f3a961851a Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents: 13219
diff changeset
4640 symbols_consed & ~(((EMACS_INT) 1) << (VALBITS - 1)));
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4641 XSETINT (consed[4],
13320
e0f3a961851a Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents: 13219
diff changeset
4642 string_chars_consed & ~(((EMACS_INT) 1) << (VALBITS - 1)));
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4643 XSETINT (consed[5],
13320
e0f3a961851a Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents: 13219
diff changeset
4644 misc_objects_consed & ~(((EMACS_INT) 1) << (VALBITS - 1)));
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4645 XSETINT (consed[6],
13320
e0f3a961851a Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents: 13219
diff changeset
4646 intervals_consed & ~(((EMACS_INT) 1) << (VALBITS - 1)));
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4647 XSETINT (consed[7],
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4648 strings_consed & ~(((EMACS_INT) 1) << (VALBITS - 1)));
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4649
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4650 return Flist (8, consed);
12748
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
4651 }
28406
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
4652
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
4653 int suppress_checking;
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
4654 void
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
4655 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
4656 const char *msg;
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
4657 const char *file;
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
4658 int line;
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
4659 {
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
4660 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
4661 file, line, msg);
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
4662 abort ();
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
4663 }
1327
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
4664
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4665 /* Initialization */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4666
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21379
diff changeset
4667 void
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4668 init_alloc_once ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4669 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4670 /* Used to do Vpurify_flag = Qt here, but Qt isn't set up yet! */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4671 pureptr = 0;
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4672 #if GC_MARK_STACK
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4673 mem_init ();
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4674 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
4675 #endif
356
5b180834eacf *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 300
diff changeset
4676 #ifdef HAVE_SHM
5b180834eacf *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 300
diff changeset
4677 pure_size = PURESIZE;
5b180834eacf *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 300
diff changeset
4678 #endif
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4679 all_vectors = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4680 ignore_warnings = 1;
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
4681 #ifdef DOUG_LEA_MALLOC
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
4682 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
4683 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
4684 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
4685 #endif
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4686 init_strings ();
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4687 init_cons ();
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4688 init_symbol ();
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4689 init_marker ();
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4690 init_float ();
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4691 init_intervals ();
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
4692
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
4693 #ifdef REL_ALLOC
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
4694 malloc_hysteresis = 32;
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
4695 #else
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
4696 malloc_hysteresis = 0;
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
4697 #endif
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
4698
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
4699 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
4700
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4701 ignore_warnings = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4702 gcprolist = 0;
26364
7b0217d9259c (Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents: 26164
diff changeset
4703 byte_stack_list = 0;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4704 staticidx = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4705 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
4706 gc_cons_threshold = 100000 * sizeof (Lisp_Object);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4707 #ifdef VIRT_ADDR_VARIES
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4708 malloc_sbrk_unused = 1<<22; /* A large number */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4709 malloc_sbrk_used = 100000; /* as reasonable as any number */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4710 #endif /* VIRT_ADDR_VARIES */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4711 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4712
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21379
diff changeset
4713 void
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4714 init_alloc ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4715 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4716 gcprolist = 0;
26364
7b0217d9259c (Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents: 26164
diff changeset
4717 byte_stack_list = 0;
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4718 #if GC_MARK_STACK
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4719 #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
4720 setjmp_tested_p = longjmps_done = 0;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4721 #endif
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4722 #endif
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4723 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4724
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4725 void
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4726 syms_of_alloc ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4727 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4728 DEFVAR_INT ("gc-cons-threshold", &gc_cons_threshold,
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4729 "*Number of bytes of consing between garbage collections.\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4730 Garbage collection can happen automatically once this many bytes have been\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4731 allocated since the last garbage collection. All data types count.\n\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4732 Garbage collection happens automatically only when `eval' is called.\n\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4733 By binding this temporarily to a large number, you can effectively\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4734 prevent garbage collection during a part of the program.");
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4735
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4736 DEFVAR_INT ("pure-bytes-used", &pureptr,
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4737 "Number of bytes of sharable Lisp data allocated so far.");
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4738
15960
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4739 DEFVAR_INT ("cons-cells-consed", &cons_cells_consed,
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4740 "Number of cons cells that have been consed so far.");
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4741
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4742 DEFVAR_INT ("floats-consed", &floats_consed,
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4743 "Number of floats that have been consed so far.");
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4744
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4745 DEFVAR_INT ("vector-cells-consed", &vector_cells_consed,
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4746 "Number of vector cells that have been consed so far.");
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4747
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4748 DEFVAR_INT ("symbols-consed", &symbols_consed,
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4749 "Number of symbols that have been consed so far.");
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4750
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4751 DEFVAR_INT ("string-chars-consed", &string_chars_consed,
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4752 "Number of string characters that have been consed so far.");
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4753
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4754 DEFVAR_INT ("misc-objects-consed", &misc_objects_consed,
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4755 "Number of miscellaneous objects that have been consed so far.");
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4756
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4757 DEFVAR_INT ("intervals-consed", &intervals_consed,
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4758 "Number of intervals that have been consed so far.");
12c61b25b7b6 (syms_of_alloc): Set up Lisp variables ...-consed,
Richard M. Stallman <rms@gnu.org>
parents: 15379
diff changeset
4759
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4760 DEFVAR_INT ("strings-consed", &strings_consed,
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4761 "Number of strings that have been consed so far.");
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4762
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4763 DEFVAR_LISP ("purify-flag", &Vpurify_flag,
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4764 "Non-nil means loading Lisp code in order to dump an executable.\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4765 This means that certain objects should be allocated in shared (pure) space.");
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4766
764
bb24f1180bb6 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4767 DEFVAR_INT ("undo-limit", &undo_limit,
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4768 "Keep no more undo information once it exceeds this size.\n\
764
bb24f1180bb6 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4769 This limit is applied when garbage collection happens.\n\
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4770 The size is counted as the number of bytes occupied,\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4771 which includes both saved text and other data.");
764
bb24f1180bb6 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4772 undo_limit = 20000;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4773
764
bb24f1180bb6 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4774 DEFVAR_INT ("undo-strong-limit", &undo_strong_limit,
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4775 "Don't keep more than this much size of undo information.\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4776 A command which pushes past this size is itself forgotten.\n\
764
bb24f1180bb6 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4777 This limit is applied when garbage collection happens.\n\
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4778 The size is counted as the number of bytes occupied,\n\
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4779 which includes both saved text and other data.");
764
bb24f1180bb6 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4780 undo_strong_limit = 30000;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4781
14959
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
4782 DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages,
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
4783 "Non-nil means display messages at start and end of garbage collection.");
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
4784 garbage_collection_messages = 0;
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
4785
6116
64417bbbb128 (memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents: 5874
diff changeset
4786 /* 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
4787 not be able to allocate the memory to hold it. */
6133
752d4237f869 (memory_signal_data): No longer static.
Richard M. Stallman <rms@gnu.org>
parents: 6116
diff changeset
4788 memory_signal_data
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
4789 = Fcons (Qerror, Fcons (build_string ("Memory exhausted--use M-x save-some-buffers RET"), Qnil));
6116
64417bbbb128 (memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents: 5874
diff changeset
4790 staticpro (&memory_signal_data);
64417bbbb128 (memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents: 5874
diff changeset
4791
11374
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
4792 staticpro (&Qgc_cons_threshold);
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
4793 Qgc_cons_threshold = intern ("gc-cons-threshold");
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
4794
13219
99b5164a319d (Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13150
diff changeset
4795 staticpro (&Qchar_table_extra_slots);
99b5164a319d (Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13150
diff changeset
4796 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
4797
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4798 defsubr (&Scons);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4799 defsubr (&Slist);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4800 defsubr (&Svector);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4801 defsubr (&Smake_byte_code);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4802 defsubr (&Smake_list);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4803 defsubr (&Smake_vector);
13141
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
4804 defsubr (&Smake_char_table);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4805 defsubr (&Smake_string);
13141
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
4806 defsubr (&Smake_bool_vector);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4807 defsubr (&Smake_symbol);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4808 defsubr (&Smake_marker);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4809 defsubr (&Spurecopy);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4810 defsubr (&Sgarbage_collect);
1327
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
4811 defsubr (&Smemory_limit);
12748
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
4812 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
4813
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4814 #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
4815 defsubr (&Sgc_status);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4816 #endif
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4817 }