[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master b1881d7dab5 1/2: More accurate static vector block size assertion
From: |
Mattias Engdegård |
Subject: |
master b1881d7dab5 1/2: More accurate static vector block size assertion |
Date: |
Sat, 16 Sep 2023 10:56:37 -0400 (EDT) |
branch: master
commit b1881d7dab53b490148b6a19bb6a3fb62f52ad22
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
More accurate static vector block size assertion
* src/alloc.c: The size of a vector block is bound by the number of
words, not bytes, represented by the pseudovector header RESTSIZE
field, because that limits how big a PVEC_FREE object can be.
---
src/alloc.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/alloc.c b/src/alloc.c
index fbb1c6ed6c3..addbb54e01f 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3054,9 +3054,8 @@ enum { VECTOR_BLOCK_SIZE = 4096 };
/* Vector size requests are a multiple of this. */
enum { roundup_size = COMMON_MULTIPLE (LISP_ALIGNMENT, word_size) };
-/* Verify assumptions described above. */
+/* Verify assumption described above. */
verify (VECTOR_BLOCK_SIZE % roundup_size == 0);
-verify (VECTOR_BLOCK_SIZE <= (1 << PSEUDOVECTOR_SIZE_BITS));
/* Round up X to nearest mult-of-ROUNDUP_SIZE --- use at compile time. */
#define vroundup_ct(x) ROUNDUP (x, roundup_size)
@@ -3067,6 +3066,11 @@ verify (VECTOR_BLOCK_SIZE <= (1 <<
PSEUDOVECTOR_SIZE_BITS));
enum {VECTOR_BLOCK_BYTES = VECTOR_BLOCK_SIZE - vroundup_ct (sizeof (void *))};
+/* The current code expects to be able to represent an unused block by
+ a single PVEC_FREE object, whose size is limited by the header word.
+ (Of course we could use multiple such objects.) */
+verify (VECTOR_BLOCK_BYTES <= (word_size << PSEUDOVECTOR_REST_BITS));
+
/* Size of the minimal vector allocated from block. */
enum { VBLOCK_BYTES_MIN = vroundup_ct (header_size + sizeof (Lisp_Object)) };