diff options
| author | Paul Eggert | 2013-10-03 09:16:31 -0700 |
|---|---|---|
| committer | Paul Eggert | 2013-10-03 09:16:31 -0700 |
| commit | 75273afb0de9e8a8eede149f3afdba0d855e7b5a (patch) | |
| tree | 3b3ac5db0ac4bc0dface5305f4edaa07324e4c85 /src | |
| parent | c9358b45b947dd66de05527629511679bb90392a (diff) | |
| download | emacs-75273afb0de9e8a8eede149f3afdba0d855e7b5a.tar.gz emacs-75273afb0de9e8a8eede149f3afdba0d855e7b5a.zip | |
* 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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/alloc.c | 8 | ||||
| -rw-r--r-- | src/data.c | 8 | ||||
| -rw-r--r-- | 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 @@ | |||
| 1 | 2013-10-03 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2013-10-03 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | * lisp.h (eassert): Assume that COND is true when optimizing. | ||
| 4 | In other words, take on the behavior of eassert_and_assume. | ||
| 5 | This makes Emacs 0.2% smaller on my platform (Fedora 19, x86-64). | ||
| 6 | (eassert_and_assume): Remove. All uses replaced by eassert. | ||
| 7 | |||
| 3 | * xdisp.c (Qglyphless_char): Now static. | 8 | * xdisp.c (Qglyphless_char): Now static. |
| 4 | 9 | ||
| 5 | Adjust to merge from gnulib. | 10 | 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, | |||
| 2023 | ptrdiff_t exact_needed_bytes; | 2023 | ptrdiff_t exact_needed_bytes; |
| 2024 | ptrdiff_t needed_bytes; | 2024 | ptrdiff_t needed_bytes; |
| 2025 | 2025 | ||
| 2026 | eassert_and_assume (nr_bits >= 0); | 2026 | eassert (nr_bits >= 0); |
| 2027 | 2027 | ||
| 2028 | exact_needed_bytes = ROUNDUP ((size_t) nr_bits, CHAR_BIT) / CHAR_BIT; | 2028 | exact_needed_bytes = ROUNDUP ((size_t) nr_bits, CHAR_BIT) / CHAR_BIT; |
| 2029 | needed_bytes = ROUNDUP ((size_t) nr_bits, BITS_PER_SIZE_T) / CHAR_BIT; | 2029 | 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. */) | |||
| 2060 | total_payload_bytes = bool_vector_payload_bytes | 2060 | total_payload_bytes = bool_vector_payload_bytes |
| 2061 | (XFASTINT (length), &exact_payload_bytes); | 2061 | (XFASTINT (length), &exact_payload_bytes); |
| 2062 | 2062 | ||
| 2063 | eassert_and_assume (exact_payload_bytes <= total_payload_bytes); | 2063 | eassert (exact_payload_bytes <= total_payload_bytes); |
| 2064 | eassert_and_assume (0 <= exact_payload_bytes); | 2064 | eassert (0 <= exact_payload_bytes); |
| 2065 | 2065 | ||
| 2066 | needed_elements = ROUNDUP ((size_t) ((bool_header_size - header_size) | 2066 | needed_elements = ROUNDUP ((size_t) ((bool_header_size - header_size) |
| 2067 | + total_payload_bytes), | 2067 | + total_payload_bytes), |
| @@ -2816,7 +2816,7 @@ vector_nbytes (struct Lisp_Vector *v) | |||
| 2816 | ptrdiff_t payload_bytes = | 2816 | ptrdiff_t payload_bytes = |
| 2817 | bool_vector_payload_bytes (bv->size, NULL); | 2817 | bool_vector_payload_bytes (bv->size, NULL); |
| 2818 | 2818 | ||
| 2819 | eassert_and_assume (payload_bytes >= 0); | 2819 | eassert (payload_bytes >= 0); |
| 2820 | size = bool_header_size + ROUNDUP (payload_bytes, word_size); | 2820 | size = bool_header_size + ROUNDUP (payload_bytes, word_size); |
| 2821 | } | 2821 | } |
| 2822 | else | 2822 | 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. */) | |||
| 2966 | static size_t | 2966 | static size_t |
| 2967 | bool_vector_spare_mask (ptrdiff_t nr_bits) | 2967 | bool_vector_spare_mask (ptrdiff_t nr_bits) |
| 2968 | { | 2968 | { |
| 2969 | eassert_and_assume (nr_bits > 0); | 2969 | eassert (nr_bits > 0); |
| 2970 | return (((size_t) 1) << (nr_bits % BITS_PER_SIZE_T)) - 1; | 2970 | return (((size_t) 1) << (nr_bits % BITS_PER_SIZE_T)) - 1; |
| 2971 | } | 2971 | } |
| 2972 | 2972 | ||
| @@ -3108,7 +3108,7 @@ bool_vector_binop_driver (Lisp_Object op1, | |||
| 3108 | nr_bits = min (nr_bits, XBOOL_VECTOR (dest)->size); | 3108 | nr_bits = min (nr_bits, XBOOL_VECTOR (dest)->size); |
| 3109 | } | 3109 | } |
| 3110 | 3110 | ||
| 3111 | eassert_and_assume (nr_bits >= 0); | 3111 | eassert (nr_bits >= 0); |
| 3112 | nr_words = ROUNDUP (nr_bits, BITS_PER_SIZE_T) / BITS_PER_SIZE_T; | 3112 | nr_words = ROUNDUP (nr_bits, BITS_PER_SIZE_T) / BITS_PER_SIZE_T; |
| 3113 | 3113 | ||
| 3114 | adata = (size_t *) XBOOL_VECTOR (dest)->data; | 3114 | adata = (size_t *) XBOOL_VECTOR (dest)->data; |
| @@ -3275,7 +3275,7 @@ Return the destination vector. */) | |||
| 3275 | bdata = (size_t *) XBOOL_VECTOR (b)->data; | 3275 | bdata = (size_t *) XBOOL_VECTOR (b)->data; |
| 3276 | adata = (size_t *) XBOOL_VECTOR (a)->data; | 3276 | adata = (size_t *) XBOOL_VECTOR (a)->data; |
| 3277 | 3277 | ||
| 3278 | eassert_and_assume (nr_bits >= 0); | 3278 | eassert (nr_bits >= 0); |
| 3279 | 3279 | ||
| 3280 | for (i = 0; i < nr_bits / BITS_PER_SIZE_T; i++) | 3280 | for (i = 0; i < nr_bits / BITS_PER_SIZE_T; i++) |
| 3281 | bdata[i] = ~adata[i]; | 3281 | bdata[i] = ~adata[i]; |
| @@ -3310,7 +3310,7 @@ A must be a bool vector. B is a generalized bool. */) | |||
| 3310 | match = NILP (b) ? (size_t) -1 : 0; | 3310 | match = NILP (b) ? (size_t) -1 : 0; |
| 3311 | adata = (size_t *) XBOOL_VECTOR (a)->data; | 3311 | adata = (size_t *) XBOOL_VECTOR (a)->data; |
| 3312 | 3312 | ||
| 3313 | eassert_and_assume (nr_bits >= 0); | 3313 | eassert (nr_bits >= 0); |
| 3314 | 3314 | ||
| 3315 | for (i = 0; i < nr_bits / BITS_PER_SIZE_T; ++i) | 3315 | for (i = 0; i < nr_bits / BITS_PER_SIZE_T; ++i) |
| 3316 | count += popcount_size_t (adata[i] ^ match); | 3316 | 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; | |||
| 108 | 108 | ||
| 109 | /* Extra internal type checking? */ | 109 | /* Extra internal type checking? */ |
| 110 | 110 | ||
| 111 | /* Define an Emacs version of 'assert (COND)', since some | 111 | /* Define an Emacs version of 'assert (COND)'. COND should be free of |
| 112 | system-defined 'assert's are flaky. COND should be free of side | 112 | side effects; it may be evaluated zero or more times. If COND is false, |
| 113 | effects; it may or may not be evaluated. */ | 113 | Emacs reliably crashes if ENABLE_CHECKING is defined and behavior |
| 114 | is undefined if not. The compiler may assume COND while optimizing. */ | ||
| 114 | #ifndef ENABLE_CHECKING | 115 | #ifndef ENABLE_CHECKING |
| 115 | # define eassert(X) ((void) (0 && (X))) /* Check that X compiles. */ | 116 | # define eassert(cond) assume (cond) |
| 116 | #else /* ENABLE_CHECKING */ | 117 | #else /* ENABLE_CHECKING */ |
| 117 | 118 | ||
| 118 | extern _Noreturn void die (const char *, const char *, int); | 119 | extern _Noreturn void die (const char *, const char *, int); |
| @@ -129,16 +130,10 @@ extern bool suppress_checking EXTERNALLY_VISIBLE; | |||
| 129 | 130 | ||
| 130 | # define eassert(cond) \ | 131 | # define eassert(cond) \ |
| 131 | (suppress_checking || (cond) \ | 132 | (suppress_checking || (cond) \ |
| 132 | ? (void) 0 \ | 133 | ? assume (cond) \ |
| 133 | : die (# cond, __FILE__, __LINE__)) | 134 | : die (# cond, __FILE__, __LINE__)) |
| 134 | #endif /* ENABLE_CHECKING */ | 135 | #endif /* ENABLE_CHECKING */ |
| 135 | 136 | ||
| 136 | /* When checking is enabled, identical to eassert. When checking is | ||
| 137 | * disabled, instruct the compiler (when the compiler has such | ||
| 138 | * capability) to assume that cond is true and optimize | ||
| 139 | * accordingly. */ | ||
| 140 | #define eassert_and_assume(cond) (eassert (cond), assume (cond)) | ||
| 141 | |||
| 142 | 137 | ||
| 143 | /* Use the configure flag --enable-check-lisp-object-type to make | 138 | /* Use the configure flag --enable-check-lisp-object-type to make |
| 144 | Lisp_Object use a struct type instead of the default int. The flag | 139 | Lisp_Object use a struct type instead of the default int. The flag |