From 03bb6a06e1af95f7540a3f11a92dbefea0894804 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Sun, 7 Sep 2003 19:15:51 +0000 Subject: Use long instead of int when casting ABLOCKS_BUSY to avoid warning. --- src/alloc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index f73edcd70e9..332e63c4fd2 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -711,7 +711,7 @@ struct ablocks #define ABLOCKS_BASE(abase) (abase) #else #define ABLOCKS_BASE(abase) \ - (1 & (int) ABLOCKS_BUSY (abase) ? abase : ((void**)abase)[-1]) + (1 & (long) ABLOCKS_BUSY (abase) ? abase : ((void**)abase)[-1]) #endif /* The list of free ablock. */ @@ -792,17 +792,17 @@ lisp_align_malloc (nbytes, type) abase->blocks[i].x.next_free = free_ablock; free_ablock = &abase->blocks[i]; } - ABLOCKS_BUSY (abase) = (struct ablocks *) aligned; + ABLOCKS_BUSY (abase) = (struct ablocks *) (long) aligned; eassert (0 == ((EMACS_UINT)abase) % BLOCK_ALIGN); eassert (ABLOCK_ABASE (&abase->blocks[3]) == abase); /* 3 is arbitrary */ eassert (ABLOCK_ABASE (&abase->blocks[0]) == abase); eassert (ABLOCKS_BASE (abase) == base); - eassert (aligned == (int)ABLOCKS_BUSY (abase)); + eassert (aligned == (long) ABLOCKS_BUSY (abase)); } abase = ABLOCK_ABASE (free_ablock); - ABLOCKS_BUSY (abase) = (struct ablocks *) (2 + (int) ABLOCKS_BUSY (abase)); + ABLOCKS_BUSY (abase) = (struct ablocks *) (2 + (long) ABLOCKS_BUSY (abase)); val = free_ablock; free_ablock = free_ablock->x.next_free; @@ -834,11 +834,11 @@ lisp_align_free (block) ablock->x.next_free = free_ablock; free_ablock = ablock; /* Update busy count. */ - ABLOCKS_BUSY (abase) = (struct ablocks *) (-2 + (int) ABLOCKS_BUSY (abase)); + ABLOCKS_BUSY (abase) = (struct ablocks *) (-2 + (long) ABLOCKS_BUSY (abase)); - if (2 > (int) ABLOCKS_BUSY (abase)) + if (2 > (long) ABLOCKS_BUSY (abase)) { /* All the blocks are free. */ - int i = 0, aligned = (int) ABLOCKS_BUSY (abase); + int i = 0, aligned = (long) ABLOCKS_BUSY (abase); struct ablock **tem = &free_ablock; struct ablock *atop = &abase->blocks[aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1]; -- cgit v1.2.1 From 0930c1a1c8ac9398e71fd8e9ed7efb93dc41125f Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 11 Sep 2003 22:22:11 +0000 Subject: (init_intervals, init_symbol, init_marker): Don't preallocate anything. (Fgarbage_collect, mark_object): Ignore the markbit. --- src/alloc.c | 70 +++++++++++++------------------------------------------------ 1 file changed, 15 insertions(+), 55 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 332e63c4fd2..2c63c1cd07e 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1131,14 +1131,10 @@ int n_interval_blocks; static void init_intervals () { - interval_block - = (struct interval_block *) lisp_malloc (sizeof *interval_block, - MEM_TYPE_NON_LISP); - interval_block->next = 0; - bzero ((char *) interval_block->intervals, sizeof interval_block->intervals); - interval_block_index = 0; + interval_block = NULL; + interval_block_index = INTERVAL_BLOCK_SIZE; interval_free_list = 0; - n_interval_blocks = 1; + n_interval_blocks = 0; } @@ -2768,13 +2764,10 @@ int n_symbol_blocks; void init_symbol () { - symbol_block = (struct symbol_block *) lisp_malloc (sizeof *symbol_block, - MEM_TYPE_SYMBOL); - symbol_block->next = 0; - bzero ((char *) symbol_block->symbols, sizeof symbol_block->symbols); - symbol_block_index = 0; + symbol_block = NULL; + symbol_block_index = SYMBOL_BLOCK_SIZE; symbol_free_list = 0; - n_symbol_blocks = 1; + n_symbol_blocks = 0; } @@ -2854,13 +2847,11 @@ int n_marker_blocks; void init_marker () { - marker_block = (struct marker_block *) lisp_malloc (sizeof *marker_block, - MEM_TYPE_MISC); - marker_block->next = 0; - bzero ((char *) marker_block->markers, sizeof marker_block->markers); - marker_block_index = 0; + marker_block = NULL; + marker_block_index = MARKER_BLOCK_SIZE; marker_free_list = 0; - n_marker_blocks = 1; + n_marker_blocks = 0; + fprintf(stderr, "union Lisp_Misc = %d\n", sizeof (union Lisp_Misc)); } /* Return a newly allocated Lisp_Misc object, with no substructure. */ @@ -4395,12 +4386,7 @@ returns nil, because real GC can't be done. */) /* clear_marks (); */ - /* Mark all the special slots that serve as the roots of accessibility. - - Usually the special slots to mark are contained in particular structures. - Then we know no slot is marked twice because the structures don't overlap. - In some cases, the structures point to the slots to be marked. - For these, we use MARKBIT to avoid double marking of the slot. */ + /* Mark all the special slots that serve as the roots of accessibility. */ for (i = 0; i < staticidx; i++) mark_object (*staticvec[i]); @@ -4413,11 +4399,7 @@ returns nil, because real GC can't be done. */) register struct gcpro *tail; for (tail = gcprolist; tail; tail = tail->next) for (i = 0; i < tail->nvars; i++) - if (!XMARKBIT (tail->var[i])) - { - mark_object (tail->var[i]); - XMARK (tail->var[i]); - } + mark_object (tail->var[i]); } #endif @@ -4439,21 +4421,14 @@ returns nil, because real GC can't be done. */) } for (backlist = backtrace_list; backlist; backlist = backlist->next) { - if (!XMARKBIT (*backlist->function)) - { - mark_object (*backlist->function); - XMARK (*backlist->function); - } + mark_object (*backlist->function); + if (backlist->nargs == UNEVALLED || backlist->nargs == MANY) i = 0; else i = backlist->nargs - 1; for (; i >= 0; i--) - if (!XMARKBIT (backlist->args[i])) - { - mark_object (backlist->args[i]); - XMARK (backlist->args[i]); - } + mark_object (backlist->args[i]); } mark_kboards (); @@ -4519,24 +4494,10 @@ returns nil, because real GC can't be done. */) || GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES) { register struct gcpro *tail; - - for (tail = gcprolist; tail; tail = tail->next) - for (i = 0; i < tail->nvars; i++) - XUNMARK (tail->var[i]); } #endif unmark_byte_stack (); - for (backlist = backtrace_list; backlist; backlist = backlist->next) - { - XUNMARK (*backlist->function); - if (backlist->nargs == UNEVALLED || backlist->nargs == MANY) - i = 0; - else - i = backlist->nargs - 1; - for (; i >= 0; i--) - XUNMARK (backlist->args[i]); - } VECTOR_UNMARK (&buffer_defaults); VECTOR_UNMARK (&buffer_local_symbols); @@ -4721,7 +4682,6 @@ mark_object (arg) int cdr_count = 0; loop: - XUNMARK (obj); if (PURE_POINTER_P (XPNTR (obj))) return; -- cgit v1.2.1 From 1aad248540c6e1d18f7138434cac3666f52308c1 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 11 Sep 2003 22:41:16 +0000 Subject: (init_marker): Remove debugging code. --- src/alloc.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 2c63c1cd07e..c84c2ebb26f 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -2851,7 +2851,6 @@ init_marker () marker_block_index = MARKER_BLOCK_SIZE; marker_free_list = 0; n_marker_blocks = 0; - fprintf(stderr, "union Lisp_Misc = %d\n", sizeof (union Lisp_Misc)); } /* Return a newly allocated Lisp_Misc object, with no substructure. */ -- cgit v1.2.1 From ad5f3636c57ec07fdd0796d98ce2471337e36d40 Mon Sep 17 00:00:00 2001 From: Dave Love Date: Fri, 19 Sep 2003 15:50:56 +0000 Subject: (GC_MALLOC_CHECK): Move conditional undef after lisp.h. --- src/alloc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index c84c2ebb26f..56a4c0b6ca0 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -31,13 +31,6 @@ Boston, MA 02111-1307, USA. */ #include -/* GC_MALLOC_CHECK defined means perform validity checks of malloc'd - memory. Can do this only if using gmalloc.c. */ - -#if defined SYSTEM_MALLOC || defined DOUG_LEA_MALLOC -#undef GC_MALLOC_CHECK -#endif - /* This file is part of the core Lisp implementation, and thus must deal with the real data structures. If the Lisp implementation is replaced, this file likely will not be used. */ @@ -56,6 +49,13 @@ Boston, MA 02111-1307, USA. */ #include "syssignal.h" #include +/* GC_MALLOC_CHECK defined means perform validity checks of malloc'd + memory. Can do this only if using gmalloc.c. */ + +#if defined SYSTEM_MALLOC || defined DOUG_LEA_MALLOC +#undef GC_MALLOC_CHECK +#endif + #ifdef HAVE_UNISTD_H #include #else -- cgit v1.2.1 From 4532fdde327e5e9b45735e8fe8e44d2601cb2dcc Mon Sep 17 00:00:00 2001 From: Richard M. Stallman Date: Mon, 13 Oct 2003 18:45:03 +0000 Subject: (lisp_align_malloc): If BASE is 0, call memory_full. --- src/alloc.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 56a4c0b6ca0..a001413cb52 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -756,6 +756,11 @@ lisp_align_malloc (nbytes, type) #else base = malloc (ABLOCKS_BYTES); abase = ALIGN (base, BLOCK_ALIGN); + if (base == 0) + { + UNBLOCK_INPUT; + memory_full (); + } #endif aligned = (base == abase); -- cgit v1.2.1 From a06681266b5297780c20dc3ddac3ec9d02279f5e Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 18 Nov 2003 00:39:13 +0000 Subject: (make_float, Fcons): Clear the markbit at init time. (make_float, Fcons, Fmake_symbol, allocate_misc): Move the increment of block_index outside of the macro call. (Fgarbage_collect): Remove null code. --- src/alloc.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index a001413cb52..1835d2a59eb 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -2229,15 +2229,17 @@ make_float (float_value) new = (struct float_block *) lisp_align_malloc (sizeof *new, MEM_TYPE_FLOAT); new->next = float_block; + bzero ((char *) new->gcmarkbits, sizeof new->gcmarkbits); float_block = new; float_block_index = 0; n_float_blocks++; } - XSETFLOAT (val, &float_block->floats[float_block_index++]); + XSETFLOAT (val, &float_block->floats[float_block_index]); + float_block_index++; } XFLOAT_DATA (val) = float_value; - FLOAT_UNMARK (XFLOAT (val)); + eassert (!FLOAT_MARKED_P (XFLOAT (val))); consing_since_gc += sizeof (struct Lisp_Float); floats_consed++; return val; @@ -2345,17 +2347,19 @@ DEFUN ("cons", Fcons, Scons, 2, 2, 0, register struct cons_block *new; new = (struct cons_block *) lisp_align_malloc (sizeof *new, MEM_TYPE_CONS); + bzero ((char *) new->gcmarkbits, sizeof new->gcmarkbits); new->next = cons_block; cons_block = new; cons_block_index = 0; n_cons_blocks++; } - XSETCONS (val, &cons_block->conses[cons_block_index++]); + XSETCONS (val, &cons_block->conses[cons_block_index]); + cons_block_index++; } XSETCAR (val, car); XSETCDR (val, cdr); - CONS_UNMARK (XCONS (val)); + eassert (!CONS_MARKED_P (XCONS (val))); consing_since_gc += sizeof (struct Lisp_Cons); cons_cells_consed++; return val; @@ -2804,7 +2808,8 @@ Its value and function definition are void, and its property list is nil. */) symbol_block_index = 0; n_symbol_blocks++; } - XSETSYMBOL (val, &symbol_block->symbols[symbol_block_index++]); + XSETSYMBOL (val, &symbol_block->symbols[symbol_block_index]); + symbol_block_index++; } p = XSYMBOL (val); @@ -2882,7 +2887,8 @@ allocate_misc () marker_block_index = 0; n_marker_blocks++; } - XSETMISC (val, &marker_block->markers[marker_block_index++]); + XSETMISC (val, &marker_block->markers[marker_block_index]); + marker_block_index++; } consing_since_gc += sizeof (union Lisp_Misc); @@ -4494,13 +4500,6 @@ returns nil, because real GC can't be done. */) /* Clear the mark bits that we set in certain root slots. */ -#if (GC_MARK_STACK == GC_USE_GCPROS_AS_BEFORE \ - || GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES) - { - register struct gcpro *tail; - } -#endif - unmark_byte_stack (); VECTOR_UNMARK (&buffer_defaults); VECTOR_UNMARK (&buffer_local_symbols); -- cgit v1.2.1 From de7515d6b8aef2312120f3749d2423cb1f8f332f Mon Sep 17 00:00:00 2001 From: Jan Djärv Date: Sun, 11 Jan 2004 21:50:12 +0000 Subject: * alloc.c (allocate_vectorlike): Surround calls to mallopt with BLOCK/UNBLOCK_INPUT. --- src/alloc.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 1835d2a59eb..91fade83609 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -2498,7 +2498,9 @@ allocate_vectorlike (len, type) /* Prevent mmap'ing the chunk. Lisp data may not be mmap'ed because mapped region contents are not preserved in a dumped Emacs. */ + BLOCK_INPUT; mallopt (M_MMAP_MAX, 0); + UNBLOCK_INPUT; #endif nbytes = sizeof *p + (len - 1) * sizeof p->contents[0]; @@ -2506,7 +2508,9 @@ allocate_vectorlike (len, type) #ifdef DOUG_LEA_MALLOC /* Back to a reasonable maximum of mmap'ed areas. */ + BLOCK_INPUT; mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); + UNBLOCK_INPUT; #endif consing_since_gc += nbytes; -- cgit v1.2.1 From d05b383acd3e295ae429ca5f72467e5f82e5df95 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 14 Jan 2004 14:35:23 +0000 Subject: (struct interval_block, struct string_block) (struct symbol_block, struct marker_block, live_string_p) (live_cons_p, live_symbol_p, live_float_p, live_misc_p): Better preserve alignment for objects in blocks. (FLOAT_BLOCK_SIZE): Adjust for possible alignment padding. --- src/alloc.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 91fade83609..484478ac3dd 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1,5 +1,5 @@ /* Storage allocation and gc for GNU Emacs Lisp interpreter. - Copyright (C) 1985, 86, 88, 93, 94, 95, 97, 98, 1999, 2000, 2001, 2002, 2003 + Copyright (C) 1985,86,88,93,94,95,97,98,1999,2000,01,02,03,2004 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -1104,8 +1104,9 @@ uninterrupt_malloc () struct interval_block { - struct interval_block *next; + /* Place `intervals' first, to preserve alignment. */ struct interval intervals[INTERVAL_BLOCK_SIZE]; + struct interval_block *next; }; /* Current interval block. Its `next' pointer points to older @@ -1343,8 +1344,9 @@ struct sblock struct string_block { - struct string_block *next; + /* Place `strings' first, to preserve alignment. */ struct Lisp_String strings[STRING_BLOCK_SIZE]; + struct string_block *next; }; /* Head and tail of the list of sblock structures holding Lisp string @@ -2125,8 +2127,10 @@ make_uninit_multibyte_string (nchars, nbytes) by GC are put on a free list to be reallocated before allocating any new float cells from the latest float_block. */ -#define FLOAT_BLOCK_SIZE \ - (((BLOCK_BYTES - sizeof (struct float_block *)) * CHAR_BIT) \ +#define FLOAT_BLOCK_SIZE \ + (((BLOCK_BYTES - sizeof (struct float_block *) \ + /* The compiler might add padding at the end. */ \ + - (sizeof (struct Lisp_Float) - sizeof (int))) * CHAR_BIT) \ / (sizeof (struct Lisp_Float) * CHAR_BIT + 1)) #define GETMARKBIT(block,n) \ @@ -2753,8 +2757,9 @@ usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INT struct symbol_block { - struct symbol_block *next; + /* Place `symbols' first, to preserve alignment. */ struct Lisp_Symbol symbols[SYMBOL_BLOCK_SIZE]; + struct symbol_block *next; }; /* Current symbol block and index of first unused Lisp_Symbol @@ -2845,8 +2850,9 @@ Its value and function definition are void, and its property list is nil. */) struct marker_block { - struct marker_block *next; + /* Place `markers' first, to preserve alignment. */ union Lisp_Misc markers[MARKER_BLOCK_SIZE]; + struct marker_block *next; }; struct marker_block *marker_block; @@ -3427,6 +3433,7 @@ live_string_p (m, p) must not be on the free-list. */ return (offset >= 0 && offset % sizeof b->strings[0] == 0 + && offset < (STRING_BLOCK_SIZE * sizeof b->strings[0]) && ((struct Lisp_String *) p)->data != NULL); } else @@ -3451,8 +3458,8 @@ live_cons_p (m, p) one of the unused cells in the current cons block, and not be on the free-list. */ return (offset >= 0 - && offset < (CONS_BLOCK_SIZE * sizeof b->conses[0]) && offset % sizeof b->conses[0] == 0 + && offset < (CONS_BLOCK_SIZE * sizeof b->conses[0]) && (b != cons_block || offset / sizeof b->conses[0] < cons_block_index) && !EQ (((struct Lisp_Cons *) p)->car, Vdead)); @@ -3480,6 +3487,7 @@ live_symbol_p (m, p) and not be on the free-list. */ return (offset >= 0 && offset % sizeof b->symbols[0] == 0 + && offset < (SYMBOL_BLOCK_SIZE * sizeof b->symbols[0]) && (b != symbol_block || offset / sizeof b->symbols[0] < symbol_block_index) && !EQ (((struct Lisp_Symbol *) p)->function, Vdead)); @@ -3505,8 +3513,8 @@ live_float_p (m, p) /* P must point to the start of a Lisp_Float and not be one of the unused cells in the current float block. */ return (offset >= 0 - && offset < (FLOAT_BLOCK_SIZE * sizeof b->floats[0]) && offset % sizeof b->floats[0] == 0 + && offset < (FLOAT_BLOCK_SIZE * sizeof b->floats[0]) && (b != float_block || offset / sizeof b->floats[0] < float_block_index)); } @@ -3533,6 +3541,7 @@ live_misc_p (m, p) and not be on the free-list. */ return (offset >= 0 && offset % sizeof b->markers[0] == 0 + && offset < (MARKER_BLOCK_SIZE * sizeof b->markers[0]) && (b != marker_block || offset / sizeof b->markers[0] < marker_block_index) && ((union Lisp_Misc *) p)->u_marker.type != Lisp_Misc_Free); -- cgit v1.2.1 From 831b476c5a3d04c772364aaecf981252f515297e Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 21 Jan 2004 03:34:32 +0000 Subject: (lisp_malloc, lisp_align_malloc) [USE_LSB_TAG]: Don't check range of malloc address. (pure_alloc) [USE_LSB_TAG]: Enforce alignment. --- src/alloc.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 484478ac3dd..f69ad5f870e 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -598,6 +598,7 @@ lisp_malloc (nbytes, type) val = (void *) malloc (nbytes); +#ifndef USE_LSB_TAG /* If the memory just allocated cannot be addressed thru a Lisp object's pointer, and it needs to be, that's equivalent to running out of memory. */ @@ -612,6 +613,7 @@ lisp_malloc (nbytes, type) val = 0; } } +#endif #if GC_MARK_STACK && !defined GC_MALLOC_CHECK if (val && type != MEM_TYPE_NON_LISP) @@ -772,6 +774,7 @@ lisp_align_malloc (nbytes, type) mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); #endif +#ifndef USE_LSB_TAG /* If the memory just allocated cannot be addressed thru a Lisp object's pointer, and it needs to be, that's equivalent to running out of memory. */ @@ -788,6 +791,7 @@ lisp_align_malloc (nbytes, type) memory_full (); } } +#endif /* Initialize the blocks and put them on the free list. Is `base' was not properly aligned, we can't use the last block. */ @@ -4076,6 +4080,9 @@ pure_alloc (size, type) int type; { POINTER_TYPE *result; +#ifdef USE_LSB_TAG + size_t alignment = (1 << GCTYPEBITS); +#else size_t alignment = sizeof (EMACS_INT); /* Give Lisp_Floats an extra alignment. */ @@ -4087,6 +4094,7 @@ pure_alloc (size, type) alignment = sizeof (struct Lisp_Float); #endif } +#endif again: result = ALIGN (purebeg + pure_bytes_used, alignment); -- cgit v1.2.1 From 41b867eaceb6bfab6be4ed62a2d4dd9cf1be62e3 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Mon, 26 Jan 2004 11:54:36 +0000 Subject: (Fpurecopy): Declare size as EMACS_INT to not lose bits. --- src/alloc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index f69ad5f870e..7be54aa1ae0 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -4230,12 +4230,13 @@ Does not copy symbols. Copies strings without text properties. */) else if (COMPILEDP (obj) || VECTORP (obj)) { register struct Lisp_Vector *vec; - register int i, size; + register int i; + EMACS_INT size; size = XVECTOR (obj)->size; if (size & PSEUDOVECTOR_FLAG) size &= PSEUDOVECTOR_SIZE_MASK; - vec = XVECTOR (make_pure_vector ((EMACS_INT) size)); + vec = XVECTOR (make_pure_vector (size)); for (i = 0; i < size; i++) vec->contents[i] = Fpurecopy (XVECTOR (obj)->contents[i]); if (COMPILEDP (obj)) -- cgit v1.2.1 From a097329fe7a950368fb74e75855488813eace8d5 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Mon, 26 Apr 2004 21:42:49 +0000 Subject: (Fmake_bool_vector): Use BOOL_VECTOR_BITS_PER_CHAR instead of BITS_PER_CHAR for bool vectors. --- src/alloc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 7be54aa1ae0..b5a96953adb 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1949,10 +1949,11 @@ LENGTH must be a number. INIT matters only in whether it is t or nil. */) CHECK_NATNUM (length); - bits_per_value = sizeof (EMACS_INT) * BITS_PER_CHAR; + bits_per_value = sizeof (EMACS_INT) * BOOL_VECTOR_BITS_PER_CHAR; length_in_elts = (XFASTINT (length) + bits_per_value - 1) / bits_per_value; - length_in_chars = ((XFASTINT (length) + BITS_PER_CHAR - 1) / BITS_PER_CHAR); + length_in_chars = ((XFASTINT (length) + BOOL_VECTOR_BITS_PER_CHAR - 1) + / BOOL_VECTOR_BITS_PER_CHAR); /* We must allocate one more elements than LENGTH_IN_ELTS for the slot `size' of the struct Lisp_Bool_Vector. */ @@ -1969,9 +1970,9 @@ LENGTH must be a number. INIT matters only in whether it is t or nil. */) p->data[i] = real_init; /* Clear the extraneous bits in the last byte. */ - if (XINT (length) != length_in_chars * BITS_PER_CHAR) + if (XINT (length) != length_in_chars * BOOL_VECTOR_BITS_PER_CHAR) XBOOL_VECTOR (val)->data[length_in_chars - 1] - &= (1 << (XINT (length) % BITS_PER_CHAR)) - 1; + &= (1 << (XINT (length) % BOOL_VECTOR_BITS_PER_CHAR)) - 1; return val; } -- cgit v1.2.1 From d2db1c32fa78470ed55f7cdd2ddeb1adfb070404 Mon Sep 17 00:00:00 2001 From: Kim F. Storm Date: Mon, 17 May 2004 12:08:02 +0000 Subject: (mark_object): Ignore Lisp_Misc_Free objects. Such objects may be freed markers which still exist on an undo list. --- src/alloc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index b5a96953adb..dd4823bd9e3 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -844,7 +844,7 @@ lisp_align_free (block) free_ablock = ablock; /* Update busy count. */ ABLOCKS_BUSY (abase) = (struct ablocks *) (-2 + (long) ABLOCKS_BUSY (abase)); - + if (2 > (long) ABLOCKS_BUSY (abase)) { /* All the blocks are free. */ int i = 0, aligned = (long) ABLOCKS_BUSY (abase); @@ -4976,6 +4976,15 @@ mark_object (arg) break; case Lisp_Misc: + if (XMISCTYPE (obj) == Lisp_Misc_Free) + { + /* This is (probably) a freed marker which may still exist on + a buffer undo list, so accept it here. */ + /* If we reuse the marker, and it still exists on the undo + list, and we do undo, behaviour is unpredictable -- + but at least we don't crash here. KFS 2004-05-17 */ + break; + } CHECK_ALLOCATED_AND_LIVE (live_misc_p); if (XMARKER (obj)->gcmarkbit) break; -- cgit v1.2.1 From d080618c7efba88e91bb3d3c9bbc318a17506f86 Mon Sep 17 00:00:00 2001 From: Kim F. Storm Date: Mon, 17 May 2004 15:20:16 +0000 Subject: (mark_object): Mark Lisp_Misc_Free cell. Fix comment. --- src/alloc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index dd4823bd9e3..c38376d80bc 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -4979,10 +4979,9 @@ mark_object (arg) if (XMISCTYPE (obj) == Lisp_Misc_Free) { /* This is (probably) a freed marker which may still exist on - a buffer undo list, so accept it here. */ - /* If we reuse the marker, and it still exists on the undo - list, and we do undo, behaviour is unpredictable -- - but at least we don't crash here. KFS 2004-05-17 */ + a buffer undo list, so accept it here, as check below will + fail (not live). KFS 2004-05-17 */ + XMARKER (obj)->gcmarkbit = 1; break; } CHECK_ALLOCATED_AND_LIVE (live_misc_p); -- cgit v1.2.1 From 74c35a48a74ba1e57f39100d030b8e299860494e Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 18 May 2004 16:22:46 +0000 Subject: (Fgarbage_collect): Do all the marking before flushing unmarked elements of the undo list. --- src/alloc.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index c38376d80bc..3dc21ca30e0 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -4465,6 +4465,17 @@ returns nil, because real GC can't be done. */) } mark_kboards (); +#if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES + mark_stack (); +#endif + +#ifdef USE_GTK + { + extern void xg_mark_data (); + xg_mark_data (); + } +#endif + /* Look thru every buffer's undo list for elements that update markers that were not marked, and delete them. */ @@ -4508,17 +4519,6 @@ returns nil, because real GC can't be done. */) } } -#if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES - mark_stack (); -#endif - -#ifdef USE_GTK - { - extern void xg_mark_data (); - xg_mark_data (); - } -#endif - gc_sweep (); /* Clear the mark bits that we set in certain root slots. */ -- cgit v1.2.1 From 0dbaecd24aeac801d6d49cdd5f0b4bee5f2c9e05 Mon Sep 17 00:00:00 2001 From: Kim F. Storm Date: Fri, 21 May 2004 23:36:10 +0000 Subject: (struct backtrace): Add debug_on_exit member. (Fgarbage_collect): Clear out buffer undo_list markers after gc_sweep. Identify those markers as Lisp_Misc_Free objects. Clear car and cdr of the removed cons cells. (mark_object): Undo previous change - disallow Lisp_Misc_Free objects. (gc_sweep): Clear cons_blocks before sweeping strings, so we don't have any cons cells pointing to unallocated stings. Do not lisp_free any marker blocks, as there may still be pointers to them from buffer undo lists at this stage of GC. --- src/alloc.c | 69 ++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 33 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 3dc21ca30e0..fb424e6aee6 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -2334,7 +2334,6 @@ free_cons (ptr) cons_free_list = ptr; } - DEFUN ("cons", Fcons, Scons, 2, 2, 0, doc: /* Create a new cons, give it CAR and CDR as components, and return it. */) (car, cdr) @@ -4286,6 +4285,8 @@ struct backtrace /* If nargs is UNEVALLED, args points to slot holding list of unevalled args. */ char evalargs; + /* Nonzero means call value of debugger when done with this operation. */ + char debug_on_exit; }; @@ -4476,34 +4477,42 @@ returns nil, because real GC can't be done. */) } #endif - /* Look thru every buffer's undo list - for elements that update markers that were not marked, - and delete them. */ + gc_sweep (); + + /* Look thru every buffer's undo list for elements that used to + contain update markers that were changed to Lisp_Misc_Free + objects and delete them. This may leave a few cons cells + unchained, but we will get those on the next sweep. */ { register struct buffer *nextb = all_buffers; while (nextb) { /* If a buffer's undo list is Qt, that means that undo is - turned off in that buffer. Calling truncate_undo_list on - Qt tends to return NULL, which effectively turns undo back on. - So don't call truncate_undo_list if undo_list is Qt. */ + turned off in that buffer. */ if (! EQ (nextb->undo_list, Qt)) { - Lisp_Object tail, prev; + Lisp_Object tail, prev, elt, car; tail = nextb->undo_list; prev = Qnil; while (CONSP (tail)) { - if (GC_CONSP (XCAR (tail)) - && GC_MARKERP (XCAR (XCAR (tail))) - && !XMARKER (XCAR (XCAR (tail)))->gcmarkbit) + if ((elt = XCAR (tail), GC_CONSP (elt)) + && (car = XCAR (elt), GC_MISCP (car)) + && XMISCTYPE (car) == Lisp_Misc_Free) { + Lisp_Object cdr = XCDR (tail); + /* Do not use free_cons here, as we don't know if + anybody else has a pointer to these conses. */ + XSETCAR (elt, Qnil); + XSETCDR (elt, Qnil); + XSETCAR (tail, Qnil); + XSETCDR (tail, Qnil); if (NILP (prev)) - nextb->undo_list = tail = XCDR (tail); + nextb->undo_list = tail = cdr; else { - tail = XCDR (tail); + tail = cdr; XSETCDR (prev, tail); } } @@ -4519,8 +4528,6 @@ returns nil, because real GC can't be done. */) } } - gc_sweep (); - /* Clear the mark bits that we set in certain root slots. */ unmark_byte_stack (); @@ -4976,14 +4983,6 @@ mark_object (arg) break; case Lisp_Misc: - if (XMISCTYPE (obj) == Lisp_Misc_Free) - { - /* This is (probably) a freed marker which may still exist on - a buffer undo list, so accept it here, as check below will - fail (not live). KFS 2004-05-17 */ - XMARKER (obj)->gcmarkbit = 1; - break; - } CHECK_ALLOCATED_AND_LIVE (live_misc_p); if (XMARKER (obj)->gcmarkbit) break; @@ -5209,16 +5208,6 @@ survives_gc_p (obj) static void gc_sweep () { - /* Remove or mark entries in weak hash tables. - This must be done before any object is unmarked. */ - sweep_weak_hash_tables (); - - sweep_strings (); -#ifdef GC_CHECK_STRING_BYTES - if (!noninteractive) - check_string_bytes (1); -#endif - /* Put all unmarked conses on free list */ { register struct cons_block *cblk; @@ -5269,6 +5258,16 @@ gc_sweep () total_free_conses = num_free; } + /* Remove or mark entries in weak hash tables. + This must be done before any object is unmarked. */ + sweep_weak_hash_tables (); + + sweep_strings (); +#ifdef GC_CHECK_STRING_BYTES + if (!noninteractive) + check_string_bytes (1); +#endif + /* Put all unmarked floats on free list */ { register struct float_block *fblk; @@ -5467,6 +5466,9 @@ gc_sweep () /* If this block contains only free markers and we have already seen more than two blocks worth of free markers then deallocate this block. */ +#if 0 + /* There may still be pointers to these markers from a buffer's + undo list, so don't free them. KFS 2004-05-21 / if (this_free == MARKER_BLOCK_SIZE && num_free > MARKER_BLOCK_SIZE) { *mprev = mblk->next; @@ -5476,6 +5478,7 @@ gc_sweep () n_marker_blocks--; } else +#endif { num_free += this_free; mprev = &mblk->next; -- cgit v1.2.1 From 69623621a48d6430ffc1eb2c3b9f67b839047a25 Mon Sep 17 00:00:00 2001 From: Richard M. Stallman Date: Sat, 22 May 2004 22:22:38 +0000 Subject: (Fmake_string): Doc fix. --- src/alloc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index fb424e6aee6..865675d96ad 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1893,8 +1893,9 @@ compact_small_strings () DEFUN ("make-string", Fmake_string, Smake_string, 2, 2, 0, - doc: /* Return a newly created string of length LENGTH, with each element being INIT. -Both LENGTH and INIT must be numbers. */) + doc: /* Return a newly created string of length LENGTH, with INIT in each element. +LENGTH must be an integer. +INIT must be an integer that represents a character. */) (length, init) Lisp_Object length, init; { -- cgit v1.2.1 From 6b67a5180dcb7547e0bbb63d1047031df63dbf3f Mon Sep 17 00:00:00 2001 From: Kim F. Storm Date: Tue, 25 May 2004 11:18:07 +0000 Subject: (marker_blocks_pending_free): New var. (gc_sweep): Store free marker blocks on that list. (Fgarbage_collect): Free them after undo-list cleanup. --- src/alloc.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 865675d96ad..bea6943c26e 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -2865,6 +2865,10 @@ int marker_block_index; union Lisp_Misc *marker_free_list; +/* Marker blocks which should be freed at end of GC. */ + +struct marker_block *marker_blocks_pending_free; + /* Total number of marker blocks now in use. */ int n_marker_blocks; @@ -2875,6 +2879,7 @@ init_marker () marker_block = NULL; marker_block_index = MARKER_BLOCK_SIZE; marker_free_list = 0; + marker_blocks_pending_free = 0; n_marker_blocks = 0; } @@ -4529,6 +4534,18 @@ returns nil, because real GC can't be done. */) } } + /* Undo lists have been cleaned up, so we can free marker blocks now. */ + + { + struct marker_block *mblk; + + while ((mblk = marker_blocks_pending_free) != 0) + { + marker_blocks_pending_free = mblk->next; + lisp_free (mblk); + } + } + /* Clear the mark bits that we set in certain root slots. */ unmark_byte_stack (); @@ -5437,6 +5454,7 @@ gc_sweep () register int num_free = 0, num_used = 0; marker_free_list = 0; + marker_blocks_pending_free = 0; for (mblk = marker_block; mblk; mblk = *mprev) { @@ -5467,19 +5485,20 @@ gc_sweep () /* If this block contains only free markers and we have already seen more than two blocks worth of free markers then deallocate this block. */ -#if 0 - /* There may still be pointers to these markers from a buffer's - undo list, so don't free them. KFS 2004-05-21 / if (this_free == MARKER_BLOCK_SIZE && num_free > MARKER_BLOCK_SIZE) { *mprev = mblk->next; /* Unhook from the free list. */ marker_free_list = mblk->markers[0].u_free.chain; - lisp_free (mblk); n_marker_blocks--; + + /* It is not safe to free the marker block at this stage, + since there may still be pointers to these markers from + a buffer's undo list. KFS 2004-05-25. */ + mblk->next = marker_blocks_pending_free; + marker_blocks_pending_free = mblk; } else -#endif { num_free += this_free; mprev = &mblk->next; -- cgit v1.2.1 From b40ea20a66404a42ee11d2690b8aa8657fba3388 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 28 May 2004 20:59:14 +0000 Subject: (struct backtrace): Remove. (Fgarbage_collect): Use the new mark_backtrace. --- src/alloc.c | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index bea6943c26e..452a1fbb2a1 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -256,6 +256,7 @@ EMACS_INT gcs_done; /* accumulated GCs */ static void mark_buffer P_ ((Lisp_Object)); extern void mark_kboards P_ ((void)); +extern void mark_backtrace P_ ((void)); static void gc_sweep P_ ((void)); static void mark_glyph_matrix P_ ((struct glyph_matrix *)); static void mark_face_cache P_ ((struct face_cache *)); @@ -4282,20 +4283,6 @@ struct catchtag struct catchtag *next; }; -struct backtrace -{ - struct backtrace *next; - Lisp_Object *function; - Lisp_Object *args; /* Points to vector of args. */ - int nargs; /* Length of vector. */ - /* If nargs is UNEVALLED, args points to slot holding list of - unevalled args. */ - char evalargs; - /* Nonzero means call value of debugger when done with this operation. */ - char debug_on_exit; -}; - - /*********************************************************************** Protection from GC @@ -4330,7 +4317,6 @@ returns nil, because real GC can't be done. */) register struct specbinding *bind; struct catchtag *catch; struct handler *handler; - register struct backtrace *backlist; char stack_top_variable; register int i; int message_p; @@ -4459,17 +4445,7 @@ returns nil, because real GC can't be done. */) mark_object (handler->handler); mark_object (handler->var); } - for (backlist = backtrace_list; backlist; backlist = backlist->next) - { - mark_object (*backlist->function); - - if (backlist->nargs == UNEVALLED || backlist->nargs == MANY) - i = 0; - else - i = backlist->nargs - 1; - for (; i >= 0; i--) - mark_object (backlist->args[i]); - } + mark_backtrace (); mark_kboards (); #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES -- cgit v1.2.1 From c37adf23e8607a6479a950c7f6b41ca819b7c73c Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sat, 29 May 2004 00:00:17 +0000 Subject: Undo Kim's recent changes and fix the same bug differently. (marker_blocks_pending_free): Remove. (Fgarbage_collect): Sweep after cleaning up undo-lists. Mark the undo lists after claning them up. Don't free block in marker_blocks_pending_free. (mark_buffer): Don't mark undo_list. (gc_sweep): Sweep hash-tables and strings first. Do free marker blocks that are empty. --- src/alloc.c | 120 ++++++++++++++++-------------------------------------------- 1 file changed, 32 insertions(+), 88 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 452a1fbb2a1..0a0b25bcb7d 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -2866,10 +2866,6 @@ int marker_block_index; union Lisp_Misc *marker_free_list; -/* Marker blocks which should be freed at end of GC. */ - -struct marker_block *marker_blocks_pending_free; - /* Total number of marker blocks now in use. */ int n_marker_blocks; @@ -2880,7 +2876,6 @@ init_marker () marker_block = NULL; marker_block_index = MARKER_BLOCK_SIZE; marker_free_list = 0; - marker_blocks_pending_free = 0; n_marker_blocks = 0; } @@ -4459,42 +4454,36 @@ returns nil, because real GC can't be done. */) } #endif - gc_sweep (); - - /* Look thru every buffer's undo list for elements that used to - contain update markers that were changed to Lisp_Misc_Free - objects and delete them. This may leave a few cons cells - unchained, but we will get those on the next sweep. */ + /* Everything is now marked, except for the things that require special + finalization, i.e. the undo_list. + Look thru every buffer's undo list + for elements that update markers that were not marked, + and delete them. */ { register struct buffer *nextb = all_buffers; while (nextb) { /* If a buffer's undo list is Qt, that means that undo is - turned off in that buffer. */ + turned off in that buffer. Calling truncate_undo_list on + Qt tends to return NULL, which effectively turns undo back on. + So don't call truncate_undo_list if undo_list is Qt. */ if (! EQ (nextb->undo_list, Qt)) { - Lisp_Object tail, prev, elt, car; + Lisp_Object tail, prev; tail = nextb->undo_list; prev = Qnil; while (CONSP (tail)) { - if ((elt = XCAR (tail), GC_CONSP (elt)) - && (car = XCAR (elt), GC_MISCP (car)) - && XMISCTYPE (car) == Lisp_Misc_Free) + if (GC_CONSP (XCAR (tail)) + && GC_MARKERP (XCAR (XCAR (tail))) + && !XMARKER (XCAR (XCAR (tail)))->gcmarkbit) { - Lisp_Object cdr = XCDR (tail); - /* Do not use free_cons here, as we don't know if - anybody else has a pointer to these conses. */ - XSETCAR (elt, Qnil); - XSETCDR (elt, Qnil); - XSETCAR (tail, Qnil); - XSETCDR (tail, Qnil); if (NILP (prev)) - nextb->undo_list = tail = cdr; + nextb->undo_list = tail = XCDR (tail); else { - tail = cdr; + tail = XCDR (tail); XSETCDR (prev, tail); } } @@ -4505,22 +4494,15 @@ returns nil, because real GC can't be done. */) } } } + /* Now that we have stripped the elements that need not be in the + undo_list any more, we can finally mark the list. */ + mark_object (nextb->undo_list); nextb = nextb->next; } } - /* Undo lists have been cleaned up, so we can free marker blocks now. */ - - { - struct marker_block *mblk; - - while ((mblk = marker_blocks_pending_free) != 0) - { - marker_blocks_pending_free = mblk->next; - lisp_free (mblk); - } - } + gc_sweep (); /* Clear the mark bits that we set in certain root slots. */ @@ -5088,41 +5070,9 @@ mark_buffer (buf) MARK_INTERVAL_TREE (BUF_INTERVALS (buffer)); - if (CONSP (buffer->undo_list)) - { - Lisp_Object tail; - tail = buffer->undo_list; - - /* We mark the undo list specially because - its pointers to markers should be weak. */ - - while (CONSP (tail)) - { - register struct Lisp_Cons *ptr = XCONS (tail); - - if (CONS_MARKED_P (ptr)) - break; - CONS_MARK (ptr); - if (GC_CONSP (ptr->car) - && !CONS_MARKED_P (XCONS (ptr->car)) - && GC_MARKERP (XCAR (ptr->car))) - { - CONS_MARK (XCONS (ptr->car)); - mark_object (XCDR (ptr->car)); - } - else - mark_object (ptr->car); - - if (CONSP (ptr->cdr)) - tail = ptr->cdr; - else - break; - } - - mark_object (XCDR (tail)); - } - else - mark_object (buffer->undo_list); + /* For now, we just don't mark the undo_list. It's done later in + a special way just before the sweep phase, and after stripping + some of its elements that are not needed any more. */ if (buffer->overlays_before) { @@ -5202,6 +5152,16 @@ survives_gc_p (obj) static void gc_sweep () { + /* Remove or mark entries in weak hash tables. + This must be done before any object is unmarked. */ + sweep_weak_hash_tables (); + + sweep_strings (); +#ifdef GC_CHECK_STRING_BYTES + if (!noninteractive) + check_string_bytes (1); +#endif + /* Put all unmarked conses on free list */ { register struct cons_block *cblk; @@ -5252,16 +5212,6 @@ gc_sweep () total_free_conses = num_free; } - /* Remove or mark entries in weak hash tables. - This must be done before any object is unmarked. */ - sweep_weak_hash_tables (); - - sweep_strings (); -#ifdef GC_CHECK_STRING_BYTES - if (!noninteractive) - check_string_bytes (1); -#endif - /* Put all unmarked floats on free list */ { register struct float_block *fblk; @@ -5430,7 +5380,6 @@ gc_sweep () register int num_free = 0, num_used = 0; marker_free_list = 0; - marker_blocks_pending_free = 0; for (mblk = marker_block; mblk; mblk = *mprev) { @@ -5466,13 +5415,8 @@ gc_sweep () *mprev = mblk->next; /* Unhook from the free list. */ marker_free_list = mblk->markers[0].u_free.chain; + lisp_free (mblk); n_marker_blocks--; - - /* It is not safe to free the marker block at this stage, - since there may still be pointers to these markers from - a buffer's undo list. KFS 2004-05-25. */ - mblk->next = marker_blocks_pending_free; - marker_blocks_pending_free = mblk; } else { -- cgit v1.2.1 From ab349c191f048bb078ef7a534e271c7a5d7727b5 Mon Sep 17 00:00:00 2001 From: Richard M. Stallman Date: Sat, 29 May 2004 16:10:27 +0000 Subject: (lisp_align_malloc): Check for base == 0 regardless of HAVE_POSIX_MEMALIGN. Clean up HAVE_POSIX_MEMALIGN handling of `err'. --- src/alloc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 0a0b25bcb7d..055f5d82347 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -754,17 +754,20 @@ lisp_align_malloc (nbytes, type) #ifdef HAVE_POSIX_MEMALIGN { int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES); - abase = err ? (base = NULL) : base; + if (err) + base = NULL; + abase = base; } #else base = malloc (ABLOCKS_BYTES); abase = ALIGN (base, BLOCK_ALIGN); +#endif + if (base == 0) { UNBLOCK_INPUT; memory_full (); } -#endif aligned = (base == abase); if (!aligned) -- cgit v1.2.1 From ae6a9bfec95d147fc83251951b2f51acb294714b Mon Sep 17 00:00:00 2001 From: Richard M. Stallman Date: Sat, 29 May 2004 16:19:41 +0000 Subject: (undo_outer_limit): New variable. (syms_of_alloc): Defvar it. (Fgarbage_collect): Pass undo_outer_limit to truncate_undo_list. --- src/alloc.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 055f5d82347..0b80fd5d9e7 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -155,6 +155,7 @@ int malloc_sbrk_unused; EMACS_INT undo_limit; EMACS_INT undo_strong_limit; +EMACS_INT undo_outer_limit; /* Number of live and free conses etc. */ @@ -4383,7 +4384,7 @@ returns nil, because real GC can't be done. */) if (! EQ (nextb->undo_list, Qt)) nextb->undo_list = truncate_undo_list (nextb->undo_list, undo_limit, - undo_strong_limit); + undo_strong_limit, undo_outer_limit); /* Shrink buffer gaps, but skip indirect and dead buffers. */ if (nextb->base_buffer == 0 && !NILP (nextb->name)) @@ -5669,12 +5670,20 @@ which includes both saved text and other data. */); DEFVAR_INT ("undo-strong-limit", &undo_strong_limit, doc: /* Don't keep more than this much size of undo information. -A command which pushes past this size is itself forgotten. -This limit is applied when garbage collection happens. +A previous command which pushes the undo list past this size +is entirely forgotten when GC happens. The size is counted as the number of bytes occupied, which includes both saved text and other data. */); undo_strong_limit = 30000; + DEFVAR_INT ("undo-outer-limit", &undo_outer_limit, + doc: /* Don't keep more than this much size of undo information. +If the current command has produced more than this much undo information, +GC discards it. This is a last-ditch limit to prevent memory overflow. +The size is counted as the number of bytes occupied, +which includes both saved text and other data. */); + undo_outer_limit = 300000; + DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages, doc: /* Non-nil means display messages at start and end of garbage collection. */); garbage_collection_messages = 0; -- cgit v1.2.1