mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-02 18:21:19 -08:00
Fix block vector allocation code to allow VECTOR_BLOCK_SIZE
values which aren't power of 2. * alloc.c (VECTOR_FREE_LIST_SIZE_MASK): New macro. Verify it's value and the value of VECTOR_BLOCK_SIZE. Adjust users accordingly.
This commit is contained in:
parent
7555c33f15
commit
ca95b3ebc8
2 changed files with 23 additions and 4 deletions
|
|
@ -1,3 +1,11 @@
|
|||
2012-07-03 Dmitry Antipov <dmantipov@yandex.ru>
|
||||
|
||||
Fix block vector allocation code to allow VECTOR_BLOCK_SIZE
|
||||
values which aren't power of 2.
|
||||
* alloc.c (VECTOR_FREE_LIST_SIZE_MASK): New macro. Verify
|
||||
it's value and the value of VECTOR_BLOCK_SIZE. Adjust users
|
||||
accordingly.
|
||||
|
||||
2012-07-03 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||
|
||||
* lisp.h (Lisp_Misc, Lisp_Fwd): Move around to group better.
|
||||
|
|
|
|||
19
src/alloc.c
19
src/alloc.c
|
|
@ -2869,6 +2869,12 @@ DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0,
|
|||
|
||||
#define VECTOR_BLOCK_SIZE 4096
|
||||
|
||||
/* This special value is used to calculate vector size when the vector is
|
||||
on a free list. It should be VECTOR_BLOCK_SIZE rounded up to nearest
|
||||
power of two, minus one. */
|
||||
|
||||
#define VECTOR_FREE_LIST_SIZE_MASK 4095
|
||||
|
||||
/* Handy constants for vectorlike objects. */
|
||||
enum
|
||||
{
|
||||
|
|
@ -2881,6 +2887,11 @@ enum
|
|||
/* ROUNDUP_SIZE must be a power of 2. */
|
||||
verify ((roundup_size & (roundup_size - 1)) == 0);
|
||||
|
||||
/* Verify assumptions described above. */
|
||||
verify ((VECTOR_BLOCK_SIZE % roundup_size) == 0);
|
||||
verify ((VECTOR_FREE_LIST_SIZE_MASK + 1) >= VECTOR_BLOCK_SIZE);
|
||||
verify ((VECTOR_FREE_LIST_SIZE_MASK & (VECTOR_FREE_LIST_SIZE_MASK + 1)) == 0);
|
||||
|
||||
/* Round up X to nearest mult-of-ROUNDUP_SIZE. */
|
||||
|
||||
#define vroundup(x) (((x) + (roundup_size - 1)) & ~(roundup_size - 1))
|
||||
|
|
@ -2908,7 +2919,7 @@ verify ((roundup_size & (roundup_size - 1)) == 0);
|
|||
this special value ORed with vector's memory footprint size. */
|
||||
|
||||
#define VECTOR_FREE_LIST_FLAG (~(ARRAY_MARK_FLAG | PSEUDOVECTOR_FLAG \
|
||||
| (VECTOR_BLOCK_SIZE - 1)))
|
||||
| VECTOR_FREE_LIST_SIZE_MASK))
|
||||
|
||||
/* Common shortcut to advance vector pointer over a block data. */
|
||||
|
||||
|
|
@ -3087,7 +3098,7 @@ sweep_vectors (void)
|
|||
if ((vector->header.size & VECTOR_FREE_LIST_FLAG)
|
||||
== VECTOR_FREE_LIST_FLAG)
|
||||
vector->header.next.nbytes =
|
||||
vector->header.size & (VECTOR_BLOCK_SIZE - 1);
|
||||
vector->header.size & VECTOR_FREE_LIST_SIZE_MASK;
|
||||
|
||||
next = ADVANCE (vector, vector->header.next.nbytes);
|
||||
|
||||
|
|
@ -3100,7 +3111,7 @@ sweep_vectors (void)
|
|||
break;
|
||||
if ((next->header.size & VECTOR_FREE_LIST_FLAG)
|
||||
== VECTOR_FREE_LIST_FLAG)
|
||||
nbytes = next->header.size & (VECTOR_BLOCK_SIZE - 1);
|
||||
nbytes = next->header.size & VECTOR_FREE_LIST_SIZE_MASK;
|
||||
else
|
||||
nbytes = next->header.next.nbytes;
|
||||
vector->header.next.nbytes += nbytes;
|
||||
|
|
@ -4334,7 +4345,7 @@ live_vector_p (struct mem_node *m, void *p)
|
|||
if ((vector->header.size & VECTOR_FREE_LIST_FLAG)
|
||||
== VECTOR_FREE_LIST_FLAG)
|
||||
vector = ADVANCE (vector, (vector->header.size
|
||||
& (VECTOR_BLOCK_SIZE - 1)));
|
||||
& VECTOR_FREE_LIST_SIZE_MASK));
|
||||
else if (vector == p)
|
||||
return 1;
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue