From 169925ec990b7e22f35eb1e2c25a1b53f49072ff Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Wed, 18 Jul 2012 13:46:07 +0400 Subject: [PATCH] Fix sweep_vectors to handle large bool vectors correctly. * alloc.c (sweep_vectors): Account total_vector_bytes for bool vectors larger than VBLOCK_BYTES_MAX. --- src/ChangeLog | 6 ++++++ src/alloc.c | 26 +++++++++++++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 368c07f1b9b..26199d888fa 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2012-07-18 Dmitry Antipov + + Fix sweep_vectors to handle large bool vectors correctly. + * alloc.c (sweep_vectors): Account total_vector_bytes for + bool vectors larger than VBLOCK_BYTES_MAX. + 2012-07-18 Chong Yidong * frame.c (x_set_frame_parameters): Revert bogus change introduced diff --git a/src/alloc.c b/src/alloc.c index b891d32d164..0c3f5de6c3e 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -3152,11 +3152,27 @@ sweep_vectors (void) { VECTOR_UNMARK (vector); total_vectors++; - /* All pseudovectors are small enough to be allocated from - vector blocks. This code should be redesigned if some - pseudovector type grows beyond VBLOCK_BYTES_MAX. */ - eassert (!(vector->header.size & PSEUDOVECTOR_FLAG)); - total_vector_bytes += header_size + vector->header.size * word_size; + if (vector->header.size & PSEUDOVECTOR_FLAG) + { + if (((vector->header.size & PVEC_TYPE_MASK) + >> PSEUDOVECTOR_SIZE_BITS) == PVEC_BOOL_VECTOR) + { + struct Lisp_Bool_Vector *b + = (struct Lisp_Bool_Vector *) vector; + total_vector_bytes += header_size + sizeof (b->size) + + (b->size + BOOL_VECTOR_BITS_PER_CHAR - 1) + / BOOL_VECTOR_BITS_PER_CHAR; + } + else + /* All other pseudovectors are small enough to be + allocated from vector blocks. This code should + be redesigned if some pseudovector type grows + beyond VBLOCK_BYTES_MAX. */ + abort (); + } + else + total_vector_bytes + += header_size + vector->header.size * word_size; vprev = &vector->header.next.vector; } else -- 2.39.2