diff options
| author | Mattias EngdegÄrd | 2023-09-16 13:07:42 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2023-09-16 16:32:05 +0200 |
| commit | b1881d7dab53b490148b6a19bb6a3fb62f52ad22 (patch) | |
| tree | 6cacc6fa96d84059f69aff95e0dff4dc12ed2524 /src/alloc.c | |
| parent | 94b1de2774b5c1fa3c28285229900657638f5c3f (diff) | |
| download | emacs-b1881d7dab53b490148b6a19bb6a3fb62f52ad22.tar.gz emacs-b1881d7dab53b490148b6a19bb6a3fb62f52ad22.zip | |
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.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 8 |
1 files 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 }; | |||
| 3054 | /* Vector size requests are a multiple of this. */ | 3054 | /* Vector size requests are a multiple of this. */ |
| 3055 | enum { roundup_size = COMMON_MULTIPLE (LISP_ALIGNMENT, word_size) }; | 3055 | enum { roundup_size = COMMON_MULTIPLE (LISP_ALIGNMENT, word_size) }; |
| 3056 | 3056 | ||
| 3057 | /* Verify assumptions described above. */ | 3057 | /* Verify assumption described above. */ |
| 3058 | verify (VECTOR_BLOCK_SIZE % roundup_size == 0); | 3058 | verify (VECTOR_BLOCK_SIZE % roundup_size == 0); |
| 3059 | verify (VECTOR_BLOCK_SIZE <= (1 << PSEUDOVECTOR_SIZE_BITS)); | ||
| 3060 | 3059 | ||
| 3061 | /* Round up X to nearest mult-of-ROUNDUP_SIZE --- use at compile time. */ | 3060 | /* Round up X to nearest mult-of-ROUNDUP_SIZE --- use at compile time. */ |
| 3062 | #define vroundup_ct(x) ROUNDUP (x, roundup_size) | 3061 | #define vroundup_ct(x) ROUNDUP (x, roundup_size) |
| @@ -3067,6 +3066,11 @@ verify (VECTOR_BLOCK_SIZE <= (1 << PSEUDOVECTOR_SIZE_BITS)); | |||
| 3067 | 3066 | ||
| 3068 | enum {VECTOR_BLOCK_BYTES = VECTOR_BLOCK_SIZE - vroundup_ct (sizeof (void *))}; | 3067 | enum {VECTOR_BLOCK_BYTES = VECTOR_BLOCK_SIZE - vroundup_ct (sizeof (void *))}; |
| 3069 | 3068 | ||
| 3069 | /* The current code expects to be able to represent an unused block by | ||
| 3070 | a single PVEC_FREE object, whose size is limited by the header word. | ||
| 3071 | (Of course we could use multiple such objects.) */ | ||
| 3072 | verify (VECTOR_BLOCK_BYTES <= (word_size << PSEUDOVECTOR_REST_BITS)); | ||
| 3073 | |||
| 3070 | /* Size of the minimal vector allocated from block. */ | 3074 | /* Size of the minimal vector allocated from block. */ |
| 3071 | 3075 | ||
| 3072 | enum { VBLOCK_BYTES_MIN = vroundup_ct (header_size + sizeof (Lisp_Object)) }; | 3076 | enum { VBLOCK_BYTES_MIN = vroundup_ct (header_size + sizeof (Lisp_Object)) }; |