]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp.h (eassert): Assume that COND is true when optimizing.
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 3 Oct 2013 16:16:31 +0000 (09:16 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 3 Oct 2013 16:16:31 +0000 (09:16 -0700)
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
src/alloc.c
src/data.c
src/lisp.h

index 26b1a54ffc88ae94262680c086d48415473e3fb6..85411622ba156ec0049a13f9bc35c7b23f6d4daf 100644 (file)
@@ -1,5 +1,10 @@
 2013-10-03  Paul Eggert  <eggert@cs.ucla.edu>
 
+       * 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.
index 6b07f0bd7b1006cb2c7815f32dddbdcacaace680..0a7fda6815cc4141aa283df674d272ffb5bbbbc8 100644 (file)
@@ -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
index 79679bae444dbc1ebcace8ee40b3909ba5378080..b268616fd264a4ca81790be19ee69105fa3af0c0 100644 (file)
@@ -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);
index 0556a95f3653995f21e4ba3f146dee9228f96edd..f949978ceed7383b4f12b07a976f93553f87a3b6 100644 (file)
@@ -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))
-
 \f
 /* Use the configure flag --enable-check-lisp-object-type to make
    Lisp_Object use a struct type instead of the default int.  The flag