[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r108843: Fix block vector allocation
From: |
Dmitry Antipov |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r108843: Fix block vector allocation code to allow VECTOR_BLOCK_SIZE |
Date: |
Tue, 03 Jul 2012 20:35:53 +0400 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 108843
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Tue 2012-07-03 20:35:53 +0400
message:
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.
modified:
src/ChangeLog
src/alloc.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2012-07-03 14:37:55 +0000
+++ b/src/ChangeLog 2012-07-03 16:35:53 +0000
@@ -1,3 +1,11 @@
+2012-07-03 Dmitry Antipov <address@hidden>
+
+ 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 <address@hidden>
* lisp.h (Lisp_Misc, Lisp_Fwd): Move around to group better.
=== modified file 'src/alloc.c'
--- a/src/alloc.c 2012-07-03 14:37:55 +0000
+++ b/src/alloc.c 2012-07-03 16:35:53 +0000
@@ -2869,6 +2869,12 @@
#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 @@
/* 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 @@
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 @@
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 @@
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 @@
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r108843: Fix block vector allocation code to allow VECTOR_BLOCK_SIZE,
Dmitry Antipov <=