From: Dmitry Antipov Date: Tue, 3 Jul 2012 11:09:36 +0000 (+0400) Subject: * alloc.c (allocate_vector_block): Remove redundant X-Git-Tag: emacs-24.2.90~1199^2~246 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d12e8f5a194b64e25eb57d5f6ea19f663c0e4f2b;p=emacs.git * alloc.c (allocate_vector_block): Remove redundant calls to mallopt if DOUG_LEA_MALLOC is defined. (allocate_vectorlike): If DOUG_LEA_MALLOC is defined, avoid calls to mallopt if zero_vector is returned. --- diff --git a/src/ChangeLog b/src/ChangeLog index d0dfa1375f6..9861fe76ca3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2012-07-03 Dmitry Antipov + + * alloc.c (allocate_vector_block): Remove redundant + calls to mallopt if DOUG_LEA_MALLOC is defined. + (allocate_vectorlike): If DOUG_LEA_MALLOC is defined, + avoid calls to mallopt if zero_vector is returned. + 2012-07-03 Dmitry Antipov * alloc.c (check_string_bytes): If GC_CHECK_STRING_BYTES diff --git a/src/alloc.c b/src/alloc.c index 3306bc4107b..0d4491e8472 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -2958,17 +2958,7 @@ static struct Lisp_Vector *zero_vector; static struct vector_block * allocate_vector_block (void) { - struct vector_block *block; - -#ifdef DOUG_LEA_MALLOC - mallopt (M_MMAP_MAX, 0); -#endif - - block = xmalloc (sizeof (struct vector_block)); - -#ifdef DOUG_LEA_MALLOC - mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); -#endif + struct vector_block *block = xmalloc (sizeof (struct vector_block)); #if GC_MARK_STACK && !defined GC_MALLOC_CHECK mem_insert (block->data, block->data + VECTOR_BLOCK_BYTES, @@ -3166,44 +3156,42 @@ static struct Lisp_Vector * allocate_vectorlike (ptrdiff_t len) { struct Lisp_Vector *p; - size_t nbytes; MALLOC_BLOCK_INPUT; -#ifdef DOUG_LEA_MALLOC - /* Prevent mmap'ing the chunk. Lisp data may not be mmap'ed - because mapped region contents are not preserved in - a dumped Emacs. */ - mallopt (M_MMAP_MAX, 0); -#endif - /* This gets triggered by code which I haven't bothered to fix. --Stef */ /* eassert (!handling_signal); */ if (len == 0) + p = zero_vector; + else { - MALLOC_UNBLOCK_INPUT; - return zero_vector; - } + size_t nbytes = header_size + len * word_size; - nbytes = header_size + len * word_size; +#ifdef DOUG_LEA_MALLOC + /* Prevent mmap'ing the chunk. Lisp data may not be mmap'ed + because mapped region contents are not preserved in + a dumped Emacs. */ + mallopt (M_MMAP_MAX, 0); +#endif - if (nbytes <= VBLOCK_BYTES_MAX) - p = allocate_vector_from_block (vroundup (nbytes)); - else - { - p = (struct Lisp_Vector *) lisp_malloc (nbytes, MEM_TYPE_VECTORLIKE); - p->header.next.vector = large_vectors; - large_vectors = p; - } + if (nbytes <= VBLOCK_BYTES_MAX) + p = allocate_vector_from_block (vroundup (nbytes)); + else + { + p = (struct Lisp_Vector *) lisp_malloc (nbytes, MEM_TYPE_VECTORLIKE); + p->header.next.vector = large_vectors; + large_vectors = p; + } #ifdef DOUG_LEA_MALLOC - /* Back to a reasonable maximum of mmap'ed areas. */ - mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); + /* Back to a reasonable maximum of mmap'ed areas. */ + mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); #endif - consing_since_gc += nbytes; - vector_cells_consed += len; + consing_since_gc += nbytes; + vector_cells_consed += len; + } MALLOC_UNBLOCK_INPUT;