aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c81
1 files changed, 22 insertions, 59 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 59d8f887c05..796de9354a6 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -161,31 +161,17 @@ static __malloc_size_t bytes_used_when_full;
161#define GC_STRING_BYTES(S) (STRING_BYTES (S)) 161#define GC_STRING_BYTES(S) (STRING_BYTES (S))
162#define GC_STRING_CHARS(S) ((S)->size & ~ARRAY_MARK_FLAG) 162#define GC_STRING_CHARS(S) ((S)->size & ~ARRAY_MARK_FLAG)
163 163
164/* Global variables. */
165struct emacs_globals globals;
166
164/* Number of bytes of consing done since the last gc. */ 167/* Number of bytes of consing done since the last gc. */
165 168
166int consing_since_gc; 169int consing_since_gc;
167 170
168/* Count the amount of consing of various sorts of space. */
169
170EMACS_INT cons_cells_consed;
171EMACS_INT floats_consed;
172EMACS_INT vector_cells_consed;
173EMACS_INT symbols_consed;
174EMACS_INT string_chars_consed;
175EMACS_INT misc_objects_consed;
176EMACS_INT intervals_consed;
177EMACS_INT strings_consed;
178
179/* Minimum number of bytes of consing since GC before next GC. */
180
181EMACS_INT gc_cons_threshold;
182
183/* Similar minimum, computed from Vgc_cons_percentage. */ 171/* Similar minimum, computed from Vgc_cons_percentage. */
184 172
185EMACS_INT gc_relative_threshold; 173EMACS_INT gc_relative_threshold;
186 174
187static Lisp_Object Vgc_cons_percentage;
188
189/* Minimum number of bytes of consing since GC before next GC, 175/* Minimum number of bytes of consing since GC before next GC,
190 when memory is full. */ 176 when memory is full. */
191 177
@@ -201,10 +187,6 @@ int gc_in_progress;
201 187
202int abort_on_gc; 188int abort_on_gc;
203 189
204/* Nonzero means display messages at beginning and end of GC. */
205
206int garbage_collection_messages;
207
208/* Number of live and free conses etc. */ 190/* Number of live and free conses etc. */
209 191
210static int total_conses, total_markers, total_symbols, total_vector_size; 192static int total_conses, total_markers, total_symbols, total_vector_size;
@@ -225,14 +207,6 @@ static char *spare_memory[7];
225 207
226static int malloc_hysteresis; 208static int malloc_hysteresis;
227 209
228/* Non-nil means defun should do purecopy on the function definition. */
229
230Lisp_Object Vpurify_flag;
231
232/* Non-nil means we are handling a memory-full error. */
233
234Lisp_Object Vmemory_full;
235
236/* Initialize it to a nonzero value to force it into data space 210/* Initialize it to a nonzero value to force it into data space
237 (rather than bss space). That way unexec will remap it into text 211 (rather than bss space). That way unexec will remap it into text
238 space (pure), on some systems. We have not implemented the 212 space (pure), on some systems. We have not implemented the
@@ -260,10 +234,6 @@ static size_t pure_bytes_used_before_overflow;
260 && ((PNTR_COMPARISON_TYPE) (P) \ 234 && ((PNTR_COMPARISON_TYPE) (P) \
261 >= (PNTR_COMPARISON_TYPE) purebeg)) 235 >= (PNTR_COMPARISON_TYPE) purebeg))
262 236
263/* Total number of bytes allocated in pure storage. */
264
265EMACS_INT pure_bytes_used;
266
267/* Index in pure at which next pure Lisp object will be allocated.. */ 237/* Index in pure at which next pure Lisp object will be allocated.. */
268 238
269static EMACS_INT pure_bytes_used_lisp; 239static EMACS_INT pure_bytes_used_lisp;
@@ -277,10 +247,6 @@ static EMACS_INT pure_bytes_used_non_lisp;
277 247
278const char *pending_malloc_warning; 248const char *pending_malloc_warning;
279 249
280/* Pre-computed signal argument for use when memory is exhausted. */
281
282Lisp_Object Vmemory_signal_data;
283
284/* Maximum amount of C stack to save when a GC happens. */ 250/* Maximum amount of C stack to save when a GC happens. */
285 251
286#ifndef MAX_SAVE_STACK 252#ifndef MAX_SAVE_STACK
@@ -301,10 +267,7 @@ Lisp_Object Qgc_cons_threshold, Qchar_table_extra_slots;
301 267
302/* Hook run after GC has finished. */ 268/* Hook run after GC has finished. */
303 269
304Lisp_Object Vpost_gc_hook, Qpost_gc_hook; 270Lisp_Object Qpost_gc_hook;
305
306Lisp_Object Vgc_elapsed; /* accumulated elapsed time in GC */
307EMACS_INT gcs_done; /* accumulated GCs */
308 271
309static void mark_buffer (Lisp_Object); 272static void mark_buffer (Lisp_Object);
310static void mark_terminals (void); 273static void mark_terminals (void);
@@ -6210,7 +6173,7 @@ init_alloc (void)
6210void 6173void
6211syms_of_alloc (void) 6174syms_of_alloc (void)
6212{ 6175{
6213 DEFVAR_INT ("gc-cons-threshold", &gc_cons_threshold, 6176 DEFVAR_INT ("gc-cons-threshold", gc_cons_threshold,
6214 doc: /* *Number of bytes of consing between garbage collections. 6177 doc: /* *Number of bytes of consing between garbage collections.
6215Garbage collection can happen automatically once this many bytes have been 6178Garbage collection can happen automatically once this many bytes have been
6216allocated since the last garbage collection. All data types count. 6179allocated since the last garbage collection. All data types count.
@@ -6221,57 +6184,57 @@ By binding this temporarily to a large number, you can effectively
6221prevent garbage collection during a part of the program. 6184prevent garbage collection during a part of the program.
6222See also `gc-cons-percentage'. */); 6185See also `gc-cons-percentage'. */);
6223 6186
6224 DEFVAR_LISP ("gc-cons-percentage", &Vgc_cons_percentage, 6187 DEFVAR_LISP ("gc-cons-percentage", Vgc_cons_percentage,
6225 doc: /* *Portion of the heap used for allocation. 6188 doc: /* *Portion of the heap used for allocation.
6226Garbage collection can happen automatically once this portion of the heap 6189Garbage collection can happen automatically once this portion of the heap
6227has been allocated since the last garbage collection. 6190has been allocated since the last garbage collection.
6228If this portion is smaller than `gc-cons-threshold', this is ignored. */); 6191If this portion is smaller than `gc-cons-threshold', this is ignored. */);
6229 Vgc_cons_percentage = make_float (0.1); 6192 Vgc_cons_percentage = make_float (0.1);
6230 6193
6231 DEFVAR_INT ("pure-bytes-used", &pure_bytes_used, 6194 DEFVAR_INT ("pure-bytes-used", pure_bytes_used,
6232 doc: /* Number of bytes of sharable Lisp data allocated so far. */); 6195 doc: /* Number of bytes of sharable Lisp data allocated so far. */);
6233 6196
6234 DEFVAR_INT ("cons-cells-consed", &cons_cells_consed, 6197 DEFVAR_INT ("cons-cells-consed", cons_cells_consed,
6235 doc: /* Number of cons cells that have been consed so far. */); 6198 doc: /* Number of cons cells that have been consed so far. */);
6236 6199
6237 DEFVAR_INT ("floats-consed", &floats_consed, 6200 DEFVAR_INT ("floats-consed", floats_consed,
6238 doc: /* Number of floats that have been consed so far. */); 6201 doc: /* Number of floats that have been consed so far. */);
6239 6202
6240 DEFVAR_INT ("vector-cells-consed", &vector_cells_consed, 6203 DEFVAR_INT ("vector-cells-consed", vector_cells_consed,
6241 doc: /* Number of vector cells that have been consed so far. */); 6204 doc: /* Number of vector cells that have been consed so far. */);
6242 6205
6243 DEFVAR_INT ("symbols-consed", &symbols_consed, 6206 DEFVAR_INT ("symbols-consed", symbols_consed,
6244 doc: /* Number of symbols that have been consed so far. */); 6207 doc: /* Number of symbols that have been consed so far. */);
6245 6208
6246 DEFVAR_INT ("string-chars-consed", &string_chars_consed, 6209 DEFVAR_INT ("string-chars-consed", string_chars_consed,
6247 doc: /* Number of string characters that have been consed so far. */); 6210 doc: /* Number of string characters that have been consed so far. */);
6248 6211
6249 DEFVAR_INT ("misc-objects-consed", &misc_objects_consed, 6212 DEFVAR_INT ("misc-objects-consed", misc_objects_consed,
6250 doc: /* Number of miscellaneous objects that have been consed so far. */); 6213 doc: /* Number of miscellaneous objects that have been consed so far. */);
6251 6214
6252 DEFVAR_INT ("intervals-consed", &intervals_consed, 6215 DEFVAR_INT ("intervals-consed", intervals_consed,
6253 doc: /* Number of intervals that have been consed so far. */); 6216 doc: /* Number of intervals that have been consed so far. */);
6254 6217
6255 DEFVAR_INT ("strings-consed", &strings_consed, 6218 DEFVAR_INT ("strings-consed", strings_consed,
6256 doc: /* Number of strings that have been consed so far. */); 6219 doc: /* Number of strings that have been consed so far. */);
6257 6220
6258 DEFVAR_LISP ("purify-flag", &Vpurify_flag, 6221 DEFVAR_LISP ("purify-flag", Vpurify_flag,
6259 doc: /* Non-nil means loading Lisp code in order to dump an executable. 6222 doc: /* Non-nil means loading Lisp code in order to dump an executable.
6260This means that certain objects should be allocated in shared (pure) space. 6223This means that certain objects should be allocated in shared (pure) space.
6261It can also be set to a hash-table, in which case this table is used to 6224It can also be set to a hash-table, in which case this table is used to
6262do hash-consing of the objects allocated to pure space. */); 6225do hash-consing of the objects allocated to pure space. */);
6263 6226
6264 DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages, 6227 DEFVAR_BOOL ("garbage-collection-messages", garbage_collection_messages,
6265 doc: /* Non-nil means display messages at start and end of garbage collection. */); 6228 doc: /* Non-nil means display messages at start and end of garbage collection. */);
6266 garbage_collection_messages = 0; 6229 garbage_collection_messages = 0;
6267 6230
6268 DEFVAR_LISP ("post-gc-hook", &Vpost_gc_hook, 6231 DEFVAR_LISP ("post-gc-hook", Vpost_gc_hook,
6269 doc: /* Hook run after garbage collection has finished. */); 6232 doc: /* Hook run after garbage collection has finished. */);
6270 Vpost_gc_hook = Qnil; 6233 Vpost_gc_hook = Qnil;
6271 Qpost_gc_hook = intern_c_string ("post-gc-hook"); 6234 Qpost_gc_hook = intern_c_string ("post-gc-hook");
6272 staticpro (&Qpost_gc_hook); 6235 staticpro (&Qpost_gc_hook);
6273 6236
6274 DEFVAR_LISP ("memory-signal-data", &Vmemory_signal_data, 6237 DEFVAR_LISP ("memory-signal-data", Vmemory_signal_data,
6275 doc: /* Precomputed `signal' argument for memory-full error. */); 6238 doc: /* Precomputed `signal' argument for memory-full error. */);
6276 /* We build this in advance because if we wait until we need it, we might 6239 /* We build this in advance because if we wait until we need it, we might
6277 not be able to allocate the memory to hold it. */ 6240 not be able to allocate the memory to hold it. */
@@ -6279,7 +6242,7 @@ do hash-consing of the objects allocated to pure space. */);
6279 = pure_cons (Qerror, 6242 = pure_cons (Qerror,
6280 pure_cons (make_pure_c_string ("Memory exhausted--use M-x save-some-buffers then exit and restart Emacs"), Qnil)); 6243 pure_cons (make_pure_c_string ("Memory exhausted--use M-x save-some-buffers then exit and restart Emacs"), Qnil));
6281 6244
6282 DEFVAR_LISP ("memory-full", &Vmemory_full, 6245 DEFVAR_LISP ("memory-full", Vmemory_full,
6283 doc: /* Non-nil means Emacs cannot get much more Lisp memory. */); 6246 doc: /* Non-nil means Emacs cannot get much more Lisp memory. */);
6284 Vmemory_full = Qnil; 6247 Vmemory_full = Qnil;
6285 6248
@@ -6289,10 +6252,10 @@ do hash-consing of the objects allocated to pure space. */);
6289 staticpro (&Qchar_table_extra_slots); 6252 staticpro (&Qchar_table_extra_slots);
6290 Qchar_table_extra_slots = intern_c_string ("char-table-extra-slots"); 6253 Qchar_table_extra_slots = intern_c_string ("char-table-extra-slots");
6291 6254
6292 DEFVAR_LISP ("gc-elapsed", &Vgc_elapsed, 6255 DEFVAR_LISP ("gc-elapsed", Vgc_elapsed,
6293 doc: /* Accumulated time elapsed in garbage collections. 6256 doc: /* Accumulated time elapsed in garbage collections.
6294The time is in seconds as a floating point value. */); 6257The time is in seconds as a floating point value. */);
6295 DEFVAR_INT ("gcs-done", &gcs_done, 6258 DEFVAR_INT ("gcs-done", gcs_done,
6296 doc: /* Accumulated number of garbage collections done. */); 6259 doc: /* Accumulated number of garbage collections done. */);
6297 6260
6298 defsubr (&Scons); 6261 defsubr (&Scons);