annotate src/alloc.c @ 64958:baff064fbe62

*** empty log message ***
author Thien-Thi Nguyen <ttn@gnuvola.org>
date Sun, 14 Aug 2005 17:36:02 +0000
parents 47f158dcf216
children 375ab086d366 532e0a9335a9 890cc78a5a24
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.
57098
0487c26b96ee (Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56539
diff changeset
2 Copyright (C) 1985, 1986, 1988, 1993, 1994, 1995, 1997, 1998, 1999,
60143
84ff5b7a4139 (BLOCK_BYTES): Harmless typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59657
diff changeset
3 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
300
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
64084
a8fa7c632ee4 Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62681
diff changeset
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
a8fa7c632ee4 Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62681
diff changeset
20 Boston, MA 02110-1301, 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>
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
24 #include <limits.h> /* For CHAR_BIT. */
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25762
diff changeset
25
47185
2ff45b08a155 (display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents: 46833
diff changeset
26 #ifdef ALLOC_DEBUG
2ff45b08a155 (display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents: 46833
diff changeset
27 #undef INLINE
2ff45b08a155 (display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents: 46833
diff changeset
28 #endif
2ff45b08a155 (display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents: 46833
diff changeset
29
13320
e0f3a961851a Cast first arg to bzero.
Richard M. Stallman <rms@gnu.org>
parents: 13219
diff changeset
30 /* Note that this declares bzero on OSF/1. How dumb. */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
31
3003
5a73d384f45e * syssignal.h: Don't #include <signal.h>
Jim Blandy <jimb@redhat.com>
parents: 2961
diff changeset
32 #include <signal.h>
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33
58818
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
34 #ifdef HAVE_GTK_AND_PTHREAD
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
35 #include <pthread.h>
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
36 #endif
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
37
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 26088
diff changeset
38 /* This file is part of the core Lisp implementation, and thus must
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 26088
diff changeset
39 deal with the real data structures. If the Lisp implementation is
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 26088
diff changeset
40 replaced, this file likely will not be used. */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
41
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 26088
diff changeset
42 #undef HIDE_LISP_IMPLEMENTATION
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 #include "lisp.h"
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
44 #include "process.h"
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
45 #include "intervals.h"
356
5b180834eacf *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 300
diff changeset
46 #include "puresize.h"
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 #include "buffer.h"
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 #include "window.h"
31102
6a0caa788013 Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents: 30914
diff changeset
49 #include "keyboard.h"
764
bb24f1180bb6 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
50 #include "frame.h"
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
51 #include "blockinput.h"
21084
371ed7bdfd2b (Fmake_string): Handle the case INIT is a multibyte character correctly.
Richard M. Stallman <rms@gnu.org>
parents: 20849
diff changeset
52 #include "charset.h"
638
40b255f55df3 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 624
diff changeset
53 #include "syssignal.h"
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
54 #include <setjmp.h>
638
40b255f55df3 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 624
diff changeset
55
52547
623355edbb1d (GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents: 52475
diff changeset
56 /* GC_MALLOC_CHECK defined means perform validity checks of malloc'd
623355edbb1d (GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents: 52475
diff changeset
57 memory. Can do this only if using gmalloc.c. */
623355edbb1d (GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents: 52475
diff changeset
58
623355edbb1d (GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents: 52475
diff changeset
59 #if defined SYSTEM_MALLOC || defined DOUG_LEA_MALLOC
623355edbb1d (GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents: 52475
diff changeset
60 #undef GC_MALLOC_CHECK
623355edbb1d (GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents: 52475
diff changeset
61 #endif
623355edbb1d (GC_MALLOC_CHECK): Move conditional undef after lisp.h.
Dave Love <fx@gnu.org>
parents: 52475
diff changeset
62
30784
dbc1e69a89a9 [HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents: 30557
diff changeset
63 #ifdef HAVE_UNISTD_H
dbc1e69a89a9 [HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents: 30557
diff changeset
64 #include <unistd.h>
dbc1e69a89a9 [HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents: 30557
diff changeset
65 #else
dbc1e69a89a9 [HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents: 30557
diff changeset
66 extern POINTER_TYPE *sbrk ();
dbc1e69a89a9 [HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents: 30557
diff changeset
67 #endif
12096
cdc859dd813b Declare sbrk.
Karl Heuer <kwzh@gnu.org>
parents: 11892
diff changeset
68
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
69 #ifdef DOUG_LEA_MALLOC
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
70
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
71 #include <malloc.h>
31892
2f3d88ac2b38 (__malloc_size_t) [DOUG_LEA_MALLOC]: Don't redefine it.
Dave Love <fx@gnu.org>
parents: 31889
diff changeset
72 /* malloc.h #defines this as size_t, at least in glibc2. */
2f3d88ac2b38 (__malloc_size_t) [DOUG_LEA_MALLOC]: Don't redefine it.
Dave Love <fx@gnu.org>
parents: 31889
diff changeset
73 #ifndef __malloc_size_t
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
74 #define __malloc_size_t int
31892
2f3d88ac2b38 (__malloc_size_t) [DOUG_LEA_MALLOC]: Don't redefine it.
Dave Love <fx@gnu.org>
parents: 31889
diff changeset
75 #endif
23973
2eb9e2f5aa33 (MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 23958
diff changeset
76
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
77 /* Specify maximum number of areas to mmap. It would be nice to use a
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
78 value that explicitly means "no limit". */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
79
23973
2eb9e2f5aa33 (MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 23958
diff changeset
80 #define MMAP_MAX_AREAS 100000000
2eb9e2f5aa33 (MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 23958
diff changeset
81
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
82 #else /* not DOUG_LEA_MALLOC */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
83
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
84 /* The following come from gmalloc.c. */
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
85
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
86 #define __malloc_size_t size_t
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
87 extern __malloc_size_t _bytes_used;
31892
2f3d88ac2b38 (__malloc_size_t) [DOUG_LEA_MALLOC]: Don't redefine it.
Dave Love <fx@gnu.org>
parents: 31889
diff changeset
88 extern __malloc_size_t __malloc_extra_blocks;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
89
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
90 #endif /* not DOUG_LEA_MALLOC */
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
91
58818
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
92 #if ! defined (SYSTEM_MALLOC) && defined (HAVE_GTK_AND_PTHREAD)
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
93
58831
408c5135b0a2 * alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58818
diff changeset
94 /* When GTK uses the file chooser dialog, different backends can be loaded
408c5135b0a2 * alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58818
diff changeset
95 dynamically. One such a backend is the Gnome VFS backend that gets loaded
408c5135b0a2 * alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58818
diff changeset
96 if you run Gnome. That backend creates several threads and also allocates
408c5135b0a2 * alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58818
diff changeset
97 memory with malloc.
408c5135b0a2 * alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58818
diff changeset
98
408c5135b0a2 * alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58818
diff changeset
99 If Emacs sets malloc hooks (! SYSTEM_MALLOC) and the emacs_blocked_*
408c5135b0a2 * alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58818
diff changeset
100 functions below are called from malloc, there is a chance that one
408c5135b0a2 * alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58818
diff changeset
101 of these threads preempts the Emacs main thread and the hook variables
58986
59945307b86b * syssignal.h: Declare main_thread.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58831
diff changeset
102 end up in an inconsistent state. So we have a mutex to prevent that (note
58831
408c5135b0a2 * alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58818
diff changeset
103 that the backend handles concurrent access to malloc within its own threads
408c5135b0a2 * alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58818
diff changeset
104 but Emacs code running in the main thread is not included in that control).
408c5135b0a2 * alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58818
diff changeset
105
59359
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
106 When UNBLOCK_INPUT is called, reinvoke_input_signal may be called. If this
58831
408c5135b0a2 * alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58818
diff changeset
107 happens in one of the backend threads we will have two threads that tries
408c5135b0a2 * alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58818
diff changeset
108 to run Emacs code at once, and the code is not prepared for that.
408c5135b0a2 * alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58818
diff changeset
109 To prevent that, we only call BLOCK/UNBLOCK from the main thread. */
408c5135b0a2 * alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58818
diff changeset
110
58818
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
111 static pthread_mutex_t alloc_mutex;
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
112
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
113 #define BLOCK_INPUT_ALLOC \
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
114 do \
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
115 { \
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
116 pthread_mutex_lock (&alloc_mutex); \
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
117 if (pthread_self () == main_thread) \
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
118 BLOCK_INPUT; \
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
119 } \
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
120 while (0)
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
121 #define UNBLOCK_INPUT_ALLOC \
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
122 do \
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
123 { \
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
124 if (pthread_self () == main_thread) \
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
125 UNBLOCK_INPUT; \
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
126 pthread_mutex_unlock (&alloc_mutex); \
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
127 } \
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
128 while (0)
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
129
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
130 #else /* SYSTEM_MALLOC || not HAVE_GTK_AND_PTHREAD */
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
131
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
132 #define BLOCK_INPUT_ALLOC BLOCK_INPUT
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
133 #define UNBLOCK_INPUT_ALLOC UNBLOCK_INPUT
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
134
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
135 #endif /* SYSTEM_MALLOC || not HAVE_GTK_AND_PTHREAD */
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
136
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
137 /* Value of _bytes_used, when spare_memory was freed. */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
138
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
139 static __malloc_size_t bytes_used_when_full;
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
140
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
141 /* Mark, unmark, query mark bit of a Lisp string. S must be a pointer
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
142 to a struct Lisp_String. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
143
51985
b52e88c3d6d0 (MARK_STRING, UNMARK_STRING, STRING_MARKED_P)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51974
diff changeset
144 #define MARK_STRING(S) ((S)->size |= ARRAY_MARK_FLAG)
b52e88c3d6d0 (MARK_STRING, UNMARK_STRING, STRING_MARKED_P)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51974
diff changeset
145 #define UNMARK_STRING(S) ((S)->size &= ~ARRAY_MARK_FLAG)
59657
f3aa25eacdb3 (STRING_MARKED_P, VECTOR_MARKED_P): Return boolean.
Kim F. Storm <storm@cua.dk>
parents: 59400
diff changeset
146 #define STRING_MARKED_P(S) (((S)->size & ARRAY_MARK_FLAG) != 0)
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
147
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
148 #define VECTOR_MARK(V) ((V)->size |= ARRAY_MARK_FLAG)
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
149 #define VECTOR_UNMARK(V) ((V)->size &= ~ARRAY_MARK_FLAG)
59657
f3aa25eacdb3 (STRING_MARKED_P, VECTOR_MARKED_P): Return boolean.
Kim F. Storm <storm@cua.dk>
parents: 59400
diff changeset
150 #define VECTOR_MARKED_P(V) (((V)->size & ARRAY_MARK_FLAG) != 0)
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
151
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
152 /* Value is the number of bytes/chars of S, a pointer to a struct
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
153 Lisp_String. This must be used instead of STRING_BYTES (S) or
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
154 S->size during GC, because S->size contains the mark bit for
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
155 strings. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
156
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
157 #define GC_STRING_BYTES(S) (STRING_BYTES (S))
51985
b52e88c3d6d0 (MARK_STRING, UNMARK_STRING, STRING_MARKED_P)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51974
diff changeset
158 #define GC_STRING_CHARS(S) ((S)->size & ~ARRAY_MARK_FLAG)
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
159
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
160 /* Number of bytes of consing done since the last gc. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
161
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 int consing_since_gc;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163
12748
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
164 /* Count the amount of consing of various sorts of space. */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
165
43713
f92c4d87863a Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43314
diff changeset
166 EMACS_INT cons_cells_consed;
f92c4d87863a Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43314
diff changeset
167 EMACS_INT floats_consed;
f92c4d87863a Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43314
diff changeset
168 EMACS_INT vector_cells_consed;
f92c4d87863a Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43314
diff changeset
169 EMACS_INT symbols_consed;
f92c4d87863a Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43314
diff changeset
170 EMACS_INT string_chars_consed;
f92c4d87863a Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43314
diff changeset
171 EMACS_INT misc_objects_consed;
f92c4d87863a Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43314
diff changeset
172 EMACS_INT intervals_consed;
f92c4d87863a Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43314
diff changeset
173 EMACS_INT strings_consed;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
174
64611
47f158dcf216 (gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents: 64273
diff changeset
175 /* Minimum number of bytes of consing since GC before next GC. */
47f158dcf216 (gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents: 64273
diff changeset
176
47f158dcf216 (gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents: 64273
diff changeset
177 EMACS_INT gc_cons_threshold;
47f158dcf216 (gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents: 64273
diff changeset
178
47f158dcf216 (gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents: 64273
diff changeset
179 /* Similar minimum, computed from Vgc_cons_percentage. */
47f158dcf216 (gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents: 64273
diff changeset
180
47f158dcf216 (gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents: 64273
diff changeset
181 EMACS_INT gc_relative_threshold;
47f158dcf216 (gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents: 64273
diff changeset
182
64267
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
183 static Lisp_Object Vgc_cons_percentage;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
185 /* Nonzero during GC. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
186
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 int gc_in_progress;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188
50745
fedd03de0f46 (abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 50626
diff changeset
189 /* Nonzero means abort if try to GC.
fedd03de0f46 (abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 50626
diff changeset
190 This is for code which is written on the assumption that
fedd03de0f46 (abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 50626
diff changeset
191 no GC will happen, so as to verify that assumption. */
fedd03de0f46 (abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 50626
diff changeset
192
fedd03de0f46 (abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 50626
diff changeset
193 int abort_on_gc;
fedd03de0f46 (abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 50626
diff changeset
194
14959
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
195 /* 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
196
14959
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
197 int garbage_collection_messages;
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
198
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 #ifndef VIRT_ADDR_VARIES
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 extern
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 #endif /* VIRT_ADDR_VARIES */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
202 int malloc_sbrk_used;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 #ifndef VIRT_ADDR_VARIES
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 extern
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 #endif /* VIRT_ADDR_VARIES */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
207 int malloc_sbrk_unused;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
209 /* 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
210
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
211 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
212 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
213 static int total_free_floats, total_floats;
19332
58f14958f5d5 (free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents: 18621
diff changeset
214
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
215 /* 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
216 out of memory. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
217
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
218 static char *spare_memory;
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
219
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
220 /* 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
221
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
222 #define SPARE_MEMORY (1 << 14)
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
223
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
224 /* 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
225
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
226 static int malloc_hysteresis;
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
227
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
228 /* 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
229
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 Lisp_Object Vpurify_flag;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231
46305
fed6b815dbeb (Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 46293
diff changeset
232 /* Non-nil means we are handling a memory-full error. */
fed6b815dbeb (Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 46293
diff changeset
233
fed6b815dbeb (Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 46293
diff changeset
234 Lisp_Object Vmemory_full;
fed6b815dbeb (Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 46293
diff changeset
235
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 #ifndef HAVE_SHM
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
237
57137
646750cbd594 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 57098
diff changeset
238 /* Initialize it to a nonzero value to force it into data space
646750cbd594 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 57098
diff changeset
239 (rather than bss space). That way unexec will remap it into text
646750cbd594 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 57098
diff changeset
240 space (pure), on some systems. We have not implemented the
646750cbd594 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 57098
diff changeset
241 remapping on more recent systems because this is less important
646750cbd594 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 57098
diff changeset
242 nowadays than in the days of small memories and timesharing. */
51908
cb3976b5e59f (pure, staticvec): Initialize these arrays to nonzero, so that they're
Paul Eggert <eggert@twinsun.com>
parents: 51907
diff changeset
243
cb3976b5e59f (pure, staticvec): Initialize these arrays to nonzero, so that they're
Paul Eggert <eggert@twinsun.com>
parents: 51907
diff changeset
244 EMACS_INT pure[PURESIZE / sizeof (EMACS_INT)] = {1,};
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245 #define PUREBEG (char *) pure
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
246
39572
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
247 #else /* HAVE_SHM */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
248
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 #define pure PURE_SEG_BITS /* Use shared memory segment */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 #define PUREBEG (char *)PURE_SEG_BITS
356
5b180834eacf *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 300
diff changeset
251
39572
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
252 #endif /* HAVE_SHM */
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
253
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
254 /* Pointer to the pure area, and its size. */
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
255
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
256 static char *purebeg;
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
257 static size_t pure_size;
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
258
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
259 /* Number of bytes of pure storage used before pure storage overflowed.
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
260 If this is non-zero, this implies that an overflow occurred. */
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
261
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
262 static size_t pure_bytes_used_before_overflow;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
264 /* 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
265
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
266 #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
267 (((PNTR_COMPARISON_TYPE) (P) \
39572
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
268 < (PNTR_COMPARISON_TYPE) ((char *) purebeg + pure_size)) \
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
269 && ((PNTR_COMPARISON_TYPE) (P) \
39572
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
270 >= (PNTR_COMPARISON_TYPE) purebeg))
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
271
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
272 /* 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
273
43713
f92c4d87863a Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43314
diff changeset
274 EMACS_INT pure_bytes_used;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
276 /* 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
277 displayed. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
278
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 char *pending_malloc_warning;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280
6116
64417bbbb128 (memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents: 5874
diff changeset
281 /* 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
282
46305
fed6b815dbeb (Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 46293
diff changeset
283 Lisp_Object Vmemory_signal_data;
6116
64417bbbb128 (memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents: 5874
diff changeset
284
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 /* Maximum amount of C stack to save when a GC happens. */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 #ifndef MAX_SAVE_STACK
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 #define MAX_SAVE_STACK 16000
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 #endif
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 /* 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
292
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 char *stack_copy;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 int stack_copy_size;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
296 /* 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
297 Currently not used. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
298
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 int ignore_warnings;
1318
0edeba6fc9fc Fixed typos.
Joseph Arceneaux <jla@gnu.org>
parents: 1300
diff changeset
300
13219
99b5164a319d (Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13150
diff changeset
301 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
302
39572
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
303 /* Hook run after GC has finished. */
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
304
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
305 Lisp_Object Vpost_gc_hook, Qpost_gc_hook;
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
306
49529
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
307 Lisp_Object Vgc_elapsed; /* accumulated elapsed time in GC */
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
308 EMACS_INT gcs_done; /* accumulated GCs */
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
309
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
310 static void mark_buffer P_ ((Lisp_Object));
51578
42f25a716cb8 (mark_kboards): Move to keyboard.c.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51318
diff changeset
311 extern void mark_kboards P_ ((void));
55798
a1bb695e9a0c (struct backtrace): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55767
diff changeset
312 extern void mark_backtrace P_ ((void));
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
313 static void gc_sweep P_ ((void));
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
314 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
315 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
316
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
317 #ifdef HAVE_WINDOW_SYSTEM
59400
eeb8b96d077d (mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents: 59359
diff changeset
318 extern void mark_fringe_data P_ ((void));
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
319 static void mark_image P_ ((struct image *));
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
320 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
321 #endif /* HAVE_WINDOW_SYSTEM */
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
322
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
323 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
324 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
325 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
326 static void sweep_strings P_ ((void));
20495
db1be942dc12 (Fgarbage_collect):
Richard M. Stallman <rms@gnu.org>
parents: 20391
diff changeset
327
db1be942dc12 (Fgarbage_collect):
Richard M. Stallman <rms@gnu.org>
parents: 20391
diff changeset
328 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
329
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
330 /* 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
331 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
332 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
333
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
334 enum mem_type
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
335 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
336 MEM_TYPE_NON_LISP,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
337 MEM_TYPE_BUFFER,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
338 MEM_TYPE_CONS,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
339 MEM_TYPE_STRING,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
340 MEM_TYPE_MISC,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
341 MEM_TYPE_SYMBOL,
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
342 MEM_TYPE_FLOAT,
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
343 /* Keep the following vector-like types together, with
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
344 MEM_TYPE_WINDOW being the last, and MEM_TYPE_VECTOR the
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
345 first. Or change the code of live_vector_p, for instance. */
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
346 MEM_TYPE_VECTOR,
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
347 MEM_TYPE_PROCESS,
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
348 MEM_TYPE_HASH_TABLE,
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
349 MEM_TYPE_FRAME,
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
350 MEM_TYPE_WINDOW
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
351 };
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
352
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
353 #if GC_MARK_STACK || defined GC_MALLOC_CHECK
27746
2556e20596b8 (enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents: 27738
diff changeset
354
2556e20596b8 (enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents: 27738
diff changeset
355 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
2556e20596b8 (enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents: 27738
diff changeset
356 #include <stdio.h> /* For fprintf. */
2556e20596b8 (enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents: 27738
diff changeset
357 #endif
2556e20596b8 (enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents: 27738
diff changeset
358
2556e20596b8 (enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents: 27738
diff changeset
359 /* 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
360 on free lists recognizable in O(1). */
2556e20596b8 (enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents: 27738
diff changeset
361
2556e20596b8 (enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents: 27738
diff changeset
362 Lisp_Object Vdead;
2556e20596b8 (enum mem_type): Compile unconditionally.
Gerd Moellmann <gerd@gnu.org>
parents: 27738
diff changeset
363
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
364 #ifdef GC_MALLOC_CHECK
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
365
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
366 enum mem_type allocated_mem_type;
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
367 int dont_register_blocks;
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
368
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
369 #endif /* GC_MALLOC_CHECK */
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
370
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
371 /* A node in the red-black tree describing allocated memory containing
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
372 Lisp data. Each such block is recorded with its start and end
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
373 address when it is allocated, and removed from the tree when it
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
374 is freed.
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
375
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
376 A red-black tree is a balanced binary tree with the following
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
377 properties:
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
378
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
379 1. Every node is either red or black.
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
380 2. Every leaf is black.
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
381 3. If a node is red, then both of its children are black.
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
382 4. Every simple path from a node to a descendant leaf contains
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
383 the same number of black nodes.
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
384 5. The root is always black.
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
385
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
386 When nodes are inserted into the tree, or deleted from the tree,
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
387 the tree is "fixed" so that these properties are always true.
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
388
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
389 A red-black tree with N internal nodes has height at most 2
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
390 log(N+1). Searches, insertions and deletions are done in O(log N).
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
391 Please see a text book about data structures for a detailed
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
392 description of red-black trees. Any book worth its salt should
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
393 describe them. */
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
394
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
395 struct mem_node
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
396 {
48907
3bf6323fe318 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 48316
diff changeset
397 /* Children of this node. These pointers are never NULL. When there
3bf6323fe318 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 48316
diff changeset
398 is no child, the value is MEM_NIL, which points to a dummy node. */
3bf6323fe318 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 48316
diff changeset
399 struct mem_node *left, *right;
3bf6323fe318 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 48316
diff changeset
400
3bf6323fe318 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 48316
diff changeset
401 /* The parent of this node. In the root node, this is NULL. */
3bf6323fe318 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 48316
diff changeset
402 struct mem_node *parent;
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
403
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
404 /* Start and end of allocated region. */
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
405 void *start, *end;
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
406
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
407 /* Node color. */
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
408 enum {MEM_BLACK, MEM_RED} color;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
409
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
410 /* Memory type. */
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
411 enum mem_type type;
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
412 };
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
413
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
414 /* Base address of stack. Set in main. */
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
415
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
416 Lisp_Object *stack_base;
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
417
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
418 /* Root of the tree describing allocated Lisp memory. */
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
419
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
420 static struct mem_node *mem_root;
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
421
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
422 /* Lowest and highest known address in the heap. */
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
423
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
424 static void *min_heap_address, *max_heap_address;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
425
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
426 /* Sentinel node of the tree. */
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
427
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
428 static struct mem_node mem_z;
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
429 #define MEM_NIL &mem_z
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
430
30914
6362b1fc09f2 (lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents: 30823
diff changeset
431 static POINTER_TYPE *lisp_malloc P_ ((size_t, enum mem_type));
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
432 static struct Lisp_Vector *allocate_vectorlike P_ ((EMACS_INT, enum mem_type));
30784
dbc1e69a89a9 [HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents: 30557
diff changeset
433 static void lisp_free P_ ((POINTER_TYPE *));
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
434 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
435 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
436 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
437 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
438 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
439 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
440 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
441 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
442 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
443 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
444 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
445 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
446 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
447 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
448 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
449 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
450 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
451 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
452
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
453 #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
454 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
455 #endif
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
456
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
457 #endif /* GC_MARK_STACK || GC_MALLOC_CHECK */
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
458
32594
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
459 /* Recording what needs to be marked for gc. */
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
460
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
461 struct gcpro *gcprolist;
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
462
51908
cb3976b5e59f (pure, staticvec): Initialize these arrays to nonzero, so that they're
Paul Eggert <eggert@twinsun.com>
parents: 51907
diff changeset
463 /* Addresses of staticpro'd variables. Initialize it to a nonzero
cb3976b5e59f (pure, staticvec): Initialize these arrays to nonzero, so that they're
Paul Eggert <eggert@twinsun.com>
parents: 51907
diff changeset
464 value; otherwise some compilers put it into BSS. */
32594
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
465
43313
32f59a921eb9 (NSTATICS): Increase to 1280.
Andreas Schwab <schwab@suse.de>
parents: 43302
diff changeset
466 #define NSTATICS 1280
51908
cb3976b5e59f (pure, staticvec): Initialize these arrays to nonzero, so that they're
Paul Eggert <eggert@twinsun.com>
parents: 51907
diff changeset
467 Lisp_Object *staticvec[NSTATICS] = {&Vpurify_flag};
32594
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
468
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
469 /* Index of next unused slot in staticvec. */
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
470
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
471 int staticidx = 0;
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
472
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
473 static POINTER_TYPE *pure_alloc P_ ((size_t, int));
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
474
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
475
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
476 /* Value is SZ rounded up to the next multiple of ALIGNMENT.
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
477 ALIGNMENT must be a power of 2. */
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
478
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
479 #define ALIGN(ptr, ALIGNMENT) \
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
480 ((POINTER_TYPE *) ((((EMACS_UINT)(ptr)) + (ALIGNMENT) - 1) \
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
481 & ~((ALIGNMENT) - 1)))
32594
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
482
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
483
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
484
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
485 /************************************************************************
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
486 Malloc
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
487 ************************************************************************/
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
488
47185
2ff45b08a155 (display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents: 46833
diff changeset
489 /* Function malloc calls this if it finds we are near exhausting storage. */
20375
1dd0bd0749b5 (malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents: 20057
diff changeset
490
1dd0bd0749b5 (malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents: 20057
diff changeset
491 void
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
492 malloc_warning (str)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493 char *str;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
495 pending_malloc_warning = str;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
496 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
497
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
498
47185
2ff45b08a155 (display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents: 46833
diff changeset
499 /* Display an already-pending malloc warning. */
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
500
20375
1dd0bd0749b5 (malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents: 20057
diff changeset
501 void
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
502 display_malloc_warning ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
503 {
47185
2ff45b08a155 (display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents: 46833
diff changeset
504 call3 (intern ("display-warning"),
2ff45b08a155 (display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents: 46833
diff changeset
505 intern ("alloc"),
2ff45b08a155 (display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents: 46833
diff changeset
506 build_string (pending_malloc_warning),
2ff45b08a155 (display_malloc_warning): Use display-warning.
Richard M. Stallman <rms@gnu.org>
parents: 46833
diff changeset
507 intern ("emergency"));
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
508 pending_malloc_warning = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
510
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
511
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
512 #ifdef DOUG_LEA_MALLOC
17831
9238a2254a23 (BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents: 17348
diff changeset
513 # 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
514 #else
17831
9238a2254a23 (BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents: 17348
diff changeset
515 # 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
516 #endif
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
517
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
518
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
519 /* 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
520
20375
1dd0bd0749b5 (malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents: 20057
diff changeset
521 void
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
522 memory_full ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
523 {
46305
fed6b815dbeb (Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 46293
diff changeset
524 Vmemory_full = Qt;
fed6b815dbeb (Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 46293
diff changeset
525
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
526 #ifndef SYSTEM_MALLOC
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
527 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
528 #endif
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
529
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
530 /* 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
531 if (spare_memory)
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
532 {
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
533 free (spare_memory);
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
534 spare_memory = 0;
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
535 }
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
536
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
537 /* 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
538 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
539 while (1)
46305
fed6b815dbeb (Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 46293
diff changeset
540 Fsignal (Qnil, Vmemory_signal_data);
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
541 }
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
542
62335
401714f3f9de (Fmemory_full_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 61685
diff changeset
543 DEFUN ("memory-full-p", Fmemory_full_p, Smemory_full_p, 0, 0, 0,
401714f3f9de (Fmemory_full_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 61685
diff changeset
544 doc: /* t if memory is nearly full, nil otherwise. */)
401714f3f9de (Fmemory_full_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 61685
diff changeset
545 ()
401714f3f9de (Fmemory_full_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 61685
diff changeset
546 {
401714f3f9de (Fmemory_full_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 61685
diff changeset
547 return (spare_memory ? Qnil : Qt);
401714f3f9de (Fmemory_full_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 61685
diff changeset
548 }
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
549
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
550 /* 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
551
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
552 void
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
553 buffer_memory_full ()
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
554 {
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
555 /* 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
556 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
557 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
558 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
559 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
560 malloc. */
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
561
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
562 #ifndef REL_ALLOC
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
563 memory_full ();
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
564 #endif
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
565
46305
fed6b815dbeb (Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 46293
diff changeset
566 Vmemory_full = Qt;
fed6b815dbeb (Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 46293
diff changeset
567
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
568 /* 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
569 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
570 while (1)
46305
fed6b815dbeb (Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 46293
diff changeset
571 Fsignal (Qnil, Vmemory_signal_data);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
572 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
573
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
574
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
575 #ifdef XMALLOC_OVERRUN_CHECK
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
576
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
577 /* Check for overrun in malloc'ed buffers by wrapping a 16 byte header
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
578 and a 16 byte trailer around each block.
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
579
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
580 The header consists of 12 fixed bytes + a 4 byte integer contaning the
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
581 original block size, while the trailer consists of 16 fixed bytes.
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
582
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
583 The header is used to detect whether this block has been allocated
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
584 through these functions -- as it seems that some low-level libc
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
585 functions may bypass the malloc hooks.
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
586 */
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
587
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
588
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
589 #define XMALLOC_OVERRUN_CHECK_SIZE 16
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
590
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
591 static char xmalloc_overrun_check_header[XMALLOC_OVERRUN_CHECK_SIZE-4] =
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
592 { 0x9a, 0x9b, 0xae, 0xaf,
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
593 0xbf, 0xbe, 0xce, 0xcf,
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
594 0xea, 0xeb, 0xec, 0xed };
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
595
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
596 static char xmalloc_overrun_check_trailer[XMALLOC_OVERRUN_CHECK_SIZE] =
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
597 { 0xaa, 0xab, 0xac, 0xad,
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
598 0xba, 0xbb, 0xbc, 0xbd,
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
599 0xca, 0xcb, 0xcc, 0xcd,
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
600 0xda, 0xdb, 0xdc, 0xdd };
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
601
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
602 /* Macros to insert and extract the block size in the header. */
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
603
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
604 #define XMALLOC_PUT_SIZE(ptr, size) \
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
605 (ptr[-1] = (size & 0xff), \
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
606 ptr[-2] = ((size >> 8) & 0xff), \
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
607 ptr[-3] = ((size >> 16) & 0xff), \
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
608 ptr[-4] = ((size >> 24) & 0xff))
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
609
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
610 #define XMALLOC_GET_SIZE(ptr) \
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
611 (size_t)((unsigned)(ptr[-1]) | \
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
612 ((unsigned)(ptr[-2]) << 8) | \
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
613 ((unsigned)(ptr[-3]) << 16) | \
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
614 ((unsigned)(ptr[-4]) << 24))
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
615
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
616
59083
4295cf593352 Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59082
diff changeset
617 /* The call depth in overrun_check functions. For example, this might happen:
4295cf593352 Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59082
diff changeset
618 xmalloc()
4295cf593352 Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59082
diff changeset
619 overrun_check_malloc()
4295cf593352 Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59082
diff changeset
620 -> malloc -> (via hook)_-> emacs_blocked_malloc
4295cf593352 Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59082
diff changeset
621 -> overrun_check_malloc
4295cf593352 Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59082
diff changeset
622 call malloc (hooks are NULL, so real malloc is called).
4295cf593352 Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59082
diff changeset
623 malloc returns 10000.
4295cf593352 Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59082
diff changeset
624 add overhead, return 10016.
4295cf593352 Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59082
diff changeset
625 <- (back in overrun_check_malloc)
59082
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
626 add overhead again, return 10032
59083
4295cf593352 Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59082
diff changeset
627 xmalloc returns 10032.
59082
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
628
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
629 (time passes).
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
630
59083
4295cf593352 Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59082
diff changeset
631 xfree(10032)
4295cf593352 Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59082
diff changeset
632 overrun_check_free(10032)
4295cf593352 Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59082
diff changeset
633 decrease overhed
4295cf593352 Update comment for check_depth.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59082
diff changeset
634 free(10016) <- crash, because 10000 is the original pointer. */
59082
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
635
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
636 static int check_depth;
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
637
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
638 /* Like malloc, but wraps allocated block with header and trailer. */
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
639
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
640 POINTER_TYPE *
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
641 overrun_check_malloc (size)
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
642 size_t size;
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
643 {
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
644 register unsigned char *val;
59082
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
645 size_t overhead = ++check_depth == 1 ? XMALLOC_OVERRUN_CHECK_SIZE*2 : 0;
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
646
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
647 val = (unsigned char *) malloc (size + overhead);
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
648 if (val && check_depth == 1)
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
649 {
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
650 bcopy (xmalloc_overrun_check_header, val, XMALLOC_OVERRUN_CHECK_SIZE - 4);
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
651 val += XMALLOC_OVERRUN_CHECK_SIZE;
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
652 XMALLOC_PUT_SIZE(val, size);
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
653 bcopy (xmalloc_overrun_check_trailer, val + size, XMALLOC_OVERRUN_CHECK_SIZE);
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
654 }
59082
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
655 --check_depth;
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
656 return (POINTER_TYPE *)val;
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
657 }
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
658
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
659
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
660 /* Like realloc, but checks old block for overrun, and wraps new block
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
661 with header and trailer. */
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
662
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
663 POINTER_TYPE *
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
664 overrun_check_realloc (block, size)
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
665 POINTER_TYPE *block;
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
666 size_t size;
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
667 {
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
668 register unsigned char *val = (unsigned char *)block;
59082
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
669 size_t overhead = ++check_depth == 1 ? XMALLOC_OVERRUN_CHECK_SIZE*2 : 0;
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
670
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
671 if (val
59082
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
672 && check_depth == 1
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
673 && bcmp (xmalloc_overrun_check_header,
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
674 val - XMALLOC_OVERRUN_CHECK_SIZE,
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
675 XMALLOC_OVERRUN_CHECK_SIZE - 4) == 0)
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
676 {
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
677 size_t osize = XMALLOC_GET_SIZE (val);
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
678 if (bcmp (xmalloc_overrun_check_trailer,
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
679 val + osize,
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
680 XMALLOC_OVERRUN_CHECK_SIZE))
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
681 abort ();
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
682 bzero (val + osize, XMALLOC_OVERRUN_CHECK_SIZE);
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
683 val -= XMALLOC_OVERRUN_CHECK_SIZE;
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
684 bzero (val, XMALLOC_OVERRUN_CHECK_SIZE);
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
685 }
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
686
59082
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
687 val = (unsigned char *) realloc ((POINTER_TYPE *)val, size + overhead);
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
688
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
689 if (val && check_depth == 1)
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
690 {
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
691 bcopy (xmalloc_overrun_check_header, val, XMALLOC_OVERRUN_CHECK_SIZE - 4);
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
692 val += XMALLOC_OVERRUN_CHECK_SIZE;
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
693 XMALLOC_PUT_SIZE(val, size);
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
694 bcopy (xmalloc_overrun_check_trailer, val + size, XMALLOC_OVERRUN_CHECK_SIZE);
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
695 }
59082
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
696 --check_depth;
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
697 return (POINTER_TYPE *)val;
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
698 }
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
699
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
700 /* Like free, but checks block for overrun. */
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
701
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
702 void
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
703 overrun_check_free (block)
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
704 POINTER_TYPE *block;
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
705 {
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
706 unsigned char *val = (unsigned char *)block;
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
707
59082
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
708 ++check_depth;
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
709 if (val
59082
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
710 && check_depth == 1
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
711 && bcmp (xmalloc_overrun_check_header,
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
712 val - XMALLOC_OVERRUN_CHECK_SIZE,
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
713 XMALLOC_OVERRUN_CHECK_SIZE - 4) == 0)
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
714 {
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
715 size_t osize = XMALLOC_GET_SIZE (val);
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
716 if (bcmp (xmalloc_overrun_check_trailer,
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
717 val + osize,
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
718 XMALLOC_OVERRUN_CHECK_SIZE))
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
719 abort ();
59400
eeb8b96d077d (mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents: 59359
diff changeset
720 #ifdef XMALLOC_CLEAR_FREE_MEMORY
eeb8b96d077d (mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents: 59359
diff changeset
721 val -= XMALLOC_OVERRUN_CHECK_SIZE;
eeb8b96d077d (mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents: 59359
diff changeset
722 memset (val, 0xff, osize + XMALLOC_OVERRUN_CHECK_SIZE*2);
eeb8b96d077d (mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents: 59359
diff changeset
723 #else
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
724 bzero (val + osize, XMALLOC_OVERRUN_CHECK_SIZE);
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
725 val -= XMALLOC_OVERRUN_CHECK_SIZE;
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
726 bzero (val, XMALLOC_OVERRUN_CHECK_SIZE);
59400
eeb8b96d077d (mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents: 59359
diff changeset
727 #endif
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
728 }
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
729
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
730 free (val);
59082
f487226310e0 * alloc.c (check_depth): New variable.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59047
diff changeset
731 --check_depth;
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
732 }
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
733
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
734 #undef malloc
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
735 #undef realloc
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
736 #undef free
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
737 #define malloc overrun_check_malloc
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
738 #define realloc overrun_check_realloc
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
739 #define free overrun_check_free
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
740 #endif
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
741
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
742
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
743 /* Like malloc but check for no memory and block interrupt input.. */
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
744
29781
4a3b0c2cbcd5 (xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents: 29743
diff changeset
745 POINTER_TYPE *
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
746 xmalloc (size)
30557
5056adb52e97 (lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents: 30317
diff changeset
747 size_t size;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
748 {
29781
4a3b0c2cbcd5 (xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents: 29743
diff changeset
749 register POINTER_TYPE *val;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
750
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
751 BLOCK_INPUT;
29781
4a3b0c2cbcd5 (xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents: 29743
diff changeset
752 val = (POINTER_TYPE *) malloc (size);
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
753 UNBLOCK_INPUT;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
754
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
755 if (!val && size)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
756 memory_full ();
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
757 return val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
758 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
759
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
760
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
761 /* 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
762
29781
4a3b0c2cbcd5 (xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents: 29743
diff changeset
763 POINTER_TYPE *
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
764 xrealloc (block, size)
29781
4a3b0c2cbcd5 (xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents: 29743
diff changeset
765 POINTER_TYPE *block;
30557
5056adb52e97 (lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents: 30317
diff changeset
766 size_t size;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
767 {
29781
4a3b0c2cbcd5 (xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents: 29743
diff changeset
768 register POINTER_TYPE *val;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
769
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
770 BLOCK_INPUT;
590
1a6483439acc *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
771 /* We must call malloc explicitly when BLOCK is 0, since some
1a6483439acc *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
772 reallocs don't do this. */
1a6483439acc *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
773 if (! block)
29781
4a3b0c2cbcd5 (xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents: 29743
diff changeset
774 val = (POINTER_TYPE *) malloc (size);
600
a8d78999e46d *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 590
diff changeset
775 else
29781
4a3b0c2cbcd5 (xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents: 29743
diff changeset
776 val = (POINTER_TYPE *) realloc (block, size);
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
777 UNBLOCK_INPUT;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
778
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
779 if (!val && size) memory_full ();
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
780 return val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
781 }
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
782
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
783
52276
5623f26dff58 (lisp_align_malloc): Change type of `aligned'.
Dave Love <fx@gnu.org>
parents: 52256
diff changeset
784 /* Like free but block interrupt input. */
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
785
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
786 void
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
787 xfree (block)
29781
4a3b0c2cbcd5 (xmalloc, xrealloc, xfree): Define using POINTER_TYPE.
Dave Love <fx@gnu.org>
parents: 29743
diff changeset
788 POINTER_TYPE *block;
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
789 {
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
790 BLOCK_INPUT;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
791 free (block);
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
792 UNBLOCK_INPUT;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
793 }
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
794
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
795
28411
ecba29fa0198 (xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents: 28406
diff changeset
796 /* Like strdup, but uses xmalloc. */
ecba29fa0198 (xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents: 28406
diff changeset
797
ecba29fa0198 (xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents: 28406
diff changeset
798 char *
ecba29fa0198 (xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents: 28406
diff changeset
799 xstrdup (s)
46459
0a9cbcbdbe45 (xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents: 46418
diff changeset
800 const char *s;
28411
ecba29fa0198 (xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents: 28406
diff changeset
801 {
30557
5056adb52e97 (lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents: 30317
diff changeset
802 size_t len = strlen (s) + 1;
28411
ecba29fa0198 (xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents: 28406
diff changeset
803 char *p = (char *) xmalloc (len);
ecba29fa0198 (xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents: 28406
diff changeset
804 bcopy (s, p, len);
ecba29fa0198 (xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents: 28406
diff changeset
805 return p;
ecba29fa0198 (xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents: 28406
diff changeset
806 }
ecba29fa0198 (xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents: 28406
diff changeset
807
ecba29fa0198 (xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents: 28406
diff changeset
808
56187
e3720731abbb (safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents: 55838
diff changeset
809 /* Unwind for SAFE_ALLOCA */
e3720731abbb (safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents: 55838
diff changeset
810
e3720731abbb (safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents: 55838
diff changeset
811 Lisp_Object
e3720731abbb (safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents: 55838
diff changeset
812 safe_alloca_unwind (arg)
e3720731abbb (safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents: 55838
diff changeset
813 Lisp_Object arg;
e3720731abbb (safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents: 55838
diff changeset
814 {
56202
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
815 register struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
816
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
817 p->dogc = 0;
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
818 xfree (p->pointer);
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
819 p->pointer = 0;
56239
a446552d2240 (allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents: 56202
diff changeset
820 free_misc (arg);
56187
e3720731abbb (safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents: 55838
diff changeset
821 return Qnil;
e3720731abbb (safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents: 55838
diff changeset
822 }
e3720731abbb (safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents: 55838
diff changeset
823
e3720731abbb (safe_alloca_unwind): New function.
Kim F. Storm <storm@cua.dk>
parents: 55838
diff changeset
824
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
825 /* 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
826 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
827 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
828
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
829 #ifndef USE_LSB_TAG
50468
16fdb9f87d89 (VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents: 50274
diff changeset
830 static void *lisp_malloc_loser;
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
831 #endif
50468
16fdb9f87d89 (VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents: 50274
diff changeset
832
30557
5056adb52e97 (lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents: 30317
diff changeset
833 static POINTER_TYPE *
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
834 lisp_malloc (nbytes, type)
30557
5056adb52e97 (lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents: 30317
diff changeset
835 size_t nbytes;
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
836 enum mem_type type;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
837 {
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
838 register void *val;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
839
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
840 BLOCK_INPUT;
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
841
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
842 #ifdef GC_MALLOC_CHECK
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
843 allocated_mem_type = type;
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
844 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
845
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
846 val = (void *) malloc (nbytes);
28411
ecba29fa0198 (xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents: 28406
diff changeset
847
53650
5558449888ec (lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53582
diff changeset
848 #ifndef USE_LSB_TAG
50468
16fdb9f87d89 (VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents: 50274
diff changeset
849 /* If the memory just allocated cannot be addressed thru a Lisp
16fdb9f87d89 (VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents: 50274
diff changeset
850 object's pointer, and it needs to be,
16fdb9f87d89 (VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents: 50274
diff changeset
851 that's equivalent to running out of memory. */
16fdb9f87d89 (VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents: 50274
diff changeset
852 if (val && type != MEM_TYPE_NON_LISP)
16fdb9f87d89 (VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents: 50274
diff changeset
853 {
16fdb9f87d89 (VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents: 50274
diff changeset
854 Lisp_Object tem;
16fdb9f87d89 (VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents: 50274
diff changeset
855 XSETCONS (tem, (char *) val + nbytes - 1);
16fdb9f87d89 (VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents: 50274
diff changeset
856 if ((char *) XCONS (tem) != (char *) val + nbytes - 1)
16fdb9f87d89 (VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents: 50274
diff changeset
857 {
16fdb9f87d89 (VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents: 50274
diff changeset
858 lisp_malloc_loser = val;
16fdb9f87d89 (VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents: 50274
diff changeset
859 free (val);
16fdb9f87d89 (VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents: 50274
diff changeset
860 val = 0;
16fdb9f87d89 (VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents: 50274
diff changeset
861 }
16fdb9f87d89 (VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents: 50274
diff changeset
862 }
53650
5558449888ec (lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53582
diff changeset
863 #endif
50468
16fdb9f87d89 (VALIDATE_LISP_STORAGE): Macro deleted. All calls deleted.
Richard M. Stallman <rms@gnu.org>
parents: 50274
diff changeset
864
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
865 #if GC_MARK_STACK && !defined GC_MALLOC_CHECK
28411
ecba29fa0198 (xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents: 28406
diff changeset
866 if (val && type != MEM_TYPE_NON_LISP)
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
867 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
868 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
869
28411
ecba29fa0198 (xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents: 28406
diff changeset
870 UNBLOCK_INPUT;
ecba29fa0198 (xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents: 28406
diff changeset
871 if (!val && nbytes)
ecba29fa0198 (xstrdup): Moved here from xfaces.c.
Gerd Moellmann <gerd@gnu.org>
parents: 28406
diff changeset
872 memory_full ();
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
873 return val;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
874 }
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
875
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
876 /* 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
877 call to lisp_malloc. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
878
30784
dbc1e69a89a9 [HAVE_UNISTD_H]: Include unistd.h; don't declare sbrk.
Dave Love <fx@gnu.org>
parents: 30557
diff changeset
879 static void
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
880 lisp_free (block)
30557
5056adb52e97 (lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents: 30317
diff changeset
881 POINTER_TYPE *block;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
882 {
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
883 BLOCK_INPUT;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
884 free (block);
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
885 #if GC_MARK_STACK && !defined GC_MALLOC_CHECK
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
886 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
887 #endif
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
888 UNBLOCK_INPUT;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
889 }
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
890
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
891 /* Allocation of aligned blocks of memory to store Lisp data. */
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
892 /* The entry point is lisp_align_malloc which returns blocks of at most */
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
893 /* BLOCK_BYTES and guarantees they are aligned on a BLOCK_ALIGN boundary. */
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
894
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
895
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
896 /* BLOCK_ALIGN has to be a power of 2. */
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
897 #define BLOCK_ALIGN (1 << 10)
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
898
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
899 /* Padding to leave at the end of a malloc'd block. This is to give
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
900 malloc a chance to minimize the amount of memory wasted to alignment.
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
901 It should be tuned to the particular malloc library used.
51907
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
902 On glibc-2.3.2, malloc never tries to align, so a padding of 0 is best.
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
903 posix_memalign on the other hand would ideally prefer a value of 4
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
904 because otherwise, there's 1020 bytes wasted between each ablocks.
60143
84ff5b7a4139 (BLOCK_BYTES): Harmless typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59657
diff changeset
905 In Emacs, testing shows that those 1020 can most of the time be
84ff5b7a4139 (BLOCK_BYTES): Harmless typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59657
diff changeset
906 efficiently used by malloc to place other objects, so a value of 0 can
84ff5b7a4139 (BLOCK_BYTES): Harmless typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59657
diff changeset
907 still preferable unless you have a lot of aligned blocks and virtually
84ff5b7a4139 (BLOCK_BYTES): Harmless typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59657
diff changeset
908 nothing else. */
51907
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
909 #define BLOCK_PADDING 0
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
910 #define BLOCK_BYTES \
60143
84ff5b7a4139 (BLOCK_BYTES): Harmless typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59657
diff changeset
911 (BLOCK_ALIGN - sizeof (struct ablock *) - BLOCK_PADDING)
51907
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
912
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
913 /* Internal data structures and constants. */
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
914
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
915 #define ABLOCKS_SIZE 16
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
916
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
917 /* An aligned block of memory. */
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
918 struct ablock
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
919 {
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
920 union
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
921 {
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
922 char payload[BLOCK_BYTES];
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
923 struct ablock *next_free;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
924 } x;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
925 /* `abase' is the aligned base of the ablocks. */
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
926 /* It is overloaded to hold the virtual `busy' field that counts
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
927 the number of used ablock in the parent ablocks.
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
928 The first ablock has the `busy' field, the others have the `abase'
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
929 field. To tell the difference, we assume that pointers will have
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
930 integer values larger than 2 * ABLOCKS_SIZE. The lowest bit of `busy'
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
931 is used to tell whether the real base of the parent ablocks is `abase'
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
932 (if not, the word before the first ablock holds a pointer to the
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
933 real base). */
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
934 struct ablocks *abase;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
935 /* The padding of all but the last ablock is unused. The padding of
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
936 the last ablock in an ablocks is not allocated. */
51907
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
937 #if BLOCK_PADDING
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
938 char padding[BLOCK_PADDING];
51758
ff38ea4b40ed (struct ablock): Only include padding when there is some.
Jason Rumney <jasonr@gnu.org>
parents: 51723
diff changeset
939 #endif
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
940 };
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
941
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
942 /* A bunch of consecutive aligned blocks. */
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
943 struct ablocks
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
944 {
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
945 struct ablock blocks[ABLOCKS_SIZE];
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
946 };
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
947
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
948 /* Size of the block requested from malloc or memalign. */
51907
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
949 #define ABLOCKS_BYTES (sizeof (struct ablocks) - BLOCK_PADDING)
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
950
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
951 #define ABLOCK_ABASE(block) \
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
952 (((unsigned long) (block)->abase) <= (1 + 2 * ABLOCKS_SIZE) \
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
953 ? (struct ablocks *)(block) \
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
954 : (block)->abase)
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
955
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
956 /* Virtual `busy' field. */
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
957 #define ABLOCKS_BUSY(abase) ((abase)->blocks[0].abase)
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
958
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
959 /* Pointer to the (not necessarily aligned) malloc block. */
51907
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
960 #ifdef HAVE_POSIX_MEMALIGN
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
961 #define ABLOCKS_BASE(abase) (abase)
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
962 #else
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
963 #define ABLOCKS_BASE(abase) \
52453
62fcd311bb98 Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
964 (1 & (long) ABLOCKS_BUSY (abase) ? abase : ((void**)abase)[-1])
51907
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
965 #endif
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
966
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
967 /* The list of free ablock. */
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
968 static struct ablock *free_ablock;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
969
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
970 /* Allocate an aligned block of nbytes.
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
971 Alignment is on a multiple of BLOCK_ALIGN and `nbytes' has to be
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
972 smaller or equal to BLOCK_BYTES. */
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
973 static POINTER_TYPE *
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
974 lisp_align_malloc (nbytes, type)
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
975 size_t nbytes;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
976 enum mem_type type;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
977 {
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
978 void *base, *val;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
979 struct ablocks *abase;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
980
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
981 eassert (nbytes <= BLOCK_BYTES);
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
982
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
983 BLOCK_INPUT;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
984
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
985 #ifdef GC_MALLOC_CHECK
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
986 allocated_mem_type = type;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
987 #endif
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
988
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
989 if (!free_ablock)
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
990 {
52276
5623f26dff58 (lisp_align_malloc): Change type of `aligned'.
Dave Love <fx@gnu.org>
parents: 52256
diff changeset
991 int i;
5623f26dff58 (lisp_align_malloc): Change type of `aligned'.
Dave Love <fx@gnu.org>
parents: 52256
diff changeset
992 EMACS_INT aligned; /* int gets warning casting to 64-bit pointer. */
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
993
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
994 #ifdef DOUG_LEA_MALLOC
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
995 /* Prevent mmap'ing the chunk. Lisp data may not be mmap'ed
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
996 because mapped region contents are not preserved in
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
997 a dumped Emacs. */
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
998 mallopt (M_MMAP_MAX, 0);
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
999 #endif
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1000
51907
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
1001 #ifdef HAVE_POSIX_MEMALIGN
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
1002 {
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
1003 int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES);
55836
a05a653f63af (lisp_align_malloc): Check for base == 0 regardless of HAVE_POSIX_MEMALIGN.
Richard M. Stallman <rms@gnu.org>
parents: 55816
diff changeset
1004 if (err)
a05a653f63af (lisp_align_malloc): Check for base == 0 regardless of HAVE_POSIX_MEMALIGN.
Richard M. Stallman <rms@gnu.org>
parents: 55816
diff changeset
1005 base = NULL;
a05a653f63af (lisp_align_malloc): Check for base == 0 regardless of HAVE_POSIX_MEMALIGN.
Richard M. Stallman <rms@gnu.org>
parents: 55816
diff changeset
1006 abase = base;
51907
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
1007 }
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
1008 #else
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1009 base = malloc (ABLOCKS_BYTES);
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1010 abase = ALIGN (base, BLOCK_ALIGN);
55836
a05a653f63af (lisp_align_malloc): Check for base == 0 regardless of HAVE_POSIX_MEMALIGN.
Richard M. Stallman <rms@gnu.org>
parents: 55816
diff changeset
1011 #endif
a05a653f63af (lisp_align_malloc): Check for base == 0 regardless of HAVE_POSIX_MEMALIGN.
Richard M. Stallman <rms@gnu.org>
parents: 55816
diff changeset
1012
52837
1bbf3f566879 (lisp_align_malloc): If BASE is 0, call memory_full.
Richard M. Stallman <rms@gnu.org>
parents: 52547
diff changeset
1013 if (base == 0)
1bbf3f566879 (lisp_align_malloc): If BASE is 0, call memory_full.
Richard M. Stallman <rms@gnu.org>
parents: 52547
diff changeset
1014 {
1bbf3f566879 (lisp_align_malloc): If BASE is 0, call memory_full.
Richard M. Stallman <rms@gnu.org>
parents: 52547
diff changeset
1015 UNBLOCK_INPUT;
1bbf3f566879 (lisp_align_malloc): If BASE is 0, call memory_full.
Richard M. Stallman <rms@gnu.org>
parents: 52547
diff changeset
1016 memory_full ();
1bbf3f566879 (lisp_align_malloc): If BASE is 0, call memory_full.
Richard M. Stallman <rms@gnu.org>
parents: 52547
diff changeset
1017 }
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1018
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1019 aligned = (base == abase);
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1020 if (!aligned)
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1021 ((void**)abase)[-1] = base;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1022
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1023 #ifdef DOUG_LEA_MALLOC
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1024 /* Back to a reasonable maximum of mmap'ed areas. */
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1025 mallopt (M_MMAP_MAX, MMAP_MAX_AREAS);
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1026 #endif
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1027
53650
5558449888ec (lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53582
diff changeset
1028 #ifndef USE_LSB_TAG
52256
36e112575ca8 (lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents: 52166
diff changeset
1029 /* If the memory just allocated cannot be addressed thru a Lisp
36e112575ca8 (lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents: 52166
diff changeset
1030 object's pointer, and it needs to be, that's equivalent to
36e112575ca8 (lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents: 52166
diff changeset
1031 running out of memory. */
36e112575ca8 (lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents: 52166
diff changeset
1032 if (type != MEM_TYPE_NON_LISP)
36e112575ca8 (lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents: 52166
diff changeset
1033 {
36e112575ca8 (lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents: 52166
diff changeset
1034 Lisp_Object tem;
36e112575ca8 (lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents: 52166
diff changeset
1035 char *end = (char *) base + ABLOCKS_BYTES - 1;
36e112575ca8 (lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents: 52166
diff changeset
1036 XSETCONS (tem, end);
36e112575ca8 (lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents: 52166
diff changeset
1037 if ((char *) XCONS (tem) != end)
36e112575ca8 (lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents: 52166
diff changeset
1038 {
36e112575ca8 (lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents: 52166
diff changeset
1039 lisp_malloc_loser = base;
36e112575ca8 (lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents: 52166
diff changeset
1040 free (base);
36e112575ca8 (lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents: 52166
diff changeset
1041 UNBLOCK_INPUT;
36e112575ca8 (lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents: 52166
diff changeset
1042 memory_full ();
36e112575ca8 (lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents: 52166
diff changeset
1043 }
36e112575ca8 (lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents: 52166
diff changeset
1044 }
53650
5558449888ec (lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53582
diff changeset
1045 #endif
52256
36e112575ca8 (lisp_align_malloc): Check for memory full when
Gerd Moellmann <gerd@gnu.org>
parents: 52166
diff changeset
1046
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1047 /* Initialize the blocks and put them on the free list.
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1048 Is `base' was not properly aligned, we can't use the last block. */
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1049 for (i = 0; i < (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1); i++)
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1050 {
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1051 abase->blocks[i].abase = abase;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1052 abase->blocks[i].x.next_free = free_ablock;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1053 free_ablock = &abase->blocks[i];
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1054 }
52453
62fcd311bb98 Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
1055 ABLOCKS_BUSY (abase) = (struct ablocks *) (long) aligned;
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1056
51907
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
1057 eassert (0 == ((EMACS_UINT)abase) % BLOCK_ALIGN);
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1058 eassert (ABLOCK_ABASE (&abase->blocks[3]) == abase); /* 3 is arbitrary */
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1059 eassert (ABLOCK_ABASE (&abase->blocks[0]) == abase);
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1060 eassert (ABLOCKS_BASE (abase) == base);
52453
62fcd311bb98 Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
1061 eassert (aligned == (long) ABLOCKS_BUSY (abase));
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1062 }
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1063
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1064 abase = ABLOCK_ABASE (free_ablock);
52453
62fcd311bb98 Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
1065 ABLOCKS_BUSY (abase) = (struct ablocks *) (2 + (long) ABLOCKS_BUSY (abase));
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1066 val = free_ablock;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1067 free_ablock = free_ablock->x.next_free;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1068
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1069 #if GC_MARK_STACK && !defined GC_MALLOC_CHECK
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1070 if (val && type != MEM_TYPE_NON_LISP)
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1071 mem_insert (val, (char *) val + nbytes, type);
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1072 #endif
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1073
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1074 UNBLOCK_INPUT;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1075 if (!val && nbytes)
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1076 memory_full ();
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1077
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1078 eassert (0 == ((EMACS_UINT)val) % BLOCK_ALIGN);
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1079 return val;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1080 }
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1081
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1082 static void
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1083 lisp_align_free (block)
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1084 POINTER_TYPE *block;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1085 {
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1086 struct ablock *ablock = block;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1087 struct ablocks *abase = ABLOCK_ABASE (ablock);
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1088
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1089 BLOCK_INPUT;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1090 #if GC_MARK_STACK && !defined GC_MALLOC_CHECK
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1091 mem_delete (mem_find (block));
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1092 #endif
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1093 /* Put on free list. */
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1094 ablock->x.next_free = free_ablock;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1095 free_ablock = ablock;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1096 /* Update busy count. */
52453
62fcd311bb98 Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
1097 ABLOCKS_BUSY (abase) = (struct ablocks *) (-2 + (long) ABLOCKS_BUSY (abase));
55634
d3542bbadad7 (mark_object): Ignore Lisp_Misc_Free objects.
Kim F. Storm <storm@cua.dk>
parents: 55159
diff changeset
1098
52453
62fcd311bb98 Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
1099 if (2 > (long) ABLOCKS_BUSY (abase))
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1100 { /* All the blocks are free. */
52453
62fcd311bb98 Use long instead of int when casting ABLOCKS_BUSY to
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
1101 int i = 0, aligned = (long) ABLOCKS_BUSY (abase);
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1102 struct ablock **tem = &free_ablock;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1103 struct ablock *atop = &abase->blocks[aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1];
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1104
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1105 while (*tem)
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1106 {
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1107 if (*tem >= (struct ablock *) abase && *tem < atop)
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1108 {
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1109 i++;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1110 *tem = (*tem)->x.next_free;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1111 }
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1112 else
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1113 tem = &(*tem)->x.next_free;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1114 }
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1115 eassert ((aligned & 1) == aligned);
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1116 eassert (i == (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1));
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1117 free (ABLOCKS_BASE (abase));
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1118 }
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1119 UNBLOCK_INPUT;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
1120 }
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
1121
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
1122 /* Return a new buffer structure allocated from the heap with
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
1123 a call to lisp_malloc. */
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
1124
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
1125 struct buffer *
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
1126 allocate_buffer ()
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
1127 {
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
1128 struct buffer *b
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
1129 = (struct buffer *) lisp_malloc (sizeof (struct buffer),
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
1130 MEM_TYPE_BUFFER);
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
1131 return b;
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
1132 }
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
1133
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1134
59359
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
1135 #ifndef SYSTEM_MALLOC
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
1136
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
1137 /* If we released our reserve (due to running out of memory),
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
1138 and we have a fair amount free once again,
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
1139 try to set aside another reserve in case we run out once more.
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
1140
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
1141 This is called when a relocatable block is freed in ralloc.c. */
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
1142
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
1143 void
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
1144 refill_memory_reserve ()
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
1145 {
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
1146 if (spare_memory == 0)
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
1147 spare_memory = (char *) malloc ((size_t) SPARE_MEMORY);
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
1148 }
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
1149
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
1150
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1151 /* 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
1152
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1153 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
1154 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
1155 elsewhere in the code should be inside a BLOCK_INPUT/UNBLOCK_INPUT
59359
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
1156 pair; unfortunately, we have no idea what C library functions
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1157 might call malloc, so we can't really protect them unless you're
49529
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
1158 using GNU malloc. Fortunately, most of the major operating systems
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
1159 can use GNU malloc. */
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1160
59359
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
1161 #ifndef SYNC_INPUT
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
1162
30914
6362b1fc09f2 (lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents: 30823
diff changeset
1163 #ifndef DOUG_LEA_MALLOC
6362b1fc09f2 (lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents: 30823
diff changeset
1164 extern void * (*__malloc_hook) P_ ((size_t));
6362b1fc09f2 (lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents: 30823
diff changeset
1165 extern void * (*__realloc_hook) P_ ((void *, size_t));
6362b1fc09f2 (lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents: 30823
diff changeset
1166 extern void (*__free_hook) P_ ((void *));
6362b1fc09f2 (lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents: 30823
diff changeset
1167 /* Else declared in malloc.h, perhaps with an extra arg. */
6362b1fc09f2 (lisp_malloc): Declare with POINTER_TYPE.
Dave Love <fx@gnu.org>
parents: 30823
diff changeset
1168 #endif /* DOUG_LEA_MALLOC */
2507
7ba4316ae840 * alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
1169 static void * (*old_malloc_hook) ();
7ba4316ae840 * alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
1170 static void * (*old_realloc_hook) ();
7ba4316ae840 * alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
1171 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
1172
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
1173 /* 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
1174
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1175 static void
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1176 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
1177 void *ptr;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1178 {
58818
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1179 BLOCK_INPUT_ALLOC;
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1180
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1181 #ifdef GC_MALLOC_CHECK
32776
416924b6f303 (emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents: 32700
diff changeset
1182 if (ptr)
416924b6f303 (emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents: 32700
diff changeset
1183 {
416924b6f303 (emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents: 32700
diff changeset
1184 struct mem_node *m;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1185
32776
416924b6f303 (emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents: 32700
diff changeset
1186 m = mem_find (ptr);
416924b6f303 (emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents: 32700
diff changeset
1187 if (m == MEM_NIL || m->start != ptr)
416924b6f303 (emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents: 32700
diff changeset
1188 {
416924b6f303 (emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents: 32700
diff changeset
1189 fprintf (stderr,
416924b6f303 (emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents: 32700
diff changeset
1190 "Freeing `%p' which wasn't allocated with malloc\n", ptr);
416924b6f303 (emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents: 32700
diff changeset
1191 abort ();
416924b6f303 (emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents: 32700
diff changeset
1192 }
416924b6f303 (emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents: 32700
diff changeset
1193 else
416924b6f303 (emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents: 32700
diff changeset
1194 {
416924b6f303 (emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents: 32700
diff changeset
1195 /* fprintf (stderr, "free %p...%p (%p)\n", m->start, m->end, ptr); */
416924b6f303 (emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents: 32700
diff changeset
1196 mem_delete (m);
416924b6f303 (emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents: 32700
diff changeset
1197 }
416924b6f303 (emacs_blocked_free) [GC_MALLOC_CHECK]: Handle freeing
Gerd Moellmann <gerd@gnu.org>
parents: 32700
diff changeset
1198 }
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1199 #endif /* GC_MALLOC_CHECK */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1200
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1201 __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
1202 free (ptr);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1203
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
1204 /* 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
1205 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
1206 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
1207 if (spare_memory == 0
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
1208 /* 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
1209 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
1210 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
1211 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
1212 && (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
1213 > BYTES_USED + max (malloc_hysteresis, 4) * SPARE_MEMORY))
30557
5056adb52e97 (lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents: 30317
diff changeset
1214 spare_memory = (char *) malloc ((size_t) SPARE_MEMORY);
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
1215
2507
7ba4316ae840 * alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
1216 __free_hook = emacs_blocked_free;
58818
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1217 UNBLOCK_INPUT_ALLOC;
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1218 }
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1219
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1220
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
1221 /* 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
1222
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1223 static void *
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1224 emacs_blocked_malloc (size)
30557
5056adb52e97 (lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents: 30317
diff changeset
1225 size_t size;
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1226 {
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1227 void *value;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1228
58818
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1229 BLOCK_INPUT_ALLOC;
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1230 __malloc_hook = old_malloc_hook;
17831
9238a2254a23 (BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents: 17348
diff changeset
1231 #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
1232 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
1233 #else
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
1234 __malloc_extra_blocks = malloc_hysteresis;
17831
9238a2254a23 (BYTES_USED): Put # at the beginning of line.
Kenichi Handa <handa@m17n.org>
parents: 17348
diff changeset
1235 #endif
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1236
3581
152fd924c7bb * alloc.c (emacs_blocked_malloc, emacs_blocked_realloc): Cast the
Jim Blandy <jimb@redhat.com>
parents: 3536
diff changeset
1237 value = (void *) malloc (size);
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1238
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1239 #ifdef GC_MALLOC_CHECK
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1240 {
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1241 struct mem_node *m = mem_find (value);
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1242 if (m != MEM_NIL)
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1243 {
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1244 fprintf (stderr, "Malloc returned %p which is already in use\n",
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1245 value);
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1246 fprintf (stderr, "Region in use is %p...%p, %u bytes, type %d\n",
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1247 m->start, m->end, (char *) m->end - (char *) m->start,
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1248 m->type);
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1249 abort ();
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1250 }
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1251
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1252 if (!dont_register_blocks)
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1253 {
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1254 mem_insert (value, (char *) value + max (1, size), allocated_mem_type);
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1255 allocated_mem_type = MEM_TYPE_NON_LISP;
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1256 }
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1257 }
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1258 #endif /* GC_MALLOC_CHECK */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1259
2507
7ba4316ae840 * alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
1260 __malloc_hook = emacs_blocked_malloc;
58818
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1261 UNBLOCK_INPUT_ALLOC;
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1262
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1263 /* fprintf (stderr, "%p malloc\n", value); */
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1264 return value;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1265 }
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1266
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1267
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1268 /* 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
1269
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1270 static void *
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1271 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
1272 void *ptr;
30557
5056adb52e97 (lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents: 30317
diff changeset
1273 size_t size;
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1274 {
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1275 void *value;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1276
58818
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1277 BLOCK_INPUT_ALLOC;
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1278 __realloc_hook = old_realloc_hook;
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1279
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1280 #ifdef GC_MALLOC_CHECK
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1281 if (ptr)
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1282 {
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1283 struct mem_node *m = mem_find (ptr);
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1284 if (m == MEM_NIL || m->start != ptr)
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1285 {
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1286 fprintf (stderr,
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1287 "Realloc of %p which wasn't allocated with malloc\n",
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1288 ptr);
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1289 abort ();
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1290 }
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1291
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1292 mem_delete (m);
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1293 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1294
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1295 /* fprintf (stderr, "%p -> realloc\n", ptr); */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1296
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1297 /* Prevent malloc from registering blocks. */
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1298 dont_register_blocks = 1;
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1299 #endif /* GC_MALLOC_CHECK */
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1300
3581
152fd924c7bb * alloc.c (emacs_blocked_malloc, emacs_blocked_realloc): Cast the
Jim Blandy <jimb@redhat.com>
parents: 3536
diff changeset
1301 value = (void *) realloc (ptr, size);
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1302
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1303 #ifdef GC_MALLOC_CHECK
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1304 dont_register_blocks = 0;
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1305
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1306 {
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1307 struct mem_node *m = mem_find (value);
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1308 if (m != MEM_NIL)
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1309 {
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1310 fprintf (stderr, "Realloc returns memory that is already in use\n");
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1311 abort ();
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1312 }
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1313
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1314 /* Can't handle zero size regions in the red-black tree. */
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1315 mem_insert (value, (char *) value + max (size, 1), MEM_TYPE_NON_LISP);
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1316 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1317
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1318 /* fprintf (stderr, "%p <- realloc\n", value); */
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
1319 #endif /* GC_MALLOC_CHECK */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1320
2507
7ba4316ae840 * alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
1321 __realloc_hook = emacs_blocked_realloc;
58818
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1322 UNBLOCK_INPUT_ALLOC;
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1323
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1324 return value;
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1325 }
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1326
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1327
58818
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1328 #ifdef HAVE_GTK_AND_PTHREAD
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1329 /* Called from Fdump_emacs so that when the dumped Emacs starts, it has a
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1330 normal malloc. Some thread implementations need this as they call
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1331 malloc before main. The pthread_self call in BLOCK_INPUT_ALLOC then
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1332 calls malloc because it is the first call, and we have an endless loop. */
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1333
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1334 void
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1335 reset_malloc_hooks ()
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1336 {
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1337 __free_hook = 0;
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1338 __malloc_hook = 0;
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1339 __realloc_hook = 0;
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1340 }
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1341 #endif /* HAVE_GTK_AND_PTHREAD */
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1342
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1343
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1344 /* 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
1345
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1346 void
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1347 uninterrupt_malloc ()
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2370
diff changeset
1348 {
58818
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1349 #ifdef HAVE_GTK_AND_PTHREAD
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1350 pthread_mutexattr_t attr;
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1351
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1352 /* GLIBC has a faster way to do this, but lets keep it portable.
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1353 This is according to the Single UNIX Specification. */
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1354 pthread_mutexattr_init (&attr);
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1355 pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1356 pthread_mutex_init (&alloc_mutex, &attr);
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1357 #endif /* HAVE_GTK_AND_PTHREAD */
f8cddae7d959 * gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58707
diff changeset
1358
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1359 if (__free_hook != emacs_blocked_free)
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1360 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
1361 __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
1362
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1363 if (__malloc_hook != emacs_blocked_malloc)
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1364 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
1365 __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
1366
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1367 if (__realloc_hook != emacs_blocked_realloc)
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1368 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
1369 __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
1370 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1371
59359
1678d14c4109 (refill_memory_reserve): Move.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59314
diff changeset
1372 #endif /* not SYNC_INPUT */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1373 #endif /* not SYSTEM_MALLOC */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1374
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1375
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1376
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1377 /***********************************************************************
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1378 Interval Allocation
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1379 ***********************************************************************/
1908
d649f2179d67 * alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents: 1893
diff changeset
1380
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1381 /* 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
1382 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
1383
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1384 #define INTERVAL_BLOCK_SIZE \
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1385 ((1020 - sizeof (struct interval_block *)) / sizeof (struct interval))
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1386
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1387 /* 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
1388 structure. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1389
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1390 struct interval_block
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1391 {
53582
b4eef5adebbf (struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53555
diff changeset
1392 /* Place `intervals' first, to preserve alignment. */
b4eef5adebbf (struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53555
diff changeset
1393 struct interval intervals[INTERVAL_BLOCK_SIZE];
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1394 struct interval_block *next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1395 };
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1396
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1397 /* 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
1398 blocks. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1399
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1400 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
1401
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1402 /* 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
1403 structure. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1404
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1405 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
1406
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1407 /* 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
1408
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1409 static int total_free_intervals, total_intervals;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1410
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1411 /* List of free intervals. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1412
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1413 INTERVAL interval_free_list;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1414
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1415 /* 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
1416
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1417 int n_interval_blocks;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1418
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1419
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1420 /* Initialize interval allocation. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1421
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1422 static void
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1423 init_intervals ()
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1424 {
52473
a3fd06a8c844 (init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52453
diff changeset
1425 interval_block = NULL;
a3fd06a8c844 (init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52453
diff changeset
1426 interval_block_index = INTERVAL_BLOCK_SIZE;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1427 interval_free_list = 0;
52473
a3fd06a8c844 (init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52453
diff changeset
1428 n_interval_blocks = 0;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1429 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1430
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1431
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1432 /* Return a new interval. */
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1433
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1434 INTERVAL
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1435 make_interval ()
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1436 {
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1437 INTERVAL val;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1438
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1439 if (interval_free_list)
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1440 {
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1441 val = interval_free_list;
28269
fd13be8ae190 Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents: 28220
diff changeset
1442 interval_free_list = INTERVAL_PARENT (interval_free_list);
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1443 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1444 else
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1445 {
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1446 if (interval_block_index == INTERVAL_BLOCK_SIZE)
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1447 {
12529
c7d32f5da2b3 (Flist): Rewritten.
Karl Heuer <kwzh@gnu.org>
parents: 12273
diff changeset
1448 register struct interval_block *newi;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1449
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1450 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
1451 MEM_TYPE_NON_LISP);
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1452
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1453 newi->next = interval_block;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1454 interval_block = newi;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1455 interval_block_index = 0;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
1456 n_interval_blocks++;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1457 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1458 val = &interval_block->intervals[interval_block_index++];
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1459 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1460 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
1461 intervals_consed++;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1462 RESET_INTERVAL (val);
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
1463 val->gcmarkbit = 0;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1464 return val;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1465 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1466
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1467
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1468 /* Mark Lisp objects in interval I. */
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1469
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1470 static void
1957
54c8c66cd9ac (mark_interval): Add ignored arg.
Richard M. Stallman <rms@gnu.org>
parents: 1939
diff changeset
1471 mark_interval (i, dummy)
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1472 register INTERVAL i;
1957
54c8c66cd9ac (mark_interval): Add ignored arg.
Richard M. Stallman <rms@gnu.org>
parents: 1939
diff changeset
1473 Lisp_Object dummy;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1474 {
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
1475 eassert (!i->gcmarkbit); /* Intervals are never shared. */
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
1476 i->gcmarkbit = 1;
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
1477 mark_object (i->plist);
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1478 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1479
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1480
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1481 /* 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
1482 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
1483
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1484 static void
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1485 mark_interval_tree (tree)
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1486 register INTERVAL tree;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1487 {
4139
0b32ee899a3a Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents: 4087
diff changeset
1488 /* 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
1489 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
1490 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
1491
39859
36068b62b4c1 (mark_interval_tree): Use traverse_intervals_noorder.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39682
diff changeset
1492 traverse_intervals_noorder (tree, mark_interval, Qnil);
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1493 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1494
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1495
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1496 /* 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
1497
4139
0b32ee899a3a Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents: 4087
diff changeset
1498 #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
1499 do { \
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
1500 if (!NULL_INTERVAL_P (i) && !i->gcmarkbit) \
4139
0b32ee899a3a Consistently use the mark bit of the root interval's parent field
Jim Blandy <jimb@redhat.com>
parents: 4087
diff changeset
1501 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
1502 } while (0)
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1503
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1504
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1505 #define UNMARK_BALANCE_INTERVALS(i) \
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1506 do { \
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1507 if (! NULL_INTERVAL_P (i)) \
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
1508 (i) = balance_intervals (i); \
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1509 } while (0)
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1510
28469
f66f2b4d5eb7 * alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents: 28411
diff changeset
1511
f66f2b4d5eb7 * alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents: 28411
diff changeset
1512 /* Number support. If NO_UNION_TYPE isn't in effect, we
f66f2b4d5eb7 * alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents: 28411
diff changeset
1513 can't create number objects in macros. */
f66f2b4d5eb7 * alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents: 28411
diff changeset
1514 #ifndef make_number
f66f2b4d5eb7 * alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents: 28411
diff changeset
1515 Lisp_Object
f66f2b4d5eb7 * alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents: 28411
diff changeset
1516 make_number (n)
60896
25e4a0f171b5 (make_number): The arg can be bigger than `int'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60143
diff changeset
1517 EMACS_INT n;
28469
f66f2b4d5eb7 * alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents: 28411
diff changeset
1518 {
f66f2b4d5eb7 * alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents: 28411
diff changeset
1519 Lisp_Object obj;
f66f2b4d5eb7 * alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents: 28411
diff changeset
1520 obj.s.val = n;
f66f2b4d5eb7 * alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents: 28411
diff changeset
1521 obj.s.type = Lisp_Int;
f66f2b4d5eb7 * alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents: 28411
diff changeset
1522 return obj;
f66f2b4d5eb7 * alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents: 28411
diff changeset
1523 }
f66f2b4d5eb7 * alloc.c (MARK_STRING, UNMARK_STRING, STRING_MARKED_P): Expand non-union-type
Ken Raeburn <raeburn@raeburn.org>
parents: 28411
diff changeset
1524 #endif
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
1525
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1526 /***********************************************************************
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1527 String Allocation
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1528 ***********************************************************************/
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1529
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1530 /* 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
1531 string_block is allocated, all the Lisp_Strings it contains are
41831
fa7af2e13043 (Fgarbage_collect): Shrink buffer gaps that are
Andrew Innes <andrewi@gnu.org>
parents: 40977
diff changeset
1532 added to a free-list string_free_list. When a new Lisp_String is
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1533 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
1534 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
1535 we keep.
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1536
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1537 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
1538 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
1539 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
1540
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1541 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
1542 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
1543 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
1544 its sdata structure.
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1545
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1546 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
1547 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
1548 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
1549 `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
1550 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
1551 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
1552
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1553 /* 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
1554 is 8192 minus malloc overhead. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1555
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1556 #define SBLOCK_SIZE 8188
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1557
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1558 /* 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
1559 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
1560
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1561 #define LARGE_STRING_BYTES 1024
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1562
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1563 /* 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
1564 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
1565
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1566 struct sdata
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1567 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1568 /* 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
1569 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
1570 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
1571 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
1572 (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
1573 contents. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1574 struct Lisp_String *string;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1575
31897
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1576 #ifdef GC_CHECK_STRING_BYTES
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1577
31897
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1578 EMACS_INT nbytes;
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1579 unsigned char data[1];
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1580
31897
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1581 #define SDATA_NBYTES(S) (S)->nbytes
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1582 #define SDATA_DATA(S) (S)->data
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1583
31897
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1584 #else /* not GC_CHECK_STRING_BYTES */
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1585
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1586 union
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1587 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1588 /* When STRING in non-null. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1589 unsigned char data[1];
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1590
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1591 /* When STRING is null. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1592 EMACS_INT nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1593 } u;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1594
31897
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1595
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1596 #define SDATA_NBYTES(S) (S)->u.nbytes
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1597 #define SDATA_DATA(S) (S)->u.data
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1598
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1599 #endif /* not GC_CHECK_STRING_BYTES */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1600 };
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1601
31897
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1602
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1603 /* 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
1604 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
1605 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
1606 as large as needed. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1607
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1608 struct sblock
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1609 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1610 /* Next in list. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1611 struct sblock *next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1612
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1613 /* 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
1614 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
1615 struct sdata *next_free;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1616
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1617 /* Start of data. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1618 struct sdata first_data;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1619 };
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1620
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1621 /* 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
1622 1024 minus malloc overhead. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1623
51907
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
1624 #define STRING_BLOCK_SIZE \
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1625 ((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
1626
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1627 /* 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
1628 are allocated. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1629
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1630 struct string_block
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1631 {
53582
b4eef5adebbf (struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53555
diff changeset
1632 /* Place `strings' first, to preserve alignment. */
b4eef5adebbf (struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53555
diff changeset
1633 struct Lisp_String strings[STRING_BLOCK_SIZE];
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1634 struct string_block *next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1635 };
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1636
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1637 /* 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
1638 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
1639 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
1640
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1641 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
1642
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1643 /* List of sblocks for large strings. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1644
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1645 static struct sblock *large_sblocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1646
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1647 /* 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
1648
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1649 static struct string_block *string_blocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1650 static int n_string_blocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1651
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1652 /* Free-list of Lisp_Strings. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1653
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1654 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
1655
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1656 /* 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
1657
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1658 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
1659
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1660 /* 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
1661
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1662 static int total_string_size;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1663
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1664 /* 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
1665 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
1666 free-list. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1667
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1668 #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
1669
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1670 /* 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
1671 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
1672 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
1673 structure starts at a constant offset in front of that. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1674
31897
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1675 #ifdef GC_CHECK_STRING_BYTES
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1676
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1677 #define SDATA_OF_STRING(S) \
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1678 ((struct sdata *) ((S)->data - sizeof (struct Lisp_String *) \
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1679 - sizeof (EMACS_INT)))
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1680
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1681 #else /* not GC_CHECK_STRING_BYTES */
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1682
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1683 #define SDATA_OF_STRING(S) \
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1684 ((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
1685
31897
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1686 #endif /* not GC_CHECK_STRING_BYTES */
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1687
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1688
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1689 #ifdef GC_CHECK_STRING_OVERRUN
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
1690
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
1691 /* We check for overrun in string data blocks by appending a small
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
1692 "cookie" after each allocated string data block, and check for the
62681
d140f1408030 Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 62335
diff changeset
1693 presence of this cookie during GC. */
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
1694
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
1695 #define GC_STRING_OVERRUN_COOKIE_SIZE 4
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
1696 static char string_overrun_cookie[GC_STRING_OVERRUN_COOKIE_SIZE] =
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
1697 { 0xde, 0xad, 0xbe, 0xef };
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
1698
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1699 #else
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
1700 #define GC_STRING_OVERRUN_COOKIE_SIZE 0
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1701 #endif
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1702
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1703 /* 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
1704 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
1705 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
1706
31897
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1707 #ifdef GC_CHECK_STRING_BYTES
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1708
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1709 #define SDATA_SIZE(NBYTES) \
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1710 ((sizeof (struct Lisp_String *) \
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1711 + (NBYTES) + 1 \
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1712 + sizeof (EMACS_INT) \
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1713 + sizeof (EMACS_INT) - 1) \
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1714 & ~(sizeof (EMACS_INT) - 1))
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1715
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1716 #else /* not GC_CHECK_STRING_BYTES */
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1717
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1718 #define SDATA_SIZE(NBYTES) \
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1719 ((sizeof (struct Lisp_String *) \
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1720 + (NBYTES) + 1 \
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1721 + sizeof (EMACS_INT) - 1) \
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1722 & ~(sizeof (EMACS_INT) - 1))
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1723
31897
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1724 #endif /* not GC_CHECK_STRING_BYTES */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1725
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
1726 /* Extra bytes to allocate for each string. */
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
1727
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
1728 #define GC_STRING_EXTRA (GC_STRING_OVERRUN_COOKIE_SIZE)
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
1729
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1730 /* 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
1731
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1732 void
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1733 init_strings ()
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1734 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1735 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
1736 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
1737 string_blocks = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1738 n_string_blocks = 0;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1739 string_free_list = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1740 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1741
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1742
32587
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
1743 #ifdef GC_CHECK_STRING_BYTES
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
1744
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
1745 static int check_string_bytes_count;
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
1746
35183
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1747 void check_string_bytes P_ ((int));
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1748 void check_sblock P_ ((struct sblock *));
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1749
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1750 #define CHECK_STRING_BYTES(S) STRING_BYTES (S)
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1751
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1752
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1753 /* Like GC_STRING_BYTES, but with debugging check. */
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1754
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1755 int
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1756 string_bytes (s)
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1757 struct Lisp_String *s;
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1758 {
51985
b52e88c3d6d0 (MARK_STRING, UNMARK_STRING, STRING_MARKED_P)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51974
diff changeset
1759 int nbytes = (s->size_byte < 0 ? s->size & ~ARRAY_MARK_FLAG : s->size_byte);
35183
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1760 if (!PURE_POINTER_P (s)
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1761 && s->data
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1762 && nbytes != SDATA_NBYTES (SDATA_OF_STRING (s)))
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1763 abort ();
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1764 return nbytes;
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1765 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1766
49529
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
1767 /* Check validity of Lisp strings' string_bytes member in B. */
35183
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1768
32587
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
1769 void
35183
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1770 check_sblock (b)
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1771 struct sblock *b;
32587
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
1772 {
35183
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1773 struct sdata *from, *end, *from_end;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1774
35183
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1775 end = b->next_free;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1776
35183
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1777 for (from = &b->first_data; from < end; from = from_end)
32587
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
1778 {
35183
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1779 /* Compute the next FROM here because copying below may
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1780 overwrite data we need to compute it. */
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1781 int nbytes;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1782
35183
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1783 /* Check that the string size recorded in the string is the
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1784 same as the one recorded in the sdata structure. */
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1785 if (from->string)
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1786 CHECK_STRING_BYTES (from->string);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1787
35183
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1788 if (from->string)
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1789 nbytes = GC_STRING_BYTES (from->string);
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1790 else
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1791 nbytes = SDATA_NBYTES (from);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1792
35183
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1793 nbytes = SDATA_SIZE (nbytes);
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1794 from_end = (struct sdata *) ((char *) from + nbytes + GC_STRING_EXTRA);
35183
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1795 }
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1796 }
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1797
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1798
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1799 /* Check validity of Lisp strings' string_bytes member. ALL_P
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1800 non-zero means check all strings, otherwise check only most
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1801 recently allocated strings. Used for hunting a bug. */
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1802
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1803 void
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1804 check_string_bytes (all_p)
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1805 int all_p;
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1806 {
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1807 if (all_p)
32587
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
1808 {
35183
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1809 struct sblock *b;
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1810
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1811 for (b = large_sblocks; b; b = b->next)
32587
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
1812 {
35183
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1813 struct Lisp_String *s = b->first_data.string;
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1814 if (s)
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1815 CHECK_STRING_BYTES (s);
32587
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
1816 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1817
35183
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1818 for (b = oldest_sblock; b; b = b->next)
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1819 check_sblock (b);
32587
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
1820 }
35183
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1821 else
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1822 check_sblock (current_sblock);
32587
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
1823 }
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
1824
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
1825 #endif /* GC_CHECK_STRING_BYTES */
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
1826
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1827 #ifdef GC_CHECK_STRING_FREE_LIST
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1828
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
1829 /* Walk through the string free list looking for bogus next pointers.
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
1830 This may catch buffer overrun from a previous string. */
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
1831
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1832 static void
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1833 check_string_free_list ()
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1834 {
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1835 struct Lisp_String *s;
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1836
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1837 /* Pop a Lisp_String off the free-list. */
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1838 s = string_free_list;
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1839 while (s != NULL)
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1840 {
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1841 if ((unsigned)s < 1024)
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1842 abort();
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1843 s = NEXT_FREE_LISP_STRING (s);
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1844 }
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1845 }
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1846 #else
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1847 #define check_string_free_list()
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1848 #endif
32587
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
1849
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1850 /* Return a new Lisp_String. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1851
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1852 static struct Lisp_String *
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1853 allocate_string ()
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1854 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1855 struct Lisp_String *s;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1856
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1857 /* 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
1858 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
1859 if (string_free_list == NULL)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1860 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1861 struct string_block *b;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1862 int i;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1863
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
1864 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
1865 bzero (b, sizeof *b);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1866 b->next = string_blocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1867 string_blocks = b;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1868 ++n_string_blocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1869
51907
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
1870 for (i = STRING_BLOCK_SIZE - 1; i >= 0; --i)
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1871 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1872 s = b->strings + i;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1873 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
1874 string_free_list = s;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1875 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1876
51907
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
1877 total_free_strings += STRING_BLOCK_SIZE;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1878 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1879
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
1880 check_string_free_list ();
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1881
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1882 /* 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
1883 s = string_free_list;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1884 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
1885
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1886 /* 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
1887 bzero (s, sizeof *s);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1888
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1889 --total_free_strings;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1890 ++total_strings;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1891 ++strings_consed;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1892 consing_since_gc += sizeof *s;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1893
32587
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
1894 #ifdef GC_CHECK_STRING_BYTES
35660
b9366f467430 * alloc.c (allocate_string) [macintosh]: Call check_string_bytes
Andrew Choi <akochoi@shaw.ca>
parents: 35183
diff changeset
1895 if (!noninteractive
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents: 44149
diff changeset
1896 #ifdef MAC_OS8
35660
b9366f467430 * alloc.c (allocate_string) [macintosh]: Call check_string_bytes
Andrew Choi <akochoi@shaw.ca>
parents: 35183
diff changeset
1897 && current_sblock
b9366f467430 * alloc.c (allocate_string) [macintosh]: Call check_string_bytes
Andrew Choi <akochoi@shaw.ca>
parents: 35183
diff changeset
1898 #endif
b9366f467430 * alloc.c (allocate_string) [macintosh]: Call check_string_bytes
Andrew Choi <akochoi@shaw.ca>
parents: 35183
diff changeset
1899 )
32587
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
1900 {
35183
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1901 if (++check_string_bytes_count == 200)
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1902 {
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1903 check_string_bytes_count = 0;
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1904 check_string_bytes (1);
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1905 }
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1906 else
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1907 check_string_bytes (0);
32587
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
1908 }
35183
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
1909 #endif /* GC_CHECK_STRING_BYTES */
32587
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
1910
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1911 return s;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1912 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1913
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1914
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1915 /* 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
1916 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
1917 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
1918 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
1919 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
1920
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1921 void
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1922 allocate_string_data (s, nchars, nbytes)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1923 struct Lisp_String *s;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1924 int nchars, nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1925 {
30293
4a27d6a88c43 (allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents: 29781
diff changeset
1926 struct sdata *data, *old_data;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1927 struct sblock *b;
30293
4a27d6a88c43 (allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents: 29781
diff changeset
1928 int needed, old_nbytes;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1929
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1930 /* 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
1931 of string data. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1932 needed = SDATA_SIZE (nbytes);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1933
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1934 if (nbytes > LARGE_STRING_BYTES)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1935 {
30557
5056adb52e97 (lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents: 30317
diff changeset
1936 size_t size = sizeof *b - sizeof (struct sdata) + needed;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1937
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1938 #ifdef DOUG_LEA_MALLOC
31576
717e7e2ca4fd Add some comments about DOUG_LEA_MALLOC's use of mmap
Gerd Moellmann <gerd@gnu.org>
parents: 31102
diff changeset
1939 /* Prevent mmap'ing the chunk. Lisp data may not be mmap'ed
717e7e2ca4fd Add some comments about DOUG_LEA_MALLOC's use of mmap
Gerd Moellmann <gerd@gnu.org>
parents: 31102
diff changeset
1940 because mapped region contents are not preserved in
51318
0b5248964d32 Comment.
Dave Love <fx@gnu.org>
parents: 51252
diff changeset
1941 a dumped Emacs.
0b5248964d32 Comment.
Dave Love <fx@gnu.org>
parents: 51252
diff changeset
1942
0b5248964d32 Comment.
Dave Love <fx@gnu.org>
parents: 51252
diff changeset
1943 In case you think of allowing it in a dumped Emacs at the
0b5248964d32 Comment.
Dave Love <fx@gnu.org>
parents: 51252
diff changeset
1944 cost of not being able to re-dump, there's another reason:
0b5248964d32 Comment.
Dave Love <fx@gnu.org>
parents: 51252
diff changeset
1945 mmap'ed data typically have an address towards the top of the
0b5248964d32 Comment.
Dave Love <fx@gnu.org>
parents: 51252
diff changeset
1946 address space, which won't fit into an EMACS_INT (at least on
0b5248964d32 Comment.
Dave Love <fx@gnu.org>
parents: 51252
diff changeset
1947 32-bit systems with the current tagging scheme). --fx */
61225
1e515cc6ca0c * alloc.c (allocate_string_data): Call BLOCK_INPUT before calling
Jan Djärv <jan.h.d@swipnet.se>
parents: 60896
diff changeset
1948 BLOCK_INPUT;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1949 mallopt (M_MMAP_MAX, 0);
61225
1e515cc6ca0c * alloc.c (allocate_string_data): Call BLOCK_INPUT before calling
Jan Djärv <jan.h.d@swipnet.se>
parents: 60896
diff changeset
1950 UNBLOCK_INPUT;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1951 #endif
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1952
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1953 b = (struct sblock *) lisp_malloc (size + GC_STRING_EXTRA, MEM_TYPE_NON_LISP);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1954
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1955 #ifdef DOUG_LEA_MALLOC
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1956 /* Back to a reasonable maximum of mmap'ed areas. */
61225
1e515cc6ca0c * alloc.c (allocate_string_data): Call BLOCK_INPUT before calling
Jan Djärv <jan.h.d@swipnet.se>
parents: 60896
diff changeset
1957 BLOCK_INPUT;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1958 mallopt (M_MMAP_MAX, MMAP_MAX_AREAS);
61225
1e515cc6ca0c * alloc.c (allocate_string_data): Call BLOCK_INPUT before calling
Jan Djärv <jan.h.d@swipnet.se>
parents: 60896
diff changeset
1959 UNBLOCK_INPUT;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1960 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1961
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1962 b->next_free = &b->first_data;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1963 b->first_data.string = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1964 b->next = large_sblocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1965 large_sblocks = b;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1966 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1967 else if (current_sblock == NULL
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1968 || (((char *) current_sblock + SBLOCK_SIZE
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1969 - (char *) current_sblock->next_free)
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1970 < (needed + GC_STRING_EXTRA)))
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1971 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1972 /* 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
1973 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
1974 b->next_free = &b->first_data;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1975 b->first_data.string = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1976 b->next = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1977
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1978 if (current_sblock)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1979 current_sblock->next = b;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1980 else
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1981 oldest_sblock = b;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1982 current_sblock = b;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1983 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1984 else
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1985 b = current_sblock;
30293
4a27d6a88c43 (allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents: 29781
diff changeset
1986
4a27d6a88c43 (allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents: 29781
diff changeset
1987 old_data = s->data ? SDATA_OF_STRING (s) : NULL;
4a27d6a88c43 (allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents: 29781
diff changeset
1988 old_nbytes = GC_STRING_BYTES (s);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
1989
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1990 data = b->next_free;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1991 data->string = s;
31897
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1992 s->data = SDATA_DATA (data);
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1993 #ifdef GC_CHECK_STRING_BYTES
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1994 SDATA_NBYTES (data) = nbytes;
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
1995 #endif
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1996 s->size = nchars;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1997 s->size_byte = nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
1998 s->data[nbytes] = '\0';
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
1999 #ifdef GC_CHECK_STRING_OVERRUN
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
2000 bcopy (string_overrun_cookie, (char *) data + needed,
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
2001 GC_STRING_OVERRUN_COOKIE_SIZE);
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
2002 #endif
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
2003 b->next_free = (struct sdata *) ((char *) data + needed + GC_STRING_EXTRA);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2004
30293
4a27d6a88c43 (allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents: 29781
diff changeset
2005 /* If S had already data assigned, mark that as free by setting its
4a27d6a88c43 (allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents: 29781
diff changeset
2006 string back-pointer to null, and recording the size of the data
30317
96e65dc07fd7 (allocate_string_data): Don't copy old string contents.
Gerd Moellmann <gerd@gnu.org>
parents: 30293
diff changeset
2007 in it. */
30293
4a27d6a88c43 (allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents: 29781
diff changeset
2008 if (old_data)
4a27d6a88c43 (allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents: 29781
diff changeset
2009 {
31897
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
2010 SDATA_NBYTES (old_data) = old_nbytes;
30293
4a27d6a88c43 (allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents: 29781
diff changeset
2011 old_data->string = NULL;
4a27d6a88c43 (allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents: 29781
diff changeset
2012 }
4a27d6a88c43 (allocate_string_data): If string had already data
Gerd Moellmann <gerd@gnu.org>
parents: 29781
diff changeset
2013
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2014 consing_since_gc += needed;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2015 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2016
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2017
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2018 /* Sweep and compact strings. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2019
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2020 static void
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2021 sweep_strings ()
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2022 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2023 struct string_block *b, *next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2024 struct string_block *live_blocks = NULL;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2025
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2026 string_free_list = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2027 total_strings = total_free_strings = 0;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2028 total_string_size = 0;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2029
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2030 /* 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
2031 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
2032 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2033 int i, nfree = 0;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2034 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
2035
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2036 next = b->next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2037
51907
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
2038 for (i = 0; i < STRING_BLOCK_SIZE; ++i)
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2039 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2040 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
2041
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2042 if (s->data)
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 /* 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
2045 if (STRING_MARKED_P (s))
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2046 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2047 /* 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
2048 UNMARK_STRING (s);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2049
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2050 if (!NULL_INTERVAL_P (s->intervals))
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2051 UNMARK_BALANCE_INTERVALS (s->intervals);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2052
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2053 ++total_strings;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2054 total_string_size += STRING_BYTES (s);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2055 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2056 else
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2057 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2058 /* 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
2059 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
2060
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2061 /* 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
2062 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
2063 back-pointer so that we know it's free. */
31897
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
2064 #ifdef GC_CHECK_STRING_BYTES
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
2065 if (GC_STRING_BYTES (s) != SDATA_NBYTES (data))
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
2066 abort ();
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
2067 #else
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2068 data->u.nbytes = GC_STRING_BYTES (s);
31897
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
2069 #endif
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2070 data->string = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2071
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2072 /* 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
2073 know it's free. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2074 s->data = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2075
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2076 /* 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
2077 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
2078 string_free_list = s;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2079 ++nfree;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2080 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2081 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2082 else
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2083 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2084 /* 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
2085 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
2086 string_free_list = s;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2087 ++nfree;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2088 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2089 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2090
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2091 /* 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
2092 the first two of them. */
51907
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
2093 if (nfree == STRING_BLOCK_SIZE
4073a8ee4fc0 (BLOCK_PADDING): Rename from ABLOCKS_PADDING. Update users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51843
diff changeset
2094 && total_free_strings > STRING_BLOCK_SIZE)
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2095 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2096 lisp_free (b);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2097 --n_string_blocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2098 string_free_list = free_list_before;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2099 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2100 else
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2101 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2102 total_free_strings += nfree;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2103 b->next = live_blocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2104 live_blocks = b;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2105 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2106 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2107
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
2108 check_string_free_list ();
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
2109
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2110 string_blocks = live_blocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2111 free_large_strings ();
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2112 compact_small_strings ();
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
2113
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
2114 check_string_free_list ();
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2115 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2116
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2117
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2118 /* Free dead large strings. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2119
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2120 static void
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2121 free_large_strings ()
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2122 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2123 struct sblock *b, *next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2124 struct sblock *live_blocks = NULL;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2125
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2126 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
2127 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2128 next = b->next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2129
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2130 if (b->first_data.string == NULL)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2131 lisp_free (b);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2132 else
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2133 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2134 b->next = live_blocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2135 live_blocks = b;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2136 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2137 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2138
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2139 large_sblocks = live_blocks;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2140 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2141
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2143 /* 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
2144 data of live strings after compaction. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2145
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2146 static void
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2147 compact_small_strings ()
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2148 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2149 struct sblock *b, *tb, *next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2150 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
2151 struct sdata *to_end, *from_end;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2152
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2153 /* 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
2154 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
2155 tb = oldest_sblock;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2156 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
2157 to = &tb->first_data;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2158
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2159 /* 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
2160 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
2161 copying will happen this way. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2162 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
2163 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2164 end = b->next_free;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2165 xassert ((char *) end <= (char *) b + SBLOCK_SIZE);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2166
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2167 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
2168 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2169 /* 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
2170 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
2171 int nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2172
31897
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
2173 #ifdef GC_CHECK_STRING_BYTES
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
2174 /* Check that the string size recorded in the string is the
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
2175 same as the one recorded in the sdata structure. */
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
2176 if (from->string
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
2177 && GC_STRING_BYTES (from->string) != SDATA_NBYTES (from))
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
2178 abort ();
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
2179 #endif /* GC_CHECK_STRING_BYTES */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2180
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2181 if (from->string)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2182 nbytes = GC_STRING_BYTES (from->string);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2183 else
31897
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
2184 nbytes = SDATA_NBYTES (from);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2185
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
2186 if (nbytes > LARGE_STRING_BYTES)
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
2187 abort ();
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
2188
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2189 nbytes = SDATA_SIZE (nbytes);
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
2190 from_end = (struct sdata *) ((char *) from + nbytes + GC_STRING_EXTRA);
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
2191
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
2192 #ifdef GC_CHECK_STRING_OVERRUN
58707
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
2193 if (bcmp (string_overrun_cookie,
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
2194 ((char *) from_end) - GC_STRING_OVERRUN_COOKIE_SIZE,
57741ce4cd6b Add commentary for last change.
Kim F. Storm <storm@cua.dk>
parents: 58631
diff changeset
2195 GC_STRING_OVERRUN_COOKIE_SIZE))
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
2196 abort ();
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
2197 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2198
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2199 /* 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
2200 if (from->string)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2201 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2202 /* If TB is full, proceed with the next sblock. */
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
2203 to_end = (struct sdata *) ((char *) to + nbytes + GC_STRING_EXTRA);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2204 if (to_end > tb_end)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2205 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2206 tb->next_free = to;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2207 tb = tb->next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2208 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
2209 to = &tb->first_data;
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
2210 to_end = (struct sdata *) ((char *) to + nbytes + GC_STRING_EXTRA);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2211 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2212
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2213 /* 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
2214 if (from != to)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2215 {
30823
8ee3740aaf60 (compact_small_strings): Use safe_bcopy, add an
Gerd Moellmann <gerd@gnu.org>
parents: 30784
diff changeset
2216 xassert (tb != b || to <= from);
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
2217 safe_bcopy ((char *) from, (char *) to, nbytes + GC_STRING_EXTRA);
31897
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
2218 to->string->data = SDATA_DATA (to);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2219 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2220
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2221 /* 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
2222 to = to_end;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2223 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2224 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2225 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2226
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2227 /* 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
2228 we can free them. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2229 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
2230 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2231 next = b->next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2232 lisp_free (b);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2233 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2234
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2235 tb->next_free = to;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2236 tb->next = NULL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2237 current_sblock = tb;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2238 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2239
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2240
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2241 DEFUN ("make-string", Fmake_string, Smake_string, 2, 2, 0,
55745
1c3b8ce97c63 (Fmake_string): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 55720
diff changeset
2242 doc: /* Return a newly created string of length LENGTH, with INIT in each element.
1c3b8ce97c63 (Fmake_string): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 55720
diff changeset
2243 LENGTH must be an integer.
1c3b8ce97c63 (Fmake_string): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 55720
diff changeset
2244 INIT must be an integer that represents a character. */)
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
2245 (length, init)
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2246 Lisp_Object length, init;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2247 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2248 register Lisp_Object val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2249 register unsigned char *p, *end;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2250 int c, nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2251
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40113
diff changeset
2252 CHECK_NATNUM (length);
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40113
diff changeset
2253 CHECK_NUMBER (init);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2254
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2255 c = XINT (init);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2256 if (SINGLE_BYTE_CHAR_P (c))
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2257 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2258 nbytes = XINT (length);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2259 val = make_uninit_string (nbytes);
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46305
diff changeset
2260 p = SDATA (val);
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46305
diff changeset
2261 end = p + SCHARS (val);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2262 while (p != end)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2263 *p++ = c;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2264 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2265 else
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2266 {
33800
7f148cfbd1f7 (Fmake_string): Use MAX_MULTIBYTE_LENGTH, instead of hard coded `4'.
Kenichi Handa <handa@m17n.org>
parents: 33764
diff changeset
2267 unsigned char str[MAX_MULTIBYTE_LENGTH];
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2268 int len = CHAR_STRING (c, str);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2269
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2270 nbytes = len * XINT (length);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2271 val = make_uninit_multibyte_string (XINT (length), nbytes);
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46305
diff changeset
2272 p = SDATA (val);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2273 end = p + nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2274 while (p != end)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2275 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2276 bcopy (str, p, len);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2277 p += len;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2278 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2279 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2280
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2281 *p = 0;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2282 return val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2283 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2284
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2285
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2286 DEFUN ("make-bool-vector", Fmake_bool_vector, Smake_bool_vector, 2, 2, 0,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
2287 doc: /* Return a new bool-vector of length LENGTH, using INIT for as each element.
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
2288 LENGTH must be a number. INIT matters only in whether it is t or nil. */)
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
2289 (length, init)
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2290 Lisp_Object length, init;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2291 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2292 register Lisp_Object val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2293 struct Lisp_Bool_Vector *p;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2294 int real_init, i;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2295 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
2296
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40113
diff changeset
2297 CHECK_NATNUM (length);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2298
55159
e4e9ec547c6f (Fmake_bool_vector): Use BOOL_VECTOR_BITS_PER_CHAR instead of
Andreas Schwab <schwab@suse.de>
parents: 53705
diff changeset
2299 bits_per_value = sizeof (EMACS_INT) * BOOL_VECTOR_BITS_PER_CHAR;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2300
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2301 length_in_elts = (XFASTINT (length) + bits_per_value - 1) / bits_per_value;
55159
e4e9ec547c6f (Fmake_bool_vector): Use BOOL_VECTOR_BITS_PER_CHAR instead of
Andreas Schwab <schwab@suse.de>
parents: 53705
diff changeset
2302 length_in_chars = ((XFASTINT (length) + BOOL_VECTOR_BITS_PER_CHAR - 1)
e4e9ec547c6f (Fmake_bool_vector): Use BOOL_VECTOR_BITS_PER_CHAR instead of
Andreas Schwab <schwab@suse.de>
parents: 53705
diff changeset
2303 / BOOL_VECTOR_BITS_PER_CHAR);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2304
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2305 /* 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
2306 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
2307 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
2308 p = XBOOL_VECTOR (val);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2309
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2310 /* 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
2311 p->vector_size = 0;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2312 XSETBOOL_VECTOR (val, p);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2313 p->size = XFASTINT (length);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2314
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2315 real_init = (NILP (init) ? 0 : -1);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2316 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
2317 p->data[i] = real_init;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2318
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2319 /* Clear the extraneous bits in the last byte. */
55159
e4e9ec547c6f (Fmake_bool_vector): Use BOOL_VECTOR_BITS_PER_CHAR instead of
Andreas Schwab <schwab@suse.de>
parents: 53705
diff changeset
2320 if (XINT (length) != length_in_chars * BOOL_VECTOR_BITS_PER_CHAR)
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2321 XBOOL_VECTOR (val)->data[length_in_chars - 1]
55159
e4e9ec547c6f (Fmake_bool_vector): Use BOOL_VECTOR_BITS_PER_CHAR instead of
Andreas Schwab <schwab@suse.de>
parents: 53705
diff changeset
2322 &= (1 << (XINT (length) % BOOL_VECTOR_BITS_PER_CHAR)) - 1;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2323
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2324 return val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2325 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2326
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2327
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2328 /* 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
2329 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
2330 multibyte, depending on the contents. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2331
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2332 Lisp_Object
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2333 make_string (contents, nbytes)
46459
0a9cbcbdbe45 (xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents: 46418
diff changeset
2334 const char *contents;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2335 int nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2336 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2337 register Lisp_Object val;
28997
fc8d42f77d4f (Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents: 28469
diff changeset
2338 int nchars, multibyte_nbytes;
fc8d42f77d4f (Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents: 28469
diff changeset
2339
fc8d42f77d4f (Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents: 28469
diff changeset
2340 parse_str_as_multibyte (contents, nbytes, &nchars, &multibyte_nbytes);
fc8d42f77d4f (Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents: 28469
diff changeset
2341 if (nbytes == nchars || nbytes != multibyte_nbytes)
fc8d42f77d4f (Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents: 28469
diff changeset
2342 /* CONTENTS contains no multibyte sequences or contains an invalid
fc8d42f77d4f (Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents: 28469
diff changeset
2343 multibyte sequence. We must make unibyte string. */
33623
dda5cbf94928 (make_string): Fix previous change. Be sure to make
Kenichi Handa <handa@m17n.org>
parents: 32776
diff changeset
2344 val = make_unibyte_string (contents, nbytes);
dda5cbf94928 (make_string): Fix previous change. Be sure to make
Kenichi Handa <handa@m17n.org>
parents: 32776
diff changeset
2345 else
dda5cbf94928 (make_string): Fix previous change. Be sure to make
Kenichi Handa <handa@m17n.org>
parents: 32776
diff changeset
2346 val = make_multibyte_string (contents, nchars, nbytes);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2347 return val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2348 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2349
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2350
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2351 /* 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
2352
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2353 Lisp_Object
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2354 make_unibyte_string (contents, length)
46459
0a9cbcbdbe45 (xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents: 46418
diff changeset
2355 const char *contents;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2356 int length;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2357 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2358 register Lisp_Object val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2359 val = make_uninit_string (length);
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46305
diff changeset
2360 bcopy (contents, SDATA (val), length);
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46305
diff changeset
2361 STRING_SET_UNIBYTE (val);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2362 return val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2363 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2364
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2365
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2366 /* 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
2367 bytes at CONTENTS. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2368
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2369 Lisp_Object
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2370 make_multibyte_string (contents, nchars, nbytes)
46459
0a9cbcbdbe45 (xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents: 46418
diff changeset
2371 const char *contents;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2372 int nchars, nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2373 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2374 register Lisp_Object val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2375 val = make_uninit_multibyte_string (nchars, nbytes);
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46305
diff changeset
2376 bcopy (contents, SDATA (val), nbytes);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2377 return val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2378 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2379
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2380
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2381 /* 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
2382 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
2383
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2384 Lisp_Object
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2385 make_string_from_bytes (contents, nchars, nbytes)
50274
a617ca0d5d85 (make_string_from_bytes): Add `const' for the arg
Kenichi Handa <handa@m17n.org>
parents: 50200
diff changeset
2386 const char *contents;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2387 int nchars, nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2388 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2389 register Lisp_Object val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2390 val = make_uninit_multibyte_string (nchars, nbytes);
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46305
diff changeset
2391 bcopy (contents, SDATA (val), nbytes);
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46305
diff changeset
2392 if (SBYTES (val) == SCHARS (val))
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46305
diff changeset
2393 STRING_SET_UNIBYTE (val);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2394 return val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2395 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2396
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2397
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2398 /* 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
2399 CONTENTS. The argument MULTIBYTE controls whether to label the
50200
fdeb795fc0ec (make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 49911
diff changeset
2400 string as multibyte. If NCHARS is negative, it counts the number of
fdeb795fc0ec (make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 49911
diff changeset
2401 characters by itself. */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2402
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2403 Lisp_Object
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2404 make_specified_string (contents, nchars, nbytes, multibyte)
50274
a617ca0d5d85 (make_string_from_bytes): Add `const' for the arg
Kenichi Handa <handa@m17n.org>
parents: 50200
diff changeset
2405 const char *contents;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2406 int nchars, nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2407 int multibyte;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2408 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2409 register Lisp_Object val;
50200
fdeb795fc0ec (make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 49911
diff changeset
2410
fdeb795fc0ec (make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 49911
diff changeset
2411 if (nchars < 0)
fdeb795fc0ec (make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 49911
diff changeset
2412 {
fdeb795fc0ec (make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 49911
diff changeset
2413 if (multibyte)
fdeb795fc0ec (make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 49911
diff changeset
2414 nchars = multibyte_chars_in_text (contents, nbytes);
fdeb795fc0ec (make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 49911
diff changeset
2415 else
fdeb795fc0ec (make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 49911
diff changeset
2416 nchars = nbytes;
fdeb795fc0ec (make_specified_string): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 49911
diff changeset
2417 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2418 val = make_uninit_multibyte_string (nchars, nbytes);
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46305
diff changeset
2419 bcopy (contents, SDATA (val), nbytes);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2420 if (!multibyte)
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46305
diff changeset
2421 STRING_SET_UNIBYTE (val);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2422 return val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2423 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2424
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2425
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2426 /* 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
2427 data warrants. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2428
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2429 Lisp_Object
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2430 build_string (str)
46459
0a9cbcbdbe45 (xstrdup, make_string, make_unibyte_string)
Ken Raeburn <raeburn@raeburn.org>
parents: 46418
diff changeset
2431 const char *str;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2432 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2433 return make_string (str, strlen (str));
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2434 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2435
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2436
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2437 /* 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
2438 occupying LENGTH bytes. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2439
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2440 Lisp_Object
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2441 make_uninit_string (length)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2442 int length;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2443 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2444 Lisp_Object val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2445 val = make_uninit_multibyte_string (length, length);
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46305
diff changeset
2446 STRING_SET_UNIBYTE (val);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2447 return val;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2448 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2449
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2450
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2451 /* 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
2452 which occupy NBYTES bytes. */
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2453
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2454 Lisp_Object
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2455 make_uninit_multibyte_string (nchars, nbytes)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2456 int nchars, nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2457 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2458 Lisp_Object string;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2459 struct Lisp_String *s;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2460
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2461 if (nchars < 0)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2462 abort ();
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2463
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2464 s = allocate_string ();
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2465 allocate_string_data (s, nchars, nbytes);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2466 XSETSTRING (string, s);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2467 string_chars_consed += nbytes;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2468 return string;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2469 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2470
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2471
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2472
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2473 /***********************************************************************
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2474 Float Allocation
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2475 ***********************************************************************/
1908
d649f2179d67 * alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents: 1893
diff changeset
2476
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2477 /* 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
2478 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
2479 by GC are put on a free list to be reallocated before allocating
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2480 any new float cells from the latest float_block. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2481
53582
b4eef5adebbf (struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53555
diff changeset
2482 #define FLOAT_BLOCK_SIZE \
b4eef5adebbf (struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53555
diff changeset
2483 (((BLOCK_BYTES - sizeof (struct float_block *) \
b4eef5adebbf (struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53555
diff changeset
2484 /* The compiler might add padding at the end. */ \
b4eef5adebbf (struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53555
diff changeset
2485 - (sizeof (struct Lisp_Float) - sizeof (int))) * CHAR_BIT) \
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2486 / (sizeof (struct Lisp_Float) * CHAR_BIT + 1))
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2487
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2488 #define GETMARKBIT(block,n) \
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2489 (((block)->gcmarkbits[(n) / (sizeof(int) * CHAR_BIT)] \
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2490 >> ((n) % (sizeof(int) * CHAR_BIT))) \
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2491 & 1)
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2492
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2493 #define SETMARKBIT(block,n) \
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2494 (block)->gcmarkbits[(n) / (sizeof(int) * CHAR_BIT)] \
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2495 |= 1 << ((n) % (sizeof(int) * CHAR_BIT))
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2496
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2497 #define UNSETMARKBIT(block,n) \
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2498 (block)->gcmarkbits[(n) / (sizeof(int) * CHAR_BIT)] \
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2499 &= ~(1 << ((n) % (sizeof(int) * CHAR_BIT)))
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2500
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2501 #define FLOAT_BLOCK(fptr) \
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2502 ((struct float_block *)(((EMACS_UINT)(fptr)) & ~(BLOCK_ALIGN - 1)))
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2503
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2504 #define FLOAT_INDEX(fptr) \
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2505 ((((EMACS_UINT)(fptr)) & (BLOCK_ALIGN - 1)) / sizeof (struct Lisp_Float))
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2506
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2507 struct float_block
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2508 {
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2509 /* Place `floats' at the beginning, to ease up FLOAT_INDEX's job. */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2510 struct Lisp_Float floats[FLOAT_BLOCK_SIZE];
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2511 int gcmarkbits[1 + FLOAT_BLOCK_SIZE / (sizeof(int) * CHAR_BIT)];
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2512 struct float_block *next;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2513 };
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2514
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2515 #define FLOAT_MARKED_P(fptr) \
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2516 GETMARKBIT (FLOAT_BLOCK (fptr), FLOAT_INDEX ((fptr)))
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2517
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2518 #define FLOAT_MARK(fptr) \
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2519 SETMARKBIT (FLOAT_BLOCK (fptr), FLOAT_INDEX ((fptr)))
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2520
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2521 #define FLOAT_UNMARK(fptr) \
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2522 UNSETMARKBIT (FLOAT_BLOCK (fptr), FLOAT_INDEX ((fptr)))
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2523
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2524 /* Current float_block. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2525
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2526 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
2527
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2528 /* 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
2529
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2530 int float_block_index;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2531
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
2532 /* 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
2533
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
2534 int n_float_blocks;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
2535
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2536 /* 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
2537
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2538 struct Lisp_Float *float_free_list;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2539
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2540
39297
aff361cfdccb Fix a typo in a comment. From Pavel Janik.
Eli Zaretskii <eliz@gnu.org>
parents: 39228
diff changeset
2541 /* Initialize float allocation. */
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2542
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2543 void
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2544 init_float ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2545 {
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2546 float_block = NULL;
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2547 float_block_index = FLOAT_BLOCK_SIZE; /* Force alloc of new float_block. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2548 float_free_list = 0;
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2549 n_float_blocks = 0;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2550 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2551
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2552
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2553 /* 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
2554
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21379
diff changeset
2555 void
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2556 free_float (ptr)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2557 struct Lisp_Float *ptr;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2558 {
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
2559 *(struct Lisp_Float **)&ptr->data = float_free_list;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2560 float_free_list = ptr;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2561 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2562
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2563
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2564 /* 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
2565
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2566 Lisp_Object
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2567 make_float (float_value)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2568 double float_value;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2569 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2570 register Lisp_Object val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2571
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2572 if (float_free_list)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2573 {
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
2574 /* 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
2575 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
2576 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
2577 float_free_list = *(struct Lisp_Float **)&float_free_list->data;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2578 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2579 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2580 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2581 if (float_block_index == FLOAT_BLOCK_SIZE)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2582 {
12529
c7d32f5da2b3 (Flist): Rewritten.
Karl Heuer <kwzh@gnu.org>
parents: 12273
diff changeset
2583 register struct float_block *new;
c7d32f5da2b3 (Flist): Rewritten.
Karl Heuer <kwzh@gnu.org>
parents: 12273
diff changeset
2584
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2585 new = (struct float_block *) lisp_align_malloc (sizeof *new,
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
2586 MEM_TYPE_FLOAT);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2587 new->next = float_block;
53093
e8f5463f3d5b (make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52837
diff changeset
2588 bzero ((char *) new->gcmarkbits, sizeof new->gcmarkbits);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2589 float_block = new;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2590 float_block_index = 0;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
2591 n_float_blocks++;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2592 }
53093
e8f5463f3d5b (make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52837
diff changeset
2593 XSETFLOAT (val, &float_block->floats[float_block_index]);
e8f5463f3d5b (make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52837
diff changeset
2594 float_block_index++;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2595 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2596
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
2597 XFLOAT_DATA (val) = float_value;
53093
e8f5463f3d5b (make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52837
diff changeset
2598 eassert (!FLOAT_MARKED_P (XFLOAT (val)));
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2599 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
2600 floats_consed++;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2601 return val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2602 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2603
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2604
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2605
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2606 /***********************************************************************
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2607 Cons Allocation
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2608 ***********************************************************************/
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2609
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2610 /* We store cons cells inside of cons_blocks, allocating a new
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2611 cons_block with malloc whenever necessary. Cons cells reclaimed by
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2612 GC are put on a free list to be reallocated before allocating
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2613 any new cons cells from the latest cons_block. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2614
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2615 #define CONS_BLOCK_SIZE \
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2616 (((BLOCK_BYTES - sizeof (struct cons_block *)) * CHAR_BIT) \
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2617 / (sizeof (struct Lisp_Cons) * CHAR_BIT + 1))
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2618
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2619 #define CONS_BLOCK(fptr) \
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2620 ((struct cons_block *)(((EMACS_UINT)(fptr)) & ~(BLOCK_ALIGN - 1)))
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2621
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2622 #define CONS_INDEX(fptr) \
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2623 ((((EMACS_UINT)(fptr)) & (BLOCK_ALIGN - 1)) / sizeof (struct Lisp_Cons))
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2624
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2625 struct cons_block
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2626 {
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2627 /* Place `conses' at the beginning, to ease up CONS_INDEX's job. */
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2628 struct Lisp_Cons conses[CONS_BLOCK_SIZE];
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2629 int gcmarkbits[1 + CONS_BLOCK_SIZE / (sizeof(int) * CHAR_BIT)];
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2630 struct cons_block *next;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2631 };
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2632
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2633 #define CONS_MARKED_P(fptr) \
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2634 GETMARKBIT (CONS_BLOCK (fptr), CONS_INDEX ((fptr)))
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2635
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2636 #define CONS_MARK(fptr) \
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2637 SETMARKBIT (CONS_BLOCK (fptr), CONS_INDEX ((fptr)))
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2638
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2639 #define CONS_UNMARK(fptr) \
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2640 UNSETMARKBIT (CONS_BLOCK (fptr), CONS_INDEX ((fptr)))
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2641
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2642 /* Current cons_block. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2643
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2644 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
2645
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2646 /* 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
2647
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2648 int cons_block_index;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2649
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2650 /* 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
2651
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2652 struct Lisp_Cons *cons_free_list;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2653
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
2654 /* 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
2655
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
2656 int n_cons_blocks;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
2657
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2658
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2659 /* Initialize cons allocation. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2660
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2661 void
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2662 init_cons ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2663 {
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2664 cons_block = NULL;
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2665 cons_block_index = CONS_BLOCK_SIZE; /* Force alloc of new cons_block. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2666 cons_free_list = 0;
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2667 n_cons_blocks = 0;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2668 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2669
27738
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 /* 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
2672
1dd0bd0749b5 (malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents: 20057
diff changeset
2673 void
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2674 free_cons (ptr)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2675 struct Lisp_Cons *ptr;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2676 {
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
2677 *(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
2678 #if GC_MARK_STACK
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2679 ptr->car = Vdead;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2680 #endif
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2681 cons_free_list = ptr;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2682 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2683
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2684 DEFUN ("cons", Fcons, Scons, 2, 2, 0,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
2685 doc: /* Create a new cons, give it CAR and CDR as components, and return it. */)
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
2686 (car, cdr)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2687 Lisp_Object car, cdr;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2688 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2689 register Lisp_Object val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2690
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2691 if (cons_free_list)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2692 {
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
2693 /* 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
2694 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
2695 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
2696 cons_free_list = *(struct Lisp_Cons **)&cons_free_list->cdr;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2697 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2698 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2699 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2700 if (cons_block_index == CONS_BLOCK_SIZE)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2701 {
12529
c7d32f5da2b3 (Flist): Rewritten.
Karl Heuer <kwzh@gnu.org>
parents: 12273
diff changeset
2702 register struct cons_block *new;
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2703 new = (struct cons_block *) lisp_align_malloc (sizeof *new,
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
2704 MEM_TYPE_CONS);
53093
e8f5463f3d5b (make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52837
diff changeset
2705 bzero ((char *) new->gcmarkbits, sizeof new->gcmarkbits);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2706 new->next = cons_block;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2707 cons_block = new;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2708 cons_block_index = 0;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
2709 n_cons_blocks++;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2710 }
53093
e8f5463f3d5b (make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52837
diff changeset
2711 XSETCONS (val, &cons_block->conses[cons_block_index]);
e8f5463f3d5b (make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52837
diff changeset
2712 cons_block_index++;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2713 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2714
39973
579177964efa Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents: 39914
diff changeset
2715 XSETCAR (val, car);
579177964efa Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents: 39914
diff changeset
2716 XSETCDR (val, cdr);
53093
e8f5463f3d5b (make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52837
diff changeset
2717 eassert (!CONS_MARKED_P (XCONS (val)));
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2718 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
2719 cons_cells_consed++;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2720 return val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2721 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2722
56539
9fc5aae4053e (check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents: 56401
diff changeset
2723 /* Get an error now if there's any junk in the cons free list. */
9fc5aae4053e (check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents: 56401
diff changeset
2724 void
9fc5aae4053e (check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents: 56401
diff changeset
2725 check_cons_list ()
9fc5aae4053e (check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents: 56401
diff changeset
2726 {
58631
7c469d30a12d Add more checks for buffer overruns.
Kim F. Storm <storm@cua.dk>
parents: 58593
diff changeset
2727 #ifdef GC_CHECK_CONS_LIST
56539
9fc5aae4053e (check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents: 56401
diff changeset
2728 struct Lisp_Cons *tail = cons_free_list;
9fc5aae4053e (check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents: 56401
diff changeset
2729
9fc5aae4053e (check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents: 56401
diff changeset
2730 while (tail)
9fc5aae4053e (check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents: 56401
diff changeset
2731 tail = *(struct Lisp_Cons **)&tail->cdr;
9fc5aae4053e (check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents: 56401
diff changeset
2732 #endif
9fc5aae4053e (check_cons_list): New function (contents commented out).
Richard M. Stallman <rms@gnu.org>
parents: 56401
diff changeset
2733 }
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2734
20849
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2735 /* 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
2736
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2737 Lisp_Object
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2738 list2 (arg1, arg2)
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2739 Lisp_Object arg1, arg2;
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2740 {
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2741 return Fcons (arg1, Fcons (arg2, Qnil));
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2742 }
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2743
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2744
20849
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2745 Lisp_Object
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2746 list3 (arg1, arg2, arg3)
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2747 Lisp_Object arg1, arg2, arg3;
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2748 {
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2749 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
2750 }
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2751
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2752
20849
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2753 Lisp_Object
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2754 list4 (arg1, arg2, arg3, arg4)
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2755 Lisp_Object arg1, arg2, arg3, arg4;
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2756 {
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2757 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
2758 }
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2759
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2760
20849
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2761 Lisp_Object
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2762 list5 (arg1, arg2, arg3, arg4, arg5)
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2763 Lisp_Object arg1, arg2, arg3, arg4, arg5;
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2764 {
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2765 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
2766 Fcons (arg5, Qnil)))));
3b2f72ed135c (list2, list3, list4, list5): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 20768
diff changeset
2767 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2768
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2769
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2770 DEFUN ("list", Flist, Slist, 0, MANY, 0,
40977
6ec709b442c8 (Flist): Reindent.
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
2771 doc: /* Return a newly created list with specified arguments as elements.
40113
66132b83e52a (Fmake_byte_code, Fvector, Flist): Add usage: string to doc string.
Miles Bader <miles@gnu.org>
parents: 40107
diff changeset
2772 Any number of arguments, even zero arguments, are allowed.
66132b83e52a (Fmake_byte_code, Fvector, Flist): Add usage: string to doc string.
Miles Bader <miles@gnu.org>
parents: 40107
diff changeset
2773 usage: (list &rest OBJECTS) */)
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
2774 (nargs, args)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2775 int nargs;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2776 register Lisp_Object *args;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2777 {
13610
8e82e46aa77b (Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents: 13553
diff changeset
2778 register Lisp_Object val;
8e82e46aa77b (Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents: 13553
diff changeset
2779 val = Qnil;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2780
13610
8e82e46aa77b (Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents: 13553
diff changeset
2781 while (nargs > 0)
8e82e46aa77b (Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents: 13553
diff changeset
2782 {
8e82e46aa77b (Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents: 13553
diff changeset
2783 nargs--;
8e82e46aa77b (Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents: 13553
diff changeset
2784 val = Fcons (args[nargs], val);
8e82e46aa77b (Flist): Avoid using -- in while condition.
Richard M. Stallman <rms@gnu.org>
parents: 13553
diff changeset
2785 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2786 return val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2787 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2788
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2789
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2790 DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
2791 doc: /* Return a newly created list of length LENGTH, with each element being INIT. */)
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
2792 (length, init)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2793 register Lisp_Object length, init;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2794 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2795 register Lisp_Object val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2796 register int size;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2797
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40113
diff changeset
2798 CHECK_NATNUM (length);
9953
e0672d4cf470 (Fmake_list, Fmake_vector, Fmake_string): Use CHECK_NATNUM instead of its
Karl Heuer <kwzh@gnu.org>
parents: 9942
diff changeset
2799 size = XFASTINT (length);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2800
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2801 val = Qnil;
35762
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2802 while (size > 0)
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2803 {
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2804 val = Fcons (init, val);
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2805 --size;
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2806
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2807 if (size > 0)
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2808 {
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2809 val = Fcons (init, val);
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2810 --size;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2811
35762
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2812 if (size > 0)
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2813 {
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2814 val = Fcons (init, val);
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2815 --size;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2816
35762
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2817 if (size > 0)
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2818 {
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2819 val = Fcons (init, val);
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2820 --size;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2821
35762
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2822 if (size > 0)
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2823 {
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2824 val = Fcons (init, val);
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2825 --size;
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2826 }
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2827 }
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2828 }
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2829 }
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2830
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2831 QUIT;
e197a82c3286 (Fmake_list): Add a QUIT in the loop; unroll the loop.
Gerd Moellmann <gerd@gnu.org>
parents: 35660
diff changeset
2832 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2833
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2834 return val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2835 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2836
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2837
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2838
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2839 /***********************************************************************
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2840 Vector Allocation
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2841 ***********************************************************************/
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2842
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2843 /* 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
2844
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2845 struct Lisp_Vector *all_vectors;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2846
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
2847 /* 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
2848
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
2849 int n_vectors;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
2850
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2851
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2852 /* 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
2853 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
2854
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2855 static struct Lisp_Vector *
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2856 allocate_vectorlike (len, type)
9968
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
2857 EMACS_INT len;
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2858 enum mem_type type;
9968
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
2859 {
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
2860 struct Lisp_Vector *p;
30557
5056adb52e97 (lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
Gerd Moellmann <gerd@gnu.org>
parents: 30317
diff changeset
2861 size_t nbytes;
9968
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
2862
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
2863 #ifdef DOUG_LEA_MALLOC
31576
717e7e2ca4fd Add some comments about DOUG_LEA_MALLOC's use of mmap
Gerd Moellmann <gerd@gnu.org>
parents: 31102
diff changeset
2864 /* Prevent mmap'ing the chunk. Lisp data may not be mmap'ed
717e7e2ca4fd Add some comments about DOUG_LEA_MALLOC's use of mmap
Gerd Moellmann <gerd@gnu.org>
parents: 31102
diff changeset
2865 because mapped region contents are not preserved in
717e7e2ca4fd Add some comments about DOUG_LEA_MALLOC's use of mmap
Gerd Moellmann <gerd@gnu.org>
parents: 31102
diff changeset
2866 a dumped Emacs. */
53555
72ce38380ab3 * alloc.c (allocate_vectorlike): Surround calls to mallopt with
Jan Djärv <jan.h.d@swipnet.se>
parents: 53093
diff changeset
2867 BLOCK_INPUT;
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
2868 mallopt (M_MMAP_MAX, 0);
53555
72ce38380ab3 * alloc.c (allocate_vectorlike): Surround calls to mallopt with
Jan Djärv <jan.h.d@swipnet.se>
parents: 53093
diff changeset
2869 UNBLOCK_INPUT;
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
2870 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2871
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2872 nbytes = sizeof *p + (len - 1) * sizeof p->contents[0];
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2873 p = (struct Lisp_Vector *) lisp_malloc (nbytes, type);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2874
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
2875 #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
2876 /* Back to a reasonable maximum of mmap'ed areas. */
53555
72ce38380ab3 * alloc.c (allocate_vectorlike): Surround calls to mallopt with
Jan Djärv <jan.h.d@swipnet.se>
parents: 53093
diff changeset
2877 BLOCK_INPUT;
23973
2eb9e2f5aa33 (MMAP_MAX_AREAS): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 23958
diff changeset
2878 mallopt (M_MMAP_MAX, MMAP_MAX_AREAS);
53555
72ce38380ab3 * alloc.c (allocate_vectorlike): Surround calls to mallopt with
Jan Djärv <jan.h.d@swipnet.se>
parents: 53093
diff changeset
2879 UNBLOCK_INPUT;
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
2880 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2881
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2882 consing_since_gc += nbytes;
12748
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
2883 vector_cells_consed += len;
9968
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
2884
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
2885 p->next = all_vectors;
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
2886 all_vectors = p;
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2887 ++n_vectors;
9968
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
2888 return p;
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
2889 }
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
2890
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
2891
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2892 /* Allocate a vector with NSLOTS slots. */
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2893
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2894 struct Lisp_Vector *
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2895 allocate_vector (nslots)
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2896 EMACS_INT nslots;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2897 {
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2898 struct Lisp_Vector *v = allocate_vectorlike (nslots, MEM_TYPE_VECTOR);
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2899 v->size = nslots;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2900 return v;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2901 }
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2902
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2903
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2904 /* Allocate other vector-like structures. */
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2905
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2906 struct Lisp_Hash_Table *
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2907 allocate_hash_table ()
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2908 {
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2909 EMACS_INT len = VECSIZE (struct Lisp_Hash_Table);
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2910 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_HASH_TABLE);
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2911 EMACS_INT i;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2912
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2913 v->size = len;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2914 for (i = 0; i < len; ++i)
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2915 v->contents[i] = Qnil;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2916
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2917 return (struct Lisp_Hash_Table *) v;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2918 }
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2919
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2920
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2921 struct window *
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2922 allocate_window ()
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2923 {
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2924 EMACS_INT len = VECSIZE (struct window);
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2925 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_WINDOW);
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2926 EMACS_INT i;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2927
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2928 for (i = 0; i < len; ++i)
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2929 v->contents[i] = Qnil;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2930 v->size = len;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2931
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2932 return (struct window *) v;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2933 }
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2934
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2935
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2936 struct frame *
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2937 allocate_frame ()
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2938 {
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2939 EMACS_INT len = VECSIZE (struct frame);
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2940 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_FRAME);
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2941 EMACS_INT i;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2942
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2943 for (i = 0; i < len; ++i)
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2944 v->contents[i] = make_number (0);
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2945 v->size = len;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2946 return (struct frame *) v;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2947 }
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2948
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2949
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2950 struct Lisp_Process *
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2951 allocate_process ()
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2952 {
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2953 EMACS_INT len = VECSIZE (struct Lisp_Process);
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2954 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_PROCESS);
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2955 EMACS_INT i;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2956
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2957 for (i = 0; i < len; ++i)
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2958 v->contents[i] = Qnil;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2959 v->size = len;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2960
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2961 return (struct Lisp_Process *) v;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2962 }
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2963
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2964
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2965 struct Lisp_Vector *
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2966 allocate_other_vector (len)
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2967 EMACS_INT len;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2968 {
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2969 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_VECTOR);
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2970 EMACS_INT i;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2971
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2972 for (i = 0; i < len; ++i)
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2973 v->contents[i] = Qnil;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2974 v->size = len;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
2975
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2976 return v;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2977 }
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2978
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2979
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2980 DEFUN ("make-vector", Fmake_vector, Smake_vector, 2, 2, 0,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
2981 doc: /* Return a newly created vector of length LENGTH, with each element being INIT.
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
2982 See also the function `vector'. */)
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
2983 (length, init)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2984 register Lisp_Object length, init;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2985 {
9968
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
2986 Lisp_Object vector;
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
2987 register EMACS_INT sizei;
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
2988 register int index;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2989 register struct Lisp_Vector *p;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2990
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40113
diff changeset
2991 CHECK_NATNUM (length);
9953
e0672d4cf470 (Fmake_list, Fmake_vector, Fmake_string): Use CHECK_NATNUM instead of its
Karl Heuer <kwzh@gnu.org>
parents: 9942
diff changeset
2992 sizei = XFASTINT (length);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2993
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
2994 p = allocate_vector (sizei);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2995 for (index = 0; index < sizei; index++)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2996 p->contents[index] = init;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2997
9968
943a61c764a5 (Fmake_vector): Call allocate_vectorlike.
Karl Heuer <kwzh@gnu.org>
parents: 9953
diff changeset
2998 XSETVECTOR (vector, p);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2999 return vector;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3000 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3001
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3002
13219
99b5164a319d (Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13150
diff changeset
3003 DEFUN ("make-char-table", Fmake_char_table, Smake_char_table, 1, 2, 0,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
3004 doc: /* Return a newly created char-table, with purpose PURPOSE.
39914
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
3005 Each element is initialized to INIT, which defaults to nil.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
3006 PURPOSE should be a symbol which has a `char-table-extra-slots' property.
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
3007 The property's value should be an integer between 0 and 10. */)
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
3008 (purpose, init)
13219
99b5164a319d (Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13150
diff changeset
3009 register Lisp_Object purpose, init;
13141
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
3010 {
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
3011 Lisp_Object vector;
13219
99b5164a319d (Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13150
diff changeset
3012 Lisp_Object n;
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40113
diff changeset
3013 CHECK_SYMBOL (purpose);
17328
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
3014 n = Fget (purpose, Qchar_table_extra_slots);
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40113
diff changeset
3015 CHECK_NUMBER (n);
13141
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
3016 if (XINT (n) < 0 || XINT (n) > 10)
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
3017 args_out_of_range (n, Qnil);
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
3018 /* 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
3019 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
3020 init);
17328
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
3021 XCHAR_TABLE (vector)->top = Qt;
13150
3778c95adca9 (Fmake_char_table): Initialize parent to nil.
Erik Naggum <erik@naggum.no>
parents: 13141
diff changeset
3022 XCHAR_TABLE (vector)->parent = Qnil;
13219
99b5164a319d (Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13150
diff changeset
3023 XCHAR_TABLE (vector)->purpose = purpose;
13141
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
3024 XSETCHAR_TABLE (vector, XCHAR_TABLE (vector));
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
3025 return vector;
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
3026 }
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
3027
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3028
61685
832617c86aa7 (make_sub_char_table): Argument changed to initial
Kenichi Handa <handa@m17n.org>
parents: 61252
diff changeset
3029 /* Return a newly created sub char table with slots initialized by INIT.
17328
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
3030 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
3031 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
3032
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
3033 Lisp_Object
61685
832617c86aa7 (make_sub_char_table): Argument changed to initial
Kenichi Handa <handa@m17n.org>
parents: 61252
diff changeset
3034 make_sub_char_table (init)
832617c86aa7 (make_sub_char_table): Argument changed to initial
Kenichi Handa <handa@m17n.org>
parents: 61252
diff changeset
3035 Lisp_Object init;
17328
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
3036 {
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
3037 Lisp_Object vector
61685
832617c86aa7 (make_sub_char_table): Argument changed to initial
Kenichi Handa <handa@m17n.org>
parents: 61252
diff changeset
3038 = Fmake_vector (make_number (SUB_CHAR_TABLE_STANDARD_SLOTS), init);
17328
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
3039 XCHAR_TABLE (vector)->top = Qnil;
61685
832617c86aa7 (make_sub_char_table): Argument changed to initial
Kenichi Handa <handa@m17n.org>
parents: 61252
diff changeset
3040 XCHAR_TABLE (vector)->defalt = Qnil;
17328
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
3041 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
3042 return vector;
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
3043 }
e2a6f31ee014 (Fmake_char_table): Adjusted for the new structure of
Kenichi Handa <handa@m17n.org>
parents: 17217
diff changeset
3044
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3045
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3046 DEFUN ("vector", Fvector, Svector, 0, MANY, 0,
40977
6ec709b442c8 (Flist): Reindent.
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
3047 doc: /* Return a newly created vector with specified arguments as elements.
40113
66132b83e52a (Fmake_byte_code, Fvector, Flist): Add usage: string to doc string.
Miles Bader <miles@gnu.org>
parents: 40107
diff changeset
3048 Any number of arguments, even zero arguments, are allowed.
66132b83e52a (Fmake_byte_code, Fvector, Flist): Add usage: string to doc string.
Miles Bader <miles@gnu.org>
parents: 40107
diff changeset
3049 usage: (vector &rest OBJECTS) */)
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
3050 (nargs, args)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3051 register int nargs;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3052 Lisp_Object *args;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3053 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3054 register Lisp_Object len, val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3055 register int index;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3056 register struct Lisp_Vector *p;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3057
9295
17d393a8eed6 (free_float, make_float, free_cons, Flist, Fvector, Fmake_byte_code,
Karl Heuer <kwzh@gnu.org>
parents: 9261
diff changeset
3058 XSETFASTINT (len, nargs);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3059 val = Fmake_vector (len, Qnil);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3060 p = XVECTOR (val);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3061 for (index = 0; index < nargs; index++)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3062 p->contents[index] = args[index];
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3063 return val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3064 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3065
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3066
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3067 DEFUN ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
3068 doc: /* Create a byte-code object with specified arguments as elements.
39914
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
3069 The arguments should be the arglist, bytecode-string, constant vector,
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
3070 stack size, (optional) doc string, and (optional) interactive spec.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
3071 The first four arguments are required; at most six have any
40113
66132b83e52a (Fmake_byte_code, Fvector, Flist): Add usage: string to doc string.
Miles Bader <miles@gnu.org>
parents: 40107
diff changeset
3072 significance.
50626
a5a77c7717cb (Fmake_byte_code): Improve the `usage' string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50468
diff changeset
3073 usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INTERACTIVE-SPEC &rest ELEMENTS) */)
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
3074 (nargs, args)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3075 register int nargs;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3076 Lisp_Object *args;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3077 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3078 register Lisp_Object len, val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3079 register int index;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3080 register struct Lisp_Vector *p;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3081
9295
17d393a8eed6 (free_float, make_float, free_cons, Flist, Fvector, Fmake_byte_code,
Karl Heuer <kwzh@gnu.org>
parents: 9261
diff changeset
3082 XSETFASTINT (len, nargs);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 434
diff changeset
3083 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
3084 val = make_pure_vector ((EMACS_INT) nargs);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3085 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3086 val = Fmake_vector (len, Qnil);
28997
fc8d42f77d4f (Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents: 28469
diff changeset
3087
fc8d42f77d4f (Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents: 28469
diff changeset
3088 if (STRINGP (args[1]) && STRING_MULTIBYTE (args[1]))
fc8d42f77d4f (Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents: 28469
diff changeset
3089 /* BYTECODE-STRING must have been produced by Emacs 20.2 or the
fc8d42f77d4f (Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents: 28469
diff changeset
3090 earlier because they produced a raw 8-bit string for byte-code
fc8d42f77d4f (Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents: 28469
diff changeset
3091 and now such a byte-code string is loaded as multibyte while
fc8d42f77d4f (Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents: 28469
diff changeset
3092 raw 8-bit characters converted to multibyte form. Thus, now we
fc8d42f77d4f (Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents: 28469
diff changeset
3093 must convert them back to the original unibyte form. */
fc8d42f77d4f (Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents: 28469
diff changeset
3094 args[1] = Fstring_as_unibyte (args[1]);
fc8d42f77d4f (Fmake_byte_code): If BYTECODE-STRING is multibyte,
Kenichi Handa <handa@m17n.org>
parents: 28469
diff changeset
3095
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3096 p = XVECTOR (val);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3097 for (index = 0; index < nargs; index++)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3098 {
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 434
diff changeset
3099 if (!NILP (Vpurify_flag))
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3100 args[index] = Fpurecopy (args[index]);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3101 p->contents[index] = args[index];
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3102 }
18104
b2a669ef69b1 (Fmake_byte_code): Set val from p, not from val.
Richard M. Stallman <rms@gnu.org>
parents: 18010
diff changeset
3103 XSETCOMPILED (val, p);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3104 return val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3105 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3106
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3107
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3108
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3109 /***********************************************************************
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3110 Symbol Allocation
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3111 ***********************************************************************/
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3112
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3113 /* 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
3114 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
3115 own overhead. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3116
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3117 #define SYMBOL_BLOCK_SIZE \
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3118 ((1020 - sizeof (struct symbol_block *)) / sizeof (struct Lisp_Symbol))
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3119
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3120 struct symbol_block
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3121 {
53582
b4eef5adebbf (struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53555
diff changeset
3122 /* Place `symbols' first, to preserve alignment. */
b4eef5adebbf (struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53555
diff changeset
3123 struct Lisp_Symbol symbols[SYMBOL_BLOCK_SIZE];
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3124 struct symbol_block *next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3125 };
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3126
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3127 /* 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
3128 structure in it. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3129
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3130 struct symbol_block *symbol_block;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3131 int symbol_block_index;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3132
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3133 /* List of free symbols. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3134
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3135 struct Lisp_Symbol *symbol_free_list;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3136
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
3137 /* 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
3138
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
3139 int n_symbol_blocks;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
3140
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3141
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3142 /* Initialize symbol allocation. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3143
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3144 void
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3145 init_symbol ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3146 {
52473
a3fd06a8c844 (init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52453
diff changeset
3147 symbol_block = NULL;
a3fd06a8c844 (init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52453
diff changeset
3148 symbol_block_index = SYMBOL_BLOCK_SIZE;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3149 symbol_free_list = 0;
52473
a3fd06a8c844 (init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52453
diff changeset
3150 n_symbol_blocks = 0;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3151 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3152
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3153
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3154 DEFUN ("make-symbol", Fmake_symbol, Smake_symbol, 1, 1, 0,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
3155 doc: /* Return a newly allocated uninterned symbol whose name is NAME.
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
3156 Its value and function definition are void, and its property list is nil. */)
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
3157 (name)
14093
338f645e6b9a (Fmake_symbol): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
3158 Lisp_Object name;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3159 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3160 register Lisp_Object val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3161 register struct Lisp_Symbol *p;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3162
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40113
diff changeset
3163 CHECK_STRING (name);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3164
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3165 if (symbol_free_list)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3166 {
9261
e5ba7993d378 (VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents: 9144
diff changeset
3167 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
3168 symbol_free_list = *(struct Lisp_Symbol **)&symbol_free_list->value;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3169 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3170 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3171 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3172 if (symbol_block_index == SYMBOL_BLOCK_SIZE)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3173 {
12529
c7d32f5da2b3 (Flist): Rewritten.
Karl Heuer <kwzh@gnu.org>
parents: 12273
diff changeset
3174 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
3175 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
3176 MEM_TYPE_SYMBOL);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3177 new->next = symbol_block;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3178 symbol_block = new;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3179 symbol_block_index = 0;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
3180 n_symbol_blocks++;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3181 }
53093
e8f5463f3d5b (make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52837
diff changeset
3182 XSETSYMBOL (val, &symbol_block->symbols[symbol_block_index]);
e8f5463f3d5b (make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52837
diff changeset
3183 symbol_block_index++;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3184 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3185
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3186 p = XSYMBOL (val);
45392
f3d7ab65641f * alloc.c (Fmake_symbol): Set symbol xname field instead of name.
Ken Raeburn <raeburn@raeburn.org>
parents: 44890
diff changeset
3187 p->xname = name;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3188 p->plist = Qnil;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3189 p->value = Qunbound;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3190 p->function = Qunbound;
39572
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
3191 p->next = NULL;
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
3192 p->gcmarkbit = 0;
39572
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
3193 p->interned = SYMBOL_UNINTERNED;
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
3194 p->constant = 0;
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
3195 p->indirect_variable = 0;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3196 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
3197 symbols_consed++;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3198 return val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3199 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3200
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3201
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3202
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3203 /***********************************************************************
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3204 Marker (Misc) Allocation
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3205 ***********************************************************************/
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3206
9437
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3207 /* Allocation of markers and other objects that share that structure.
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3208 Works like allocation of conses. */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3209
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3210 #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
3211 ((1020 - sizeof (struct marker_block *)) / sizeof (union Lisp_Misc))
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3212
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3213 struct marker_block
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
3214 {
53582
b4eef5adebbf (struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53555
diff changeset
3215 /* Place `markers' first, to preserve alignment. */
b4eef5adebbf (struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53555
diff changeset
3216 union Lisp_Misc markers[MARKER_BLOCK_SIZE];
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3217 struct marker_block *next;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3218 };
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3219
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3220 struct marker_block *marker_block;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3221 int marker_block_index;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3222
9437
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3223 union Lisp_Misc *marker_free_list;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3224
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
3225 /* 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
3226
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
3227 int n_marker_blocks;
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
3228
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3229 void
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3230 init_marker ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3231 {
52473
a3fd06a8c844 (init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52453
diff changeset
3232 marker_block = NULL;
a3fd06a8c844 (init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52453
diff changeset
3233 marker_block_index = MARKER_BLOCK_SIZE;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3234 marker_free_list = 0;
52473
a3fd06a8c844 (init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52453
diff changeset
3235 n_marker_blocks = 0;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3236 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3237
9437
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3238 /* 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
3239
9437
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3240 Lisp_Object
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3241 allocate_misc ()
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3242 {
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3243 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
3244
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3245 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
3246 {
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3247 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
3248 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
3249 }
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3250 else
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3251 {
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3252 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
3253 {
12529
c7d32f5da2b3 (Flist): Rewritten.
Karl Heuer <kwzh@gnu.org>
parents: 12273
diff changeset
3254 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
3255 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
3256 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
3257 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
3258 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
3259 marker_block_index = 0;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
3260 n_marker_blocks++;
56239
a446552d2240 (allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents: 56202
diff changeset
3261 total_free_markers += MARKER_BLOCK_SIZE;
9437
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3262 }
53093
e8f5463f3d5b (make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52837
diff changeset
3263 XSETMISC (val, &marker_block->markers[marker_block_index]);
e8f5463f3d5b (make_float, Fcons): Clear the markbit at init time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52837
diff changeset
3264 marker_block_index++;
9437
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3265 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3266
56239
a446552d2240 (allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents: 56202
diff changeset
3267 --total_free_markers;
9437
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3268 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
3269 misc_objects_consed++;
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
3270 XMARKER (val)->gcmarkbit = 0;
9437
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3271 return val;
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3272 }
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3273
56239
a446552d2240 (allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents: 56202
diff changeset
3274 /* Free a Lisp_Misc object */
a446552d2240 (allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents: 56202
diff changeset
3275
a446552d2240 (allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents: 56202
diff changeset
3276 void
a446552d2240 (allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents: 56202
diff changeset
3277 free_misc (misc)
a446552d2240 (allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents: 56202
diff changeset
3278 Lisp_Object misc;
a446552d2240 (allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents: 56202
diff changeset
3279 {
a446552d2240 (allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents: 56202
diff changeset
3280 XMISC (misc)->u_marker.type = Lisp_Misc_Free;
a446552d2240 (allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents: 56202
diff changeset
3281 XMISC (misc)->u_free.chain = marker_free_list;
a446552d2240 (allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents: 56202
diff changeset
3282 marker_free_list = XMISC (misc);
a446552d2240 (allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents: 56202
diff changeset
3283
a446552d2240 (allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents: 56202
diff changeset
3284 total_free_markers++;
a446552d2240 (allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents: 56202
diff changeset
3285 }
a446552d2240 (allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents: 56202
diff changeset
3286
49055
cea2e52c7ca5 (make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 48907
diff changeset
3287 /* Return a Lisp_Misc_Save_Value object containing POINTER and
cea2e52c7ca5 (make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 48907
diff changeset
3288 INTEGER. This is used to package C values to call record_unwind_protect.
cea2e52c7ca5 (make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 48907
diff changeset
3289 The unwind function can get the C values back using XSAVE_VALUE. */
cea2e52c7ca5 (make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 48907
diff changeset
3290
cea2e52c7ca5 (make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 48907
diff changeset
3291 Lisp_Object
cea2e52c7ca5 (make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 48907
diff changeset
3292 make_save_value (pointer, integer)
cea2e52c7ca5 (make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 48907
diff changeset
3293 void *pointer;
cea2e52c7ca5 (make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 48907
diff changeset
3294 int integer;
cea2e52c7ca5 (make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 48907
diff changeset
3295 {
cea2e52c7ca5 (make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 48907
diff changeset
3296 register Lisp_Object val;
cea2e52c7ca5 (make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 48907
diff changeset
3297 register struct Lisp_Save_Value *p;
cea2e52c7ca5 (make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 48907
diff changeset
3298
cea2e52c7ca5 (make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 48907
diff changeset
3299 val = allocate_misc ();
cea2e52c7ca5 (make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 48907
diff changeset
3300 XMISCTYPE (val) = Lisp_Misc_Save_Value;
cea2e52c7ca5 (make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 48907
diff changeset
3301 p = XSAVE_VALUE (val);
cea2e52c7ca5 (make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 48907
diff changeset
3302 p->pointer = pointer;
cea2e52c7ca5 (make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 48907
diff changeset
3303 p->integer = integer;
56202
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
3304 p->dogc = 0;
49055
cea2e52c7ca5 (make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 48907
diff changeset
3305 return val;
cea2e52c7ca5 (make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 48907
diff changeset
3306 }
cea2e52c7ca5 (make_save_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 48907
diff changeset
3307
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3308 DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
3309 doc: /* Return a newly allocated marker which does not point at any place. */)
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
3310 ()
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3311 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3312 register Lisp_Object val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3313 register struct Lisp_Marker *p;
638
40b255f55df3 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 624
diff changeset
3314
9437
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
3315 val = allocate_misc ();
11243
054ecfce1820 (Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents: 11048
diff changeset
3316 XMISCTYPE (val) = Lisp_Misc_Marker;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3317 p = XMARKER (val);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3318 p->buffer = 0;
20565
aa9b7c5f0f62 (Fmake_marker): Initialize marker's bytepos and charpos.
Richard M. Stallman <rms@gnu.org>
parents: 20495
diff changeset
3319 p->bytepos = 0;
aa9b7c5f0f62 (Fmake_marker): Initialize marker's bytepos and charpos.
Richard M. Stallman <rms@gnu.org>
parents: 20495
diff changeset
3320 p->charpos = 0;
51668
0f333fd92a1d (survives_gc_p): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51658
diff changeset
3321 p->next = NULL;
13008
f042ef632b22 (Fmake_marker): Initialize insertion_type to 0.
Richard M. Stallman <rms@gnu.org>
parents: 12748
diff changeset
3322 p->insertion_type = 0;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3323 return val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3324 }
19332
58f14958f5d5 (free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents: 18621
diff changeset
3325
58f14958f5d5 (free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents: 18621
diff changeset
3326 /* 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
3327
20375
1dd0bd0749b5 (malloc_warning, display_malloc_warning): Return void.
Andreas Schwab <schwab@suse.de>
parents: 20057
diff changeset
3328 void
19332
58f14958f5d5 (free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents: 18621
diff changeset
3329 free_marker (marker)
58f14958f5d5 (free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents: 18621
diff changeset
3330 Lisp_Object marker;
58f14958f5d5 (free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents: 18621
diff changeset
3331 {
51668
0f333fd92a1d (survives_gc_p): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51658
diff changeset
3332 unchain_marker (XMARKER (marker));
56239
a446552d2240 (allocate_misc): Update total_free_markers.
Kim F. Storm <storm@cua.dk>
parents: 56202
diff changeset
3333 free_misc (marker);
19332
58f14958f5d5 (free_marker): New function.
Richard M. Stallman <rms@gnu.org>
parents: 18621
diff changeset
3334 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3335
21258
693573ac0944 (make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21244
diff changeset
3336
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3337 /* 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
3338 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
3339 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
3340
e2a164ac4088 (Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
3341 Any number of arguments, even zero arguments, are allowed. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3342
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3343 Lisp_Object
2013
e2a164ac4088 (Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
3344 make_event_array (nargs, args)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3345 register int nargs;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3346 Lisp_Object *args;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3347 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3348 int i;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3349
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3350 for (i = 0; i < nargs; i++)
2013
e2a164ac4088 (Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
3351 /* 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
3352 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
3353 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
3354 if (!INTEGERP (args[i])
3536
58d5ee6ec253 (make_event_array): Ignore bits above CHAR_META.
Richard M. Stallman <rms@gnu.org>
parents: 3181
diff changeset
3355 || (XUINT (args[i]) & ~(-CHAR_META)) >= 0200)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3356 return Fvector (nargs, args);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3357
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3358 /* Since the loop exited, we know that all the things in it are
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3359 characters, so we can make a string. */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3360 {
6492
8372dce85f8a (make_event_array): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents: 6227
diff changeset
3361 Lisp_Object result;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3362
18104
b2a669ef69b1 (Fmake_byte_code): Set val from p, not from val.
Richard M. Stallman <rms@gnu.org>
parents: 18010
diff changeset
3363 result = Fmake_string (make_number (nargs), make_number (0));
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3364 for (i = 0; i < nargs; i++)
2013
e2a164ac4088 (Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
3365 {
46418
b12a32662433 * alloc.c (make_event_array): Use SSET for storing into a string.
Ken Raeburn <raeburn@raeburn.org>
parents: 46370
diff changeset
3366 SSET (result, i, XINT (args[i]));
2013
e2a164ac4088 (Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
3367 /* 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
3368 if (XINT (args[i]) & CHAR_META)
46418
b12a32662433 * alloc.c (make_event_array): Use SSET for storing into a string.
Ken Raeburn <raeburn@raeburn.org>
parents: 46370
diff changeset
3369 SSET (result, i, SREF (result, i) | 0x80);
2013
e2a164ac4088 (Fmake_rope, Frope_elt): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
3370 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3371
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3372 return result;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3373 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3374 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
3375
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
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 C Stack Marking
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3380 ************************************************************************/
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3381
32700
25c6c2562e31 (toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents: 32699
diff changeset
3382 #if GC_MARK_STACK || defined GC_MALLOC_CHECK
25c6c2562e31 (toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents: 32699
diff changeset
3383
42403
6643f205d5db Add a comment.
Gerd Moellmann <gerd@gnu.org>
parents: 42096
diff changeset
3384 /* Conservative C stack marking requires a method to identify possibly
6643f205d5db Add a comment.
Gerd Moellmann <gerd@gnu.org>
parents: 42096
diff changeset
3385 live Lisp objects given a pointer value. We do this by keeping
6643f205d5db Add a comment.
Gerd Moellmann <gerd@gnu.org>
parents: 42096
diff changeset
3386 track of blocks of Lisp data that are allocated in a red-black tree
6643f205d5db Add a comment.
Gerd Moellmann <gerd@gnu.org>
parents: 42096
diff changeset
3387 (see also the comment of mem_node which is the type of nodes in
6643f205d5db Add a comment.
Gerd Moellmann <gerd@gnu.org>
parents: 42096
diff changeset
3388 that tree). Function lisp_malloc adds information for an allocated
6643f205d5db Add a comment.
Gerd Moellmann <gerd@gnu.org>
parents: 42096
diff changeset
3389 block to the red-black tree with calls to mem_insert, and function
6643f205d5db Add a comment.
Gerd Moellmann <gerd@gnu.org>
parents: 42096
diff changeset
3390 lisp_free removes it with mem_delete. Functions live_string_p etc
6643f205d5db Add a comment.
Gerd Moellmann <gerd@gnu.org>
parents: 42096
diff changeset
3391 call mem_find to lookup information about a given pointer in the
6643f205d5db Add a comment.
Gerd Moellmann <gerd@gnu.org>
parents: 42096
diff changeset
3392 tree, and use that to determine if the pointer points to a Lisp
6643f205d5db Add a comment.
Gerd Moellmann <gerd@gnu.org>
parents: 42096
diff changeset
3393 object or not. */
6643f205d5db Add a comment.
Gerd Moellmann <gerd@gnu.org>
parents: 42096
diff changeset
3394
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3395 /* 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
3396
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3397 static void
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3398 mem_init ()
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3399 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3400 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
3401 mem_z.parent = NULL;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3402 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
3403 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
3404 mem_root = MEM_NIL;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3405 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3406
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3407
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3408 /* 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
3409 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
3410
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3411 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
3412 mem_find (start)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3413 void *start;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3414 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3415 struct mem_node *p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3416
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
3417 if (start < min_heap_address || start > max_heap_address)
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
3418 return MEM_NIL;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
3419
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3420 /* 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
3421 mem_z.start = start;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3422 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
3423
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3424 p = mem_root;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3425 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
3426 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
3427 return p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3428 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3429
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3430
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3431 /* 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
3432 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
3433 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
3434
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3435 static struct mem_node *
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3436 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
3437 void *start, *end;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3438 enum mem_type type;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3439 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3440 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
3441
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
3442 if (start < min_heap_address)
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
3443 min_heap_address = start;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
3444 if (end > max_heap_address)
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
3445 max_heap_address = end;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
3446
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3447 /* 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
3448 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
3449 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
3450 c = mem_root;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3451 parent = NULL;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3452
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3453 #if GC_MARK_STACK != GC_MAKE_GCPROS_NOOPS
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3454
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3455 while (c != MEM_NIL)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3456 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3457 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
3458 abort ();
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3459 parent = c;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3460 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
3461 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3462
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3463 #else /* GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3464
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3465 while (c != MEM_NIL)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3466 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3467 parent = c;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3468 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
3469 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3470
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3471 #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
3472
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3473 /* Create a new node. */
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
3474 #ifdef GC_MALLOC_CHECK
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
3475 x = (struct mem_node *) _malloc_internal (sizeof *x);
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
3476 if (x == NULL)
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
3477 abort ();
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
3478 #else
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3479 x = (struct mem_node *) xmalloc (sizeof *x);
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
3480 #endif
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3481 x->start = start;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3482 x->end = end;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3483 x->type = type;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3484 x->parent = parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3485 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
3486 x->color = MEM_RED;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3487
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3488 /* 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
3489 if (parent)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3490 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3491 if (start < parent->start)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3492 parent->left = x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3493 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3494 parent->right = x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3495 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3496 else
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3497 mem_root = x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3498
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3499 /* 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
3500 mem_insert_fixup (x);
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
3501
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3502 return x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3503 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3504
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3505
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3506 /* 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
3507 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
3508
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3509 static void
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3510 mem_insert_fixup (x)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3511 struct mem_node *x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3512 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3513 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
3514 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3515 /* 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
3516 red-black tree property #3. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3517
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3518 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
3519 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3520 /* 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
3521 "uncle". */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3522 struct mem_node *y = x->parent->parent->right;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3523
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3524 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
3525 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3526 /* 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
3527 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
3528 with the grandparent. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3529 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
3530 y->color = MEM_BLACK;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3531 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
3532 x = x->parent->parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3533 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3534 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3535 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3536 /* 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
3537 red, uncle is black. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3538 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
3539 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3540 x = x->parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3541 mem_rotate_left (x);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3542 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3543
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3544 x->parent->color = MEM_BLACK;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3545 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
3546 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
3547 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3548 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3549 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3550 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3551 /* 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
3552 struct mem_node *y = x->parent->parent->left;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3553
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3554 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
3555 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3556 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
3557 y->color = MEM_BLACK;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3558 x->parent->parent->color = MEM_RED;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3559 x = x->parent->parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3560 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3561 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3562 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3563 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
3564 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3565 x = x->parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3566 mem_rotate_right (x);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3567 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3568
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3569 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
3570 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
3571 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
3572 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3573 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3574 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3575
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3576 /* 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
3577 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
3578 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
3579 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3580
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3581
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3582 /* (x) (y)
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3583 / \ / \
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3584 a (y) ===> (x) c
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3585 / \ / \
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3586 b c a b */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3587
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3588 static void
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3589 mem_rotate_left (x)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3590 struct mem_node *x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3591 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3592 struct mem_node *y;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3593
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3594 /* 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
3595 y = x->right;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3596 x->right = y->left;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3597 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
3598 y->left->parent = x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3599
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3600 /* 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
3601 if (y != MEM_NIL)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3602 y->parent = x->parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3603
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3604 /* 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
3605 if (x->parent)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3606 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3607 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
3608 x->parent->left = y;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3609 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3610 x->parent->right = y;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3611 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3612 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3613 mem_root = y;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3614
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3615 /* 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
3616 y->left = x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3617 if (x != MEM_NIL)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3618 x->parent = y;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3619 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3620
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3621
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3622 /* (x) (Y)
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3623 / \ / \
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3624 (y) c ===> a (x)
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3625 / \ / \
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3626 a b b c */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3627
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3628 static void
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3629 mem_rotate_right (x)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3630 struct mem_node *x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3631 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3632 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
3633
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3634 x->left = y->right;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3635 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
3636 y->right->parent = x;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3637
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3638 if (y != MEM_NIL)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3639 y->parent = x->parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3640 if (x->parent)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3641 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3642 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
3643 x->parent->right = y;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3644 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3645 x->parent->left = y;
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 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3648 mem_root = y;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3649
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3650 y->right = x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3651 if (x != MEM_NIL)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3652 x->parent = y;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3653 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3654
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3655
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3656 /* 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
3657
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3658 static void
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3659 mem_delete (z)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3660 struct mem_node *z;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3661 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3662 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
3663
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3664 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
3665 return;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3666
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3667 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
3668 y = z;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3669 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3670 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3671 y = z->right;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3672 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
3673 y = y->left;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3674 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3675
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3676 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
3677 x = y->left;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3678 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3679 x = y->right;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3680
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3681 x->parent = y->parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3682 if (y->parent)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3683 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3684 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
3685 y->parent->left = x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3686 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3687 y->parent->right = x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3688 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3689 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3690 mem_root = x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3691
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3692 if (y != z)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3693 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3694 z->start = y->start;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3695 z->end = y->end;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3696 z->type = y->type;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3697 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3698
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3699 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
3700 mem_delete_fixup (x);
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
3701
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
3702 #ifdef GC_MALLOC_CHECK
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
3703 _free_internal (y);
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
3704 #else
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3705 xfree (y);
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
3706 #endif
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3707 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3708
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3709
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3710 /* 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
3711 deletion. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3712
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3713 static void
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3714 mem_delete_fixup (x)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3715 struct mem_node *x;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3716 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3717 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
3718 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3719 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
3720 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3721 struct mem_node *w = x->parent->right;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3722
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3723 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
3724 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3725 w->color = MEM_BLACK;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3726 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
3727 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
3728 w = x->parent->right;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3729 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3730
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3731 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
3732 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3733 w->color = MEM_RED;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3734 x = x->parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3735 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3736 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3737 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3738 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
3739 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3740 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
3741 w->color = MEM_RED;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3742 mem_rotate_right (w);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3743 w = x->parent->right;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3744 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3745 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
3746 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
3747 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
3748 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
3749 x = mem_root;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3750 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3751 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3752 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3753 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3754 struct mem_node *w = x->parent->left;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3755
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3756 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
3757 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3758 w->color = MEM_BLACK;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3759 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
3760 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
3761 w = x->parent->left;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3762 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3763
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3764 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
3765 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3766 w->color = MEM_RED;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3767 x = x->parent;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3768 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3769 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3770 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3771 if (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
3772 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3773 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
3774 w->color = MEM_RED;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3775 mem_rotate_left (w);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3776 w = x->parent->left;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3777 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3778
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3779 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
3780 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
3781 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
3782 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
3783 x = mem_root;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3784 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3785 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3786 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3787
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3788 x->color = MEM_BLACK;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3789 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3790
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3791
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3792 /* 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
3793 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
3794
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3795 static INLINE int
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3796 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
3797 struct mem_node *m;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3798 void *p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3799 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3800 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
3801 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3802 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
3803 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
3804
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3805 /* 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
3806 must not be on the free-list. */
37049
184d1fb71cc1 (live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents: 36487
diff changeset
3807 return (offset >= 0
184d1fb71cc1 (live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents: 36487
diff changeset
3808 && offset % sizeof b->strings[0] == 0
53582
b4eef5adebbf (struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53555
diff changeset
3809 && offset < (STRING_BLOCK_SIZE * sizeof b->strings[0])
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3810 && ((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
3811 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3812 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3813 return 0;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3814 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3815
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3816
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3817 /* 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
3818 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
3819
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3820 static INLINE int
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3821 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
3822 struct mem_node *m;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3823 void *p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3824 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3825 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
3826 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3827 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
3828 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
3829
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3830 /* 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
3831 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
3832 and not be on the free-list. */
37049
184d1fb71cc1 (live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents: 36487
diff changeset
3833 return (offset >= 0
53582
b4eef5adebbf (struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53555
diff changeset
3834 && offset % sizeof b->conses[0] == 0
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
3835 && offset < (CONS_BLOCK_SIZE * sizeof b->conses[0])
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3836 && (b != cons_block
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3837 || 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
3838 && !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
3839 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3840 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3841 return 0;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3842 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3843
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3844
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3845 /* 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
3846 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
3847
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3848 static INLINE int
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3849 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
3850 struct mem_node *m;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3851 void *p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3852 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3853 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
3854 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3855 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
3856 int offset = (char *) p - (char *) &b->symbols[0];
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3857
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3858 /* 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
3859 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
3860 and not be on the free-list. */
37049
184d1fb71cc1 (live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents: 36487
diff changeset
3861 return (offset >= 0
184d1fb71cc1 (live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents: 36487
diff changeset
3862 && offset % sizeof b->symbols[0] == 0
53582
b4eef5adebbf (struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53555
diff changeset
3863 && offset < (SYMBOL_BLOCK_SIZE * sizeof b->symbols[0])
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3864 && (b != symbol_block
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3865 || 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
3866 && !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
3867 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3868 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3869 return 0;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3870 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3871
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3872
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3873 /* 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
3874 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
3875
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3876 static INLINE int
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3877 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
3878 struct mem_node *m;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3879 void *p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3880 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3881 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
3882 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3883 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
3884 int offset = (char *) p - (char *) &b->floats[0];
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3885
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
3886 /* P must point to the start of a Lisp_Float and not be
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
3887 one of the unused cells in the current float block. */
37049
184d1fb71cc1 (live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents: 36487
diff changeset
3888 return (offset >= 0
53582
b4eef5adebbf (struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53555
diff changeset
3889 && offset % sizeof b->floats[0] == 0
51779
f01acdb936f9 (live_float_p): Check that p is not past the `floats' array,
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51770
diff changeset
3890 && offset < (FLOAT_BLOCK_SIZE * sizeof b->floats[0])
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3891 && (b != float_block
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
3892 || offset / sizeof b->floats[0] < float_block_index));
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3893 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3894 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3895 return 0;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3896 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3897
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3898
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3899 /* 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
3900 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
3901
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3902 static INLINE int
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3903 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
3904 struct mem_node *m;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3905 void *p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3906 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3907 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
3908 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3909 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
3910 int offset = (char *) p - (char *) &b->markers[0];
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
3911
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3912 /* 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
3913 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
3914 and not be on the free-list. */
37049
184d1fb71cc1 (live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents: 36487
diff changeset
3915 return (offset >= 0
184d1fb71cc1 (live_string_p, live_cons_p, live_symbol_p)
Gerd Moellmann <gerd@gnu.org>
parents: 36487
diff changeset
3916 && offset % sizeof b->markers[0] == 0
53582
b4eef5adebbf (struct interval_block, struct string_block)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53555
diff changeset
3917 && offset < (MARKER_BLOCK_SIZE * sizeof b->markers[0])
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3918 && (b != marker_block
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3919 || 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
3920 && ((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
3921 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3922 else
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3923 return 0;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3924 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3925
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3926
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3927 /* 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
3928 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
3929
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3930 static INLINE int
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3931 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
3932 struct mem_node *m;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3933 void *p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3934 {
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
3935 return (p == m->start
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
3936 && m->type >= MEM_TYPE_VECTOR
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
3937 && m->type <= MEM_TYPE_WINDOW);
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3938 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3939
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3940
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
3941 /* Value is non-zero if P is a pointer to a live buffer. M is a
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3942 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
3943
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3944 static INLINE int
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3945 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
3946 struct mem_node *m;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3947 void *p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3948 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3949 /* 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
3950 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
3951 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
3952 && p == m->start
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3953 && !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
3954 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3955
32700
25c6c2562e31 (toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents: 32699
diff changeset
3956 #endif /* GC_MARK_STACK || defined GC_MALLOC_CHECK */
25c6c2562e31 (toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents: 32699
diff changeset
3957
25c6c2562e31 (toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents: 32699
diff changeset
3958 #if GC_MARK_STACK
25c6c2562e31 (toplevel): Conditionalize compilation of mem_*
Gerd Moellmann <gerd@gnu.org>
parents: 32699
diff changeset
3959
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3960 #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
3961
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3962 /* 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
3963 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
3964
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3965 #define MAX_ZOMBIES 10
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3966 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
3967
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3968 /* Number of zombie objects. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3969
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3970 static int nzombies;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3971
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3972 /* Number of garbage collections. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3973
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3974 static int ngcs;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3975
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3976 /* 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
3977
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3978 static double avg_zombies;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3979
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3980 /* 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
3981
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3982 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
3983
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3984 /* 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
3985
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3986 static double avg_live;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3987
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3988 DEFUN ("gc-status", Fgc_status, Sgc_status, 0, 0, "",
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
3989 doc: /* Show information about live and zombie objects. */)
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
3990 ()
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3991 {
49357
90e4c5eeb9a0 (Fgc_status): Print zombie list.
Dave Love <fx@gnu.org>
parents: 49322
diff changeset
3992 Lisp_Object args[8], zombie_list = Qnil;
90e4c5eeb9a0 (Fgc_status): Print zombie list.
Dave Love <fx@gnu.org>
parents: 49322
diff changeset
3993 int i;
90e4c5eeb9a0 (Fgc_status): Print zombie list.
Dave Love <fx@gnu.org>
parents: 49322
diff changeset
3994 for (i = 0; i < nzombies; i++)
90e4c5eeb9a0 (Fgc_status): Print zombie list.
Dave Love <fx@gnu.org>
parents: 49322
diff changeset
3995 zombie_list = Fcons (zombies[i], zombie_list);
90e4c5eeb9a0 (Fgc_status): Print zombie list.
Dave Love <fx@gnu.org>
parents: 49322
diff changeset
3996 args[0] = build_string ("%d GCs, avg live/zombies = %.2f/%.2f (%f%%), max %d/%d\nzombies: %S");
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
3997 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
3998 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
3999 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
4000 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
4001 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
4002 args[6] = make_number (max_zombies);
49357
90e4c5eeb9a0 (Fgc_status): Print zombie list.
Dave Love <fx@gnu.org>
parents: 49322
diff changeset
4003 args[7] = zombie_list;
90e4c5eeb9a0 (Fgc_status): Print zombie list.
Dave Love <fx@gnu.org>
parents: 49322
diff changeset
4004 return Fmessage (8, args);
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4005 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4006
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4007 #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
4008
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4009
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4010 /* 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
4011
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4012 static INLINE void
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4013 mark_maybe_object (obj)
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4014 Lisp_Object obj;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4015 {
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4016 void *po = (void *) XPNTR (obj);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4017 struct mem_node *m = mem_find (po);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
4018
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4019 if (m != MEM_NIL)
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4020 {
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4021 int mark_p = 0;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4022
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4023 switch (XGCTYPE (obj))
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4024 {
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4025 case Lisp_String:
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4026 mark_p = (live_string_p (m, po)
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4027 && !STRING_MARKED_P ((struct Lisp_String *) po));
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4028 break;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4029
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4030 case Lisp_Cons:
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
4031 mark_p = (live_cons_p (m, po) && !CONS_MARKED_P (XCONS (obj)));
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4032 break;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4033
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4034 case Lisp_Symbol:
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
4035 mark_p = (live_symbol_p (m, po) && !XSYMBOL (obj)->gcmarkbit);
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4036 break;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4037
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4038 case Lisp_Float:
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
4039 mark_p = (live_float_p (m, po) && !FLOAT_MARKED_P (XFLOAT (obj)));
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4040 break;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4041
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4042 case Lisp_Vectorlike:
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4043 /* 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
4044 buffer because checking that dereferences the pointer
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4045 PO which might point anywhere. */
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4046 if (live_vector_p (m, po))
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
4047 mark_p = !GC_SUBRP (obj) && !VECTOR_MARKED_P (XVECTOR (obj));
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4048 else if (live_buffer_p (m, po))
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
4049 mark_p = GC_BUFFERP (obj) && !VECTOR_MARKED_P (XBUFFER (obj));
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4050 break;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4051
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4052 case Lisp_Misc:
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
4053 mark_p = (live_misc_p (m, po) && !XMARKER (obj)->gcmarkbit);
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4054 break;
31829
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31576
diff changeset
4055
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31576
diff changeset
4056 case Lisp_Int:
31897
a292cc13911a (GC_CHECK_STRING_BYTES): Temporarily define, for bug
Gerd Moellmann <gerd@gnu.org>
parents: 31892
diff changeset
4057 case Lisp_Type_Limit:
31829
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31576
diff changeset
4058 break;
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4059 }
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4060
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4061 if (mark_p)
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4062 {
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4063 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4064 if (nzombies < MAX_ZOMBIES)
49357
90e4c5eeb9a0 (Fgc_status): Print zombie list.
Dave Love <fx@gnu.org>
parents: 49322
diff changeset
4065 zombies[nzombies] = obj;
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4066 ++nzombies;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4067 #endif
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
4068 mark_object (obj);
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4069 }
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4070 }
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4071 }
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4072
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4073
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4074 /* If P points to Lisp data, mark that as live if it isn't already
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4075 marked. */
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4076
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4077 static INLINE void
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4078 mark_maybe_pointer (p)
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4079 void *p;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4080 {
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4081 struct mem_node *m;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4082
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4083 /* Quickly rule out some values which can't point to Lisp data. We
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4084 assume that Lisp data is aligned on even addresses. */
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4085 if ((EMACS_INT) p & 1)
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4086 return;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
4087
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4088 m = mem_find (p);
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4089 if (m != MEM_NIL)
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4090 {
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4091 Lisp_Object obj = Qnil;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
4092
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4093 switch (m->type)
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4094 {
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4095 case MEM_TYPE_NON_LISP:
36487
4df2ac60690e (mark_maybe_pointer): Fix a typo in a comment.
Eli Zaretskii <eliz@gnu.org>
parents: 36435
diff changeset
4096 /* Nothing to do; not a pointer to Lisp memory. */
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4097 break;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
4098
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4099 case MEM_TYPE_BUFFER:
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
4100 if (live_buffer_p (m, p) && !VECTOR_MARKED_P((struct buffer *)p))
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4101 XSETVECTOR (obj, p);
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4102 break;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
4103
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4104 case MEM_TYPE_CONS:
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
4105 if (live_cons_p (m, p) && !CONS_MARKED_P ((struct Lisp_Cons *) p))
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4106 XSETCONS (obj, p);
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4107 break;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
4108
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4109 case MEM_TYPE_STRING:
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4110 if (live_string_p (m, p)
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4111 && !STRING_MARKED_P ((struct Lisp_String *) p))
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4112 XSETSTRING (obj, p);
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4113 break;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4114
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4115 case MEM_TYPE_MISC:
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
4116 if (live_misc_p (m, p) && !((struct Lisp_Free *) p)->gcmarkbit)
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
4117 XSETMISC (obj, p);
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4118 break;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
4119
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4120 case MEM_TYPE_SYMBOL:
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
4121 if (live_symbol_p (m, p) && !((struct Lisp_Symbol *) p)->gcmarkbit)
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4122 XSETSYMBOL (obj, p);
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4123 break;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
4124
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4125 case MEM_TYPE_FLOAT:
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
4126 if (live_float_p (m, p) && !FLOAT_MARKED_P (p))
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4127 XSETFLOAT (obj, p);
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4128 break;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
4129
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4130 case MEM_TYPE_VECTOR:
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4131 case MEM_TYPE_PROCESS:
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4132 case MEM_TYPE_HASH_TABLE:
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4133 case MEM_TYPE_FRAME:
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4134 case MEM_TYPE_WINDOW:
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4135 if (live_vector_p (m, p))
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4136 {
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4137 Lisp_Object tem;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4138 XSETVECTOR (tem, p);
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
4139 if (!GC_SUBRP (tem) && !VECTOR_MARKED_P (XVECTOR (tem)))
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4140 obj = tem;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4141 }
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4142 break;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4143
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4144 default:
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4145 abort ();
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4146 }
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4147
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4148 if (!GC_NILP (obj))
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
4149 mark_object (obj);
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4150 }
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4151 }
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4152
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4153
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4154 /* Mark Lisp objects referenced from the address range START..END. */
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4155
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
4156 static void
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4157 mark_memory (start, end)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4158 void *start, *end;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4159 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4160 Lisp_Object *p;
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4161 void **pp;
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4162
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4163 #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
4164 nzombies = 0;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4165 #endif
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4166
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4167 /* 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
4168 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
4169 if (end < start)
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4170 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4171 void *tem = start;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4172 start = end;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4173 end = tem;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4174 }
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4175
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4176 /* Mark Lisp_Objects. */
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4177 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
4178 mark_maybe_object (*p);
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4179
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4180 /* Mark Lisp data pointed to. This is necessary because, in some
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4181 situations, the C compiler optimizes Lisp objects away, so that
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4182 only a pointer to them remains. Example:
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4183
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4184 DEFUN ("testme", Ftestme, Stestme, 0, 0, 0, "")
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
4185 ()
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4186 {
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4187 Lisp_Object obj = build_string ("test");
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4188 struct Lisp_String *s = XSTRING (obj);
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4189 Fgarbage_collect ();
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4190 fprintf (stderr, "test `%s'\n", s->data);
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4191 return Qnil;
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4192 }
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4193
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4194 Here, `obj' isn't really used, and the compiler optimizes it
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4195 away. The only reference to the life string is through the
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4196 pointer `s'. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
4197
36435
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4198 for (pp = (void **) start; (void *) pp < end; ++pp)
5a989d353a68 (toplevel): Include process.h.
Gerd Moellmann <gerd@gnu.org>
parents: 35762
diff changeset
4199 mark_maybe_pointer (*pp);
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4200 }
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4201
48316
043dddbc037a (SETJMP_WILL_NOT_WORK): Add note.
Dave Love <fx@gnu.org>
parents: 47391
diff changeset
4202 /* setjmp will work with GCC unless NON_SAVING_SETJMP is defined in
043dddbc037a (SETJMP_WILL_NOT_WORK): Add note.
Dave Love <fx@gnu.org>
parents: 47391
diff changeset
4203 the GCC system configuration. In gcc 3.2, the only systems for
043dddbc037a (SETJMP_WILL_NOT_WORK): Add note.
Dave Love <fx@gnu.org>
parents: 47391
diff changeset
4204 which this is so are i386-sco5 non-ELF, i386-sysv3 (maybe included
043dddbc037a (SETJMP_WILL_NOT_WORK): Add note.
Dave Love <fx@gnu.org>
parents: 47391
diff changeset
4205 by others?) and ns32k-pc532-min. */
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4206
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4207 #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
4208
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4209 static int setjmp_tested_p, longjmps_done;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4210
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4211 #define SETJMP_WILL_LIKELY_WORK "\
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4212 \n\
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4213 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
4214 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
4215 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
4216 \n\
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4217 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
4218 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
4219 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
4220 \n\
43200
4082674ce69b (SETJMP_WILL_LIKELY_WORK, SETJMP_WILL_NOT_WORK):
Kim F. Storm <storm@cua.dk>
parents: 43161
diff changeset
4221 Please mail the result to <emacs-devel@gnu.org>.\n\
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4222 "
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4223
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4224 #define SETJMP_WILL_NOT_WORK "\
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4225 \n\
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4226 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
4227 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
4228 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
4229 solution for your system.\n\
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4230 \n\
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4231 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
4232 try to find a way to make it work on your system.\n\
48316
043dddbc037a (SETJMP_WILL_NOT_WORK): Add note.
Dave Love <fx@gnu.org>
parents: 47391
diff changeset
4233 \n\
043dddbc037a (SETJMP_WILL_NOT_WORK): Add note.
Dave Love <fx@gnu.org>
parents: 47391
diff changeset
4234 Note that you may get false negatives, depending on the compiler.\n\
043dddbc037a (SETJMP_WILL_NOT_WORK): Add note.
Dave Love <fx@gnu.org>
parents: 47391
diff changeset
4235 In particular, you need to use -O with GCC for this test.\n\
043dddbc037a (SETJMP_WILL_NOT_WORK): Add note.
Dave Love <fx@gnu.org>
parents: 47391
diff changeset
4236 \n\
43200
4082674ce69b (SETJMP_WILL_LIKELY_WORK, SETJMP_WILL_NOT_WORK):
Kim F. Storm <storm@cua.dk>
parents: 43161
diff changeset
4237 Please mail the result to <emacs-devel@gnu.org>.\n\
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4238 "
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4239
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4240
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4241 /* 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
4242 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
4243 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
4244 conservative stack marking. Only the sources or a disassembly
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4245 can prove that. */
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4246
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4247 static void
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4248 test_setjmp ()
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4249 {
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4250 char buf[10];
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4251 register int x;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4252 jmp_buf jbuf;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4253 int result = 0;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4254
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4255 /* Arrange for X to be put in a register. */
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4256 sprintf (buf, "1");
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4257 x = strlen (buf);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4258 x = 2 * x - 1;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4259
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4260 setjmp (jbuf);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4261 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
4262 {
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4263 /* 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
4264
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4265 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
4266 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
4267 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
4268 isn't sure.
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4269
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4270 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
4271 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
4272
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4273 if (x == 1)
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4274 fprintf (stderr, SETJMP_WILL_LIKELY_WORK);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4275 else
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4276 {
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4277 fprintf (stderr, SETJMP_WILL_NOT_WORK);
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4278 exit (1);
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4279 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4280 }
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4281
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4282 ++longjmps_done;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4283 x = 2;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4284 if (longjmps_done == 1)
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4285 longjmp (jbuf, 1);
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4286 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4287
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4288 #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
4289
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4290
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4291 #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
4292
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4293 /* 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
4294
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4295 static void
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4296 check_gcpros ()
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4297 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4298 struct gcpro *p;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4299 int i;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4300
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4301 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
4302 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
4303 if (!survives_gc_p (p->var[i]))
50626
a5a77c7717cb (Fmake_byte_code): Improve the `usage' string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50468
diff changeset
4304 /* FIXME: It's not necessarily a bug. It might just be that the
a5a77c7717cb (Fmake_byte_code): Improve the `usage' string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50468
diff changeset
4305 GCPRO is unnecessary or should release the object sooner. */
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4306 abort ();
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4307 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4308
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4309 #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
4310
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4311 static void
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4312 dump_zombies ()
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4313 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4314 int i;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4315
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4316 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
4317 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
4318 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4319 fprintf (stderr, " %d = ", i);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4320 debug_print (zombies[i]);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4321 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4322 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4323
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4324 #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
4325
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4326
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4327 /* Mark live Lisp objects on the C stack.
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4328
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4329 There are several system-dependent problems to consider when
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4330 porting this to new architectures:
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4331
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4332 Processor Registers
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4333
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4334 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
4335 variables or are used to pass parameters.
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4336
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4337 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
4338 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
4339 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
4340
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4341 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
4342 implementation assumes that calling setjmp saves registers we need
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4343 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
4344 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
4345 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
4346
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4347 Stack Layout
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4348
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4349 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
4350 For example, the stack might look like this
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4351
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4352 +----------------+
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4353 | Lisp_Object | size = 4
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4354 +----------------+
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4355 | something else | size = 2
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4356 +----------------+
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4357 | Lisp_Object | size = 4
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4358 +----------------+
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4359 | ... |
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4360
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4361 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
4362 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
4363 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
4364 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
4365 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
4366 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
4367 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
4368 from the stack start.
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4369
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4370 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
4371 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
4372
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4373 static void
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4374 mark_stack ()
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4375 {
43160
630c8b6deafd (mark_stack): Don't assume sizeof (Lisp_Object) is 4.
Andreas Schwab <schwab@suse.de>
parents: 43005
diff changeset
4376 int i;
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4377 jmp_buf j;
31829
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31576
diff changeset
4378 volatile int stack_grows_down_p = (char *) &j > (char *) stack_base;
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4379 void *end;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4380
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4381 /* 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
4382 the process is contained in the stack. */
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
4383 /* Fixme: Code in the Boehm GC suggests flushing (with `flushrs') is
49414
668c96afa702 (mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents: 49357
diff changeset
4384 needed on ia64 too. See mach_dep.c, where it also says inline
668c96afa702 (mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents: 49357
diff changeset
4385 assembler doesn't work with relevant proprietary compilers. */
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4386 #ifdef sparc
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4387 asm ("ta 3");
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4388 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
4389
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4390 /* 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
4391 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
4392 pass parameters. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4393 #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
4394 GC_SAVE_REGISTERS_ON_STACK (end);
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4395 #else /* not GC_SAVE_REGISTERS_ON_STACK */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
4396
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4397 #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
4398 setjmp will definitely work, test it
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4399 and print a message with the result
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4400 of the test. */
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4401 if (!setjmp_tested_p)
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4402 {
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4403 setjmp_tested_p = 1;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4404 test_setjmp ();
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4405 }
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4406 #endif /* GC_SETJMP_WORKS */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
4407
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4408 setjmp (j);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4409 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
4410 #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
4411
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4412 /* 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
4413 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
4414 over the stack segments. */
43160
630c8b6deafd (mark_stack): Don't assume sizeof (Lisp_Object) is 4.
Andreas Schwab <schwab@suse.de>
parents: 43005
diff changeset
4415 #ifndef GC_LISP_OBJECT_ALIGNMENT
49414
668c96afa702 (mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents: 49357
diff changeset
4416 #ifdef __GNUC__
668c96afa702 (mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents: 49357
diff changeset
4417 #define GC_LISP_OBJECT_ALIGNMENT __alignof__ (Lisp_Object)
668c96afa702 (mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents: 49357
diff changeset
4418 #else
43160
630c8b6deafd (mark_stack): Don't assume sizeof (Lisp_Object) is 4.
Andreas Schwab <schwab@suse.de>
parents: 43005
diff changeset
4419 #define GC_LISP_OBJECT_ALIGNMENT sizeof (Lisp_Object)
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
4420 #endif
49414
668c96afa702 (mark_stack) [!GC_LISP_OBJECT_ALIGNMENT && __GNUC__]:
Dave Love <fx@gnu.org>
parents: 49357
diff changeset
4421 #endif
43161
8a549ab185a2 Fix thinko in last change.
Andreas Schwab <schwab@suse.de>
parents: 43160
diff changeset
4422 for (i = 0; i < sizeof (Lisp_Object); i += GC_LISP_OBJECT_ALIGNMENT)
43160
630c8b6deafd (mark_stack): Don't assume sizeof (Lisp_Object) is 4.
Andreas Schwab <schwab@suse.de>
parents: 43005
diff changeset
4423 mark_memory ((char *) stack_base + i, end);
58593
ff0c144203a1 (mark_stack): Call GC_MARK_SECONDARY_STACK if defined.
Andreas Schwab <schwab@suse.de>
parents: 57137
diff changeset
4424 /* Allow for marking a secondary stack, like the register stack on the
ff0c144203a1 (mark_stack): Call GC_MARK_SECONDARY_STACK if defined.
Andreas Schwab <schwab@suse.de>
parents: 57137
diff changeset
4425 ia64. */
ff0c144203a1 (mark_stack): Call GC_MARK_SECONDARY_STACK if defined.
Andreas Schwab <schwab@suse.de>
parents: 57137
diff changeset
4426 #ifdef GC_MARK_SECONDARY_STACK
ff0c144203a1 (mark_stack): Call GC_MARK_SECONDARY_STACK if defined.
Andreas Schwab <schwab@suse.de>
parents: 57137
diff changeset
4427 GC_MARK_SECONDARY_STACK ();
ff0c144203a1 (mark_stack): Call GC_MARK_SECONDARY_STACK if defined.
Andreas Schwab <schwab@suse.de>
parents: 57137
diff changeset
4428 #endif
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4429
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4430 #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
4431 check_gcpros ();
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4432 #endif
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4433 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4434
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4435
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4436 #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
4437
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4438
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4439
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4440 /***********************************************************************
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4441 Pure Storage Management
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4442 ***********************************************************************/
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4443
32594
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4444 /* Allocate room for SIZE bytes from pure Lisp storage and return a
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4445 pointer to it. TYPE is the Lisp type for which the memory is
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4446 allocated. TYPE < 0 means it's not used for a Lisp object.
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4447
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4448 If store_pure_type_info is set and TYPE is >= 0, the type of
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4449 the allocated object is recorded in pure_types. */
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4450
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4451 static POINTER_TYPE *
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4452 pure_alloc (size, type)
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4453 size_t size;
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4454 int type;
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4455 {
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4456 POINTER_TYPE *result;
53650
5558449888ec (lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53582
diff changeset
4457 #ifdef USE_LSB_TAG
5558449888ec (lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53582
diff changeset
4458 size_t alignment = (1 << GCTYPEBITS);
5558449888ec (lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53582
diff changeset
4459 #else
49159
bc82a79251b5 (pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents: 49158
diff changeset
4460 size_t alignment = sizeof (EMACS_INT);
32594
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4461
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4462 /* Give Lisp_Floats an extra alignment. */
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4463 if (type == Lisp_Float)
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4464 {
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4465 #if defined __GNUC__ && __GNUC__ >= 2
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4466 alignment = __alignof (struct Lisp_Float);
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4467 #else
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4468 alignment = sizeof (struct Lisp_Float);
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4469 #endif
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4470 }
53650
5558449888ec (lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]:
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53582
diff changeset
4471 #endif
49159
bc82a79251b5 (pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents: 49158
diff changeset
4472
bc82a79251b5 (pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents: 49158
diff changeset
4473 again:
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
4474 result = ALIGN (purebeg + pure_bytes_used, alignment);
49159
bc82a79251b5 (pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents: 49158
diff changeset
4475 pure_bytes_used = ((char *)result - (char *)purebeg) + size;
bc82a79251b5 (pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents: 49158
diff changeset
4476
bc82a79251b5 (pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents: 49158
diff changeset
4477 if (pure_bytes_used <= pure_size)
bc82a79251b5 (pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents: 49158
diff changeset
4478 return result;
bc82a79251b5 (pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents: 49158
diff changeset
4479
bc82a79251b5 (pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents: 49158
diff changeset
4480 /* Don't allocate a large amount here,
bc82a79251b5 (pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents: 49158
diff changeset
4481 because it might get mmap'd and then its address
bc82a79251b5 (pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents: 49158
diff changeset
4482 might not be usable. */
bc82a79251b5 (pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents: 49158
diff changeset
4483 purebeg = (char *) xmalloc (10000);
bc82a79251b5 (pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents: 49158
diff changeset
4484 pure_size = 10000;
bc82a79251b5 (pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents: 49158
diff changeset
4485 pure_bytes_used_before_overflow += pure_bytes_used - size;
bc82a79251b5 (pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents: 49158
diff changeset
4486 pure_bytes_used = 0;
bc82a79251b5 (pure_alloc): Rewritten and simplified.
Kim F. Storm <storm@cua.dk>
parents: 49158
diff changeset
4487 goto again;
32594
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4488 }
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4489
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4490
44149
a3e6cfa20afd (check_pure_size): Update the comment.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44100
diff changeset
4491 /* Print a warning if PURESIZE is too small. */
39572
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
4492
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
4493 void
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
4494 check_pure_size ()
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
4495 {
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
4496 if (pure_bytes_used_before_overflow)
44100
57e965380c39 (check_pure_size): Only output a warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43751
diff changeset
4497 message ("Pure Lisp storage overflow (approx. %d bytes needed)",
57e965380c39 (check_pure_size): Only output a warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43751
diff changeset
4498 (int) (pure_bytes_used + pure_bytes_used_before_overflow));
39572
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
4499 }
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
4500
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
4501
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4502 /* 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
4503 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
4504 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
4505
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4506 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
4507 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
4508 string; then the string is not protected from gc. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4509
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4510 Lisp_Object
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4511 make_pure_string (data, nchars, nbytes, multibyte)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4512 char *data;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4513 int nchars, nbytes;
21258
693573ac0944 (make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21244
diff changeset
4514 int multibyte;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4515 {
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4516 Lisp_Object string;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4517 struct Lisp_String *s;
32594
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4518
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4519 s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String);
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4520 s->data = (unsigned char *) pure_alloc (nbytes + 1, -1);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4521 s->size = nchars;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4522 s->size_byte = multibyte ? nbytes : -1;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4523 bcopy (data, s->data, nbytes);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4524 s->data[nbytes] = '\0';
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4525 s->intervals = NULL_INTERVAL;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4526 XSETSTRING (string, s);
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4527 return string;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4528 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4529
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4530
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4531 /* 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
4532 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
4533
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4534 Lisp_Object
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4535 pure_cons (car, cdr)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4536 Lisp_Object car, cdr;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4537 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4538 register Lisp_Object new;
32594
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4539 struct Lisp_Cons *p;
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4540
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4541 p = (struct Lisp_Cons *) pure_alloc (sizeof *p, Lisp_Cons);
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4542 XSETCONS (new, p);
39973
579177964efa Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents: 39914
diff changeset
4543 XSETCAR (new, Fpurecopy (car));
579177964efa Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents: 39914
diff changeset
4544 XSETCDR (new, Fpurecopy (cdr));
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4545 return new;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4546 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4547
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4548
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4549 /* 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
4550
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4551 Lisp_Object
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4552 make_pure_float (num)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4553 double num;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4554 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4555 register Lisp_Object new;
32594
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4556 struct Lisp_Float *p;
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4557
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4558 p = (struct Lisp_Float *) pure_alloc (sizeof *p, Lisp_Float);
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4559 XSETFLOAT (new, p);
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
4560 XFLOAT_DATA (new) = num;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4561 return new;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4562 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4563
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4564
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4565 /* 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
4566 pure space. */
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4567
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4568 Lisp_Object
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4569 make_pure_vector (len)
8817
48ff00bebef6 (pure, pure_size): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents: 7307
diff changeset
4570 EMACS_INT len;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4571 {
32594
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4572 Lisp_Object new;
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4573 struct Lisp_Vector *p;
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4574 size_t size = sizeof *p + (len - 1) * sizeof (Lisp_Object);
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4575
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4576 p = (struct Lisp_Vector *) pure_alloc (size, Lisp_Vectorlike);
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4577 XSETVECTOR (new, p);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4578 XVECTOR (new)->size = len;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4579 return new;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4580 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4581
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4582
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4583 DEFUN ("purecopy", Fpurecopy, Spurecopy, 1, 1, 0,
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
4584 doc: /* Make a copy of OBJECT in pure storage.
39914
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
4585 Recursively copies contents of vectors and cons cells.
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
4586 Does not copy symbols. Copies strings without text properties. */)
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
4587 (obj)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4588 register Lisp_Object obj;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4589 {
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 434
diff changeset
4590 if (NILP (Vpurify_flag))
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4591 return obj;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4592
32594
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
4593 if (PURE_POINTER_P (XPNTR (obj)))
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4594 return obj;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4595
10004
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
4596 if (CONSP (obj))
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
4597 return pure_cons (XCAR (obj), XCDR (obj));
10004
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
4598 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
4599 return make_pure_float (XFLOAT_DATA (obj));
10004
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
4600 else if (STRINGP (obj))
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46305
diff changeset
4601 return make_pure_string (SDATA (obj), SCHARS (obj),
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46305
diff changeset
4602 SBYTES (obj),
21258
693573ac0944 (make_specified_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21244
diff changeset
4603 STRING_MULTIBYTE (obj));
10004
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
4604 else if (COMPILEDP (obj) || VECTORP (obj))
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
4605 {
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
4606 register struct Lisp_Vector *vec;
53705
db8cbe59ee5c (Fpurecopy): Declare size as EMACS_INT to not lose bits.
Andreas Schwab <schwab@suse.de>
parents: 53650
diff changeset
4607 register int i;
db8cbe59ee5c (Fpurecopy): Declare size as EMACS_INT to not lose bits.
Andreas Schwab <schwab@suse.de>
parents: 53650
diff changeset
4608 EMACS_INT size;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4609
10004
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
4610 size = XVECTOR (obj)->size;
10427
5faba1b094d5 (Fpurecopy): Mask size field when copying pseudovector.
Karl Heuer <kwzh@gnu.org>
parents: 10414
diff changeset
4611 if (size & PSEUDOVECTOR_FLAG)
5faba1b094d5 (Fpurecopy): Mask size field when copying pseudovector.
Karl Heuer <kwzh@gnu.org>
parents: 10414
diff changeset
4612 size &= PSEUDOVECTOR_SIZE_MASK;
53705
db8cbe59ee5c (Fpurecopy): Declare size as EMACS_INT to not lose bits.
Andreas Schwab <schwab@suse.de>
parents: 53650
diff changeset
4613 vec = XVECTOR (make_pure_vector (size));
10004
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
4614 for (i = 0; i < size; i++)
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
4615 vec->contents[i] = Fpurecopy (XVECTOR (obj)->contents[i]);
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
4616 if (COMPILEDP (obj))
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
4617 XSETCOMPILED (obj, vec);
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
4618 else
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
4619 XSETVECTOR (obj, vec);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4620 return obj;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4621 }
10004
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
4622 else if (MARKERP (obj))
2c57cb7eba5f (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9968
diff changeset
4623 error ("Attempt to copy a marker to pure storage");
31829
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31576
diff changeset
4624
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31576
diff changeset
4625 return obj;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4626 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4627
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4628
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4629
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4630 /***********************************************************************
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4631 Protection from GC
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4632 ***********************************************************************/
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4633
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4634 /* 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
4635 VARADDRESS. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4636
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4637 void
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4638 staticpro (varaddress)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4639 Lisp_Object *varaddress;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4640 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4641 staticvec[staticidx++] = varaddress;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4642 if (staticidx >= NSTATICS)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4643 abort ();
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4644 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4645
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4646 struct catchtag
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4647 {
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4648 Lisp_Object tag;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4649 Lisp_Object val;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4650 struct catchtag *next;
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4651 };
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4652
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4653
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4654 /***********************************************************************
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4655 Protection from GC
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4656 ***********************************************************************/
1908
d649f2179d67 * alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents: 1893
diff changeset
4657
11374
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
4658 /* Temporarily prevent garbage collection. */
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
4659
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
4660 int
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
4661 inhibit_garbage_collection ()
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
4662 {
46293
1fb8f75062c6 Use macro SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents: 46285
diff changeset
4663 int count = SPECPDL_INDEX ();
41867
a555c6419185 (inhibit_garbage_collection): Don't exceed value an int can hold.
Andreas Schwab <schwab@suse.de>
parents: 41831
diff changeset
4664 int nbits = min (VALBITS, BITS_PER_INT);
a555c6419185 (inhibit_garbage_collection): Don't exceed value an int can hold.
Andreas Schwab <schwab@suse.de>
parents: 41831
diff changeset
4665
a555c6419185 (inhibit_garbage_collection): Don't exceed value an int can hold.
Andreas Schwab <schwab@suse.de>
parents: 41831
diff changeset
4666 specbind (Qgc_cons_threshold, make_number (((EMACS_INT) 1 << (nbits - 1)) - 1));
11374
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
4667 return count;
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
4668 }
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
4669
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4670
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4671 DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "",
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
4672 doc: /* Reclaim storage for Lisp objects no longer needed.
51788
43d663a05e2d (Fgarbage_collect): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 51779
diff changeset
4673 Garbage collection happens automatically if you cons more than
43d663a05e2d (Fgarbage_collect): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 51779
diff changeset
4674 `gc-cons-threshold' bytes of Lisp data since previous garbage collection.
43d663a05e2d (Fgarbage_collect): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 51779
diff changeset
4675 `garbage-collect' normally returns a list with info on amount of space in use:
39914
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
4676 ((USED-CONSES . FREE-CONSES) (USED-SYMS . FREE-SYMS)
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
4677 (USED-MARKERS . FREE-MARKERS) USED-STRING-CHARS USED-VECTOR-SLOTS
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
4678 (USED-FLOATS . FREE-FLOATS) (USED-INTERVALS . FREE-INTERVALS)
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
4679 (USED-STRINGS . FREE-STRINGS))
51788
43d663a05e2d (Fgarbage_collect): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 51779
diff changeset
4680 However, if there was overflow in pure space, `garbage-collect'
43d663a05e2d (Fgarbage_collect): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 51779
diff changeset
4681 returns nil, because real GC can't be done. */)
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
4682 ()
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4683 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4684 register struct specbinding *bind;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4685 struct catchtag *catch;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4686 struct handler *handler;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4687 char stack_top_variable;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4688 register int i;
25343
fe92158a9e83 (Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents: 25133
diff changeset
4689 int message_p;
34270
773e6aa2ec38 (Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents: 33800
diff changeset
4690 Lisp_Object total[8];
46285
3f111801efb4 Rename BINDING_STACK_SIZE to SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents: 45392
diff changeset
4691 int count = SPECPDL_INDEX ();
49529
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
4692 EMACS_TIME t1, t2, t3;
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
4693
50745
fedd03de0f46 (abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 50626
diff changeset
4694 if (abort_on_gc)
fedd03de0f46 (abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 50626
diff changeset
4695 abort ();
fedd03de0f46 (abort_on_gc): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 50626
diff changeset
4696
39572
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
4697 /* Can't GC if pure storage overflowed because we can't determine
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
4698 if something is a pure object or not. */
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
4699 if (pure_bytes_used_before_overflow)
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
4700 return Qnil;
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
4701
61252
d24c6e8f9add (Fgarbage_collect): Call CHECK_CONS_LIST before and after gc.
Kim F. Storm <storm@cua.dk>
parents: 61225
diff changeset
4702 CHECK_CONS_LIST ();
d24c6e8f9add (Fgarbage_collect): Call CHECK_CONS_LIST before and after gc.
Kim F. Storm <storm@cua.dk>
parents: 61225
diff changeset
4703
59047
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4704 /* Don't keep undo information around forever.
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4705 Do this early on, so it is no problem if the user quits. */
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4706 {
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4707 register struct buffer *nextb = all_buffers;
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4708
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4709 while (nextb)
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4710 {
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4711 /* If a buffer's undo list is Qt, that means that undo is
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4712 turned off in that buffer. Calling truncate_undo_list on
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4713 Qt tends to return NULL, which effectively turns undo back on.
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4714 So don't call truncate_undo_list if undo_list is Qt. */
59314
9c620c1aa7fa (Fgarbage_collect): Don't truncate_undo_list on dead buffers.
Richard M. Stallman <rms@gnu.org>
parents: 59083
diff changeset
4715 if (! NILP (nextb->name) && ! EQ (nextb->undo_list, Qt))
59047
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4716 truncate_undo_list (nextb);
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4717
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4718 /* Shrink buffer gaps, but skip indirect and dead buffers. */
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4719 if (nextb->base_buffer == 0 && !NILP (nextb->name))
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4720 {
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4721 /* If a buffer's gap size is more than 10% of the buffer
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4722 size, or larger than 2000 bytes, then shrink it
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4723 accordingly. Keep a minimum size of 20 bytes. */
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4724 int size = min (2000, max (20, (nextb->text->z_byte / 10)));
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4725
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4726 if (nextb->text->gap_size > size)
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4727 {
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4728 struct buffer *save_current = current_buffer;
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4729 current_buffer = nextb;
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4730 make_gap (-(nextb->text->gap_size - size));
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4731 current_buffer = save_current;
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4732 }
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4733 }
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4734
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4735 nextb = nextb->next;
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4736 }
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4737 }
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4738
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4739 EMACS_GET_TIME (t1);
0d2678a6add0 (Fgarbage_collect): Update call to truncate_undo_list.
Richard M. Stallman <rms@gnu.org>
parents: 58986
diff changeset
4740
11892
6be0b7a0ac44 (Fgarbage_collect): Clear consing_since_gc first thing.
Karl Heuer <kwzh@gnu.org>
parents: 11727
diff changeset
4741 /* 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
4742 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
4743 consing_since_gc = 0;
6be0b7a0ac44 (Fgarbage_collect): Clear consing_since_gc first thing.
Karl Heuer <kwzh@gnu.org>
parents: 11727
diff changeset
4744
25343
fe92158a9e83 (Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents: 25133
diff changeset
4745 /* 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
4746 message_p = push_message ();
47391
1afd007f814f (Fgarbage_collect): Use pop_message_unwind.
Richard M. Stallman <rms@gnu.org>
parents: 47185
diff changeset
4747 record_unwind_protect (pop_message_unwind, Qnil);
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4748
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4749 /* Save a copy of the contents of the stack, for debugging. */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4750 #if MAX_SAVE_STACK > 0
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 434
diff changeset
4751 if (NILP (Vpurify_flag))
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4752 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4753 i = &stack_top_variable - stack_bottom;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4754 if (i < 0) i = -i;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4755 if (i < MAX_SAVE_STACK)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4756 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4757 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
4758 stack_copy = (char *) xmalloc (stack_copy_size = i);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4759 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
4760 stack_copy = (char *) xrealloc (stack_copy, (stack_copy_size = i));
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4761 if (stack_copy)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4762 {
8817
48ff00bebef6 (pure, pure_size): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents: 7307
diff changeset
4763 if ((EMACS_INT) (&stack_top_variable - stack_bottom) > 0)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4764 bcopy (stack_bottom, stack_copy, i);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4765 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4766 bcopy (&stack_top_variable, stack_copy, i);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4767 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4768 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4769 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4770 #endif /* MAX_SAVE_STACK > 0 */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4771
14959
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
4772 if (garbage_collection_messages)
10395
c121703d35c7 (Fgarbage_collect): Don't log the GC message.
Karl Heuer <kwzh@gnu.org>
parents: 10389
diff changeset
4773 message1_nolog ("Garbage collecting...");
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4774
23534
6f9c70db3a58 (Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents: 22382
diff changeset
4775 BLOCK_INPUT;
6f9c70db3a58 (Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents: 22382
diff changeset
4776
22220
a0cd311af6e3 (Fgarbage_collect): Call shrink_regexp_cache.
Richard M. Stallman <rms@gnu.org>
parents: 21948
diff changeset
4777 shrink_regexp_cache ();
a0cd311af6e3 (Fgarbage_collect): Call shrink_regexp_cache.
Richard M. Stallman <rms@gnu.org>
parents: 21948
diff changeset
4778
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4779 gc_in_progress = 1;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4780
16231
5ce3b59f093b Comment changes.
Erik Naggum <erik@naggum.no>
parents: 16223
diff changeset
4781 /* clear_marks (); */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4782
52473
a3fd06a8c844 (init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52453
diff changeset
4783 /* Mark all the special slots that serve as the roots of accessibility. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4784
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4785 for (i = 0; i < staticidx; i++)
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
4786 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
4787
57098
0487c26b96ee (Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56539
diff changeset
4788 for (bind = specpdl; bind != specpdl_ptr; bind++)
0487c26b96ee (Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56539
diff changeset
4789 {
0487c26b96ee (Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56539
diff changeset
4790 mark_object (bind->symbol);
0487c26b96ee (Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56539
diff changeset
4791 mark_object (bind->old_value);
0487c26b96ee (Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56539
diff changeset
4792 }
0487c26b96ee (Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56539
diff changeset
4793 mark_kboards ();
0487c26b96ee (Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56539
diff changeset
4794
0487c26b96ee (Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56539
diff changeset
4795 #ifdef USE_GTK
0487c26b96ee (Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56539
diff changeset
4796 {
0487c26b96ee (Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56539
diff changeset
4797 extern void xg_mark_data ();
0487c26b96ee (Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56539
diff changeset
4798 xg_mark_data ();
0487c26b96ee (Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56539
diff changeset
4799 }
0487c26b96ee (Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56539
diff changeset
4800 #endif
0487c26b96ee (Fgarbage_collect): Mark keyboards, gtk data, and specpdl
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56539
diff changeset
4801
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4802 #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
4803 || 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
4804 mark_stack ();
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4805 #else
51228
42d9bef83464 (Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51029
diff changeset
4806 {
42d9bef83464 (Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51029
diff changeset
4807 register struct gcpro *tail;
42d9bef83464 (Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51029
diff changeset
4808 for (tail = gcprolist; tail; tail = tail->next)
42d9bef83464 (Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51029
diff changeset
4809 for (i = 0; i < tail->nvars; i++)
52473
a3fd06a8c844 (init_intervals, init_symbol, init_marker): Don't preallocate anything.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52453
diff changeset
4810 mark_object (tail->var[i]);
51228
42d9bef83464 (Fgarbage_collect): Remove `unused var tail' warning.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51029
diff changeset
4811 }
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4812 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
4813
26364
7b0217d9259c (Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents: 26164
diff changeset
4814 mark_byte_stack ();
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4815 for (catch = catchlist; catch; catch = catch->next)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4816 {
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
4817 mark_object (catch->tag);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
4818 mark_object (catch->val);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
4819 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4820 for (handler = handlerlist; handler; handler = handler->next)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4821 {
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
4822 mark_object (handler->handler);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
4823 mark_object (handler->var);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
4824 }
55798
a1bb695e9a0c (struct backtrace): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55767
diff changeset
4825 mark_backtrace ();
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4826
59400
eeb8b96d077d (mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents: 59359
diff changeset
4827 #ifdef HAVE_WINDOW_SYSTEM
eeb8b96d077d (mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents: 59359
diff changeset
4828 mark_fringe_data ();
eeb8b96d077d (mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents: 59359
diff changeset
4829 #endif
eeb8b96d077d (mark_fringe_data): Declare extern.
Kim F. Storm <storm@cua.dk>
parents: 59359
diff changeset
4830
55667
57f4a242e8f4 (Fgarbage_collect): Do all the marking before flushing
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55635
diff changeset
4831 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
57f4a242e8f4 (Fgarbage_collect): Do all the marking before flushing
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55635
diff changeset
4832 mark_stack ();
57f4a242e8f4 (Fgarbage_collect): Do all the marking before flushing
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55635
diff changeset
4833 #endif
57f4a242e8f4 (Fgarbage_collect): Do all the marking before flushing
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55635
diff changeset
4834
55816
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
4835 /* Everything is now marked, except for the things that require special
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
4836 finalization, i.e. the undo_list.
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
4837 Look thru every buffer's undo list
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
4838 for elements that update markers that were not marked,
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
4839 and delete them. */
21306
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4840 {
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4841 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
4842
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4843 while (nextb)
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4844 {
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4845 /* If a buffer's undo list is Qt, that means that undo is
55816
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
4846 turned off in that buffer. Calling truncate_undo_list on
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
4847 Qt tends to return NULL, which effectively turns undo back on.
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
4848 So don't call truncate_undo_list if undo_list is Qt. */
21306
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4849 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
4850 {
55816
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
4851 Lisp_Object tail, prev;
21306
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4852 tail = nextb->undo_list;
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4853 prev = Qnil;
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4854 while (CONSP (tail))
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4855 {
55816
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
4856 if (GC_CONSP (XCAR (tail))
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
4857 && GC_MARKERP (XCAR (XCAR (tail)))
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
4858 && !XMARKER (XCAR (XCAR (tail)))->gcmarkbit)
21306
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4859 {
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4860 if (NILP (prev))
55816
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
4861 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
4862 else
39973
579177964efa Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents: 39914
diff changeset
4863 {
55816
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
4864 tail = XCDR (tail);
39973
579177964efa Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents: 39914
diff changeset
4865 XSETCDR (prev, tail);
579177964efa Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents: 39914
diff changeset
4866 }
21306
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4867 }
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4868 else
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4869 {
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4870 prev = tail;
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25544
diff changeset
4871 tail = XCDR (tail);
21306
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4872 }
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4873 }
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4874 }
55816
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
4875 /* Now that we have stripped the elements that need not be in the
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
4876 undo_list any more, we can finally mark the list. */
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
4877 mark_object (nextb->undo_list);
21306
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4878
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4879 nextb = nextb->next;
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4880 }
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4881 }
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
4882
55816
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
4883 gc_sweep ();
55767
ee3a30045908 (marker_blocks_pending_free): New var.
Kim F. Storm <storm@cua.dk>
parents: 55745
diff changeset
4884
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4885 /* Clear the mark bits that we set in certain root slots. */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4886
26378
cbf297593a79 (Fgarbage_collect): Call unmark_byte_stack.
Gerd Moellmann <gerd@gnu.org>
parents: 26372
diff changeset
4887 unmark_byte_stack ();
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
4888 VECTOR_UNMARK (&buffer_defaults);
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
4889 VECTOR_UNMARK (&buffer_local_symbols);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4890
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4891 #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
4892 dump_zombies ();
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4893 #endif
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4894
23534
6f9c70db3a58 (Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents: 22382
diff changeset
4895 UNBLOCK_INPUT;
6f9c70db3a58 (Fgarbage_collect): Block input around most of the function.
Richard M. Stallman <rms@gnu.org>
parents: 22382
diff changeset
4896
61252
d24c6e8f9add (Fgarbage_collect): Call CHECK_CONS_LIST before and after gc.
Kim F. Storm <storm@cua.dk>
parents: 61225
diff changeset
4897 CHECK_CONS_LIST ();
d24c6e8f9add (Fgarbage_collect): Call CHECK_CONS_LIST before and after gc.
Kim F. Storm <storm@cua.dk>
parents: 61225
diff changeset
4898
16231
5ce3b59f093b Comment changes.
Erik Naggum <erik@naggum.no>
parents: 16223
diff changeset
4899 /* clear_marks (); */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4900 gc_in_progress = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4901
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4902 consing_since_gc = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4903 if (gc_cons_threshold < 10000)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4904 gc_cons_threshold = 10000;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4905
64267
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
4906 if (FLOATP (Vgc_cons_percentage))
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
4907 { /* Set gc_cons_combined_threshold. */
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
4908 EMACS_INT total = 0;
64611
47f158dcf216 (gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents: 64273
diff changeset
4909
64267
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
4910 total += total_conses * sizeof (struct Lisp_Cons);
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
4911 total += total_symbols * sizeof (struct Lisp_Symbol);
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
4912 total += total_markers * sizeof (union Lisp_Misc);
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
4913 total += total_string_size;
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
4914 total += total_vector_size * sizeof (Lisp_Object);
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
4915 total += total_floats * sizeof (struct Lisp_Float);
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
4916 total += total_intervals * sizeof (struct interval);
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
4917 total += total_strings * sizeof (struct Lisp_String);
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
4918
64611
47f158dcf216 (gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents: 64273
diff changeset
4919 gc_relative_threshold = total * XFLOAT_DATA (Vgc_cons_percentage);
64267
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
4920 }
64611
47f158dcf216 (gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents: 64273
diff changeset
4921 else
47f158dcf216 (gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents: 64273
diff changeset
4922 gc_relative_threshold = 0;
64267
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
4923
14959
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
4924 if (garbage_collection_messages)
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
4925 {
25343
fe92158a9e83 (Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents: 25133
diff changeset
4926 if (message_p || minibuf_level > 0)
fe92158a9e83 (Fgarbage_collect): Use push_message, restore_message,
Gerd Moellmann <gerd@gnu.org>
parents: 25133
diff changeset
4927 restore_message ();
14959
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
4928 else
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
4929 message1_nolog ("Garbage collecting...done");
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
4930 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4931
35170
a9b677239421 (Fgarbage_collect): Use a record_unwind_protect to
Gerd Moellmann <gerd@gnu.org>
parents: 34325
diff changeset
4932 unbind_to (count, Qnil);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4933
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4934 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
4935 make_number (total_free_conses));
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4936 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
4937 make_number (total_free_symbols));
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4938 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
4939 make_number (total_free_markers));
34270
773e6aa2ec38 (Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents: 33800
diff changeset
4940 total[3] = make_number (total_string_size);
773e6aa2ec38 (Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents: 33800
diff changeset
4941 total[4] = make_number (total_vector_size);
773e6aa2ec38 (Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents: 33800
diff changeset
4942 total[5] = Fcons (make_number (total_floats),
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4943 make_number (total_free_floats));
34270
773e6aa2ec38 (Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents: 33800
diff changeset
4944 total[6] = Fcons (make_number (total_intervals),
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4945 make_number (total_free_intervals));
34270
773e6aa2ec38 (Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents: 33800
diff changeset
4946 total[7] = Fcons (make_number (total_strings),
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4947 make_number (total_free_strings));
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4948
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4949 #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
4950 {
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4951 /* 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
4952 double nlive = 0;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
4953
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4954 for (i = 0; i < 7; ++i)
49357
90e4c5eeb9a0 (Fgc_status): Print zombie list.
Dave Love <fx@gnu.org>
parents: 49322
diff changeset
4955 if (CONSP (total[i]))
90e4c5eeb9a0 (Fgc_status): Print zombie list.
Dave Love <fx@gnu.org>
parents: 49322
diff changeset
4956 nlive += XFASTINT (XCAR (total[i]));
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4957
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4958 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
4959 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
4960 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
4961 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
4962 ++ngcs;
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4963 }
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4964 #endif
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4965
39572
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
4966 if (!NILP (Vpost_gc_hook))
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
4967 {
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
4968 int count = inhibit_garbage_collection ();
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
4969 safe_run_hooks (Qpost_gc_hook);
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
4970 unbind_to (count, Qnil);
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
4971 }
49529
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
4972
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
4973 /* Accumulate statistics. */
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
4974 EMACS_GET_TIME (t2);
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
4975 EMACS_SUB_TIME (t3, t2, t1);
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
4976 if (FLOATP (Vgc_elapsed))
49911
d9ade23e09df (Fgarbage_collect): Don't use XSETFLOAT.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49600
diff changeset
4977 Vgc_elapsed = make_float (XFLOAT_DATA (Vgc_elapsed) +
d9ade23e09df (Fgarbage_collect): Don't use XSETFLOAT.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49600
diff changeset
4978 EMACS_SECS (t3) +
d9ade23e09df (Fgarbage_collect): Don't use XSETFLOAT.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49600
diff changeset
4979 EMACS_USECS (t3) * 1.0e-6);
49529
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
4980 gcs_done++;
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
4981
34270
773e6aa2ec38 (Fgarbage_collect): Dox fix. Return a list as
Gerd Moellmann <gerd@gnu.org>
parents: 33800
diff changeset
4982 return Flist (sizeof total / sizeof *total, total);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4983 }
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
4984
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4985
25367
823e14641544 (mark_glyph_matrix): Mark strings only.
Gerd Moellmann <gerd@gnu.org>
parents: 25343
diff changeset
4986 /* 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
4987 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
4988
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4989 static void
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4990 mark_glyph_matrix (matrix)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4991 struct glyph_matrix *matrix;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4992 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4993 struct glyph_row *row = matrix->rows;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4994 struct glyph_row *end = row + matrix->nrows;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
4995
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4996 for (; row < end; ++row)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4997 if (row->enabled_p)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4998 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
4999 int area;
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
5000 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
5001 {
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
5002 struct glyph *glyph = row->glyphs[area];
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
5003 struct glyph *end_glyph = glyph + row->used[area];
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
5004
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
5005 for (; glyph < end_glyph; ++glyph)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
5006 if (GC_STRINGP (glyph->object)
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
5007 && !STRING_MARKED_P (XSTRING (glyph->object)))
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5008 mark_object (glyph->object);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
5009 }
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
5010 }
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5011 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5012
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
5013
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5014 /* 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
5015
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5016 static void
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5017 mark_face_cache (c)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5018 struct face_cache *c;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5019 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5020 if (c)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5021 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5022 int i, j;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5023 for (i = 0; i < c->used; ++i)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5024 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5025 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
5026
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5027 if (face)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5028 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5029 for (j = 0; j < LFACE_VECTOR_SIZE; ++j)
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5030 mark_object (face->lface[j]);
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5031 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5032 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5033 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5034 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5035
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5036
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5037 #ifdef HAVE_WINDOW_SYSTEM
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5038
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5039 /* Mark Lisp objects in image IMG. */
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5040
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5041 static void
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5042 mark_image (img)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5043 struct image *img;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5044 {
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5045 mark_object (img->spec);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
5046
31892
2f3d88ac2b38 (__malloc_size_t) [DOUG_LEA_MALLOC]: Don't redefine it.
Dave Love <fx@gnu.org>
parents: 31889
diff changeset
5047 if (!NILP (img->data.lisp_val))
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5048 mark_object (img->data.lisp_val);
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5049 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5050
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5051
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5052 /* 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
5053 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
5054
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5055 static void
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5056 mark_image_cache (f)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5057 struct frame *f;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5058 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5059 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
5060 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5061
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5062 #endif /* HAVE_X_WINDOWS */
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5063
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5064
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5065
1908
d649f2179d67 * alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents: 1893
diff changeset
5066 /* 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
5067 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
5068 all the references contained in it. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5069
1168
2b07af77d7ec (mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents: 1114
diff changeset
5070 #define LAST_MARKED_SIZE 500
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5071 Lisp_Object last_marked[LAST_MARKED_SIZE];
1168
2b07af77d7ec (mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents: 1114
diff changeset
5072 int last_marked_index;
2b07af77d7ec (mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents: 1114
diff changeset
5073
46833
b80760a75295 (mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents: 46459
diff changeset
5074 /* For debugging--call abort when we cdr down this many
b80760a75295 (mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents: 46459
diff changeset
5075 links of a list, in mark_object. In debugging,
b80760a75295 (mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents: 46459
diff changeset
5076 the call to abort will hit a breakpoint.
b80760a75295 (mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents: 46459
diff changeset
5077 Normally this is zero and the check never goes off. */
b80760a75295 (mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents: 46459
diff changeset
5078 int mark_object_loop_halt;
b80760a75295 (mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents: 46459
diff changeset
5079
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5080 void
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5081 mark_object (arg)
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5082 Lisp_Object arg;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5083 {
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5084 register Lisp_Object obj = arg;
29743
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5085 #ifdef GC_CHECK_MARKED_OBJECTS
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5086 void *po;
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5087 struct mem_node *m;
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5088 #endif
46833
b80760a75295 (mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents: 46459
diff changeset
5089 int cdr_count = 0;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5090
5868
a7bd57a60cb8 (mark_object): Fetch obj from *objptr at loop, not at the gotos.
Karl Heuer <kwzh@gnu.org>
parents: 5353
diff changeset
5091 loop:
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5092
32594
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
5093 if (PURE_POINTER_P (XPNTR (obj)))
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5094 return;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5095
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5096 last_marked[last_marked_index++] = obj;
1168
2b07af77d7ec (mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents: 1114
diff changeset
5097 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
5098 last_marked_index = 0;
2b07af77d7ec (mark_object): Save last 500 values of objptr.
Richard M. Stallman <rms@gnu.org>
parents: 1114
diff changeset
5099
29743
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5100 /* Perform some sanity checks on the objects marked here. Abort if
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5101 we encounter an object we know is bogus. This increases GC time
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5102 by ~80%, and requires compilation with GC_MARK_STACK != 0. */
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5103 #ifdef GC_CHECK_MARKED_OBJECTS
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5104
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5105 po = (void *) XPNTR (obj);
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5106
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5107 /* Check that the object pointed to by PO is known to be a Lisp
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5108 structure allocated from the heap. */
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5109 #define CHECK_ALLOCATED() \
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5110 do { \
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5111 m = mem_find (po); \
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5112 if (m == MEM_NIL) \
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5113 abort (); \
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5114 } while (0)
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5115
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5116 /* Check that the object pointed to by PO is live, using predicate
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5117 function LIVEP. */
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5118 #define CHECK_LIVE(LIVEP) \
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5119 do { \
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5120 if (!LIVEP (m, po)) \
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5121 abort (); \
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5122 } while (0)
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5123
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5124 /* Check both of the above conditions. */
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5125 #define CHECK_ALLOCATED_AND_LIVE(LIVEP) \
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5126 do { \
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5127 CHECK_ALLOCATED (); \
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5128 CHECK_LIVE (LIVEP); \
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5129 } while (0) \
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
5130
29743
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5131 #else /* not GC_CHECK_MARKED_OBJECTS */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
5132
29743
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5133 #define CHECK_ALLOCATED() (void) 0
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5134 #define CHECK_LIVE(LIVEP) (void) 0
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5135 #define CHECK_ALLOCATED_AND_LIVE(LIVEP) (void) 0
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
5136
29743
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5137 #endif /* not GC_CHECK_MARKED_OBJECTS */
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5138
10457
2ab3bd0288a9 Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents: 10427
diff changeset
5139 switch (SWITCH_ENUM_CAST (XGCTYPE (obj)))
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5140 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5141 case Lisp_String:
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5142 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5143 register struct Lisp_String *ptr = XSTRING (obj);
29743
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5144 CHECK_ALLOCATED_AND_LIVE (live_string_p);
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5145 MARK_INTERVAL_TREE (ptr->intervals);
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
5146 MARK_STRING (ptr);
32587
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
5147 #ifdef GC_CHECK_STRING_BYTES
35183
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
5148 /* Check that the string size recorded in the string is the
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
5149 same as the one recorded in the sdata structure. */
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
5150 CHECK_STRING_BYTES (ptr);
32587
b3918817f15f (mark_object) [GC_CHECK_STRING_BYTES]: Check validity of
Gerd Moellmann <gerd@gnu.org>
parents: 32360
diff changeset
5151 #endif /* GC_CHECK_STRING_BYTES */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5152 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5153 break;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5154
10009
82f3daf76995 (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 10004
diff changeset
5155 case Lisp_Vectorlike:
29743
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5156 #ifdef GC_CHECK_MARKED_OBJECTS
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5157 m = mem_find (po);
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5158 if (m == MEM_NIL && !GC_SUBRP (obj)
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5159 && po != &buffer_defaults
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5160 && po != &buffer_local_symbols)
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5161 abort ();
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5162 #endif /* GC_CHECK_MARKED_OBJECTS */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
5163
10307
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
5164 if (GC_BUFFERP (obj))
10340
ef58c7a5a4d6 (mark_object, mark_buffer): Don't mark buffer twice.
Karl Heuer <kwzh@gnu.org>
parents: 10320
diff changeset
5165 {
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5166 if (!VECTOR_MARKED_P (XBUFFER (obj)))
29743
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5167 {
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5168 #ifdef GC_CHECK_MARKED_OBJECTS
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5169 if (po != &buffer_defaults && po != &buffer_local_symbols)
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5170 {
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5171 struct buffer *b;
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5172 for (b = all_buffers; b && b != po; b = b->next)
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5173 ;
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5174 if (b == NULL)
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5175 abort ();
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5176 }
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5177 #endif /* GC_CHECK_MARKED_OBJECTS */
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5178 mark_buffer (obj);
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5179 }
10340
ef58c7a5a4d6 (mark_object, mark_buffer): Don't mark buffer twice.
Karl Heuer <kwzh@gnu.org>
parents: 10320
diff changeset
5180 }
10307
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
5181 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
5182 break;
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
5183 else if (GC_COMPILEDP (obj))
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
5184 /* 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
5185 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
5186 recursion there. */
10291
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
5187 {
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
5188 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
5189 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
5190 register int i;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5191
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5192 if (VECTOR_MARKED_P (ptr))
10291
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
5193 break; /* Already marked */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
5194
29743
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5195 CHECK_LIVE (live_vector_p);
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5196 VECTOR_MARK (ptr); /* Else mark it */
10009
82f3daf76995 (Fpurecopy): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 10004
diff changeset
5197 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
5198 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
5199 {
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
5200 if (i != COMPILED_CONSTANTS)
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5201 mark_object (ptr->contents[i]);
10291
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
5202 }
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5203 obj = ptr->contents[COMPILED_CONSTANTS];
10291
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
5204 goto loop;
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
5205 }
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
5206 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
5207 {
32360
d8b668a486d7 (mark_object): Remove all workarounds installed on
Andreas Schwab <schwab@suse.de>
parents: 32099
diff changeset
5208 register struct frame *ptr = XFRAME (obj);
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5209
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5210 if (VECTOR_MARKED_P (ptr)) break; /* Already marked */
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5211 VECTOR_MARK (ptr); /* Else mark it */
1295
a9241dc503ab (mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents: 1168
diff changeset
5212
29743
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5213 CHECK_LIVE (live_vector_p);
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5214 mark_object (ptr->name);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5215 mark_object (ptr->icon_name);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5216 mark_object (ptr->title);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5217 mark_object (ptr->focus_frame);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5218 mark_object (ptr->selected_window);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5219 mark_object (ptr->minibuffer_window);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5220 mark_object (ptr->param_alist);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5221 mark_object (ptr->scroll_bars);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5222 mark_object (ptr->condemned_scroll_bars);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5223 mark_object (ptr->menu_bar_items);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5224 mark_object (ptr->face_alist);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5225 mark_object (ptr->menu_bar_vector);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5226 mark_object (ptr->buffer_predicate);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5227 mark_object (ptr->buffer_list);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5228 mark_object (ptr->menu_bar_window);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5229 mark_object (ptr->tool_bar_window);
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5230 mark_face_cache (ptr->face_cache);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5231 #ifdef HAVE_WINDOW_SYSTEM
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5232 mark_image_cache (ptr);
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5233 mark_object (ptr->tool_bar_items);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5234 mark_object (ptr->desired_tool_bar_string);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5235 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
5236 #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
5237 }
13141
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
5238 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
5239 {
5cd52d4838f8 (mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents: 14959
diff changeset
5240 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
5241
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5242 if (VECTOR_MARKED_P (ptr))
15379
5cd52d4838f8 (mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents: 14959
diff changeset
5243 break; /* Already marked */
29743
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5244 CHECK_LIVE (live_vector_p);
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5245 VECTOR_MARK (ptr); /* Else mark it */
15379
5cd52d4838f8 (mark_object): Do set ARRAY_MARK_FLAG for bool-vectors.
Richard M. Stallman <rms@gnu.org>
parents: 14959
diff changeset
5246 }
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5247 else if (GC_WINDOWP (obj))
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5248 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5249 register struct Lisp_Vector *ptr = XVECTOR (obj);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5250 struct window *w = XWINDOW (obj);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5251 register int i;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5252
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5253 /* Stop if already marked. */
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5254 if (VECTOR_MARKED_P (ptr))
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5255 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5256
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5257 /* Mark it. */
29743
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5258 CHECK_LIVE (live_vector_p);
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5259 VECTOR_MARK (ptr);
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5260
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5261 /* 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
5262 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
5263 for (i = 0;
32360
d8b668a486d7 (mark_object): Remove all workarounds installed on
Andreas Schwab <schwab@suse.de>
parents: 32099
diff changeset
5264 (char *) &ptr->contents[i] < (char *) &w->current_matrix;
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5265 i++)
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5266 mark_object (ptr->contents[i]);
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5267
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5268 /* 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
5269 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
5270 memory. */
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5271 if (NILP (w->hchild)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5272 && NILP (w->vchild)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5273 && w->current_matrix)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5274 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5275 mark_glyph_matrix (w->current_matrix);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5276 mark_glyph_matrix (w->desired_matrix);
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5277 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5278 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5279 else if (GC_HASH_TABLE_P (obj))
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5280 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5281 struct Lisp_Hash_Table *h = XHASH_TABLE (obj);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
5282
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5283 /* Stop if already marked. */
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5284 if (VECTOR_MARKED_P (h))
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5285 break;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
5286
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5287 /* Mark it. */
29743
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5288 CHECK_LIVE (live_vector_p);
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5289 VECTOR_MARK (h);
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5290
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5291 /* Mark contents. */
43005
0ab7a9a5666c Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 42403
diff changeset
5292 /* Do not mark next_free or next_weak.
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
5293 Being in the next_weak chain
43005
0ab7a9a5666c Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 42403
diff changeset
5294 should not keep the hash table alive.
0ab7a9a5666c Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 42403
diff changeset
5295 No need to mark `count' since it is an integer. */
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5296 mark_object (h->test);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5297 mark_object (h->weak);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5298 mark_object (h->rehash_size);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5299 mark_object (h->rehash_threshold);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5300 mark_object (h->hash);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5301 mark_object (h->next);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5302 mark_object (h->index);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5303 mark_object (h->user_hash_function);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5304 mark_object (h->user_cmp_function);
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5305
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5306 /* 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
5307 For weak tables, mark only the vector. */
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5308 if (GC_NILP (h->weak))
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5309 mark_object (h->key_and_value);
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5310 else
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5311 VECTOR_MARK (XVECTOR (h->key_and_value));
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5312 }
10291
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
5313 else
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
5314 {
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
5315 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
5316 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
5317 register int i;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5318
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5319 if (VECTOR_MARKED_P (ptr)) break; /* Already marked */
29743
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5320 CHECK_LIVE (live_vector_p);
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5321 VECTOR_MARK (ptr); /* Else mark it */
10291
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
5322 if (size & PSEUDOVECTOR_FLAG)
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
5323 size &= PSEUDOVECTOR_SIZE_MASK;
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5324
10291
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
5325 for (i = 0; i < size; i++) /* and then mark its elements */
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5326 mark_object (ptr->contents[i]);
10291
96273a6ec492 (mark_object): Don't use Lisp_Process, Lisp_Window.
Richard M. Stallman <rms@gnu.org>
parents: 10206
diff changeset
5327 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5328 break;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5329
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5330 case Lisp_Symbol:
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5331 {
32360
d8b668a486d7 (mark_object): Remove all workarounds installed on
Andreas Schwab <schwab@suse.de>
parents: 32099
diff changeset
5332 register struct Lisp_Symbol *ptr = XSYMBOL (obj);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5333 struct Lisp_Symbol *ptrx;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5334
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
5335 if (ptr->gcmarkbit) break;
29743
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5336 CHECK_ALLOCATED_AND_LIVE (live_symbol_p);
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
5337 ptr->gcmarkbit = 1;
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5338 mark_object (ptr->value);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5339 mark_object (ptr->function);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5340 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
5341
45392
f3d7ab65641f * alloc.c (Fmake_symbol): Set symbol xname field instead of name.
Ken Raeburn <raeburn@raeburn.org>
parents: 44890
diff changeset
5342 if (!PURE_POINTER_P (XSTRING (ptr->xname)))
f3d7ab65641f * alloc.c (Fmake_symbol): Set symbol xname field instead of name.
Ken Raeburn <raeburn@raeburn.org>
parents: 44890
diff changeset
5343 MARK_STRING (XSTRING (ptr->xname));
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46305
diff changeset
5344 MARK_INTERVAL_TREE (STRING_INTERVALS (ptr->xname));
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
5345
20768
6ebcbdec2e07 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
5346 /* Note that we do not mark the obarray of the symbol.
6ebcbdec2e07 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
5347 It is safe not to do so because nothing accesses that
6ebcbdec2e07 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
5348 slot except to check whether it is nil. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5349 ptr = ptr->next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5350 if (ptr)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5351 {
2507
7ba4316ae840 * alloc.c (__malloc_hook, __realloc_hook, __free_hook): Declare
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
5352 ptrx = ptr; /* Use of ptrx avoids compiler bug on Sun */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5353 XSETSYMBOL (obj, ptrx);
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5354 goto loop;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5355 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5356 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5357 break;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5358
9437
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
5359 case Lisp_Misc:
29743
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5360 CHECK_ALLOCATED_AND_LIVE (live_misc_p);
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
5361 if (XMARKER (obj)->gcmarkbit)
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
5362 break;
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
5363 XMARKER (obj)->gcmarkbit = 1;
56202
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
5364
11243
054ecfce1820 (Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents: 11048
diff changeset
5365 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
5366 {
9893
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
5367 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
5368 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
5369 {
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
5370 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
5371 = XBUFFER_LOCAL_VALUE (obj);
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
5372 /* 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
5373 if (EQ (ptr->cdr, Qnil))
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
5374 {
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5375 obj = ptr->realvalue;
9893
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
5376 goto loop;
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
5377 }
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5378 mark_object (ptr->realvalue);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5379 mark_object (ptr->buffer);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5380 mark_object (ptr->frame);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5381 obj = ptr->cdr;
9893
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
5382 goto loop;
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
5383 }
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
5384
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
5385 case Lisp_Misc_Marker:
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
5386 /* DO NOT mark thru the marker's chain.
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
5387 The buffer's markers chain does not preserve markers from gc;
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
5388 instead, markers are removed from the chain when freed by gc. */
56202
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
5389 break;
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
5390
9463
a40af805e036 (mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9437
diff changeset
5391 case Lisp_Misc_Intfwd:
a40af805e036 (mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9437
diff changeset
5392 case Lisp_Misc_Boolfwd:
a40af805e036 (mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9437
diff changeset
5393 case Lisp_Misc_Objfwd:
a40af805e036 (mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9437
diff changeset
5394 case Lisp_Misc_Buffer_Objfwd:
11018
2d9bdf1ba3d1 (mark_kboards): Renamed from mark_perdisplays.
Karl Heuer <kwzh@gnu.org>
parents: 10936
diff changeset
5395 case Lisp_Misc_Kboard_Objfwd:
9463
a40af805e036 (mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9437
diff changeset
5396 /* Don't bother with Lisp_Buffer_Objfwd,
a40af805e036 (mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9437
diff changeset
5397 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
5398 /* 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
5399 are protected with staticpro. */
56202
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
5400 break;
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
5401
52166
25f780eb3fd8 (mark_object): Handle Lisp_Misc_Save_Value.
Andreas Schwab <schwab@suse.de>
parents: 51985
diff changeset
5402 case Lisp_Misc_Save_Value:
56401
1529ab7bab88 (mark_object): Only look at Lisp_Misc_Save_Value if GC_MARK_STACK.
Kim F. Storm <storm@cua.dk>
parents: 56239
diff changeset
5403 #if GC_MARK_STACK
56202
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
5404 {
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
5405 register struct Lisp_Save_Value *ptr = XSAVE_VALUE (obj);
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
5406 /* If DOGC is set, POINTER is the address of a memory
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
5407 area containing INTEGER potential Lisp_Objects. */
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
5408 if (ptr->dogc)
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
5409 {
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
5410 Lisp_Object *p = (Lisp_Object *) ptr->pointer;
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
5411 int nelt;
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
5412 for (nelt = ptr->integer; nelt > 0; nelt--, p++)
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
5413 mark_maybe_object (*p);
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
5414 }
db1817b88294 (safe_alloca_unwind): Clear dogc and pointer members.
Kim F. Storm <storm@cua.dk>
parents: 56187
diff changeset
5415 }
56401
1529ab7bab88 (mark_object): Only look at Lisp_Misc_Save_Value if GC_MARK_STACK.
Kim F. Storm <storm@cua.dk>
parents: 56239
diff changeset
5416 #endif
9463
a40af805e036 (mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9437
diff changeset
5417 break;
a40af805e036 (mark_object): Use the new substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9437
diff changeset
5418
9926
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
5419 case Lisp_Misc_Overlay:
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
5420 {
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
5421 struct Lisp_Overlay *ptr = XOVERLAY (obj);
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5422 mark_object (ptr->start);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5423 mark_object (ptr->end);
51843
65772ad7d4e1 (mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51788
diff changeset
5424 mark_object (ptr->plist);
65772ad7d4e1 (mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51788
diff changeset
5425 if (ptr->next)
65772ad7d4e1 (mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51788
diff changeset
5426 {
65772ad7d4e1 (mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51788
diff changeset
5427 XSETMISC (obj, ptr->next);
65772ad7d4e1 (mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51788
diff changeset
5428 goto loop;
65772ad7d4e1 (mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51788
diff changeset
5429 }
9926
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
5430 }
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
5431 break;
2a9f99682f82 (mark_object, gc_sweep): Use new overlay substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9893
diff changeset
5432
9437
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
5433 default:
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
5434 abort ();
c7d7fb56b42d (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the
Karl Heuer <kwzh@gnu.org>
parents: 9367
diff changeset
5435 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5436 break;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5437
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5438 case Lisp_Cons:
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5439 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5440 register struct Lisp_Cons *ptr = XCONS (obj);
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
5441 if (CONS_MARKED_P (ptr)) break;
29743
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5442 CHECK_ALLOCATED_AND_LIVE (live_cons_p);
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
5443 CONS_MARK (ptr);
1295
a9241dc503ab (mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents: 1168
diff changeset
5444 /* 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
5445 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
5446 {
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5447 obj = ptr->car;
46833
b80760a75295 (mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents: 46459
diff changeset
5448 cdr_count = 0;
1295
a9241dc503ab (mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents: 1168
diff changeset
5449 goto loop;
a9241dc503ab (mark_object): Avoid car recursion on cons with nil in cdr.
Richard M. Stallman <rms@gnu.org>
parents: 1168
diff changeset
5450 }
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5451 mark_object (ptr->car);
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5452 obj = ptr->cdr;
46833
b80760a75295 (mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents: 46459
diff changeset
5453 cdr_count++;
b80760a75295 (mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents: 46459
diff changeset
5454 if (cdr_count == mark_object_loop_halt)
b80760a75295 (mark_object): Detect long lists for debugging.
Richard M. Stallman <rms@gnu.org>
parents: 46459
diff changeset
5455 abort ();
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5456 goto loop;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5457 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5458
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5459 case Lisp_Float:
29743
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5460 CHECK_ALLOCATED_AND_LIVE (live_float_p);
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
5461 FLOAT_MARK (XFLOAT (obj));
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5462 break;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5463
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5464 case Lisp_Int:
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5465 break;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5466
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5467 default:
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5468 abort ();
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5469 }
29743
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5470
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5471 #undef CHECK_LIVE
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5472 #undef CHECK_ALLOCATED
1d802b332e0d (mark_object) [GC_CHECK_MARKED_OBJECTS]: Check that no
Gerd Moellmann <gerd@gnu.org>
parents: 28997
diff changeset
5473 #undef CHECK_ALLOCATED_AND_LIVE
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5474 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5475
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5476 /* Mark the pointers in a buffer structure. */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5477
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5478 static void
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5479 mark_buffer (buf)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5480 Lisp_Object buf;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5481 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5482 register struct buffer *buffer = XBUFFER (buf);
51843
65772ad7d4e1 (mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51788
diff changeset
5483 register Lisp_Object *ptr, tmp;
10307
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
5484 Lisp_Object base_buffer;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5485
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5486 VECTOR_MARK (buffer);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5487
10307
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
5488 MARK_INTERVAL_TREE (BUF_INTERVALS (buffer));
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5489
55816
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
5490 /* For now, we just don't mark the undo_list. It's done later in
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
5491 a special way just before the sweep phase, and after stripping
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
5492 some of its elements that are not needed any more. */
21306
dc2cbd40703c (mark_buffer): Mark the undo_list slot specially;
Richard M. Stallman <rms@gnu.org>
parents: 21258
diff changeset
5493
51843
65772ad7d4e1 (mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51788
diff changeset
5494 if (buffer->overlays_before)
65772ad7d4e1 (mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51788
diff changeset
5495 {
65772ad7d4e1 (mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51788
diff changeset
5496 XSETMISC (tmp, buffer->overlays_before);
65772ad7d4e1 (mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51788
diff changeset
5497 mark_object (tmp);
65772ad7d4e1 (mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51788
diff changeset
5498 }
65772ad7d4e1 (mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51788
diff changeset
5499 if (buffer->overlays_after)
65772ad7d4e1 (mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51788
diff changeset
5500 {
65772ad7d4e1 (mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51788
diff changeset
5501 XSETMISC (tmp, buffer->overlays_after);
65772ad7d4e1 (mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51788
diff changeset
5502 mark_object (tmp);
65772ad7d4e1 (mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51788
diff changeset
5503 }
65772ad7d4e1 (mark_object): Mark the new `next' field of overlays.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51788
diff changeset
5504
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5505 for (ptr = &buffer->name;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5506 (char *)ptr < (char *)buffer + sizeof (struct buffer);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5507 ptr++)
51770
ad47aa3ee2d7 (mark_object): Change arg to only take Lisp_Object rather than *Lisp_Object.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51758
diff changeset
5508 mark_object (*ptr);
10307
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
5509
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
5510 /* If this is an indirect buffer, mark its base buffer. */
51686
17c015f1f795 (mark_buffer): Fix missed buffer->name in last patch.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51683
diff changeset
5511 if (buffer->base_buffer && !VECTOR_MARKED_P (buffer->base_buffer))
10307
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
5512 {
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
5513 XSETBUFFER (base_buffer, buffer->base_buffer);
10307
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
5514 mark_buffer (base_buffer);
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
5515 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5516 }
10649
52cdd8cc8d3e (mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents: 10581
diff changeset
5517
52cdd8cc8d3e (mark_perdisplays): New function.
Karl Heuer <kwzh@gnu.org>
parents: 10581
diff changeset
5518
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5519 /* 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
5520 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
5521
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5522 int
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5523 survives_gc_p (obj)
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5524 Lisp_Object obj;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5525 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5526 int survives_p;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
5527
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5528 switch (XGCTYPE (obj))
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5529 {
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5530 case Lisp_Int:
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5531 survives_p = 1;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5532 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5533
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5534 case Lisp_Symbol:
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
5535 survives_p = XSYMBOL (obj)->gcmarkbit;
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5536 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5537
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5538 case Lisp_Misc:
51668
0f333fd92a1d (survives_gc_p): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51658
diff changeset
5539 survives_p = XMARKER (obj)->gcmarkbit;
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5540 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5541
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5542 case Lisp_String:
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
5543 survives_p = STRING_MARKED_P (XSTRING (obj));
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5544 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5545
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5546 case Lisp_Vectorlike:
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
5547 survives_p = GC_SUBRP (obj) || VECTOR_MARKED_P (XVECTOR (obj));
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5548 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5549
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5550 case Lisp_Cons:
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
5551 survives_p = CONS_MARKED_P (XCONS (obj));
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5552 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5553
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5554 case Lisp_Float:
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
5555 survives_p = FLOAT_MARKED_P (XFLOAT (obj));
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5556 break;
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5557
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5558 default:
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5559 abort ();
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5560 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5561
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
5562 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
5563 }
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5564
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5565
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5566
1908
d649f2179d67 * alloc.c (make_pure_float): Align pureptr on a sizeof (double)
Jim Blandy <jimb@redhat.com>
parents: 1893
diff changeset
5567 /* Sweep: find all structures not marked, and free them. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5568
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5569 static void
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5570 gc_sweep ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5571 {
55816
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
5572 /* Remove or mark entries in weak hash tables.
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
5573 This must be done before any object is unmarked. */
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
5574 sweep_weak_hash_tables ();
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
5575
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
5576 sweep_strings ();
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
5577 #ifdef GC_CHECK_STRING_BYTES
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
5578 if (!noninteractive)
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
5579 check_string_bytes (1);
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
5580 #endif
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
5581
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5582 /* Put all unmarked conses on free list */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5583 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5584 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
5585 struct cons_block **cprev = &cons_block;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5586 register int lim = cons_block_index;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5587 register int num_free = 0, num_used = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5588
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5589 cons_free_list = 0;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
5590
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5591 for (cblk = cons_block; cblk; cblk = *cprev)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5592 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5593 register int i;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5594 int this_free = 0;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5595 for (i = 0; i < lim; i++)
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
5596 if (!CONS_MARKED_P (&cblk->conses[i]))
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5597 {
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5598 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
5599 *(struct Lisp_Cons **)&cblk->conses[i].cdr = cons_free_list;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5600 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
5601 #if GC_MARK_STACK
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
5602 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
5603 #endif
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5604 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5605 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5606 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5607 num_used++;
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
5608 CONS_UNMARK (&cblk->conses[i]);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5609 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5610 lim = CONS_BLOCK_SIZE;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5611 /* 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
5612 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
5613 this block. */
21379
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5614 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
5615 {
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5616 *cprev = cblk->next;
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5617 /* Unhook from the free list. */
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5618 cons_free_list = *(struct Lisp_Cons **) &cblk->conses[0].cdr;
51938
20d4eb1de9b0 Use bitmaps for cons cells, as was done for floats.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51908
diff changeset
5619 lisp_align_free (cblk);
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
5620 n_cons_blocks--;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5621 }
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5622 else
21379
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5623 {
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5624 num_free += this_free;
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5625 cprev = &cblk->next;
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5626 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5627 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5628 total_conses = num_used;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5629 total_free_conses = num_free;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5630 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5631
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5632 /* Put all unmarked floats on free list */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5633 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5634 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
5635 struct float_block **fprev = &float_block;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5636 register int lim = float_block_index;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5637 register int num_free = 0, num_used = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5638
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5639 float_free_list = 0;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
5640
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5641 for (fblk = float_block; fblk; fblk = *fprev)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5642 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5643 register int i;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5644 int this_free = 0;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5645 for (i = 0; i < lim; i++)
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
5646 if (!FLOAT_MARKED_P (&fblk->floats[i]))
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5647 {
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5648 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
5649 *(struct Lisp_Float **)&fblk->floats[i].data = float_free_list;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5650 float_free_list = &fblk->floats[i];
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5651 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5652 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5653 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5654 num_used++;
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
5655 FLOAT_UNMARK (&fblk->floats[i]);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5656 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5657 lim = FLOAT_BLOCK_SIZE;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5658 /* 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
5659 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
5660 this block. */
21379
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5661 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
5662 {
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5663 *fprev = fblk->next;
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5664 /* Unhook from the free list. */
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5665 float_free_list = *(struct Lisp_Float **) &fblk->floats[0].data;
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
5666 lisp_align_free (fblk);
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
5667 n_float_blocks--;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5668 }
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5669 else
21379
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5670 {
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5671 num_free += this_free;
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5672 fprev = &fblk->next;
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5673 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5674 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5675 total_floats = num_used;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5676 total_free_floats = num_free;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5677 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5678
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5679 /* Put all unmarked intervals on free list */
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5680 {
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5681 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
5682 struct interval_block **iprev = &interval_block;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5683 register int lim = interval_block_index;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5684 register int num_free = 0, num_used = 0;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5685
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5686 interval_free_list = 0;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5687
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5688 for (iblk = interval_block; iblk; iblk = *iprev)
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5689 {
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5690 register int i;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5691 int this_free = 0;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5692
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5693 for (i = 0; i < lim; i++)
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5694 {
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
5695 if (!iblk->intervals[i].gcmarkbit)
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5696 {
28269
fd13be8ae190 Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents: 28220
diff changeset
5697 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
5698 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
5699 this_free++;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5700 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5701 else
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5702 {
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5703 num_used++;
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
5704 iblk->intervals[i].gcmarkbit = 0;
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5705 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5706 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5707 lim = INTERVAL_BLOCK_SIZE;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5708 /* 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
5709 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
5710 deallocate this block. */
21379
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5711 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
5712 {
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5713 *iprev = iblk->next;
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5714 /* Unhook from the free list. */
28269
fd13be8ae190 Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents: 28220
diff changeset
5715 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
5716 lisp_free (iblk);
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
5717 n_interval_blocks--;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5718 }
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5719 else
21379
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5720 {
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5721 num_free += this_free;
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5722 iprev = &iblk->next;
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5723 }
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5724 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5725 total_intervals = num_used;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5726 total_free_intervals = num_free;
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5727 }
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5728
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5729 /* Put all unmarked symbols on free list */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5730 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5731 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
5732 struct symbol_block **sprev = &symbol_block;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5733 register int lim = symbol_block_index;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5734 register int num_free = 0, num_used = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5735
34308
6d490e8ef117 (gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents: 34270
diff changeset
5736 symbol_free_list = NULL;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
5737
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5738 for (sblk = symbol_block; sblk; sblk = *sprev)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5739 {
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5740 int this_free = 0;
34308
6d490e8ef117 (gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents: 34270
diff changeset
5741 struct Lisp_Symbol *sym = sblk->symbols;
6d490e8ef117 (gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents: 34270
diff changeset
5742 struct Lisp_Symbol *end = sym + lim;
6d490e8ef117 (gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents: 34270
diff changeset
5743
6d490e8ef117 (gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents: 34270
diff changeset
5744 for (; sym < end; ++sym)
6d490e8ef117 (gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents: 34270
diff changeset
5745 {
34325
a65d8c29442a (gc_sweep): Add comment.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34308
diff changeset
5746 /* Check if the symbol was created during loadup. In such a case
a65d8c29442a (gc_sweep): Add comment.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34308
diff changeset
5747 it might be pointed to by pure bytecode which we don't trace,
a65d8c29442a (gc_sweep): Add comment.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34308
diff changeset
5748 so we conservatively assume that it is live. */
45392
f3d7ab65641f * alloc.c (Fmake_symbol): Set symbol xname field instead of name.
Ken Raeburn <raeburn@raeburn.org>
parents: 44890
diff changeset
5749 int pure_p = PURE_POINTER_P (XSTRING (sym->xname));
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
5750
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
5751 if (!sym->gcmarkbit && !pure_p)
34308
6d490e8ef117 (gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents: 34270
diff changeset
5752 {
6d490e8ef117 (gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents: 34270
diff changeset
5753 *(struct Lisp_Symbol **) &sym->value = symbol_free_list;
6d490e8ef117 (gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents: 34270
diff changeset
5754 symbol_free_list = sym;
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
5755 #if GC_MARK_STACK
34308
6d490e8ef117 (gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents: 34270
diff changeset
5756 symbol_free_list->function = Vdead;
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
5757 #endif
34308
6d490e8ef117 (gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents: 34270
diff changeset
5758 ++this_free;
6d490e8ef117 (gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents: 34270
diff changeset
5759 }
6d490e8ef117 (gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents: 34270
diff changeset
5760 else
6d490e8ef117 (gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents: 34270
diff changeset
5761 {
6d490e8ef117 (gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents: 34270
diff changeset
5762 ++num_used;
6d490e8ef117 (gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents: 34270
diff changeset
5763 if (!pure_p)
45392
f3d7ab65641f * alloc.c (Fmake_symbol): Set symbol xname field instead of name.
Ken Raeburn <raeburn@raeburn.org>
parents: 44890
diff changeset
5764 UNMARK_STRING (XSTRING (sym->xname));
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
5765 sym->gcmarkbit = 0;
34308
6d490e8ef117 (gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents: 34270
diff changeset
5766 }
6d490e8ef117 (gc_sweep): Prevent symbols read during loadup
Gerd Moellmann <gerd@gnu.org>
parents: 34270
diff changeset
5767 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
5768
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5769 lim = SYMBOL_BLOCK_SIZE;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5770 /* 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
5771 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
5772 this block. */
21379
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5773 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
5774 {
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5775 *sprev = sblk->next;
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5776 /* Unhook from the free list. */
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5777 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
5778 lisp_free (sblk);
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
5779 n_symbol_blocks--;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5780 }
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5781 else
21379
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5782 {
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5783 num_free += this_free;
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5784 sprev = &sblk->next;
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5785 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5786 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5787 total_symbols = num_used;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5788 total_free_symbols = num_free;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5789 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5790
21143
ce12eac1ee45 (gc_sweep, mark_object): Handle new data structure
Richard M. Stallman <rms@gnu.org>
parents: 21084
diff changeset
5791 /* 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
5792 For a marker, first unchain it from the buffer it points into. */
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5793 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5794 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
5795 struct marker_block **mprev = &marker_block;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5796 register int lim = marker_block_index;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5797 register int num_free = 0, num_used = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5798
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5799 marker_free_list = 0;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
5800
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5801 for (mblk = marker_block; mblk; mblk = *mprev)
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5802 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5803 register int i;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5804 int this_free = 0;
11403
bd3241a14d0a (gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents: 11374
diff changeset
5805
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5806 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
5807 {
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
5808 if (!mblk->markers[i].u_marker.gcmarkbit)
9893
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
5809 {
11243
054ecfce1820 (Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents: 11048
diff changeset
5810 if (mblk->markers[i].u_marker.type == Lisp_Misc_Marker)
51668
0f333fd92a1d (survives_gc_p): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51658
diff changeset
5811 unchain_marker (&mblk->markers[i].u_marker);
11403
bd3241a14d0a (gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents: 11374
diff changeset
5812 /* 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
5813 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
5814 but this might catch bugs faster. */
11243
054ecfce1820 (Fmake_marker, mark_object): Use XMISCTYPE.
Richard M. Stallman <rms@gnu.org>
parents: 11048
diff changeset
5815 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
5816 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
5817 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
5818 this_free++;
9893
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
5819 }
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
5820 else
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
5821 {
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
5822 num_used++;
51658
00b3e009b3f5 (make_interval, Fmake_symbol, allocate_misc):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51578
diff changeset
5823 mblk->markers[i].u_marker.gcmarkbit = 0;
9893
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
5824 }
8421d09f2afe (mark_object): New code to handle buffer-local substructure.
Karl Heuer <kwzh@gnu.org>
parents: 9463
diff changeset
5825 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5826 lim = MARKER_BLOCK_SIZE;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5827 /* 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
5828 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
5829 this block. */
21379
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5830 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
5831 {
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5832 *mprev = mblk->next;
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5833 /* Unhook from the free list. */
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5834 marker_free_list = mblk->markers[0].u_free.chain;
55816
a4fe04f4d9c2 Undo Kim's recent changes and fix the same bug differently.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55798
diff changeset
5835 lisp_free (mblk);
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
5836 n_marker_blocks--;
20057
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5837 }
612cd201aea5 (gc_sweep): Free memory blocks that contain only unused
Karl Heuer <kwzh@gnu.org>
parents: 19666
diff changeset
5838 else
21379
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5839 {
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5840 num_free += this_free;
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5841 mprev = &mblk->next;
1701bf5b9dec (gc_sweep): Avoid using two loop variables counting the
Andreas Schwab <schwab@suse.de>
parents: 21306
diff changeset
5842 }
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5843 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5844
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5845 total_markers = num_used;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5846 total_free_markers = num_free;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5847 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5848
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5849 /* Free all unmarked buffers */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5850 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5851 register struct buffer *buffer = all_buffers, *prev = 0, *next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5852
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5853 while (buffer)
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5854 if (!VECTOR_MARKED_P (buffer))
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5855 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5856 if (prev)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5857 prev->next = buffer->next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5858 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5859 all_buffers = buffer->next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5860 next = buffer->next;
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
5861 lisp_free (buffer);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5862 buffer = next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5863 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5864 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5865 {
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5866 VECTOR_UNMARK (buffer);
10307
e6e75fd0916d (mark_buffer, gc_sweep): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents: 10291
diff changeset
5867 UNMARK_BALANCE_INTERVALS (BUF_INTERVALS (buffer));
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5868 prev = buffer, buffer = buffer->next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5869 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5870 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5871
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5872 /* Free all unmarked vectors */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5873 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5874 register struct Lisp_Vector *vector = all_vectors, *prev = 0, *next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5875 total_vector_size = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5876
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5877 while (vector)
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5878 if (!VECTOR_MARKED_P (vector))
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5879 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5880 if (prev)
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5881 prev->next = vector->next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5882 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5883 all_vectors = vector->next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5884 next = vector->next;
23958
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
5885 lisp_free (vector);
7094b74ce0a6 (lisp_malloc, lisp_free): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 23534
diff changeset
5886 n_vectors--;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5887 vector = next;
25024
3bb745067f0e (gc_sweep): Call sweep_weak_hash_tables.
Gerd Moellmann <gerd@gnu.org>
parents: 23973
diff changeset
5888
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5889 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5890 else
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5891 {
51683
fb960854a12c (VECTOR_MARK, VECTOR_UNMARK, VECTOR_MARKED_P): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51668
diff changeset
5892 VECTOR_UNMARK (vector);
11403
bd3241a14d0a (gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents: 11374
diff changeset
5893 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
5894 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
5895 else
bd3241a14d0a (gc_sweep): If a misc has type Lisp_Misc_Free,
Richard M. Stallman <rms@gnu.org>
parents: 11374
diff changeset
5896 total_vector_size += vector->size;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5897 prev = vector, vector = vector->next;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5898 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5899 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49529
diff changeset
5900
35183
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
5901 #ifdef GC_CHECK_STRING_BYTES
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
5902 if (!noninteractive)
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
5903 check_string_bytes (1);
cc2a06489f0d (CHECK_STRING_BYTES) [GC_CHECK_STRING_BYTES]: New macro.
Gerd Moellmann <gerd@gnu.org>
parents: 35170
diff changeset
5904 #endif
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5905 }
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
5906
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
5907
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
5908
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5909
1327
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
5910 /* Debugging aids. */
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
5911
5353
6389ed5b45ac (Fmemory_limit): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 4956
diff changeset
5912 DEFUN ("memory-limit", Fmemory_limit, Smemory_limit, 0, 0, 0,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
5913 doc: /* Return the address of the last byte Emacs has allocated, divided by 1024.
39914
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
5914 This may be helpful in debugging Emacs's memory usage.
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
5915 We divide the value by 1024 to make sure it fits in a Lisp integer. */)
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
5916 ()
1327
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
5917 {
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
5918 Lisp_Object end;
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
5919
9261
e5ba7993d378 (VALIDATE_LISP_STORAGE, make_float, Fcons, Fmake_vector, Fmake_symbol,
Karl Heuer <kwzh@gnu.org>
parents: 9144
diff changeset
5920 XSETINT (end, (EMACS_INT) sbrk (0) / 1024);
1327
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
5921
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
5922 return end;
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
5923 }
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
5924
12748
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
5925 DEFUN ("memory-use-counts", Fmemory_use_counts, Smemory_use_counts, 0, 0, 0,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
5926 doc: /* Return a list of counters that measure how much consing there has been.
39914
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
5927 Each of these counters increments for a certain kind of object.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
5928 The counters wrap around from the largest positive integer to zero.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
5929 Garbage collection does not decrease them.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
5930 The elements of the value are as follows:
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
5931 (CONSES FLOATS VECTOR-CELLS SYMBOLS STRING-CHARS MISCS INTERVALS STRINGS)
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
5932 All are in units of 1 = one object consed
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
5933 except for VECTOR-CELLS and STRING-CHARS, which count the total length of
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
5934 objects consed.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
5935 MISCS include overlays, markers, and some internal types.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
5936 Frames, windows, buffers, and subprocesses count as vectors
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
5937 (but the contents of a buffer's text do not count here). */)
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
5938 ()
12748
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
5939 {
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
5940 Lisp_Object consed[8];
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
5941
39633
a0bf0cb8ff3e (inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents: 39572
diff changeset
5942 consed[0] = make_number (min (MOST_POSITIVE_FIXNUM, cons_cells_consed));
a0bf0cb8ff3e (inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents: 39572
diff changeset
5943 consed[1] = make_number (min (MOST_POSITIVE_FIXNUM, floats_consed));
a0bf0cb8ff3e (inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents: 39572
diff changeset
5944 consed[2] = make_number (min (MOST_POSITIVE_FIXNUM, vector_cells_consed));
a0bf0cb8ff3e (inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents: 39572
diff changeset
5945 consed[3] = make_number (min (MOST_POSITIVE_FIXNUM, symbols_consed));
a0bf0cb8ff3e (inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents: 39572
diff changeset
5946 consed[4] = make_number (min (MOST_POSITIVE_FIXNUM, string_chars_consed));
a0bf0cb8ff3e (inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents: 39572
diff changeset
5947 consed[5] = make_number (min (MOST_POSITIVE_FIXNUM, misc_objects_consed));
a0bf0cb8ff3e (inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents: 39572
diff changeset
5948 consed[6] = make_number (min (MOST_POSITIVE_FIXNUM, intervals_consed));
a0bf0cb8ff3e (inhibit_garbage_collection): Simplify.
Gerd Moellmann <gerd@gnu.org>
parents: 39572
diff changeset
5949 consed[7] = make_number (min (MOST_POSITIVE_FIXNUM, strings_consed));
27142
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
5950
f742c86fcc15 (Fgarbage_collect): Return number of live and free
Gerd Moellmann <gerd@gnu.org>
parents: 27006
diff changeset
5951 return Flist (8, consed);
12748
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
5952 }
28406
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
5953
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
5954 int suppress_checking;
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
5955 void
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
5956 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
5957 const char *msg;
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
5958 const char *file;
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
5959 int line;
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
5960 {
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
5961 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
5962 file, line, msg);
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
5963 abort ();
451721e784a8 Stop assuming interval pointers and lisp objects can be distinguished by
Ken Raeburn <raeburn@raeburn.org>
parents: 28374
diff changeset
5964 }
1327
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
5965
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5966 /* Initialization */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5967
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21379
diff changeset
5968 void
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5969 init_alloc_once ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5970 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5971 /* Used to do Vpurify_flag = Qt here, but Qt isn't set up yet! */
39572
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
5972 purebeg = PUREBEG;
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
5973 pure_size = PURESIZE;
32594
e0646c73bf81 (pure_bytes_used): Renamed from pureptr.
Gerd Moellmann <gerd@gnu.org>
parents: 32587
diff changeset
5974 pure_bytes_used = 0;
39572
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
5975 pure_bytes_used_before_overflow = 0;
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
5976
51723
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
5977 /* Initialize the list of free aligned blocks. */
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
5978 free_ablock = NULL;
635066222916 (ALIGN): Add casts to simplify usage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51686
diff changeset
5979
32692
0343fe9ef3ac (toplevel) [SYSTEM_MALLOC || DOUG_LEA_MALLOC]: Undef
Gerd Moellmann <gerd@gnu.org>
parents: 32609
diff changeset
5980 #if GC_MARK_STACK || defined GC_MALLOC_CHECK
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
5981 mem_init ();
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
5982 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
5983 #endif
39572
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
5984
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5985 all_vectors = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5986 ignore_warnings = 1;
17345
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
5987 #ifdef DOUG_LEA_MALLOC
4e11e27ce1f1 For glibc's malloc, include <malloc.h> for mallinfo,
Richard M. Stallman <rms@gnu.org>
parents: 17328
diff changeset
5988 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
5989 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
5990 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
5991 #endif
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5992 init_strings ();
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5993 init_cons ();
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5994 init_symbol ();
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5995 init_marker ();
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5996 init_float ();
27738
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
5997 init_intervals ();
1300
b13b79e28eb5 * alloc.c: #include "intervals.h".
Joseph Arceneaux <jla@gnu.org>
parents: 1295
diff changeset
5998
10673
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
5999 #ifdef REL_ALLOC
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
6000 malloc_hysteresis = 32;
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
6001 #else
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
6002 malloc_hysteresis = 0;
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
6003 #endif
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
6004
337c3a4d5fef (emacs_blocked_malloc): Set __malloc_extra_blocks here.
Richard M. Stallman <rms@gnu.org>
parents: 10649
diff changeset
6005 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
6006
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6007 ignore_warnings = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6008 gcprolist = 0;
26364
7b0217d9259c (Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents: 26164
diff changeset
6009 byte_stack_list = 0;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6010 staticidx = 0;
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6011 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
6012 gc_cons_threshold = 100000 * sizeof (Lisp_Object);
64611
47f158dcf216 (gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents: 64273
diff changeset
6013 gc_relative_threshold = 0;
47f158dcf216 (gc_cons_threshold): Not static.
Richard M. Stallman <rms@gnu.org>
parents: 64273
diff changeset
6014
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6015 #ifdef VIRT_ADDR_VARIES
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6016 malloc_sbrk_unused = 1<<22; /* A large number */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6017 malloc_sbrk_used = 100000; /* as reasonable as any number */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6018 #endif /* VIRT_ADDR_VARIES */
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6019 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6020
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21379
diff changeset
6021 void
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6022 init_alloc ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6023 {
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6024 gcprolist = 0;
26364
7b0217d9259c (Fgarbage_collect): Call mark_byte_stack and
Gerd Moellmann <gerd@gnu.org>
parents: 26164
diff changeset
6025 byte_stack_list = 0;
28365
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
6026 #if GC_MARK_STACK
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
6027 #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
6028 setjmp_tested_p = longjmps_done = 0;
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
6029 #endif
a72abbd8dc16 (mark_maybe_object): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28269
diff changeset
6030 #endif
49529
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
6031 Vgc_elapsed = make_float (0.0);
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
6032 gcs_done = 0;
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6033 }
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6034
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6035 void
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6036 syms_of_alloc ()
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6037 {
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6038 DEFVAR_INT ("gc-cons-threshold", &gc_cons_threshold,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
6039 doc: /* *Number of bytes of consing between garbage collections.
39914
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
6040 Garbage collection can happen automatically once this many bytes have been
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
6041 allocated since the last garbage collection. All data types count.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
6042
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
6043 Garbage collection happens automatically only when `eval' is called.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
6044
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
6045 By binding this temporarily to a large number, you can effectively
64267
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
6046 prevent garbage collection during a part of the program.
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
6047 See also `gc-cons-percentage'. */);
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
6048
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
6049 DEFVAR_LISP ("gc-cons-percentage", &Vgc_cons_percentage,
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
6050 doc: /* *Portion of the heap used for allocation.
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
6051 Garbage collection can happen automatically once this portion of the heap
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
6052 has been allocated since the last garbage collection.
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
6053 If this portion is smaller than `gc-cons-threshold', this is ignored. */);
5c7cbbd6dbb4 (gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64084
diff changeset
6054 Vgc_cons_percentage = make_float (0.1);
39914
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
6055
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6056 DEFVAR_INT ("pure-bytes-used", &pure_bytes_used,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
6057 doc: /* Number of bytes of sharable Lisp data allocated so far. */);
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6058
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6059 DEFVAR_INT ("cons-cells-consed", &cons_cells_consed,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
6060 doc: /* Number of cons cells that have been consed so far. */);
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6061
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6062 DEFVAR_INT ("floats-consed", &floats_consed,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
6063 doc: /* Number of floats that have been consed so far. */);
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6064
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6065 DEFVAR_INT ("vector-cells-consed", &vector_cells_consed,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
6066 doc: /* Number of vector cells that have been consed so far. */);
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6067
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6068 DEFVAR_INT ("symbols-consed", &symbols_consed,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
6069 doc: /* Number of symbols that have been consed so far. */);
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6070
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6071 DEFVAR_INT ("string-chars-consed", &string_chars_consed,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
6072 doc: /* Number of string characters that have been consed so far. */);
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6073
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6074 DEFVAR_INT ("misc-objects-consed", &misc_objects_consed,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
6075 doc: /* Number of miscellaneous objects that have been consed so far. */);
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6076
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6077 DEFVAR_INT ("intervals-consed", &intervals_consed,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
6078 doc: /* Number of intervals that have been consed so far. */);
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6079
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6080 DEFVAR_INT ("strings-consed", &strings_consed,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
6081 doc: /* Number of strings that have been consed so far. */);
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6082
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6083 DEFVAR_LISP ("purify-flag", &Vpurify_flag,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
6084 doc: /* Non-nil means loading Lisp code in order to dump an executable.
39914
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
6085 This means that certain objects should be allocated in shared (pure) space. */);
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39859
diff changeset
6086
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6087 DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
6088 doc: /* Non-nil means display messages at start and end of garbage collection. */);
14959
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
6089 garbage_collection_messages = 0;
f2b5d784fa88 (garbage_collection_messages): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14764
diff changeset
6090
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
6091 DEFVAR_LISP ("post-gc-hook", &Vpost_gc_hook,
40107
d3cc7dd5d75a Reindent DEFUNs with doc: keywords.
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
6092 doc: /* Hook run after garbage collection has finished. */);
39572
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
6093 Vpost_gc_hook = Qnil;
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
6094 Qpost_gc_hook = intern ("post-gc-hook");
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
6095 staticpro (&Qpost_gc_hook);
715a67381594 (purebeg, pure_size, pure_bytes_used_before_overflow):
Gerd Moellmann <gerd@gnu.org>
parents: 39297
diff changeset
6096
46305
fed6b815dbeb (Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 46293
diff changeset
6097 DEFVAR_LISP ("memory-signal-data", &Vmemory_signal_data,
fed6b815dbeb (Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 46293
diff changeset
6098 doc: /* Precomputed `signal' argument for memory-full error. */);
6116
64417bbbb128 (memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents: 5874
diff changeset
6099 /* 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
6100 not be able to allocate the memory to hold it. */
46305
fed6b815dbeb (Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 46293
diff changeset
6101 Vmemory_signal_data
fed6b815dbeb (Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 46293
diff changeset
6102 = list2 (Qerror,
fed6b815dbeb (Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 46293
diff changeset
6103 build_string ("Memory exhausted--use M-x save-some-buffers then exit and restart Emacs"));
fed6b815dbeb (Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 46293
diff changeset
6104
fed6b815dbeb (Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 46293
diff changeset
6105 DEFVAR_LISP ("memory-full", &Vmemory_full,
fed6b815dbeb (Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 46293
diff changeset
6106 doc: /* Non-nil means we are handling a memory-full error. */);
fed6b815dbeb (Vmemory_full): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 46293
diff changeset
6107 Vmemory_full = Qnil;
6116
64417bbbb128 (memory_full): Use new variable memory_signal_data with precomputed value
Karl Heuer <kwzh@gnu.org>
parents: 5874
diff changeset
6108
11374
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
6109 staticpro (&Qgc_cons_threshold);
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
6110 Qgc_cons_threshold = intern ("gc-cons-threshold");
1ebc81f84aa4 (inhibit_garbage_collection): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11341
diff changeset
6111
13219
99b5164a319d (Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13150
diff changeset
6112 staticpro (&Qchar_table_extra_slots);
99b5164a319d (Qchar_table_extra_slots): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13150
diff changeset
6113 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
6114
49529
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
6115 DEFVAR_LISP ("gc-elapsed", &Vgc_elapsed,
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
6116 doc: /* Accumulated time elapsed in garbage collections.
51974
111cc76606c6 (syms_of_alloc): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 51938
diff changeset
6117 The time is in seconds as a floating point value. */);
49529
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
6118 DEFVAR_INT ("gcs-done", &gcs_done,
51974
111cc76606c6 (syms_of_alloc): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 51938
diff changeset
6119 doc: /* Accumulated number of garbage collections done. */);
49529
fd79b3081e01 (Vgc_elapsed, gcs_done): New variables.
Dave Love <fx@gnu.org>
parents: 49414
diff changeset
6120
62335
401714f3f9de (Fmemory_full_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 61685
diff changeset
6121 defsubr (&Smemory_full_p);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6122 defsubr (&Scons);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6123 defsubr (&Slist);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6124 defsubr (&Svector);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6125 defsubr (&Smake_byte_code);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6126 defsubr (&Smake_list);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6127 defsubr (&Smake_vector);
13141
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
6128 defsubr (&Smake_char_table);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6129 defsubr (&Smake_string);
13141
4a4d1d8e89e5 (Fmake_chartable, Fmake_boolvector): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 13008
diff changeset
6130 defsubr (&Smake_bool_vector);
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6131 defsubr (&Smake_symbol);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6132 defsubr (&Smake_marker);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6133 defsubr (&Spurecopy);
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6134 defsubr (&Sgarbage_collect);
1327
ef16e7c0d402 * alloc.c (Fmemory_limit): New function.
Jim Blandy <jimb@redhat.com>
parents: 1318
diff changeset
6135 defsubr (&Smemory_limit);
12748
3433bb446e06 (cons_cells_consed, floats_consed, vector_cells_consed)
Richard M. Stallman <rms@gnu.org>
parents: 12605
diff changeset
6136 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
6137
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
6138 #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
6139 defsubr (&Sgc_status);
581c76c41ca4 (mark_object): Don't mark symbol names in pure space.
Gerd Moellmann <gerd@gnu.org>
parents: 27727
diff changeset
6140 #endif
300
4ee2046fcb72 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6141 }
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 52276
diff changeset
6142
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 52276
diff changeset
6143 /* arch-tag: 6695ca10-e3c5-4c2c-8bc3-ed26a7dda857
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 52276
diff changeset
6144 (do not change this comment) */