From 75273afb0de9e8a8eede149f3afdba0d855e7b5a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 3 Oct 2013 09:16:31 -0700 Subject: [PATCH] * lisp.h (eassert): Assume that COND is true when optimizing. In other words, take on the behavior of eassert_and_assume. This makes Emacs 0.2% smaller on my platform (Fedora 19, x86-64). (eassert_and_assume): Remove. All uses replaced by eassert. --- src/ChangeLog | 5 +++++ src/alloc.c | 8 ++++---- src/data.c | 8 ++++---- src/lisp.h | 17 ++++++----------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 26b1a54ffc8..85411622ba1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2013-10-03 Paul Eggert + * lisp.h (eassert): Assume that COND is true when optimizing. + In other words, take on the behavior of eassert_and_assume. + This makes Emacs 0.2% smaller on my platform (Fedora 19, x86-64). + (eassert_and_assume): Remove. All uses replaced by eassert. + * xdisp.c (Qglyphless_char): Now static. Adjust to merge from gnulib. diff --git a/src/alloc.c b/src/alloc.c index 6b07f0bd7b1..0a7fda6815c 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -2023,7 +2023,7 @@ bool_vector_payload_bytes (ptrdiff_t nr_bits, ptrdiff_t exact_needed_bytes; ptrdiff_t needed_bytes; - eassert_and_assume (nr_bits >= 0); + eassert (nr_bits >= 0); exact_needed_bytes = ROUNDUP ((size_t) nr_bits, CHAR_BIT) / CHAR_BIT; needed_bytes = ROUNDUP ((size_t) nr_bits, BITS_PER_SIZE_T) / CHAR_BIT; @@ -2060,8 +2060,8 @@ LENGTH must be a number. INIT matters only in whether it is t or nil. */) total_payload_bytes = bool_vector_payload_bytes (XFASTINT (length), &exact_payload_bytes); - eassert_and_assume (exact_payload_bytes <= total_payload_bytes); - eassert_and_assume (0 <= exact_payload_bytes); + eassert (exact_payload_bytes <= total_payload_bytes); + eassert (0 <= exact_payload_bytes); needed_elements = ROUNDUP ((size_t) ((bool_header_size - header_size) + total_payload_bytes), @@ -2816,7 +2816,7 @@ vector_nbytes (struct Lisp_Vector *v) ptrdiff_t payload_bytes = bool_vector_payload_bytes (bv->size, NULL); - eassert_and_assume (payload_bytes >= 0); + eassert (payload_bytes >= 0); size = bool_header_size + ROUNDUP (payload_bytes, word_size); } else diff --git a/src/data.c b/src/data.c index 79679bae444..b268616fd26 100644 --- a/src/data.c +++ b/src/data.c @@ -2966,7 +2966,7 @@ lowercase l) for small endian machines. */) static size_t bool_vector_spare_mask (ptrdiff_t nr_bits) { - eassert_and_assume (nr_bits > 0); + eassert (nr_bits > 0); return (((size_t) 1) << (nr_bits % BITS_PER_SIZE_T)) - 1; } @@ -3108,7 +3108,7 @@ bool_vector_binop_driver (Lisp_Object op1, nr_bits = min (nr_bits, XBOOL_VECTOR (dest)->size); } - eassert_and_assume (nr_bits >= 0); + eassert (nr_bits >= 0); nr_words = ROUNDUP (nr_bits, BITS_PER_SIZE_T) / BITS_PER_SIZE_T; adata = (size_t *) XBOOL_VECTOR (dest)->data; @@ -3275,7 +3275,7 @@ Return the destination vector. */) bdata = (size_t *) XBOOL_VECTOR (b)->data; adata = (size_t *) XBOOL_VECTOR (a)->data; - eassert_and_assume (nr_bits >= 0); + eassert (nr_bits >= 0); for (i = 0; i < nr_bits / BITS_PER_SIZE_T; i++) bdata[i] = ~adata[i]; @@ -3310,7 +3310,7 @@ A must be a bool vector. B is a generalized bool. */) match = NILP (b) ? (size_t) -1 : 0; adata = (size_t *) XBOOL_VECTOR (a)->data; - eassert_and_assume (nr_bits >= 0); + eassert (nr_bits >= 0); for (i = 0; i < nr_bits / BITS_PER_SIZE_T; ++i) count += popcount_size_t (adata[i] ^ match); diff --git a/src/lisp.h b/src/lisp.h index 0556a95f365..f949978ceed 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -108,11 +108,12 @@ typedef EMACS_UINT uprintmax_t; /* Extra internal type checking? */ -/* Define an Emacs version of 'assert (COND)', since some - system-defined 'assert's are flaky. COND should be free of side - effects; it may or may not be evaluated. */ +/* Define an Emacs version of 'assert (COND)'. COND should be free of + side effects; it may be evaluated zero or more times. If COND is false, + Emacs reliably crashes if ENABLE_CHECKING is defined and behavior + is undefined if not. The compiler may assume COND while optimizing. */ #ifndef ENABLE_CHECKING -# define eassert(X) ((void) (0 && (X))) /* Check that X compiles. */ +# define eassert(cond) assume (cond) #else /* ENABLE_CHECKING */ extern _Noreturn void die (const char *, const char *, int); @@ -129,16 +130,10 @@ extern bool suppress_checking EXTERNALLY_VISIBLE; # define eassert(cond) \ (suppress_checking || (cond) \ - ? (void) 0 \ + ? assume (cond) \ : die (# cond, __FILE__, __LINE__)) #endif /* ENABLE_CHECKING */ -/* When checking is enabled, identical to eassert. When checking is - * disabled, instruct the compiler (when the compiler has such - * capability) to assume that cond is true and optimize - * accordingly. */ -#define eassert_and_assume(cond) (eassert (cond), assume (cond)) - /* Use the configure flag --enable-check-lisp-object-type to make Lisp_Object use a struct type instead of the default int. The flag -- 2.39.2