From b1881d7dab53b490148b6a19bb6a3fb62f52ad22 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20Engdeg=C3=A5rd?= Date: Sat, 16 Sep 2023 13:07:42 +0200 Subject: [PATCH] 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)) }; -- 2.39.5